Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site utcs.uucp Path: utzoo!utcs!geoff From: geoff@utcs.uucp (Geoff Collyer) Newsgroups: net.bugs.4bsd,net.unix-wizards Subject: atrun doesn't set all of user's groups (4.2BSD) Message-ID: <936@utcs.uucp> Date: Wed, 23-Oct-85 02:22:21 EDT Article-I.D.: utcs.936 Posted: Wed Oct 23 02:22:21 1985 Date-Received: Wed, 23-Oct-85 04:15:19 EDT Organization: University of Toronto - General Purpose UNIX Lines: 73 Xref: utcs net.bugs.4bsd:1741 net.unix-wizards:14742 Index: usr.lib/atrun.c 4.2BSD Description: atrun doesn't invoke initgroups(3) to set all the groups to which a user belongs. Repeat-By: Type groups echo 'groups | mail me' | at Observe the different outputs from groups. Fix: Amend at(1). Apply these diffs to atrun.c. Line numbers may vary. *** /tmp/,RCSt1022307 Wed Oct 23 02:05:08 1985 --- /tmp/,RCSt2022307 Wed Oct 23 02:05:10 1985 *************** *** 5,10 * Run programs submitted by at. */ #include #include #include #include --- 6,12 ----- * Run programs submitted by at. */ #include + #include #include #include #include *************** *** 80,85 struct stat stbuf; register pid, i; char sbuf[64]; /* printf("running %s\n", file); */ if (fork()!=0) --- 85,92 ----- register pid, i; struct stat stbuf; char sbuf[64]; + struct passwd *pwp; + struct passwd *getpwuid(); /* printf("running %s\n", file); */ if (fork()!=0) *************** *** 101,106 exit(0); } setgid(stbuf.st_gid); setuid(stbuf.st_uid); execl("/bin/sh", "sh", file, 0); execl("/usr/bin/sh", "sh", file, 0); --- 108,116 ----- exit(0); } setgid(stbuf.st_gid); + if ((pwp = getpwuid(stbuf.st_uid)) == NULL) + exit(1); /* no password file entry */ + initgroups(pwp->pw_name, stbuf.st_gid); setuid(stbuf.st_uid); execl("/bin/sh", "sh", file, 0); execl("/usr/bin/sh", "sh", file, 0); -- Net news is the television of computing.