File linux_pcnfsd2.dif of Package linux_pcnfsd2

--- Makefile.linux
+++ Makefile.linux
@@ -40,13 +40,14 @@
 
 LINTFLAGS= -hbax
 # uncomment as appropriate for debugging
-CFLAGS = -DOSVER_BSD386 
+CFLAGS = -O2 -fexpensive-optimizations -pipe -DOSVER_BSD386 $(RPM_OPT_FLAGS)
 #CFLAGS = -g -DDEBUG -DOSVER_BSD386
-LIBS= #-lrpc
-LFLAGS = 
+LIBS = #-lrpc
+LIBCRYPT = -lcrypt
+LFLAGS =
 
 linux/rpc.pcnfsd: $(LINUX_OBJS) $(HDRS)
-	$(CC)  -o $@ $(CFLAGS) $(LFLAGS) $(LINUX_OBJS) $(LIBS)
+	$(CC)  -o $@ $(CFLAGS) $(LFLAGS) $(LINUX_OBJS) $(LIBS) $(LIBCRYPT)
 
 linux/pcnfsd_svc.o: $(HDRS) pcnfsd_svc.c
 	$(CC)  -c $(CFLAGS) -o $@ pcnfsd_svc.c
--- common.h
+++ common.h
@@ -67,7 +67,7 @@
 **---------------------------------------------------------------------
 **/
 
-/* #define SHADOW_SUPPORT */
+#define SHADOW_SUPPORT
 
 /*
 **---------------------------------------------------------------------
--- pcnfsd_misc.c
+++ pcnfsd_misc.c
@@ -29,6 +29,7 @@
 #include <string.h>
 #include <memory.h>
 #include <ctype.h>
+#include <paths.h>
 
 #ifdef ISC_2_0
 #include <sys/fcntl.h>
@@ -48,7 +49,7 @@
 
 /*
 **---------------------------------------------------------------------
-** Other #define's 
+** Other #define's
 **---------------------------------------------------------------------
 */
 
@@ -68,7 +69,7 @@
 */
 /*
 **---------------------------------------------------------------------
-**                          Support procedures 
+**                          Support procedures
 **---------------------------------------------------------------------
 */
 
