From 2aa8ad1b403058c417e8dd7f0a3061410dbb9c7e Mon Sep 17 00:00:00 2001 From: joerg Date: Thu, 9 Aug 2007 23:54:17 +0000 Subject: Make var_set and var_get arguments always use full path names. --- pkgtools/pkg_install/files/admin/main.c | 7 ++++--- pkgtools/pkg_install/files/info/info.h | 4 ++-- pkgtools/pkg_install/files/info/perform.c | 8 ++++---- pkgtools/pkg_install/files/info/show.c | 10 +++++++--- 4 files changed, 17 insertions(+), 12 deletions(-) diff --git a/pkgtools/pkg_install/files/admin/main.c b/pkgtools/pkg_install/files/admin/main.c index c069bb9ad43..f39f222650b 100644 --- a/pkgtools/pkg_install/files/admin/main.c +++ b/pkgtools/pkg_install/files/admin/main.c @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.22 2007/08/08 22:33:38 joerg Exp $ */ +/* $NetBSD: main.c,v 1.23 2007/08/09 23:54:17 joerg Exp $ */ #if HAVE_CONFIG_H #include "config.h" @@ -8,7 +8,7 @@ #include #endif #ifndef lint -__RCSID("$NetBSD: main.c,v 1.22 2007/08/08 22:33:38 joerg Exp $"); +__RCSID("$NetBSD: main.c,v 1.23 2007/08/09 23:54:17 joerg Exp $"); #endif /* @@ -761,7 +761,8 @@ set_installed_info_var(const char *name, void *cookie) char *filename; int retval; - if (asprintf(&filename, "%s/%s", name, INSTALLED_INFO_FNAME) == -1) + if (asprintf(&filename, "%s/%s/%s", _pkgdb_getPKGDB_DIR(), name, + INSTALLED_INFO_FNAME) == -1) errx(EXIT_FAILURE, "asprintf failed"); retval = var_set(filename, arg->variable, arg->value); diff --git a/pkgtools/pkg_install/files/info/info.h b/pkgtools/pkg_install/files/info/info.h index 95e95e40225..f09890726de 100644 --- a/pkgtools/pkg_install/files/info/info.h +++ b/pkgtools/pkg_install/files/info/info.h @@ -1,4 +1,4 @@ -/* $NetBSD: info.h,v 1.14 2007/08/09 23:06:42 joerg Exp $ */ +/* $NetBSD: info.h,v 1.15 2007/08/09 23:54:17 joerg Exp $ */ /* from FreeBSD Id: info.h,v 1.10 1997/02/22 16:09:40 peter Exp */ @@ -72,7 +72,7 @@ extern size_t termwidth; extern lpkg_head_t pkgs; extern void show_file(const char *, const char *, const char *, Boolean); -extern void show_var(const char *, const char *); +extern void show_var(const char *, const char *, const char *); extern void show_plist(const char *, package_t *, pl_ent_t); extern void show_files(const char *, package_t *); extern void show_depends(const char *, package_t *); diff --git a/pkgtools/pkg_install/files/info/perform.c b/pkgtools/pkg_install/files/info/perform.c index c1fdf1713d2..8f63668aebc 100644 --- a/pkgtools/pkg_install/files/info/perform.c +++ b/pkgtools/pkg_install/files/info/perform.c @@ -1,4 +1,4 @@ -/* $NetBSD: perform.c,v 1.36 2007/08/09 23:18:30 joerg Exp $ */ +/* $NetBSD: perform.c,v 1.37 2007/08/09 23:54:17 joerg Exp $ */ #if HAVE_CONFIG_H #include "config.h" @@ -14,7 +14,7 @@ #if 0 static const char *rcsid = "from FreeBSD Id: perform.c,v 1.23 1997/10/13 15:03:53 jkh Exp"; #else -__RCSID("$NetBSD: perform.c,v 1.36 2007/08/09 23:18:30 joerg Exp $"); +__RCSID("$NetBSD: perform.c,v 1.37 2007/08/09 23:54:17 joerg Exp $"); #endif #endif @@ -209,9 +209,9 @@ pkg_do(const char *pkg) } else if (Flags & SHOW_BI_VAR) { if (strcspn(BuildInfoVariable, "ABCDEFGHIJKLMNOPQRSTUVWXYZ") == strlen(BuildInfoVariable)) - show_var(INSTALLED_INFO_FNAME, BuildInfoVariable); + show_var(pkg, INSTALLED_INFO_FNAME, BuildInfoVariable); else - show_var(BUILD_INFO_FNAME, BuildInfoVariable); + show_var(pkg, BUILD_INFO_FNAME, BuildInfoVariable); } else { FILE *fp; package_t plist; diff --git a/pkgtools/pkg_install/files/info/show.c b/pkgtools/pkg_install/files/info/show.c index 11dbc4e87f0..6e73fcc633d 100644 --- a/pkgtools/pkg_install/files/info/show.c +++ b/pkgtools/pkg_install/files/info/show.c @@ -1,4 +1,4 @@ -/* $NetBSD: show.c,v 1.15 2007/08/09 23:06:42 joerg Exp $ */ +/* $NetBSD: show.c,v 1.16 2007/08/09 23:54:17 joerg Exp $ */ #if HAVE_CONFIG_H #include "config.h" @@ -11,7 +11,7 @@ #if 0 static const char *rcsid = "from FreeBSD Id: show.c,v 1.11 1997/10/08 07:47:38 charnier Exp"; #else -__RCSID("$NetBSD: show.c,v 1.15 2007/08/09 23:06:42 joerg Exp $"); +__RCSID("$NetBSD: show.c,v 1.16 2007/08/09 23:54:17 joerg Exp $"); #endif #endif @@ -137,9 +137,13 @@ show_file(const char *pkg, const char *title, const char *fname, Boolean separat } void -show_var(const char *fname, const char *variable) +show_var(const char *pkg, const char *fname, const char *variable) { char *value; + char filename[BUFSIZ]; + + (void)snprintf(filename, sizeof(filename), "%s/%s/%s", + _pkgdb_getPKGDB_DIR(), pkg, fname); if ((value=var_get(fname, variable)) != NULL) { (void) printf("%s\n", value); -- cgit v1.2.3