🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: net.bugs.4bsd
Article #1688

tip doesn't set uid correctly in children

#1688
From: ed
Date: Fri, 26 Sep 1986 18:30
70 lines
2183 bytes
From: ed@fred.MTXINU (Ed Gould)

Description:
	Tip does not set the uid correctly in the child process
	when it forks.
Repeat-By:
	Invoke tip and use ~s for a shell escape.  The shell will complain
	because the real end effective uid's are not the same.
Fix:
	Whenever tip forks, the real and effective uid and gid in the
	child should be set to the real id's from the time tip
	was invoked.  Apply the following diff to effect the fix.

	*** /usr/src/usr.bin/tip/cmds.c	Tue Aug 26 18:10:31 1986
	--- cmds.c.new			Fri Sep 26 10:21:36 1986
	***************
	*** 187,192 ****
	--- 187,194 ----
		} else {
			register int f;
	  
	+ 		setregid(gid, gid);
	+ 		setreuid(uid, uid);
			dup2(pdes[0], 0);
			close(pdes[0]);
			for (f = 3; f < 20; f++)
	***************
	*** 448,453 ****
	--- 450,457 ----
		} else {
			register int i;
	  
	+ 		setregid(gid, gid);
	+ 		setreuid(uid, uid);
			dup2(FD, 1);
			for (i = 3; i < 20; i++)
				close(i);
	***************
	*** 501,506 ****
	--- 505,512 ----
		} else {
			register int i;
	  
	+ 		setregid(gid, gid);
	+ 		setreuid(uid, uid);
			dup2(FD, 3);
			dup2(3, 4);
			for (i = 5; i < 20; i++)
	***************
	*** 541,546 ****
	--- 547,554 ----
			signal(SIGQUIT, SIG_DFL);
			return;
		} else {
	+ 		setregid(gid, gid);
	+ 		setreuid(uid, uid);
			signal(SIGQUIT, SIG_DFL);
			signal(SIGINT, SIG_DFL);
			if ((cp = rindex(value(SHELL), '/')) == NULL)
	***************
	*** 794,799 ****
	--- 802,809 ----
		}
		sprintf(cmdbuf, "echo %s", name);
		if ((pid = vfork()) == 0) {
	+ 		setregid(gid, gid);
	+ 		setreuid(uid, uid);
			Shell = value(SHELL);
			if (Shell == NOSTR)
				Shell = "/bin/sh";
Technical Details
Message-ID: <119@mtxinu.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!cbatt!ihnp4!qantel!lll-lcc!unisoft!mtxinu!ed@fred

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!cbatt!ihnp4!qantel!lll-lcc!unisoft!mtxinu!ed@fred
From: ed@fred
Newsgroups: net.bugs.4bsd
Subject: tip doesn't set uid correctly in children
Message-ID: <119@mtxinu.UUCP>
Date: Fri, 26-Sep-86 14:30:08 EDT
Article-I.D.: mtxinu.119
Posted: Fri Sep 26 14:30:08 1986
Date-Received: Tue, 30-Sep-86 05:55:59 EDT
Sender: daemon@mtxinu.UUCP
Organization: mt Xinu, Berkeley, CA
Lines: 70