Fix the unsigned issue for gid/uid handling

This commit is contained in:
Jaroslav Kysela 2015-03-18 09:48:32 +01:00
parent de0d8d379f
commit 28e8db1dc2
2 changed files with 3 additions and 3 deletions

View file

@ -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;

View file

@ -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);