aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin/pkg_install
diff options
context:
space:
mode:
authorFlorent Thoumie <flz@FreeBSD.org>2009-01-06 19:00:12 +0000
committerFlorent Thoumie <flz@FreeBSD.org>2009-01-06 19:00:12 +0000
commit853e670bb4c7c7baf2c38683c1b8f0472f12f2e3 (patch)
tree422127871d469515fef2c695a052ce00b4b8893a /usr.sbin/pkg_install
parent73de1e839517c66fc2de06772a34c32780da7c8c (diff)
downloadsrc-853e670bb4c7c7baf2c38683c1b8f0472f12f2e3.tar.gz
src-853e670bb4c7c7baf2c38683c1b8f0472f12f2e3.zip
Notes
Diffstat (limited to 'usr.sbin/pkg_install')
-rw-r--r--usr.sbin/pkg_install/lib/lib.h2
-rw-r--r--usr.sbin/pkg_install/lib/plist.c83
2 files changed, 24 insertions, 61 deletions
diff --git a/usr.sbin/pkg_install/lib/lib.h b/usr.sbin/pkg_install/lib/lib.h
index 5f66a3ae7cc7..422912e8d4a7 100644
--- a/usr.sbin/pkg_install/lib/lib.h
+++ b/usr.sbin/pkg_install/lib/lib.h
@@ -105,7 +105,7 @@
* Version of the package tools - increase only when some
* functionality used by bsd.port.mk is changed, added or removed
*/
-#define PKG_INSTALL_VERSION 20081227
+#define PKG_INSTALL_VERSION 20090106
#define PKG_WRAPCONF_FNAME "/var/db/pkg_install.conf"
#define main(argc, argv) real_main(argc, argv)
diff --git a/usr.sbin/pkg_install/lib/plist.c b/usr.sbin/pkg_install/lib/plist.c
index 8cb33aa013bd..283b87f9c1b1 100644
--- a/usr.sbin/pkg_install/lib/plist.c
+++ b/usr.sbin/pkg_install/lib/plist.c
@@ -544,82 +544,45 @@ delete_package(Boolean ign_err, Boolean nukedirs, Package *pkg)
int
delete_hierarchy(const char *dir, Boolean ign_err, Boolean nukedirs)
{
- char *cp1, *cp2, realdir[FILENAME_MAX];
+ char *cp1, *cp2;
- if (realdir == NULL) {
- warnx("Couldn't allocate enough memory\n");
- return (ign_err ? SUCCESS : FAIL);
- }
-
- if (issymlink(dir) && readlink(dir, realdir, FILENAME_MAX-1) == -1)
- return (ign_err ? SUCCESS : FAIL);
-
- strlcpy(realdir, dir, FILENAME_MAX-1);
-
- cp1 = cp2 = strdup(realdir);
- if (cp1 == NULL) {
- warnx("Couldn't allocate enough memory\n");
- return (ign_err ? SUCCESS : FAIL);
- }
-
- if (!fexists(realdir)) {
+ cp1 = cp2 = strdup(dir);
+ if (!fexists(dir)) {
if (!ign_err)
warnx("%s '%s' doesn't exist",
- isdir(realdir) ? "directory" : "file", realdir);
- free(cp1);
- return (ign_err ? SUCCESS : FAIL);
+ isdir(dir) ? "directory" : "file", dir);
+ return !ign_err;
}
else if (nukedirs) {
- if (vsystem("%s -r%s %s", REMOVE_CMD, (ign_err ? "f" : ""), realdir)) {
- free(cp1);
- return (ign_err ? SUCCESS : FAIL);
- }
+ if (vsystem("%s -r%s %s", REMOVE_CMD, (ign_err ? "f" : ""), dir))
+ return 1;
}
- else if (isdir(realdir)) {
- if (RMDIR(realdir)) {
- free(cp1);
- return (ign_err ? SUCCESS : FAIL);
- }
+ else if (isdir(dir) && !issymlink(dir)) {
+ if (RMDIR(dir) && !ign_err)
+ return 1;
}
else {
- if (REMOVE(realdir, ign_err)) {
- free(cp1);
- return (ign_err ? SUCCESS : FAIL);
- }
+ if (REMOVE(dir, ign_err))
+ return 1;
}
- if (!nukedirs) {
- free(cp1);
- return (SUCCESS);
- }
+ if (!nukedirs)
+ return 0;
while (cp2) {
if ((cp2 = strrchr(cp1, '/')) != NULL)
*cp2 = '\0';
- if (!isemptydir(realdir)) {
- free(cp1);
- return (SUCCESS);
- }
- if (RMDIR(realdir) && !ign_err) {
- if (!fexists(realdir)) {
- warnx("directory '%s' doesn't exist", realdir);
- free(cp1);
- return (SUCCESS);
- } else {
- free(cp1);
- return (FAIL);
- }
+ if (!isemptydir(dir))
+ return 0;
+ if (RMDIR(dir) && !ign_err) {
+ if (!fexists(dir))
+ warnx("directory '%s' doesn't exist", dir);
+ else
+ return 1;
}
/* back up the pathname one component */
if (cp2) {
- free(cp1);
- cp1 = strdup(realdir);
- if (cp1 == NULL) {
- warnx("Couldn't allocate enough memory\n");
- return (ign_err ? SUCCESS : FAIL);
- }
+ cp1 = strdup(dir);
}
}
- free(cp1);
- return (SUCCESS);
+ return 0;
}
-