From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Tolpin Message-Id: <200403170718.i2H7ICJm083368@adat.davidashen.net> To: 9fans@cse.psu.edu Subject: Re: [9fans] Novice question - run as other In-Reply-To: <5697eeee83e079696212a62a1122c1f9@9netics.com> Date: Wed, 17 Mar 2004 11:18:12 +0400 Topicbox-Message-UUID: 31f1a4ee-eacd-11e9-9e20-41e7f4b1d025 > > a program from a shell script and change the user it runs as. > > The security model doesn't allow this. Perhaps by running it as a service > on a cpu. Check /sys/src/cmd/auth/cron.c and cap(3). For somethings > you can cpu over and change to a different uid: The following works: cpu% cat > test.c #include #include void main(int argc,char **argv) { int fd = open("#c/user",OWRITE); if(argc==1) exits("argument required"); fd>=0 && (write(fd,"none",strlen("none"))!=-1) || (exits("cannot become none"),1); close(fd); exec(argv[1], argv+1); } ^D cpu% 8c test.c cpu% 8l test.8 cpu% 8.out /bin/rc -c 'while () {}' In another window cpu% ps -a|grep 8.out none 4546 0:15 0:00 244K Ready /bin/rc -c 'while () {}' How can I do this without the code in C? David