From: Tobias Oetiker Date: Thu, 11 Aug 2005 19:18:36 +0000 (+0000) Subject: only bomb is there is no chroot and someone tries to use it. X-Git-Tag: 1.2.12~44 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c9308aeaa9b343753749a94e32978c8ba5160783;p=thirdparty%2Frrdtool-1.x.git only bomb is there is no chroot and someone tries to use it. git-svn-id: svn://svn.oetiker.ch/rrdtool/branches/1.2/program@672 a5681a0c-68f1-0310-ab6d-d61299d08faa --- diff --git a/src/rrd_tool.c b/src/rrd_tool.c index ecd88f97..fba0fa04 100644 --- a/src/rrd_tool.c +++ b/src/rrd_tool.c @@ -331,9 +331,9 @@ int main(int argc, char *argv[]) gettimeofday(&starttime,&tz); #endif RemoteMode=1; -#ifdef HAVE_CHROOT if ((argc == 3) && strcmp("",argv[2])){ if (getuid()==0){ +#ifdef HAVE_CHROOT chroot(argv[2]); if (errno!=0){ fprintf(stderr,"ERROR: can't change root to '%s' errno=%d\n", @@ -342,8 +342,12 @@ int main(int argc, char *argv[]) } ChangeRoot=1; firstdir="/"; - } - else{ +#else + fprintf(stderr,"ERROR: change root is not supported by your OS " + "or at least by this copy of rrdtool\n"); + exit(1); +#endif + } else { firstdir=argv[2]; } } @@ -354,11 +358,6 @@ int main(int argc, char *argv[]) exit(errno); } } -#else - fprintf(stderr,"ERROR: change root is not supported by your OS " - "or at least by this copy of rrdtool\n"); - exit(1); -#endif while (fgets(aLine, sizeof(aLine)-1, stdin)){ if ((argc = CountArgs(aLine)) == 0) {