Blame ecryptfs-utils-87-fixexecgid.patch

538c2f
diff -up ecryptfs-utils-99/src/pam_ecryptfs/pam_ecryptfs.c.fixexecgid ecryptfs-utils-99/src/pam_ecryptfs/pam_ecryptfs.c
538c2f
--- ecryptfs-utils-99/src/pam_ecryptfs/pam_ecryptfs.c.fixexecgid	2012-07-24 13:20:58.456297563 +0200
538c2f
+++ ecryptfs-utils-99/src/pam_ecryptfs/pam_ecryptfs.c	2012-07-24 13:21:53.250786224 +0200
538c2f
@@ -337,8 +337,10 @@ static int private_dir(pam_handle_t *pam
538c2f
 				_exit(0);
538c2f
 			}
538c2f
 			clearenv();
538c2f
-			if (setgroups(1, &pwd->pw_gid) < 0 || setgid(pwd->pw_gid) < 0)
538c2f
+			if (initgroups(pwd->pw_name, pwd->pw_gid) != 0) {
538c2f
+				syslog(LOG_ERR, "Unable to set user's groups : %m");
538c2f
 				_exit(255);
538c2f
+			}
538c2f
 			/* run mount.ecryptfs_private as the user */
538c2f
 			if (setresuid(pwd->pw_uid, pwd->pw_uid, pwd->pw_uid) < 0)
538c2f
 				_exit(255);
538c2f
@@ -352,8 +354,10 @@ static int private_dir(pam_handle_t *pam
538c2f
 				_exit(0);
538c2f
 			}
538c2f
 			clearenv();
538c2f
-			if (setgroups(1, &pwd->pw_gid) < 0 || setgid(pwd->pw_gid) < 0)
538c2f
+			if (initgroups(pwd->pw_name, pwd->pw_gid) != 0) {
538c2f
+				syslog(LOG_ERR, "Unable to set user's groups : %m");
538c2f
 				_exit(255);
538c2f
+			}
538c2f
 			/* run umount.ecryptfs_private as the user */
538c2f
 			if (setresuid(pwd->pw_uid, pwd->pw_uid, pwd->pw_uid) < 0)
538c2f
 				_exit(255);