X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=zpm-script.c;h=7c03b241792ae1f91ea504215b1400526580c71b;hb=4b448fbc77510c589cc7f367c05bef63acc07858;hp=ba057ef72303d2e02d358fc2d6a10d785d62aafd;hpb=49ff42bdf62fe00f15ec217171649f0ce8848c14;p=zpackage diff --git a/zpm-script.c b/zpm-script.c index ba057ef..7c03b24 100644 --- a/zpm-script.c +++ b/zpm-script.c @@ -30,11 +30,12 @@ void usage(void) { } int setdir(char *rootdir) { + if (chdir(rootdir ? rootdir : "/") == -1) { + perror("can not chdir to rootdir"); + return 0; + } +#if 0 if (rootdir && strcmp(rootdir, "/")) { - if (chdir(rootdir) == -1) { - perror("can not chdir to rootdir"); - return 0; - } if (geteuid() == 0) { /* chroot is deprecated, and not in posix. need to use * OS/kernel specific code. @@ -43,12 +44,8 @@ int setdir(char *rootdir) { } else { fprintf(stderr, "unable to chroot as non root user\n"); } - } else { - if (chdir("/") == -1) { - perror("can not chdir to /"); - return 0; - } } +#endif return 1; }