[Rpm-maint] [Suse patch] Make transaction lock relative to --root

Panu Matilainen pmatilai at redhat.com
Wed May 23 09:04:58 UTC 2007


As far as I can tell, this has already been fixed in rpm.org tree, albeit 
somewhat differently: http://hg.rpm.org/rpm?cs=0a840aa65e58

 	- Panu -

---

Obey --root option when calculating the directory of the
transaction lock.

Already fixed in rpm-4.4.7.

--- ./lib/rpmlock.c.orig	2005-12-21 14:34:27.000000000 +0000
+++ ./lib/rpmlock.c	2005-12-21 14:42:59.000000000 +0000
@@ -45,12 +45,18 @@ static rpmlock rpmlock_new(/*@unused@*/
  	}
  	if (lock != NULL) {
  		mode_t oldmask = umask(022);
-		lock->fd = open(rpmlock_path, O_RDWR|O_CREAT, 0644);
+		char *path = rpmlock_path;
+		if (rootdir && *rootdir == '/' && rootdir[1] != 0) {
+			path = xmalloc(strlen(rootdir) + strlen(rpmlock_path) + 1);
+			strcpy(path, rootdir);
+			strcat(path, rpmlock_path);
+		}
+		lock->fd = open(path, O_RDWR|O_CREAT, 0644);
  		(void) umask(oldmask);

  /*@-branchstate@*/
  		if (lock->fd == -1) {
-			lock->fd = open(rpmlock_path, O_RDONLY);
+			lock->fd = open(path, O_RDONLY);
  			if (lock->fd == -1) {
  				free(lock);
  				lock = NULL;
@@ -64,6 +70,8 @@ static rpmlock rpmlock_new(/*@unused@*/
  			lock->openmode = RPMLOCK_WRITE | RPMLOCK_READ;
  /*@=nullderef@*/
  		}
+		if (path != rpmlock_path)
+			free(path);
  /*@=branchstate@*/
  	}
  /*@-compdef@*/



More information about the Rpm-maint mailing list