]> git.proxmox.com Git - mirror_lxc.git/commitdiff
replace fprintf by ERROR call in lxc_unshare.c
authorMichel Normand <normand@fr.ibm.com>
Thu, 14 May 2009 13:11:40 +0000 (15:11 +0200)
committerDaniel Lezcano <dlezcano@fr.ibm.com>
Thu, 14 May 2009 13:11:40 +0000 (15:11 +0200)
Do it except for the usage functions that will be removed by another patch

This is a follow on a previous patch that treated
all src/lxc/lxc_*.c but this file.

Signed-off-by: Michel Normand <normand@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
src/lxc/lxc_unshare.c

index 6a021cc8e68082b27c9f36345ba090921c8e8e81..831a75a877c6051bc0f62f4885f46f22c0d520ba 100644 (file)
@@ -34,6 +34,8 @@
 
 #include <lxc/lxc.h>
 
+lxc_log_define(lxc_unshare, lxc);
+
 void usage(char *cmd)
 {
        fprintf(stderr, "%s <options> [command]\n", basename(cmd));
@@ -67,13 +69,13 @@ static uid_t lookup_user(const char *optarg)
                        return uid;
 
                if (getpwnam_r(name, &pwent, buff, bufflen, &pent) || !pent) {
-                       fprintf(stderr, "invalid username %s\n", name);
+                       ERROR("invalid username %s", name);
                        return uid;
                }
                uid = pent->pw_uid;
        } else {
                if (getpwuid_r(uid, &pwent, buff, bufflen, &pent) || !pent) {
-                       fprintf(stderr, "invalid uid %d\n", uid);
+                       ERROR("invalid uid %d", uid);
                        uid = -1;
                        return uid;
                }
@@ -131,45 +133,45 @@ int main(int argc, char *argv[])
                pid = fork_ns(flags);
 
                if (pid < 0) {
-                       fprintf(stderr, "failed to fork into a new namespace: %s\n",
+                       ERROR("failed to fork into a new namespace: %s",
                                strerror(errno));
                        return 1;
                }
 
                if (!pid) {
                        if (flags & CLONE_NEWUSER && setuid(uid)) {
-                               fprintf(stderr, "failed to set uid %d: %s\n",
+                               ERROR("failed to set uid %d: %s",
                                        uid, strerror(errno));
                                exit(1);
                        }
 
                        execvp(args[0], args);
-                       fprintf(stderr, "failed to exec: '%s': %s\n",
+                       ERROR("failed to exec: '%s': %s",
                                argv[0], strerror(errno));
                        exit(1);
                }
                
                if (waitpid(pid, &status, 0) < 0)
-                       fprintf(stderr, "failed to wait for '%d'\n", pid);
+                       ERROR("failed to wait for '%d'", pid);
                
                return status;
        }
 
        if (unshare_ns(flags)) {
-               fprintf(stderr, "failed to unshare the current process: %s\n",
+               ERROR("failed to unshare the current process: %s",
                        strerror(errno));
                return 1;
        }
 
        if (flags & CLONE_NEWUSER && setuid(uid)) {
-               fprintf(stderr, "failed to set uid %d: %s\n",
+               ERROR("failed to set uid %d: %s",
                        uid, strerror(errno));
                return 1;
        }
 
        if (argv[optind] && strlen(argv[optind])) {
                execvp(args[0], args);
-               fprintf(stderr, "failed to exec: '%s': %s\n",
+               ERROR("failed to exec: '%s': %s",
                        argv[0], strerror(errno));
                return 1;
        }