summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2001-04-18 14:34:32 +0000
committerMarc Espie <espie@cvs.openbsd.org>2001-04-18 14:34:32 +0000
commite3f402ef03e043da9718c8bc7033da97b1247240 (patch)
tree80fe4d6f00575a6b7a5a653b6f5bcd9e8459be40 /usr.sbin
parent7c49b06f19ce1950794f68a3800430ab0f7d75a8 (diff)
fix two bugs.
- create a full path name to the package, so that the chdir of playpen won't confuse tar. - do a chdir dbdir in pkg_info -a mode, so that we only get installed packages, and not pick up whatever is around in the current directory instead.
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/pkg_install/info/perform.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/usr.sbin/pkg_install/info/perform.c b/usr.sbin/pkg_install/info/perform.c
index f9fe41d7e73..83f09fe2845 100644
--- a/usr.sbin/pkg_install/info/perform.c
+++ b/usr.sbin/pkg_install/info/perform.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: perform.c,v 1.9 2001/04/08 16:45:47 espie Exp $ */
+/* $OpenBSD: perform.c,v 1.10 2001/04/18 14:34:31 espie Exp $ */
#ifndef lint
-static const char *rcsid = "$OpenBSD: perform.c,v 1.9 2001/04/08 16:45:47 espie Exp $";
+static const char *rcsid = "$OpenBSD: perform.c,v 1.10 2001/04/18 14:34:31 espie Exp $";
#endif
/* This is OpenBSD pkg_install, based on:
@@ -78,6 +78,7 @@ pkg_do(char *pkg)
char *cp = NULL;
int code = 0;
char *pkg2 = 0; /* hold full name of package, storage to free */
+ int len;
set_pkg(pkg);
@@ -87,7 +88,6 @@ pkg_do(char *pkg)
isTMP = TRUE;
}
} else if (fexists(pkg) && isfile(pkg)) {
- int len;
if (*pkg != '/') {
if (!getcwd(fname, FILENAME_MAX)) {
@@ -100,8 +100,17 @@ pkg_do(char *pkg)
strcpy(fname, pkg);
cp = fname;
} else {
- if ((cp = fileFindByPath(NULL, pkg)) != NULL)
- strncpy(fname, cp, FILENAME_MAX);
+ if ((cp = fileFindByPath(NULL, pkg)) != NULL) {
+ strncpy(fname, cp, FILENAME_MAX);
+ if (*cp != '/') {
+ if (!getcwd(fname, FILENAME_MAX)) {
+ cleanup(0);
+ err(1, "fatal error during execution: getcwd");
+ }
+ len = strlen(fname);
+ snprintf(&fname[len], FILENAME_MAX - len, "/%s", cp);
+ }
+ }
}
if (cp) {
if (isURL(pkg)) {
@@ -270,7 +279,9 @@ pkg_perform(char **pkgs)
if (!(isdir(tmp) || islinktodir(tmp)))
return 1;
- if ((dirp = opendir(tmp)) != (DIR *) NULL) {
+ if (chdir(tmp) != 0)
+ return 1;
+ if ((dirp = opendir(".")) != (DIR *) NULL) {
while ((dp = readdir(dirp)) != (struct dirent *) NULL) {
if (strcmp(dp->d_name, ".") && strcmp(dp->d_name, "..")) {
err_cnt += pkg_do(dp->d_name);