tip doesn't set uid correctly in children
ed at fred
ed at fred
Sat Sep 27 04:30:08 AEST 1986
From: ed at 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";
More information about the Comp.bugs.4bsd.ucb-fixes
mailing list