From: Michel Normand Date: Thu, 14 May 2009 13:11:40 +0000 (+0200) Subject: replace fprintf by ERROR call in lxc_unshare.c X-Git-Tag: lxc_0_6_3~104 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d00184d36137ca2aae2f7e868bb529cf68f08371;p=thirdparty%2Flxc.git replace fprintf by ERROR call in lxc_unshare.c 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 Signed-off-by: Daniel Lezcano --- diff --git a/src/lxc/lxc_unshare.c b/src/lxc/lxc_unshare.c index 6a021cc8e..831a75a87 100644 --- a/src/lxc/lxc_unshare.c +++ b/src/lxc/lxc_unshare.c @@ -34,6 +34,8 @@ #include +lxc_log_define(lxc_unshare, lxc); + void usage(char *cmd) { fprintf(stderr, "%s [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; }