[darwinbuild-changes] [896] branches/PR-8488185
source_changes at macosforge.org
source_changes at macosforge.org
Mon Oct 25 17:09:55 PDT 2010
Revision: 896
http://trac.macosforge.org/projects/darwinbuild/changeset/896
Author: wsiegrist at apple.com
Date: 2010-10-25 17:09:53 -0700 (Mon, 25 Oct 2010)
Log Message:
-----------
Guard against recursive installs.
Modified Paths:
--------------
branches/PR-8488185/darwinup/Depot.cpp
branches/PR-8488185/darwinup/main.cpp
branches/PR-8488185/testing/darwinup/run-tests.sh
Modified: branches/PR-8488185/darwinup/Depot.cpp
===================================================================
--- branches/PR-8488185/darwinup/Depot.cpp 2010-10-25 22:07:40 UTC (rev 895)
+++ branches/PR-8488185/darwinup/Depot.cpp 2010-10-26 00:09:53 UTC (rev 896)
@@ -426,6 +426,12 @@
IF_DEBUG("[analyze] %s\n", file->path());
+ if (strcasestr(file->path(), ".DarwinDepot")) {
+ fprintf(stderr, "Error: Root contains a .DarwinDepot, "
+ "aborting to avoid damaging darwinup metadata.\n");
+ return DEPOT_ERROR;
+ }
+
// Perform a three-way-diff between the file to be installed (file),
// the file we last installed in this location (preceding),
// and the file that actually exists in this location (actual).
Modified: branches/PR-8488185/darwinup/main.cpp
===================================================================
--- branches/PR-8488185/darwinup/main.cpp 2010-10-25 22:07:40 UTC (rev 895)
+++ branches/PR-8488185/darwinup/main.cpp 2010-10-26 00:09:53 UTC (rev 896)
@@ -211,7 +211,23 @@
for (int i = 1; i < argc && res == 0; i++) {
if (strcmp(argv[0], "install") == 0) {
if (i==1 && depot->initialize(true)) exit(13);
- res = depot->install(argv[i]);
+ // gaurd against installing paths ontop of themselves
+ if (strncmp(path, argv[i], strlen(argv[i])) == 0
+ && (strlen(path) == strlen(argv[i])
+ || strlen(path) - 1 == strlen(argv[i]))) {
+ if (strncmp(path, "/", 1) == 0 && strlen(path) == 1) {
+ fprintf(stderr, "Error: You provided '/' as a path to a root. "
+ "If you meant to specify a destination of '/', then you "
+ "just need to remove the '/' argument as the destination "
+ "defaults to '/'. Use the -p option to specify another "
+ "destination.\n");
+ } else {
+ fprintf(stderr, "Error: You cannot install the root at '%s' onto"
+ " itself.\n", path);
+ }
+ res = DEPOT_ERROR;
+ }
+ if (res == 0) res = depot->install(argv[i]);
} else if (strcmp(argv[0], "upgrade") == 0) {
if (i==1 && depot->initialize(true)) exit(14);
// find most recent matching archive by name
Modified: branches/PR-8488185/testing/darwinup/run-tests.sh
===================================================================
--- branches/PR-8488185/testing/darwinup/run-tests.sh 2010-10-25 22:07:40 UTC (rev 895)
+++ branches/PR-8488185/testing/darwinup/run-tests.sh 2010-10-26 00:09:53 UTC (rev 896)
@@ -63,6 +63,7 @@
done;
cp corrupt.tgz $PREFIX/
+cp depotroot.tar.gz $PREFIX/
mkdir -p $ORIG
cp -R $DEST/* $ORIG/
@@ -438,6 +439,22 @@
$DIFF $ORIG $DEST 2>&1
if [ $? -ne 0 ]; then exit 1; fi
+echo "========== TEST: testing recursive install guards ==========";
+$DARWINUP install $PREFIX/depotroot.tar.gz
+if [ $? -ne 255 ]; then exit 1; fi
+echo "DIFF: diffing original test files to dest (should be no diffs) ..."
+$DIFF $ORIG $DEST 2>&1
+if [ $? -ne 0 ]; then exit 1; fi
+$DARWINUP install $DEST
+if [ $? -ne 255 ]; then exit 1; fi
+echo "DIFF: diffing original test files to dest (should be no diffs) ..."
+$DIFF $ORIG $DEST 2>&1
+if [ $? -ne 0 ]; then exit 1; fi
+darwinup $1 install /
+if [ $? -ne 255 ]; then exit 1; fi
+echo "DIFF: diffing original test files to dest (should be no diffs) ..."
+$DIFF $ORIG $DEST 2>&1
+if [ $? -ne 0 ]; then exit 1; fi
echo "========== TEST: Try replacing File with Directory =========="
$DARWINUP install $PREFIX/rep_file_dir
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/darwinbuild-changes/attachments/20101025/3f2446f0/attachment.html>
More information about the darwinbuild-changes
mailing list