*** pcnfsd_v2.c	Mon Oct 11 02:43:43 1993
--- pcnfsd_v2.1.7.c	Sun Feb 28 03:18:11 1993
***************
*** 1,9 ****
! /* RE_SID: @(%)/usr/dosnfs/shades_SCCS/unix/pcnfsd/v2/src/SCCS/s.pcnfsd_v2.c 1.2 91/12/18 13:26:13 SMI */
  /*
  **=====================================================================
! ** Copyright (c) 1986,1987,1988,1989,1990,1991 by Sun Microsystems, Inc.
! **	@(#)pcnfsd_v2.c	1.2	12/18/91
  **=====================================================================
  */
  #include "common.h"
  /*
--- 1,11 ----
! /* RE_SID: @(%)/tmp_mnt/vol/dosnfs/shades_SCCS/unix/pcnfsd/v2/src/SCCS/s.pcnfsd_v2.c 1.7 93/01/29 17:54:10 SMI */
  /*
  **=====================================================================
! ** Copyright (c) 1986-1993 by Sun Microsystems, Inc.
! **      @(#)pcnfsd_v2.c	1.7     1/29/93
  **=====================================================================
+ *    Code hacked by meister@ftp.com to allow Ultrix4.X auth database to be 
+ *    understood 10/15/92
  */
  #include "common.h"
  /*
***************
*** 43,48 ****
--- 45,54 ----
  #include <shadow.h>
  #endif
  
+ #ifdef ULTRIX_AUTH
+ # include <auth.h>
+ #endif
+ 
  /*
  **---------------------------------------------------------------------
  ** Other #define's 
***************
*** 50,59 ****
--- 56,67 ----
  */
  
  void            fillin_extra_groups();
+ extern char    *my_strdup();
  extern void     scramble();
  extern void    *grab();
  extern char    *crypt();
  extern int      build_pr_list();
+ extern void	mon_printers();
  extern pirstat  build_pr_queue();
  extern psrstat  pr_start();
  extern psrstat  pr_start2();
***************
*** 87,93 ****
  
  static char no_comment[] = "No comment";
  static char not_supported[] = "Not supported";
! static char pcnfsd_version[] = "@(#)pcnfsd_v2.c	1.2 - rpc.pcnfsd V2.0 (c) 1991 Sun Technology Enterprises, Inc.";
  
  /*ARGSUSED*/
  void *pcnfsd2_null_2(arg)
--- 95,101 ----
  
  static char no_comment[] = "No comment";
  static char not_supported[] = "Not supported";
! static char pcnfsd_version[] = "@(#)pcnfsd_v2.c	1.6 - rpc.pcnfsd V2.0 (c) 1991 Sun Technology Enterprises, Inc.";
  
  /*ARGSUSED*/
  void *pcnfsd2_null_2(arg)
***************
*** 108,118 ****
--- 116,131 ----
  struct passwd  *p;
  static u_int           extra_gids[EXTRAGIDLEN];
  static char     home[256];
+ char	       *msgp = NULL;
  #ifdef USE_YP
  char           *yphome;
  char           *cp;
  #endif /*USE_YP*/
  
+ #ifdef ULTRIX_AUTH
+     struct authorization *authbuf;
+     char   salt [2];
+ #endif
  
  	r.stat = AUTH_RES_FAIL;	/* assume failure */
  	r.uid = (int)-2;
***************
*** 152,161 ****
     }
  #endif
  
! 	p = get_password(uname);
  	if (p == (struct passwd *)NULL)
  	   return (&r);
  
  	c1 = strlen(pw);
  	c2 = strlen(p->pw_passwd);
  	if ((c1 && !c2) || (c2 && !c1) ||
--- 165,198 ----
     }
  #endif
  
! 	p = get_password(uname, &msgp);
! 	if(msgp)
! 		r.cm = msgp;
  	if (p == (struct passwd *)NULL)
  	   return (&r);
  
+ #ifdef ULTRIX_AUTH
+         if (p->pw_passwd [0] == '*')
+         {
+ 	    authbuf = getauthuid (p->pw_uid);
+             if (!authbuf)
+             {    return (&r);
+             }
+ 
+             salt [0] = authbuf->a_password [0];
+             salt [1] = authbuf->a_password [1];
+             c1 = strlen(pw);
+             c2 = strlen(authbuf->a_password);
+             if ((c1 && !c2) || (c2 && !c1))
+                 return (&r);
+             if (strncmp (crypt16 (pw, salt), authbuf->a_password, 
+                 CRYPT_PASSWORD_LENGTH))
+             {   return (&r);
+             }
+         }   
+         else
+         {
+ #endif
  	c1 = strlen(pw);
  	c2 = strlen(p->pw_passwd);
  	if ((c1 && !c2) || (c2 && !c1) ||
***************
*** 163,168 ****
--- 200,209 ----
             {
  	   return (&r);
  	   }
+ #ifdef ULTRIX_AUTH
+        }
+ #endif
+ 
  	r.stat = AUTH_RES_OK;
  	r.uid = p->pw_uid;
  	r.gid = p->pw_gid;
***************
*** 224,229 ****
--- 265,271 ----
  {
  static v2_pr_list_results res;
  
+ 	mon_printers();
  	if(printers == NULL)
  		(void)build_pr_list();
  	res.cm = &no_comment[0];
***************
*** 337,351 ****
  	return;
  }
  
- static char *
- my_strdup(s)
- char *s;
- {
- char *r;
- 	r = (char *)grab(strlen(s)+1);
- 	strcpy(r, s);
- 	return(r);
- }
  
  v2_mapid_results *pcnfsd2_mapid_2(arg)
  v2_mapid_args *arg;
--- 379,384 ----
***************
*** 525,536 ****
--- 558,573 ----
  	static char domain[YPMAXDOMAIN+1];
  
  	if(getdomainname(domain, YPMAXDOMAIN) ) {
+ #ifdef DEBUG
  		msg_out("rpc.pcnfsd: getdomainname failed");
+ #endif
  		return(NULL);
  	}
  
  	if (err = yp_bind(domain)) {
+ #ifdef DEBUG
  		msg_out("rpc.pcnfsd: yp_bind failed");
+ #endif
  		return(NULL);
  	}
  
***************
*** 537,543 ****
--- 574,582 ----
  	err = yp_match(domain, map, key, strlen(key), &val, &len);
  
  	if (err) {
+ #ifdef DEBUG
  		msg_out("rpc.pcnfsd: yp_match failed");
+ #endif
  		return(NULL);
  	}
  
