[dovecot-cvs] dovecot/src/lib restrict-access.c,1.3,1.4

cras at procontrol.fi cras at procontrol.fi
Tue Dec 17 05:00:46 EET 2002


Update of /home/cvs/dovecot/src/lib
In directory danu:/tmp/cvs-serv28872/lib

Modified Files:
	restrict-access.c 
Log Message:
Clear separation of virtual and system usernames. passwd-file didn't work
before if the user didn't exist in system. Prefixed also all setuid/etc.
restriction environments with RESTRICT_.



Index: restrict-access.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib/restrict-access.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- restrict-access.c	26 Nov 2002 19:49:06 -0000	1.3
+++ restrict-access.c	17 Dec 2002 03:00:44 -0000	1.4
@@ -34,12 +34,12 @@
 			     const char *chroot_dir)
 {
 	if (user != NULL && *user != '\0')
-		env_put(t_strconcat("USER=", user, NULL));
+		env_put(t_strconcat("RESTRICT_USER=", user, NULL));
 	if (chroot_dir != NULL && *chroot_dir != '\0')
-		env_put(t_strconcat("CHROOT=", chroot_dir, NULL));
+		env_put(t_strconcat("RESTRICT_CHROOT=", chroot_dir, NULL));
 
-	env_put(t_strdup_printf("SETUID=%ld", (long) uid));
-	env_put(t_strdup_printf("SETGID=%ld", (long) gid));
+	env_put(t_strdup_printf("RESTRICT_SETUID=%ld", (long) uid));
+	env_put(t_strdup_printf("RESTRICT_SETGID=%ld", (long) gid));
 }
 
 void restrict_access_by_env(void)
@@ -49,7 +49,7 @@
 	uid_t uid;
 
 	/* chrooting */
-	env = getenv("CHROOT");
+	env = getenv("RESTRICT_CHROOT");
 	if (env != NULL) {
 		/* kludge: localtime() must be called before chroot(),
 		   or the timezone isn't known */
@@ -65,13 +65,13 @@
 
 	/* groups - the getgid() checks are just so we don't fail if we're
 	   not running as root and try to just use our own GID. */
-	env = getenv("SETGID");
+	env = getenv("RESTRICT_SETGID");
 	gid = env == NULL ? 0 : (gid_t) atol(env);
 	if (gid != 0 && (gid != getgid() || gid != getegid())) {
 		if (setgid(gid) != 0)
 			i_fatal("setgid(%ld) failed: %m", (long) gid);
 
-		env = getenv("USER");
+		env = getenv("RESTRICT_USER");
 		if (env == NULL) {
 			/* user not known, use only this one group */
 			(void)setgroups(1, &gid);
@@ -84,7 +84,7 @@
 	}
 
 	/* uid last */
-	env = getenv("SETUID");
+	env = getenv("RESTRICT_SETUID");
 	uid = env == NULL ? 0 : (uid_t) atol(env);
 	if (uid != 0) {
 		if (setuid(uid) != 0)




More information about the dovecot-cvs mailing list