Skip to content

Commit

Permalink
stop moxi from refusing to run under root
Browse files Browse the repository at this point in the history
Because nobody cares. And because our memcached fork has been updated
to don't care as well.

Change-Id: I5627c37e26f827a74a62aad115a8940e3fa2815a
Reviewed-on: http://review.couchbase.org/35506
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Reviewed-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>
  • Loading branch information
Aliaksey Kandratsenka authored and aartamonau committed Apr 9, 2014
1 parent 1228df3 commit e4d3748
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions src/memcached.c
Expand Up @@ -4920,20 +4920,15 @@ int main (int argc, char **argv) {
#ifndef MAIN_CHECK
#ifdef HAVE_GETPWNAM
if (getuid() == 0 || geteuid() == 0) {
if (username == 0 || *username == '\0') {
moxi_log_write("can't run as root without the -u switch\n");
if (ml->log_mode != ERRORLOG_STDERR) {
fprintf(stderr, "can't run as root without the -u switch\n");
if (username != NULL) {
if ((pw = getpwnam(username)) == 0) {
moxi_log_write("can't find the user %s to switch to\n", username);
exit(EX_NOUSER);
}
if (setgid(pw->pw_gid) < 0 || setuid(pw->pw_uid) < 0) {
moxi_log_write("failed to assume identity of user %s\n", username);
exit(EX_OSERR);
}
exit(EX_USAGE);
}
if ((pw = getpwnam(username)) == 0) {
moxi_log_write("can't find the user %s to switch to\n", username);
exit(EX_NOUSER);
}
if (setgid(pw->pw_gid) < 0 || setuid(pw->pw_uid) < 0) {
moxi_log_write("failed to assume identity of user %s\n", username);
exit(EX_OSERR);
}
}
#endif
Expand Down

0 comments on commit e4d3748

Please sign in to comment.