rpms/SysVinit/devel sysvinit-2.85-fixscripts.patch,1.1,1.2

fedora-cvs-commits at redhat.com fedora-cvs-commits at redhat.com
Thu Jun 30 20:04:37 UTC 2005


Author: notting

Update of /cvs/dist/rpms/SysVinit/devel
In directory cvs.devel.redhat.com:/tmp/cvs-serv14537

Modified Files:
	sysvinit-2.85-fixscripts.patch 
Log Message:
fix patch to avoid calling realpath() (and equivalents) if at all possible


sysvinit-2.85-fixscripts.patch:
 killall5.c |   45 ++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 40 insertions(+), 5 deletions(-)

Index: sysvinit-2.85-fixscripts.patch
===================================================================
RCS file: /cvs/dist/rpms/SysVinit/devel/sysvinit-2.85-fixscripts.patch,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- sysvinit-2.85-fixscripts.patch	25 Apr 2005 22:07:54 -0000	1.1
+++ sysvinit-2.85-fixscripts.patch	30 Jun 2005 20:04:12 -0000	1.2
@@ -1,16 +1,16 @@
-diff -ru sysvinit-2.85/src/killall5.c sysvinit-2.85-new/src/killall5.c
---- sysvinit-2.85/src/killall5.c	2005-04-25 17:21:08.000000000 -0400
-+++ sysvinit-2.85-new/src/killall5.c	2005-04-25 17:20:19.000000000 -0400
-@@ -50,6 +50,8 @@
+--- sysvinit-2.85/src/killall5.c.fixscripts	2005-06-30 09:42:52.000000000 -0400
++++ sysvinit-2.85/src/killall5.c	2005-06-30 10:13:34.000000000 -0400
+@@ -50,6 +50,9 @@
    char *fullname;	/* Name as found out from argv[0] */
    char *basename;	/* Only the part after the last / */
    char *statname;	/* the statname without braces    */
 +  char *scriptname;     /* (potential) script name	  */
++  char *scriptpath;	/* (potential) script dir	  */
 +       
    pid_t pid;		/* Process ID.			  */
    int sid;		/* Session ID.			  */
    struct _proc_ *next;	/* Pointer to next struct. 	  */
-@@ -177,6 +179,7 @@
+@@ -177,6 +180,7 @@
  
  	/* Walk through the directory. */
  	while ((d = readdir(dir)) != NULL) {
@@ -18,7 +18,7 @@
  
  		/* See if this is a process */
  		if ((pid = atoi(d->d_name)) == 0) continue;
-@@ -235,13 +238,13 @@
+@@ -235,13 +239,13 @@
  		}
  
  		/* Now read argv[0] */
@@ -33,7 +33,7 @@
  
  			/* Store the name into malloced memory. */
  			p->fullname = (char *)xmalloc(f);
-@@ -252,12 +255,30 @@
+@@ -252,12 +256,28 @@
  				p->basename++;
  			else
  				p->basename = p->fullname;
@@ -53,26 +53,58 @@
 +		snprintf(path, sizeof(path), "/proc/%s/cwd", d->d_name);
 +		memset(cwd,'\0',sizeof(cwd));
 +		if (tmparg[0] && readlink(path, cwd, PATH_MAX) != -1) {
-+			p->scriptname = (char *)xmalloc(PATH_MAX);
-+			snprintf(path, sizeof(path),"%s/%s",cwd,tmparg);
-+			if (!realpath(path,p->scriptname)) {
-+				p->scriptname = NULL;
-+			}
++			p->scriptname = strdup(tmparg);
++			p->scriptpath = strdup(cwd);
 +		} else {
 +			p->scriptname = NULL;
++			p->scriptpath = NULL;
 +		}
  
  		/* Try to stat the executable. */
  		snprintf(path, sizeof(path), "/proc/%s/exe", d->d_name);
-@@ -369,8 +390,9 @@
+@@ -324,6 +344,18 @@
+ 	return NULL;
+ }
+ 
++int check_realpath(char *dir, char *entry, char *check)
++{
++	char tmp[PATH_MAX], *path;
++	
++	memset(tmp,'\0',sizeof(tmp));
++	snprintf(tmp,255,"%s/%s", dir, entry);
++	path = canonicalize_file_name(tmp);
++	if (path && !strcmp(path, check))
++		return 1;
++	return 0;
++}
++
+ /* Try to get the process ID of a given process. */
+ PIDQ *pidof(char *prog)
+ {
+@@ -333,10 +365,10 @@
+ 	char *s;
+ 	int foundone = 0;
+ 	int ok = 0;
+-	char real_path[PATH_MAX];
++	char *real_path;
+ 
+ 	/* Try to stat the executable. */
+-	if (prog[0] == '/' && realpath(prog, real_path)) dostat++;
++	if (prog[0] == '/' && (real_path = canonicalize_file_name(prog))) dostat++;
+ 
+ 	/* Get basename of program. */
+ 	if ((s = strrchr(prog, '/')) == NULL)
+@@ -369,8 +401,11 @@
  			    strchr(p->fullname, ' ') ||
  			    scripts_too)
  				ok += (strcmp(p->statname, s) == 0);
 -		        
 -			if (prog[0] == '/' && p->pathname && strcmp(prog,p->pathname))
 +			
++			if (!ok) continue;
++			
 +			if (prog[0] == '/' && p->pathname && strcmp(prog,p->pathname) &&
-+			    !(p->scriptname && !strcmp(p->scriptname,prog) && !strcmp(p->statname,s)))
++			    !(!strcmp(p->statname,s) && check_realpath(p->scriptpath, p->scriptname, prog)))
  				ok = 0;
  
  			if (ok) add_pid_to_q(q, p);




More information about the fedora-cvs-commits mailing list