Fix the unsigned issue for gid/uid handling
This commit is contained in:
parent
de0d8d379f
commit
28e8db1dc2
2 changed files with 3 additions and 3 deletions
|
@ -756,12 +756,12 @@ main(int argc, char **argv)
|
|||
if (opt_fork)
|
||||
pidfile = tvh_fopen(opt_pidpath, "w+");
|
||||
|
||||
if (gid >= 0 && (getgid() != gid) && setgid(gid)) {
|
||||
if (gid != -1 && (getgid() != gid) && setgid(gid)) {
|
||||
tvhlog(LOG_ALERT, "START",
|
||||
"setgid(%d) failed, do you have permission?", gid);
|
||||
return 1;
|
||||
}
|
||||
if (uid >= 0 && (getuid() != uid) && setuid(uid)) {
|
||||
if (uid != -1 && (getuid() != uid) && setuid(uid)) {
|
||||
tvhlog(LOG_ALERT, "START",
|
||||
"setuid(%d) failed, do you have permission?", uid);
|
||||
return 1;
|
||||
|
|
|
@ -491,7 +491,7 @@ makedirs ( const char *inpath, int mode, gid_t gid, uid_t uid )
|
|||
path[x] = 0;
|
||||
if (stat(path, &st)) {
|
||||
err = mkdir(path, mode);
|
||||
if (!err && gid >= 0 && uid >= 0)
|
||||
if (!err && gid != -1 && uid != -1)
|
||||
err = chown(path, uid, gid);
|
||||
tvhtrace("settings", "Creating directory \"%s\" with octal permissions "
|
||||
"\"%o\" gid %d uid %d", path, mode, gid, uid);
|
||||
|
|
Loading…
Add table
Reference in a new issue