changeset 9173:2db158dd88be HEAD

dump-capability: Use nobody/nogroup as uid/gid if they exist.
author Timo Sirainen <tss@iki.fi>
date Sat, 27 Jun 2009 21:52:30 -0400
parents bc880b70d731
children eed86bcc33aa
files src/master/master-settings.c
diffstat 1 files changed, 12 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/master/master-settings.c	Sat Jun 27 21:45:04 2009 -0400
+++ b/src/master/master-settings.c	Sat Jun 27 21:52:30 2009 -0400
@@ -682,6 +682,18 @@
 		/* use the current user */
 		args[0] = t_strdup_printf("uid=%s", dec2str(uid));
 		args[1] = t_strdup_printf("gid=%s", dec2str(getegid()));
+	} else {
+		/* try to use some existing user. at least osx launchd
+		   doesn't like non-existing users. */
+		struct passwd *pw;
+		struct group *gr;
+
+		pw = getpwnam("nobody");
+		if (pw != NULL)
+			args[0] = t_strdup_printf("uid=%s", dec2str(pw->pw_uid));
+		gr = getgrnam("nogroup");
+		if (gr != NULL)
+			args[1] = t_strdup_printf("gid=%s", dec2str(gr->gr_gid));
 	}
 
 	if (pipe(fd) < 0) {