diff options
author | Warren Dukes <warren.dukes@gmail.com> | 2004-11-02 02:44:11 +0000 |
---|---|---|
committer | Warren Dukes <warren.dukes@gmail.com> | 2004-11-02 02:44:11 +0000 |
commit | aab6515c52aebd5532ba6d5326196395928d39ba (patch) | |
tree | e1a6f6a49d3d43404906e792ca9fabf81557db3f /src/main.c | |
parent | 9ef68105cb3fde47c15224054e1c6755c333018f (diff) | |
download | mpd-aab6515c52aebd5532ba6d5326196395928d39ba.tar.gz mpd-aab6515c52aebd5532ba6d5326196395928d39ba.tar.xz mpd-aab6515c52aebd5532ba6d5326196395928d39ba.zip |
patches for 0.11.5 bug fix from the following revision changes:
1993
2000
2001
2026
2028
2038
2078
2116
2163
2164
2230
2236
2270
2337
2339
2420
2426
git-svn-id: https://svn.musicpd.org/mpd/branches/branch-0.11.4-fixes@2461 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 30 |
1 files changed, 7 insertions, 23 deletions
diff --git a/src/main.c b/src/main.c index c34c71f5b..9c0361328 100644 --- a/src/main.c +++ b/src/main.c @@ -229,21 +229,14 @@ void establishListen(Options * options) { void changeToUser(Options * options) { if (options->usr && strlen(options->usr)) { - int uid, gid; -#ifdef _BSD_SOURCE - gid_t gid_list[NGROUPS_MAX]; -#endif - /* get uid */ struct passwd * userpwd; if ((userpwd = getpwnam(options->usr)) == NULL) { ERROR("no such user: %s\n", options->usr); exit(EXIT_FAILURE); } - uid = userpwd->pw_uid; - gid = userpwd->pw_gid; - if(setgid(gid) == -1) { + if(setgid(userpwd->pw_gid) == -1) { ERROR("cannot setgid of user %s: %s\n", options->usr, strerror(errno)); exit(EXIT_FAILURE); @@ -253,33 +246,24 @@ void changeToUser(Options * options) { /* init suplementary groups * (must be done before we change our uid) */ - if (initgroups(options->usr, gid) == -1) { - ERROR("cannot init suplementary groups " - "of user %s: %s\n", options->usr, - strerror(errno)); - } - else if(getgroups(NGROUPS_MAX, gid_list) == -1) { - ERROR("cannot get groups " + if (initgroups(options->usr, userpwd->pw_gid) == -1) { + WARNING("cannot init suplementary groups " "of user %s: %s\n", options->usr, strerror(errno)); - exit(EXIT_FAILURE); - } - else if(setgroups(NGROUPS_MAX, gid_list) == -1) { - ERROR("cannot set groups " - "of user %s: %s\n", options->usr, - strerror(errno)); - exit(EXIT_FAILURE); } #endif /* set uid */ - if (setuid(uid) == -1) { + if (setuid(userpwd->pw_uid) == -1) { ERROR("cannot change to uid of user " "%s: %s\n", options->usr, strerror(errno)); exit(EXIT_FAILURE); } + if(userpwd->pw_dir) { + setenv("HOME", userpwd->pw_dir, 1); + } } } |