Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix the unsigned issue for gid/uid handling
  • Loading branch information
perexg committed Mar 18, 2015
1 parent de0d8d3 commit 28e8db1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/main.c
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/utils.c
Expand Up @@ -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);
Expand Down

0 comments on commit 28e8db1

Please sign in to comment.