@@ -114,8 +115,13 @@
 int suspicious (s)
 char *s;
 {
-	if(strpbrk(s, ";|&<>`'#!?*()[]^/") != NULL)
-		return 1;
+        /* Linux rpc.pcnfsd patch developed by Mark Zielinski of RSI.
+           Http://www.repsec.com */
+
+        if (strspn(s, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_=:+1234567890@%,.")
+          != strlen(s))
+            return 1;
+
 	return 0;
 }
 
@@ -124,7 +130,7 @@
 char           *s1;
 char           *s2;
 {
-	while (*s1) 
+	while (*s1)
 	      {
 	      *s2++ = (*s1 ^ zchar) & 0x7f;
 	      s1++;
@@ -212,6 +218,7 @@
 #endif
 
 #ifdef SHADOW_SUPPORT
+#if 0
 	/*
         **--------------------------------------------------------------
 	** Check the existence of SHADOW.  If it is there, then we are
@@ -231,7 +238,7 @@
 	   (shadowfile && (sp = getspnam(usrnam)) == (struct spwd *)NULL))
 	return ((struct passwd *)NULL);
 
-	if (shadowfile) 
+	if (shadowfile)
            {
 /*
  * New - check password expiry situation
@@ -271,10 +278,22 @@
 		}
 	   pswd = sp->sp_pwdp;
 	   (void) endspent();
-	   } 
+	   }
         else
 	   pswd = p->pw_passwd;
+#endif
+	p = getpwnam(usrnam);
+	if (p == (struct passwd *)NULL)
+		return ((struct passwd *)NULL);
+	endpwent();
+
+	sp = getspnam(p->pw_name);
+	endspent();
 
+	if (sp)
+		pswd = sp->sp_pwdp;
+	else
+		pswd = p->pw_passwd;
 #else
 	p = getpwnam(usrnam);
 	if (p == (struct passwd *)NULL)
@@ -283,12 +302,12 @@
 #endif
 
 #ifdef ISC_2_0
-	/* 
+	/*
         **-----------------------------------------------------------
 	** We may have an 'x' in which case look in /etc/shadow ..
         **-----------------------------------------------------------
         */
-	if (((strlen(pswd)) == 1) && pswd[0] == 'x') 
+	if (((strlen(pswd)) == 1) && pswd[0] == 'x')
 	   {
 	   struct spwd    *shadow = getspnam(usrnam);
 
@@ -340,7 +359,7 @@
 
 /*
 **---------------------------------------------------------------------
-**                      Print support procedures 
+**                      Print support procedures
 **---------------------------------------------------------------------
 */
 
@@ -440,7 +459,7 @@
 
 /*
 **---------------------------------------------------------------------
-**                      WTMP update support 
+**                      WTMP update support
 **---------------------------------------------------------------------
 */
 
@@ -480,7 +499,8 @@
 #else SVR4
 
 #include <utmp.h>
-#define WTMP_PATH "/usr/adm/wtmp"
+#define WTMP_PATH _PATH_WTMP
+
 
 void
 wlogin(name)
@@ -509,7 +529,7 @@
 
 /*
 **---------------------------------------------------------------------
-**                      Run-process-as-user procedures 
+**                      Run-process-as-user procedures
 **---------------------------------------------------------------------
 */
 
@@ -737,7 +757,7 @@
 				wtmp_enabled = 0;;
 			continue;
 		}
-#endif	
+#endif
 		if(!mystrcasecmp(kw, "printer")) {
 			arg1 = strtok(NULL, " \t");
 			arg2 = (arg1 == NULL ? NULL : strtok(NULL, ""));
--- pcnfsd_print.c
+++ pcnfsd_print.c
@@ -96,7 +96,7 @@
 char            pathname[MAXPATHLEN];
 char            new_pathname[MAXPATHLEN];
 char            sp_name[MAXPATHLEN] = SPOOLDIR;
-char            tempstr[256];
+static char            tempstr[256];
 char            delims[] = " \t\r\n:()";
 
 pr_list         printers = NULL;
@@ -219,8 +219,11 @@
 char *pr;
 char**sp;
 {
-int    dir_mode = 0777;
-int rc;
+
+        /* Linux rpc.pcnfsd patch developed by Mark Zielinski of RSI.
+           Http://www.repsec.com */
+
+        int dir_mode = 0777, rc, oldumask;
 
 	*sp = &pathname[0];
 	pathname[0] = '\0';
@@ -230,12 +233,19 @@
 
 	/* get pathname of current directory and return to client */
 
-	(void)sprintf(pathname,"%s/%s",sp_name, sys);
+        oldumask = umask(0);
+        (void)sprintf(pathname,"%s/%s",sp_name, sys);
+        (void)mkdir(sp_name, dir_mode); /* ignore the return code */
+        rc = mkdir(pathname, dir_mode); /* DON'T ignore this return code */
+        umask(oldumask);
+
+	(void)snprintf(pathname, (sizeof(pathname)-1), "%s/%s",sp_name,
+          sys);
+
 	(void)mkdir(sp_name, dir_mode);	/* ignore the return code */
-	(void)chmod(sp_name, dir_mode);
 	rc = mkdir(pathname, dir_mode);	/* DON'T ignore this return code */
+
 	if((rc < 0 && errno != EEXIST) ||
-	   (chmod(pathname, dir_mode) != 0) ||
 	   (stat(pathname, &statbuf) != 0) ||
 	   !(statbuf.st_mode & S_IFDIR)) {
 	   (void)sprintf(tempstr,
@@ -395,7 +405,7 @@
 	        */
 		if(!xcmd) {
 #ifdef BSD_STYLE_PRINT
-#ifdef BSD386
+#if defined ( BSD386 ) || defined ( linux )
 			sprintf(cmdbuf, "/usr/bin/lpr -P%s -C%s -J%s %s",
 				pr, system, user, new_pathname);
 #else
@@ -1487,7 +1497,7 @@
 char default_cmd[] = "lp $FILE";
 #endif SVR4_STYLE_PRINT
 #ifdef BSD_STYLE_PRINT
-#ifdef BSD386
+#if defined ( BSD386 ) || defined ( linux )
 char default_cmd[] = "/usr/bin/lpr $FILE";
 #else
 char default_cmd[] = "/usr/ucb/lpr $FILE";