fix login as per man page suggestion Reference: /n/sources/patch/loginfix Date: Sun Mar 23 15:28:52 CET 2014 Signed-off-by: quanstro@quanstro.net --- /sys/man/8/auth Sun Mar 23 15:28:43 2014 +++ /sys/man/8/auth Sun Mar 23 15:28:42 2014 @@ -35,6 +35,10 @@ .B auth/wrkey .PP .B auth/login +[ +.B -a +.I authdom +] .I user .PP .B auth/newns @@ -298,10 +302,3 @@ or .IR convkeys2 . .PP -.I Login -has the string -.L "cs.bell-labs.com" -embedded in it. -You'll want to change that to your local domain -(or fix -.IR login ). --- /sys/src/cmd/auth/login.c Sun Mar 23 15:28:45 2014 +++ /sys/src/cmd/auth/login.c Sun Mar 23 15:28:44 2014 @@ -2,6 +2,10 @@ #include #include #include +#include +#include + +char *authdom; void readln(char *prompt, char *line, int len, int raw) @@ -111,6 +115,35 @@ } /* + * find authdom + */ +char* +getauthdom(void) +{ + char *sysname, *s; + Ndbtuple *t, *p; + + if(authdom != nil) + return authdom; + + sysname = getenv("sysname"); + if(sysname == nil) + return strdup("cs.bell-labs.com"); + + s = "authdom"; + t = csipinfo(nil, "sys", sysname, &s, 1); + free(sysname); + for(p = t; p != nil; p = p->entry) + if(strcmp(p->attr, s) == 0){ + authdom = strdup(p->val); + break; + } + ndbfree(t); +fprint(2, "authdom=%s\n", authdom); + return authdom; +} + +/* * start a new factotum and pass it the username and password */ void @@ -141,11 +174,18 @@ fd = open("/mnt/factotum/ctl", ORDWR); if(fd < 0) sysfatal("opening factotum: %r"); - fprint(fd, "key proto=p9sk1 dom=cs.bell-labs.com user=%q !password=%q", user, password); + fprint(fd, "key proto=p9sk1 dom=%s user=%q !password=%q", getauthdom(), user, password); close(fd); } void +usage(void) +{ + fprint(2, "usage: %s [-a authdom] user\n", argv0); + exits(""); +} + +void main(int argc, char *argv[]) { char pass[ANAMELEN]; @@ -156,7 +196,16 @@ AuthInfo *ai; ARGBEGIN{ + case 'a': + authdom = EARGF(usage()); + break; + default: + usage(); + break; }ARGEND; + + if(argc != 1) + usage(); rfork(RFENVG|RFNAMEG);