pkgsrc-Bugs archive

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

Re: bin/58809: pkg_add gets confused with -P and library installs



The following reply was made to PR pkg/58809; it has been noted by GNATS.

From: Martin Husemann <martin%duskware.de@localhost>
To: gnats-bugs%netbsd.org@localhost
Cc: 
Subject: Re: bin/58809: pkg_add gets confused with -P and library installs
Date: Fri, 27 Dec 2024 18:25:26 +0100

 Here is a better patch.
 
 Martin
 
 Index: perform.c
 ===================================================================
 RCS file: /cvsroot/pkgsrc/pkgtools/pkg_install/files/add/perform.c,v
 retrieving revision 1.128
 diff -u -p -r1.128 perform.c
 --- perform.c	7 Dec 2024 13:56:46 -0000	1.128
 +++ perform.c	27 Dec 2024 17:22:29 -0000
 @@ -693,6 +693,13 @@ extract_files(struct pkg_task *pkg)
  	plist_t *p;
  	const char *last_file;
  	char *fullpath;
 +#ifdef O_DIRECTORY
 +	int workdir;
 +#define	NO_WORK_DIR	-1
 +#else
 +	char *workdir;
 +#define	NO_WORK_DIR	NULL
 +#endif
  
  	if (Fake)
  		return 0;
 @@ -707,6 +714,16 @@ extract_files(struct pkg_task *pkg)
  		return -1;
  	}
  
 +#ifdef O_DIRECTORY
 +	workdir = open(".", O_RDONLY|O_CLOEXEC|O_DIRECTORY);
 +#else
 +	workdir = getcwd(NULL, 0);
 +#endif
 +	if (workdir == NO_WORK_DIR) {
 +		warn("Can't open current working directory");
 +		return -1;
 +	}
 +
  	if (chdir(pkg->install_prefix) == -1) {
  		warn("Can't change into prefix: %s", pkg->install_prefix);
  		return -1;
 @@ -833,6 +850,14 @@ out:
  		pkgdb_close();
  	archive_write_free(writer);
  
 +#ifdef O_DIRECTORY
 +	fchdir(workdir);
 +	close(workdir);
 +#else
 +	chdir(workdir);
 +	free(workdir);
 +#endif
 +
  	return r;
  }
  
 


Home | Main Index | Thread Index | Old Index