[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

patches



these are 2 patches that apply on checkinstall 1.5.0 :

checkinstall-1.diff corrects a little trouble in parameters parsing
checkinstall-2.diff  corrects a bad return code handling.
checkinstall-1.5.0-pbtest.diff corrects a segfault in the installwatch test 
program.

i had already posted the 2 first, but before i saw the mailing list was there.

a note on the third one :

it corrects essentially the segfault trouble due to the RTLD_NEXT usage , but 
- and if my patches seem ok - the method used to verify that the libc calls 
are correctly intercepted seem to depend to much on the libc version.

hope this helps.

A+OF

-- 
mailto:olivier.fleurigeon@xxxxxxxxxx
work=0149092200:2782
diff -c -b -r checkinstall-1.5.0/checkinstall checkinstall-1.5.0-p1/checkinstall
*** checkinstall-1.5.0/checkinstall	Sun Nov 18 08:35:25 2001
--- checkinstall-1.5.0-p1/checkinstall	Tue Nov 27 13:51:07 2001
***************
*** 244,257 ****
  # Arguments parsing
  
  CKNAME=`basename $0`
! PARAMS=`getopt -a -n $CKNAME -o +d:DA:t:RShHy -l arch:,type:,si,showinstall::,ss,showslack::,deldoc::,delspec::,deldesc::,strip::,bk,backup::,autodoinst::,spec:,exclude:,pkgname:,pkgversion:,pkgrelease:,pkglicense:,pkggroup:,pkgsource:,pkgaltsource:,pakdir:,dpkgflags:,rpmflags:,pkgarch:,help,version,copyright,default -- $*`
  
  [ $? -gt 0 ] && help_notice
  
  eval set -- $PARAMS
  
  while [ "$1" != "--" ]; do
!    case $1 in
        -h|-H|--help)
           usage;;
        -d)
--- 244,257 ----
  # Arguments parsing
  
  CKNAME=`basename $0`
! PARAMS=`getopt -a -n $CKNAME -o +d:DA:t:RShHy -l arch:,type:,si,showinstall::,ss,showslack::,deldoc::,delspec::,deldesc::,strip::,bk,backup::,autodoinst::,spec:,exclude:,pkgname:,pkgversion:,pkgrelease:,pkglicense:,pkggroup:,pkgsource:,pkgaltsource:,pakdir:,dpkgflags:,rpmflags:,pkgarch:,help,version,copyright,default -- "$@"`
  
  [ $? -gt 0 ] && help_notice
  
  eval set -- $PARAMS
  
  while [ "$1" != "--" ]; do
!    case "$1" in
        -h|-H|--help)
           usage;;
        -d)
diff -c -b -r checkinstall-1.5.0-p1/checkinstall checkinstall-1.5.0-p2/checkinstall
*** checkinstall-1.5.0-p1/checkinstall	Tue Nov 27 13:51:07 2001
--- checkinstall-1.5.0-p2/checkinstall	Tue Nov 27 13:54:04 2001
***************
*** 696,704 ****
--- 696,706 ----
  
  # Run the install command, showing the results interactively if we were asked
  # to do so in the configuration section (see the SHOW_INSTALL switch above)
+ INSTALL_FAILED=0
  if [ $SHOW_INSTALL -eq 0 ]; then
     $INSTALLWATCH -o /${TMP_DIR}/newfiles.tmp $TMP_SCRIPT &> /${TMP_DIR}/install.log
     okfail
+    INSTALL_FAILED=$?
     unset INSTALLWATCH_BACKUP_PATH
  else
     echo
***************
*** 708,720 ****
     if [ $? -eq 0 ]; then 
        echo
        echo ======================== Installation succesful ==========================
!       true     #
!    else        # This is ugly, but it works  ;-)
!       false    #
     fi
  fi
  
- INSTALL_FAILED=$?
  unset INSTALLWATCH_BACKUP_PATH
  
  unset LD_PRELOAD
--- 710,720 ----
     if [ $? -eq 0 ]; then 
        echo
        echo ======================== Installation succesful ==========================
!    else    
!       INSTALL_FAILED=1
     fi
  fi
  
  unset INSTALLWATCH_BACKUP_PATH
  
  unset LD_PRELOAD
diff -Naur checkinstall-1.5.0/installwatch-0.6.2/Makefile checkinstall-1.5.0-pbtest/installwatch-0.6.2/Makefile
--- checkinstall-1.5.0/installwatch-0.6.2/Makefile	Sun Nov 18 09:35:47 2001
+++ checkinstall-1.5.0-pbtest/installwatch-0.6.2/Makefile	Thu Dec 13 12:17:29 2001
@@ -41,7 +41,7 @@
 	tar -czvC .. -f ../installwatch-$(VERSION).tar.gz installwatch-$(VERSION)
 
 test: install
-	gcc -Wall -DVERSION=\"$(VERSION)\" -o test-installwatch test-installwatch.c -ldl
+	gcc -Wall -DLIBDIR=\"$(LIBDIR)\" -D_GNU_SOURCE -DVERSION=\"$(VERSION)\" -o test-installwatch test-installwatch.c -ldl
 	$(PREFIX)/bin/installwatch ./test-installwatch
 
 
diff -Naur checkinstall-1.5.0/installwatch-0.6.2/installwatch.c checkinstall-1.5.0-pbtest/installwatch-0.6.2/installwatch.c
--- checkinstall-1.5.0/installwatch-0.6.2/installwatch.c	Sun Nov 18 09:35:47 2001
+++ checkinstall-1.5.0-pbtest/installwatch-0.6.2/installwatch.c	Thu Dec 13 11:45:17 2001
@@ -34,11 +34,12 @@
 #include <errno.h>
 #include <unistd.h>
 #include <string.h>
