From: Vadim Antonov avg@postman.ncube.com
Subject: Set User (aka su)
Date: Fri, 18 Aug 1995 05:34:19 -0400 [thread overview]
Message-ID: <19950818093419.NOIrLSz1PNoVAo6_3AB0gntwH4XC1fku2Nkp1qXq1G4@z> (raw)
Hi -- there's an equivalent of Unix "su" for Plan9, to
allow to become a different user temporarily.
It uses the file /lib/namespace.su to remount the root file
system under new user name. On a CPU server or terminal
running kfs that should be
naiad% cat /lib/namespace.su
mount -bc /srv/kfs /
naiad%
Does anybody know a better way to tell the file system that
user name has changed? Also, note the magic incantation "cd `{pwd}".
God, if feels like the quote from ken/slp.c.
--vadim
naiad% pwd
/sys/src/cmd/auth
naiad% diff mkfile.old mkfile
16a17
> su\
37a39,41
>
> $BIN/su:V: $O.su
> cp $O.su /$objtype/bin/su
naiad% cat su.c
#include <u.h>
#include <libc.h>
#include <auth.h>
#include "authsrv.h"
void
main(int argc, char *argv[])
{
char buf[32], pass[32], key[DESKEYLEN];
int fd;
Chalstate ch;
char *s;
if( argc != 2 ) {
fprint(2, "usage: su user\n");
exits("usage");
}
s = getenv("service");
if(s && strcmp(s, "cpu") == 0){
fprint(2, "su must not be run on the cpu server\n");
exits("boofhead");
}
if(getchal(&ch, argv[1]) < 0) {
fprint(2, "Authentication failure\n");
exits("can't get challenge");
}
readln("Password: ", pass, sizeof pass, 1);
passtokey(key, pass);
strcpy(buf, ch.chal);
netcrypt(key, buf);
if( chalreply(&ch, buf) < 0 ) {
fprint(2, "Authentication failed\n");
exits("bad response");
}
rfork(RFNAMEG|RFENVG);
if( (fd = create("#e/prompt", OWRITE, 0644)) >= 0 ) {
snprint(buf, sizeof buf, "[%s]%% ", argv[1]);
write(fd, buf, strlen(buf));
close(fd);
}
if( (fd = create("#e/user", OWRITE, 0644)) >= 0 ) {
write(fd, argv[1], strlen(argv[1]));
close(fd);
}
/* Do some magic and start interactive shell */
execl("/bin/rc", "rc", "-c",
". /lib/namespace.su; cd `{pwd}; exec /bin/rc -i", 0);
fprint(2, "Exec failed\n");
exits("exec");
}
naiad%
next reply other threads:[~1995-08-18 9:34 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
1995-08-18 9:34 Vadim [this message]
1995-08-19 7:25 rob
1995-08-21 4:36 Vadim
1995-08-21 6:59 Vadim
1995-08-21 11:24 Vadim
1995-08-21 12:04 Vadim
1995-08-21 21:01 Steve
1995-08-21 21:14 Steve
1995-08-21 23:42 forsyth
1995-08-21 23:51 rob
1995-08-22 3:27 rob
1995-08-22 11:37 dhog
1995-08-22 15:28 carvell
1995-08-22 19:03 Walter
1995-08-22 21:50 Bill
1995-08-23 8:36 Nigel
1995-08-23 15:31 Berry
1995-08-27 14:46 Gary
1995-08-28 4:28 Byron
1995-08-30 16:05 Andrew
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=19950818093419.NOIrLSz1PNoVAo6_3AB0gntwH4XC1fku2Nkp1qXq1G4@z \
--to=9fans@9fans.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).