patch-1.3.7 linux/kernel/sys.c

Next file: linux/net/802/p8022.c
Previous file: linux/kernel/ksyms.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v1.3.6/linux/kernel/sys.c linux/kernel/sys.c
@@ -195,6 +195,7 @@
 asmlinkage int sys_setregid(gid_t rgid, gid_t egid)
 {
 	int old_rgid = current->gid;
+	int old_egid = current->egid;
 
 	if (rgid != (gid_t) -1) {
 		if ((old_rgid == rgid) ||
@@ -219,6 +220,8 @@
 	    (egid != (gid_t) -1 && egid != old_rgid))
 		current->sgid = current->egid;
 	current->fsgid = current->egid;
+	if (current->egid != old_egid)
+		current->dumpable = 0;
 	return 0;
 }
 
@@ -227,12 +230,16 @@
  */
 asmlinkage int sys_setgid(gid_t gid)
 {
+	int old_egid = current->egid;
+
 	if (suser())
 		current->gid = current->egid = current->sgid = current->fsgid = gid;
 	else if ((gid == current->gid) || (gid == current->sgid))
 		current->egid = current->fsgid = gid;
 	else
 		return -EPERM;
+	if (current->egid != old_egid)
+		current->dumpable = 0;
 	return 0;
 }
 
@@ -284,6 +291,7 @@
 asmlinkage int sys_setreuid(uid_t ruid, uid_t euid)
 {
 	int old_ruid = current->uid;
+	int old_euid = current->euid;
 
 	if (ruid != (uid_t) -1) {
 		if ((old_ruid == ruid) || 
@@ -308,6 +316,8 @@
 	    (euid != (uid_t) -1 && euid != old_ruid))
 		current->suid = current->euid;
 	current->fsuid = current->euid;
+	if (current->euid != old_euid)
+		current->dumpable = 0;
 	return 0;
 }
 
@@ -324,12 +334,16 @@
  */
 asmlinkage int sys_setuid(uid_t uid)
 {
+	int old_euid = current->euid;
+
 	if (suser())
 		current->uid = current->euid = current->suid = current->fsuid = uid;
 	else if ((uid == current->uid) || (uid == current->suid))
 		current->fsuid = current->euid = uid;
 	else
 		return -EPERM;
+	if (current->euid != old_euid)
+		current->dumpable = 0;
 	return(0);
 }
 
@@ -346,6 +360,8 @@
 	if (uid == current->uid || uid == current->euid ||
 	    uid == current->suid || uid == current->fsuid || suser())
 		current->fsuid = uid;
+	if (current->fsuid != old_fsuid)
+		current->dumpable = 0;
 	return old_fsuid;
 }
 
@@ -359,6 +375,8 @@
 	if (gid == current->gid || gid == current->egid ||
 	    gid == current->sgid || gid == current->fsgid || suser())
 		current->fsgid = gid;
+	if (current->fsgid != old_fsgid)
+		current->dumpable = 0;
 	return old_fsgid;
 }
 

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov with Sam's (original) version
of this