+#include <time.h>
 #include <dlfcn.h>
 
 #include "localdecls.h"
 
-/*#define DEBUG 1*/ 
+#define DEBUG 1 
 
 #define LOGLEVEL (LOG_USER | LOG_INFO | LOG_PID)
 #define BUFSIZE 1024
@@ -46,9 +47,12 @@
 #define error(X) (X < 0 ? strerror(errno) : "success")
 
 int __installwatch_refcount = 0;
+int __installwatch_timecount = 0;
 
 #define REFCOUNT __installwatch_refcount++
+#define TIMECOUNT __installwatch_timecount++
 
+static time_t (*true_time) (time_t *);
 static int(*true_chmod)(const char *, mode_t);
 static int(*true_chown)(const char *, uid_t, gid_t);
 static int(*true_chroot)(const char *);
@@ -98,6 +102,7 @@
 	#endif
 
 
+	true_time = dlsym(libc_handle, "time");
 	true_chmod = dlsym(libc_handle, "chmod");
 	true_chown = dlsym(libc_handle, "chown");
 	true_chroot = dlsym(libc_handle, "chroot");
@@ -123,6 +128,7 @@
 	true_open64 = dlsym(libc_handle, "open64");
 	true_truncate64 = dlsym(libc_handle, "truncate64");
 #endif
+
 }
 
 static void log(const char *format, ...) {
@@ -375,6 +381,15 @@
 
 }
 
+time_t time (time_t *timer) {
+	TIMECOUNT;
+
+#if DEBUG
+	puts("time\n");
+#endif
+
+return true_time(timer);
+}
 
 int chmod(const char *path, mode_t mode) {
 	int result;
@@ -384,7 +399,7 @@
 	canonicalize(path, canonic);
 	
      #if DEBUG
-	puts ("chmod\n");
+	puts ("in installwatch chmod\n");
      #endif
 	backup (canonic);
 
diff -Naur checkinstall-1.5.0/installwatch-0.6.2/test-installwatch.c checkinstall-1.5.0-pbtest/installwatch-0.6.2/test-installwatch.c
--- checkinstall-1.5.0/installwatch-0.6.2/test-installwatch.c	Thu Dec 13 11:18:32 2001
+++ checkinstall-1.5.0-pbtest/installwatch-0.6.2/test-installwatch.c	Thu Dec 13 12:29:20 2001
@@ -16,25 +16,56 @@
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
-#include <dlfcn.h>
 #include <fcntl.h>
 #include <stdio.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <unistd.h>
+#include <time.h>
+#include <dlfcn.h>
 
 #include "localdecls.h"
 
+#ifndef	LIBDIR 
+	#define LIBDIR "/usr/local/lib"
+#endif
+
 #define TESTFILE "/tmp/installwatch-test"
 #define TESTFILE2 TESTFILE "2"
 
 int *refcount;
+int *timecount;
 int passed, failed;
+void* libc_handle=NULL;
 
 void check_installwatch(void) {
-	refcount = (int *)dlsym(RTLD_NEXT, "__installwatch_refcount");
-	if(refcount == NULL) {
+	char *error;
+
+	time(NULL);
+
+	libc_handle=dlopen(LIBDIR"/installwatch.so",RTLD_LAZY);
+	if(!libc_handle) {
+		puts("Unable to open "LIBDIR"/installwatch.so");
+		exit(255);
+	}
+
+	time(NULL);
+
+	timecount=(int*)dlsym(libc_handle,"__installwatch_timecount");	
+	if ((error = dlerror()) != NULL)  {
+		fputs(error, stderr);
+		exit(255);
+	}
+
+	if((*timecount)<2) {
 		puts("This program must be run with installwatch");
+		dlclose(libc_handle);
+		exit(255);
+	}
+
+	refcount=(int*)dlsym(libc_handle,"__installwatch_refcount");	
+	if ((error = dlerror()) != NULL)  {
+		fputs(error, stderr);
 		exit(255);
 	}
 }
@@ -225,11 +256,15 @@
 	old_refcount = *refcount;
 	function();
 	if(*refcount == old_refcount + increment) {
+		printf("wanted refcount=%d returned refcount=%d",
+			(old_refcount+increment),*refcount);
 		puts("passed");
 		passed++;
 		return 0;
 	} else {
-		puts("failed");
+		printf("wanted refcount=%d returned refcount=%d",
+			(old_refcount+increment),*refcount);
+	        puts("failed");
 		failed++;
 		return 1;
 	}
@@ -239,6 +274,7 @@
 	struct stat statbuf;
 
 	check_installwatch();
+
 	if(stat(TESTFILE, &statbuf) != -1) {
 		printf(TESTFILE " already exists. Please remove it and run %s again\n", argv[0]);
 		exit(254);
@@ -250,7 +286,6 @@
 	puts("Testing installwatch " VERSION);
 	puts("Using " TESTFILE " and " TESTFILE2 " as a test files\n");
 	passed = failed = 0;
-
 	do_test("chmod", test_chmod, 4);
 	do_test("chown", test_chown, 3);
 	do_test("chroot", test_chroot, 1);
@@ -292,6 +327,9 @@
 		printf("\tnm %s\n", argv[0]);
 	} else
 		printf("All tests successful!\n");
+
+	if(libc_handle!=NULL)
+		dlclose(libc_handle);
 
 	return failed;
 }