Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-1-4]: src/usr.sbin/pkg_install/add Pull up revisions 1.21-1.22 (r...
details: https://anonhg.NetBSD.org/src/rev/2ffd4e852f86
branches: netbsd-1-4
changeset: 470818:2ffd4e852f86
user: he <he%NetBSD.org@localhost>
date: Mon Jul 31 18:18:21 2000 +0000
description:
Pull up revisions 1.21-1.22 (requested by hubertf):
Update pkg_install tools by bringing in bug fixes and feature
additions since the last release. Fixes PR#10083 and PR#10687
and a number of problems not formally reported.
diffstat:
usr.sbin/pkg_install/add/extract.c | 55 +++++++++++++++++++++++++++----------
1 files changed, 40 insertions(+), 15 deletions(-)
diffs (133 lines):
diff -r 46f319f55efd -r 2ffd4e852f86 usr.sbin/pkg_install/add/extract.c
--- a/usr.sbin/pkg_install/add/extract.c Mon Jul 31 18:18:17 2000 +0000
+++ b/usr.sbin/pkg_install/add/extract.c Mon Jul 31 18:18:21 2000 +0000
@@ -1,11 +1,11 @@
-/* $NetBSD: extract.c,v 1.16.2.2 1999/09/13 21:10:29 he Exp $ */
+/* $NetBSD: extract.c,v 1.16.2.3 2000/07/31 18:18:21 he Exp $ */
#include <sys/cdefs.h>
#ifndef lint
#if 0
static const char *rcsid = "FreeBSD - Id: extract.c,v 1.17 1997/10/08 07:45:35 charnier Exp";
#else
-__RCSID("$NetBSD: extract.c,v 1.16.2.2 1999/09/13 21:10:29 he Exp $");
+__RCSID("$NetBSD: extract.c,v 1.16.2.3 2000/07/31 18:18:21 he Exp $");
#endif
#endif
@@ -34,15 +34,24 @@
#include "add.h"
#define TAR_ARGS " cf - "
+#define TARX_CMD "|" TAR_CMD " xf - -C "
-#define TOOBIG(str) ((strlen(str) + 22 + strlen(home) + where_count > maxargs) \
- || (strlen(str) + 6 + strlen(home) + perm_count > maxargs))
+/*
+ * This macro is used to determine if the 'where_args' buffer is big enough to add the
+ * current string (usually a filename) plus some extra commands (the contents of TARX_CMD, and
+ * the directory name stored in 'Directory').
+ *
+ * The string " 'str'" will be added so we need room for the string plus 3 chars plus the other arguments.
+ *
+ * In addition, we will add " 'srt'" to the perm_args buffer so we need to ensure that there is room
+ * for that.
+ */
+#define TOOBIG(str) ((strlen(str) + 3 + strlen(TARX_CMD) + strlen(Directory) + where_count >= maxargs) \
+ || (strlen(str) + 3 + perm_count >= maxargs))
#define PUSHOUT(todir) /* push out string */ \
if (where_count > sizeof(TAR_CMD) + sizeof(TAR_ARGS)-1) { \
- strcat(where_args, "|"); \
- strcat(where_args, TAR_CMD); \
- strcat(where_args, " xf - -C "); \
+ strcat(where_args, TARX_CMD); \
strcat(where_args, todir); \
if (system(where_args)) { \
cleanup(0); \
@@ -50,9 +59,8 @@
(u_long)strlen(where_args), TAR_CMD, \
where_args); \
} \
- strcpy(where_args, TAR_CMD); \
- strcat(where_args, TAR_ARGS); \
- where_count = sizeof(TAR_CMD) + sizeof(TAR_ARGS)-2; \
+ strcpy(where_args, TAR_CMD TAR_ARGS); \
+ where_count = strlen(where_args); \
} \
if (perm_count) { \
apply_perms(todir, perm_args); \
@@ -86,7 +94,11 @@
}
}
-void
+
+/*
+ * Return 0 on error, 1 for success.
+ */
+int
extract_plist(char *home, package_t *pkg)
{
plist_t *p = pkg->head;
@@ -106,10 +118,19 @@
cleanup(0);
errx(2, "can't get argument list space");
}
- strcpy(where_args, TAR_CMD);
- strcat(where_args, TAR_ARGS);
- where_count = sizeof(TAR_CMD) + sizeof(TAR_ARGS) - 2;
+ strcpy(where_args, TAR_CMD TAR_ARGS);
+ /*
+ * we keep track of how many characters are stored in 'where_args' with 'where_count'.
+ * Note this doesn't include the trailing null character.
+ */
+ where_count = strlen(where_args);
+
perm_args[0] = 0;
+ /*
+ * we keep track of how many characters are stored in 'perm__args' with 'perm_count'.
+ * Note this doesn't include the trailing null character.
+ */
+ perm_count = 0;
last_chdir = 0;
preserve = find_plist_option(pkg, "preserve") ? TRUE : FALSE;
@@ -162,7 +183,7 @@
"unable to back up %s to %s, aborting pkg_add",
try, pf);
rollback(PkgName, home, pkg->head, p);
- return;
+ return 0;
}
}
}
@@ -194,6 +215,7 @@
if (p->name[0] == '/' || TOOBIG(p->name)) {
PUSHOUT(Directory);
}
+ /* note, if the following line is modified, TOOBIG must be adjusted accordingly */
add_count = snprintf(&perm_args[perm_count], maxargs - perm_count, "'%s' ", p->name);
if (add_count > maxargs - perm_count) {
cleanup(0);
@@ -208,12 +230,14 @@
} else if (p->name[0] == '/' || TOOBIG(p->name)) {
PUSHOUT(Directory);
}
+ /* note, if the following line is modified, TOOBIG must be adjusted accordingly */
add_count = snprintf(&where_args[where_count], maxargs - where_count, " '%s'", p->name);
if (add_count > maxargs - where_count) {
cleanup(0);
errx(2, "oops, miscounted strings!");
}
where_count += add_count;
+ /* note, if the following line is modified, TOOBIG must be adjusted accordingly */
add_count = snprintf(&perm_args[perm_count],
maxargs - perm_count,
"'%s' ", p->name);
@@ -311,4 +335,5 @@
}
PUSHOUT(Directory);
pkgdb_close();
+ return 1;
}
Home |
Main Index |
Thread Index |
Old Index