Sophie

Sophie

distrib > Mageia > 6 > armv5tl > media > core-release-src > by-pkgid > 30481cc1ce5b90273dfd25fd8fbc31bc > files > 2

linux_pcnfsd2-1.6-2.mga6.src.rpm

Index: Makefile.linux
===================================================================
--- Makefile.linux.orig
+++ Makefile.linux
@@ -40,13 +40,14 @@ HDRS= pcnfsd.h common.h
 
 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
Index: common.h
===================================================================
--- common.h.orig
+++ common.h
@@ -67,7 +67,7 @@
 **---------------------------------------------------------------------
 **/
 
-/* #define SHADOW_SUPPORT */
+#define SHADOW_SUPPORT
 
 /*
 **---------------------------------------------------------------------
Index: pcnfsd_misc.c
===================================================================
--- pcnfsd_misc.c.orig
+++ pcnfsd_misc.c
@@ -18,10 +18,15 @@
 #include "pcnfsd.h"
 
 #include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
 #include <pwd.h>
+#include <time.h>
 #include <sys/file.h>
 #include <signal.h>
 #include <sys/time.h>
+#include <sys/types.h>
+#include <wait.h>
 #include <sys/stat.h>
 #include <sys/ioctl.h>
 #include <netdb.h>
@@ -29,6 +34,7 @@
 #include <string.h>
 #include <memory.h>
 #include <ctype.h>
+#include <paths.h>
 
 #ifdef ISC_2_0
 #include <sys/fcntl.h>
@@ -48,7 +54,7 @@ extern char *getusershell();
 
 /*
 **---------------------------------------------------------------------
-** Other #define's 
+** Other #define's
 **---------------------------------------------------------------------
 */
 
@@ -68,7 +74,7 @@ int		uidrhi[NUMUIDS];
 */
 /*
 **---------------------------------------------------------------------
-**                          Support procedures 
+**                          Support procedures
 **---------------------------------------------------------------------
 */
 
@@ -114,8 +120,13 @@ char *r;
 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 +135,7 @@ scramble(s1, s2)
 char           *s1;
 char           *s2;
 {
-	while (*s1) 
+	while (*s1)
 	      {
 	      *s2++ = (*s1 ^ zchar) & 0x7f;
 	      s1++;
@@ -212,6 +223,7 @@ long		expday;
 #endif
 
 #ifdef SHADOW_SUPPORT
+#if 0
 	/*
         **--------------------------------------------------------------
 	** Check the existence of SHADOW.  If it is there, then we are
@@ -231,7 +243,7 @@ long		expday;
 	   (shadowfile && (sp = getspnam(usrnam)) == (struct spwd *)NULL))
 	return ((struct passwd *)NULL);
 
-	if (shadowfile) 
+	if (shadowfile)
            {
 /*
  * New - check password expiry situation
@@ -271,10 +283,22 @@ long		expday;
 		}
 	   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 +307,12 @@ long		expday;
 #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 +364,7 @@ long		expday;
 
 /*
 **---------------------------------------------------------------------
-**                      Print support procedures 
+**                      Print support procedures
 **---------------------------------------------------------------------
 */
 
@@ -440,7 +464,7 @@ run_ps630(f, opts)
 
 /*
 **---------------------------------------------------------------------
-**                      WTMP update support 
+**                      WTMP update support
 **---------------------------------------------------------------------
 */
 
@@ -480,7 +504,8 @@ extern char *getcallername();
 #else SVR4
 
 #include <utmp.h>
-#define WTMP_PATH "/usr/adm/wtmp"
+#define WTMP_PATH _PATH_WTMP
+
 
 void
 wlogin(name)
@@ -509,7 +534,7 @@ extern char *getcallername();
 
 /*
 **---------------------------------------------------------------------
-**                      Run-process-as-user procedures 
+**                      Run-process-as-user procedures
 **---------------------------------------------------------------------
 */
 
@@ -644,8 +669,14 @@ su_popen(user, cmd, maxtime)
 		}
 		dup2(1, 2);	/* let's get stderr as well */
 
-		(void) setgid(cached_gid);
-		(void) setuid(cached_uid);
+		if (-1 == setgid(cached_gid)) {
+			perror ("setgid");
+			exit(1);
+		}
+		if (-1 == setuid(cached_uid)) {
+			perror ("setuid");
+			exit(1);
+		}
 
 		(void) execl("/bin/sh", "sh", "-c", cmd, (char *) NULL);
 		_exit(255);
@@ -737,7 +768,7 @@ char *arg2;
 				wtmp_enabled = 0;;
 			continue;
 		}
-#endif	
+#endif
 		if(!mystrcasecmp(kw, "printer")) {
 			arg1 = strtok(NULL, " \t");
 			arg2 = (arg1 == NULL ? NULL : strtok(NULL, ""));
Index: pcnfsd_print.c
===================================================================
--- pcnfsd_print.c.orig
+++ pcnfsd_print.c
@@ -17,6 +17,7 @@
 */
 #include "pcnfsd.h"
 #include <stdlib.h>
+#include <unistd.h>
 #include <stdio.h>
 #include <pwd.h>
 #include <ctype.h>
@@ -96,7 +97,7 @@ struct stat     statbuf;
 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 +220,11 @@ char *sys;
 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 +234,19 @@ int rc;
 
 	/* 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 +406,7 @@ int failed = 0;
 	        */
 		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 +1498,7 @@ struct {
 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";
Index: pcnfsd_svc.c
===================================================================
--- pcnfsd_svc.c.orig
+++ pcnfsd_svc.c
@@ -10,10 +10,12 @@
 #include "common.h"
 
 #include <stdio.h>
+#include <unistd.h>
 #include <rpc/rpc.h>
 #include <signal.h>
 #include <sys/socket.h>
 #include <sys/ioctl.h>
+#include <fcntl.h>
 
 /* The following changes for Ultrix 4.2 were suggested by various users */
 #ifndef ULTRIX