--- /sys/src/cmd/screenlock.c Sat Jul 31 02:09:51 2010 +++ /sys/src/cmd/screenlock.c Sun Nov 30 00:00:00 2025 @@ -6,13 +6,17 @@ #include #include +enum { + Stacksize = 8*1024, +}; + char pic[] = "/lib/bunny.bit"; int vgactl; int debug; int doblank; -int chatty = 0; - +int chatty = 1; +int mainstacksize = 16*1024; char user[256]; void @@ -77,7 +81,7 @@ if(read(0, &c, 1) != 1 || c == '\04' || c == '\177'){ i = 0; break; - } else if(c == '\n') + } else if(c == '\n' || c == '\r') break; else if(c == '\b' && i > 0) --i; @@ -119,7 +123,7 @@ for(;;){ if(chatty || !must) - fprint(2, "%s's screenlock password: ", user); + fprint(2, "%s's password: ", user); memset(buf, 0, sizeof buf); readline(buf, sizeof buf); blankscreen(0); @@ -138,7 +142,8 @@ auth_freeAI(ai); if(chatty || !must) - fprint(2, "password mismatch\n"); + fprint(2, "password mismatch (or factotum " + "role=server attribute missing)\n"); doblank = 1; } memset(buf, 0, sizeof buf); @@ -146,6 +151,25 @@ } void +ensurefactotumentry(char *user) +{ + char *fmt; + Chalstate *ch; + static char tuplefmt[] = "user=%q proto=p9cr role=server"; + + /* + * borrowed from auth_userpasswd. + */ + ch = auth_challenge(tuplefmt, user); + if(ch == nil) { + fmt = smprint("factotum tuple not found: %s\n", tuplefmt); + fprint(2, fmt, user); + exits("no factotum tuple"); + } + auth_freechal(ch); +} + +void blanker(void *) { int tics; @@ -228,8 +252,8 @@ error("no display"); /* screen is now open and covered. grab mouse and hold on tight */ - procrfork(grabmouse, nil, 4096, RFFDG); - procrfork(blanker, nil, 4096, RFFDG); + procrfork(grabmouse, nil, Stacksize, RFFDG); + procrfork(blanker, nil, Stacksize, RFFDG); fd = open(pic, OREAD); if(fd > 0){ i = readimage(display, fd, 0); @@ -283,6 +307,7 @@ if(argc != 0) usage(); + ensurefactotumentry(user); doblank = 1; lockscreen(); checkpassword(); --- /n/9pi/sys/man/8/screenlock Sat Feb 27 02:09:32 2010 +++ /sys/man/8/screenlock Sun Sep 14 17:27:51 2025 @@ -16,5 +16,26 @@ the image displayed while the terminal is locked .SH SOURCE .B /sys/src/cmd/screenlock.c +.SH SEE ALSO +.IR auth (2), +.IR factotum (4) +.SH DIAGNOSTICS +Per +.BR BUGS , +a missing +.L role=server +attribute makes +.I screenlock +misleadingly report a password mismatch. .SH BUGS Use of this program on communal terminals is anti-social. +.PP +.I Screenlock +uses +.IR auth_userpasswd , +which requires a +.L role=server +attribute in a +.I factotum +entry for the invoking user. +This requirement may be a mistake.