summaryrefslogtreecommitdiffstats
path: root/usr.sbin/pkg_install/delete
diff options
context:
space:
mode:
authordes <des@FreeBSD.org>2003-02-25 15:01:54 +0000
committerdes <des@FreeBSD.org>2003-02-25 15:01:54 +0000
commit8193b0d6a25349dc5c392eaabaa7f5707314edd2 (patch)
treef222f56e7d5756ebaa79f510feda6e3e5915ebe8 /usr.sbin/pkg_install/delete
parent951fcfa2386ce765b364a819150fa48e20cd3d47 (diff)
downloadFreeBSD-src-8193b0d6a25349dc5c392eaabaa7f5707314edd2.zip
FreeBSD-src-8193b0d6a25349dc5c392eaabaa7f5707314edd2.tar.gz
Fix a long-standing bug where if the package being deleted had no
post-deinstall script, the variable intended to hold the name of that script would be used uninitialized. In some cases, fexists() would succeed, causing pkg_delete to try to chmod +x it, then execute it, resulting in bizarre error messages such as: .//: Permission denied This bug would normally only occur when multiple packages were specified on the command line; otherwise post_script would be located in a previously unused part of the stack, and implicitly (but quite accidentally) initialized to all-zeros. MFC after: 3 days
Diffstat (limited to 'usr.sbin/pkg_install/delete')
-rw-r--r--usr.sbin/pkg_install/delete/Makefile2
-rw-r--r--usr.sbin/pkg_install/delete/perform.c24
2 files changed, 12 insertions, 14 deletions
diff --git a/usr.sbin/pkg_install/delete/Makefile b/usr.sbin/pkg_install/delete/Makefile
index 7002e75..954e5e6 100644
--- a/usr.sbin/pkg_install/delete/Makefile
+++ b/usr.sbin/pkg_install/delete/Makefile
@@ -5,7 +5,7 @@ SRCS= main.c perform.c
CFLAGS+= ${DEBUG} -I${.CURDIR}/../lib
-WARNS?= 2
+WARNS?= 4
DPADD= ${LIBINSTALL} ${LIBMD}
LDADD= ${LIBINSTALL} -lmd
diff --git a/usr.sbin/pkg_install/delete/perform.c b/usr.sbin/pkg_install/delete/perform.c
index 1102165..dce1260 100644
--- a/usr.sbin/pkg_install/delete/perform.c
+++ b/usr.sbin/pkg_install/delete/perform.c
@@ -126,9 +126,8 @@ pkg_do(char *pkg)
int i, len;
/* support for separate pre/post install scripts */
int new_m = 0;
- char pre_script[FILENAME_MAX] = DEINSTALL_FNAME;
- char post_script[FILENAME_MAX];
- char pre_arg[FILENAME_MAX], post_arg[FILENAME_MAX];
+ const char *pre_script = DEINSTALL_FNAME;
+ const char *post_script, *pre_arg, *post_arg;
struct reqr_by_entry *rb_entry;
struct reqr_by_head *rb_list;
@@ -224,18 +223,17 @@ pkg_do(char *pkg)
if (fexists(POST_DEINSTALL_FNAME)) {
new_m = 1;
- sprintf(post_script, "%s", POST_DEINSTALL_FNAME);
- pre_arg[0] = '\0';
- post_arg[0] = '\0';
+ post_script = POST_DEINSTALL_FNAME;
+ pre_arg = post_arg = "";
+ } else if (fexists(DEINSTALL_FNAME)) {
+ post_script = DEINSTALL_FNAME;
+ pre_arg = "DEINSTALL";
+ post_arg = "POST-DEINSTALL";
} else {
- if (fexists(DEINSTALL_FNAME)) {
- sprintf(post_script, "%s", DEINSTALL_FNAME);
- sprintf(pre_arg, "DEINSTALL");
- sprintf(post_arg, "POST-DEINSTALL");
- }
+ post_script = pre_arg = post_arg = NULL;
}
- if (!NoDeInstall && fexists(pre_script)) {
+ if (!NoDeInstall && pre_script != NULL && fexists(pre_script)) {
if (Fake)
printf("Would execute de-install script at this point.\n");
else {
@@ -268,7 +266,7 @@ pkg_do(char *pkg)
return 1;
}
- if (!NoDeInstall && fexists(post_script)) {
+ if (!NoDeInstall && post_script != NULL && fexists(post_script)) {
if (Fake)
printf("Would execute post-deinstall script at this point.\n");
else {
OpenPOWER on IntegriCloud