X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;ds=sidebyside;f=src%2Fcapchroot.c;h=71ad0616e9ad23abe20bafc8e4d885b4e320cf22;hb=3b34449070c0846fdc49436d1edd5916512f1644;hp=69dbe3725fdbf6d33bedd5b6286b1424fec2b818;hpb=7370d748ee384dd549f2947c60ebc9a647907d06;p=util-vserver.git diff --git a/src/capchroot.c b/src/capchroot.c index 69dbe37..71ad061 100644 --- a/src/capchroot.c +++ b/src/capchroot.c @@ -1,4 +1,4 @@ -// $Id: capchroot.c,v 1.7 2004/03/24 01:41:28 ensc Exp $ +// $Id: capchroot.c 2403 2006-11-24 23:06:08Z dhozac $ // Copyright (C) 2003 Enrico Scholz // based on capchroot.cc by Jacques Gelinas @@ -66,6 +66,11 @@ static void showHelp(int fd, char const *cmd, int res) { VSERVER_DECLARE_CMD(cmd); + +#if !defined(VC_ENABLE_API_COMPAT) && !defined(VC_ENABLE_API_LEGACY) + WRITE_MSG(1, "ERROR: tools were built without legacy API support; capchroot will not work!\n\n"); +#endif + WRITE_MSG(fd, "Usage: "); WRITE_STR(fd, cmd); WRITE_MSG(fd, @@ -92,11 +97,11 @@ showVersion() exit(0); } -static void +static UNUSED void setUser(char const *user) { struct passwd *p = 0; - if (user!=0 && strcmp(user, "root")!=0) { + if (user!=0 && strcmp(user, "root")!=0 && strcmp(user, "0")!=0) { errno = 0; p = getpwnam(user); if (p==0) { @@ -135,12 +140,13 @@ int main (int argc, char *argv[]) default : WRITE_MSG(2, "Try '"); WRITE_STR(2, argv[0]); - WRITE_MSG(2, " --help\" for more information.\n"); + WRITE_MSG(2, " --help' for more information.\n"); return EXIT_FAILURE; break; } } +#if defined(VC_ENABLE_API_COMPAT) || defined(VC_ENABLE_API_LEGACY) if (optind==argc) WRITE_MSG(2, "No directory specified; try '--help' for more information\n"); else if (optind+1==argc) @@ -159,6 +165,9 @@ int main (int argc, char *argv[]) setUser(suid_user); EexecvpD(argv[optind+1], argv+optind+1); } - +#else + WRITE_MSG(2, "capchroot: tools were built without legacy API support; can not continue\n"); +#endif + return EXIT_FAILURE; }