From: sanjuan!pmacdona@sol.UVic.CA (Peter MacDonald)
Subject: SLS warning + Xlock shadow password patches.
Originator: mdw@db.TC.Cornell.EDU
Keywords: SLS xlock patch shadow passwd
Organization: University of Victoria, Victoria, BC, CANADA
Date: Tue, 15 Dec 1992 16:58:10 GMT

Oh damn.  I didn't bother trying the .99 kernel from floppy.
So don't download it until tomorrow evening.  I will put in
Linus's two line patch.

Also, here is the patch to get Xlock working again under SLS
with shadow password support.   You have to add -DSHADOW_PWD
to the makefile, and "xlock" must now be setuid root.

Peter
-----------------------------------------------------------

*** usleep.c.old	Fri May  8 21:06:10 1992
--- usleep.c	Mon Dec 14 22:48:29 1992
***************
*** 12,18 ****
   */
  
  #include "xlock.h"
! 
  int
  usleep(usec)
      unsigned long usec;
--- 12,18 ----
   */
  
  #include "xlock.h"
! #if 0
  int
  usleep(usec)
      unsigned long usec;
***************
*** 23,28 ****
--- 23,29 ----
      select(0, (void *) 0, (void *) 0, (void *) 0, &timeout);
      return 0;
  }
+ #endif
  
  /*
   * returns the number of seconds since 01-Jan-70.
*** xlock.c.old	Fri May  8 20:43:51 1992
--- xlock.c	Mon Dec 14 22:43:13 1992
***************
*** 405,410 ****
--- 405,422 ----
  
  
  
+ char *mycrypt(char clear[], char salt[] )
+ {
+ 	static char buffer[PASSLENGTH+2];
+ 	char *cp = crypt (clear, salt);
+ 	strcpy (buffer, cp);
+ 	if (strlen (clear) > 8) {
+ 		cp = crypt (clear + 8, salt);
+ 		strcat (buffer, cp + 2);
+ 	}
+ 	return(buffer);
+ }
+ 
  static int
  getPassword()
  {
***************
*** 415,420 ****
--- 427,465 ----
      XWindowAttributes xgwa;
      int         y, left, done;
      struct passwd *pw;
+ #ifdef SHADOW_PWD
+ #include <shadow.h>
+     struct spwd *spw;
+     char *cp, name[30];
+     int amroot = (getuid() == 0);
+ 
+     spw = getspnam("root");
+     strcpy(rootpass, (spw ? spw->sp_pwdp : "" ));
+ 
+     if (amroot) {
+ 	strcpy (name, "root");
+     } else if (cp = getlogin ()) {
+ 	strncpy (name, cp, sizeof name);
+ 	name[ sizeof name - 1 ] = '\0';
+     }
+     else
+ 	strcpy(name,"nobody");
+ puts(name);
+ 
+     user = name;
+ 
+     if ( !(pw = getpwnam (name))) 
+ 	    strcpy(userpass,"x");
+     else
+     if (! amroot && pw->pw_uid != getuid ()) {
+ 	strcpy(userpass,"x");
+     }
+     else
+     {
+ 	spw = getspnam(name);
+ 	strcpy(userpass, (spw ? spw->sp_pwdp : "x" ));
+     }
+ #else
  
      pw = getpwnam("root");
      strcpy(rootpass, pw->pw_passwd);
***************
*** 421,426 ****
--- 466,472 ----
  
      pw = getpwnam(cuserid(NULL));
      strcpy(userpass, pw->pw_passwd);
+ #endif
  
      user = pw->pw_name;
  
***************
*** 475,482 ****
  	 * only
  	 */
  
! 	done = !((strcmp(crypt(buffer, userpass), userpass))
! 	       && (!allowroot || strcmp(crypt(buffer, rootpass), rootpass)));
  
  	if (!done && *buffer == NULL) {
  	    /* just hit return, and it wasn't his password */
--- 521,528 ----
  	 * only
  	 */
  
! 	done = !((strcmp(mycrypt(buffer, userpass), userpass))
! 	       && (!allowroot || strcmp(mycrypt(buffer, rootpass), rootpass)));
  
  	if (!done && *buffer == NULL) {
  	    /* just hit return, and it wasn't his password */

-- 
Send submissions for comp.os.linux.announce to: linux-announce@tc.cornell.edu