[Box Backup-commit] COMMIT r1619 - box/chris/merge/lib/backupclient

boxbackup-dev at fluffy.co.uk boxbackup-dev at fluffy.co.uk
Sun Apr 29 14:47:04 BST 2007


Author: chris
Date: 2007-04-29 14:47:03 +0100 (Sun, 29 Apr 2007)
New Revision: 1619

Modified:
   box/chris/merge/lib/backupclient/BackupClientRestore.cpp
Log:
Make directories user-writable while restoring them, so that restoring
read-only directories as a non-root user doesn't crash. Restore the
correct permissions after restoring the directory's contents. (refs #3)


Modified: box/chris/merge/lib/backupclient/BackupClientRestore.cpp
===================================================================
--- box/chris/merge/lib/backupclient/BackupClientRestore.cpp	2007-04-29 13:46:22 UTC (rev 1618)
+++ box/chris/merge/lib/backupclient/BackupClientRestore.cpp	2007-04-29 13:47:03 UTC (rev 1619)
@@ -412,7 +412,7 @@
 
 	try
 	{
-		dirAttr.WriteAttributes(rLocalDirectoryName.c_str());
+		dirAttr.WriteAttributes(rLocalDirectoryName.c_str(), true);
 	}
 	catch (BoxException &e)
 	{
@@ -591,6 +591,7 @@
 		}
 	}
 
+
 	// Make sure the restore info has been saved	
 	if(bytesWrittenSinceLastRestoreInfoSave != 0)
 	{
@@ -663,6 +664,30 @@
 		}
 	}
 
+	// now remove the user writable flag, if we added it earlier
+	try
+	{
+		dirAttr.WriteAttributes(rLocalDirectoryName.c_str(), false);
+	}
+	catch (BoxException &e)
+	{
+		::syslog(LOG_ERR, "Failed to restore attributes for %s: %s", 
+			rLocalDirectoryName.c_str(), e.what());
+		return Restore_UnknownError;
+	}
+	catch(std::exception &e)
+	{
+		::syslog(LOG_ERR, "Failed to restore attributes for %s: %s", 
+			rLocalDirectoryName.c_str(), e.what());
+		return Restore_UnknownError;
+	}
+	catch(...)
+	{
+		::syslog(LOG_ERR, "Failed to restore attributes for %s: "
+			"unknown error", rLocalDirectoryName.c_str());
+		return Restore_UnknownError;
+	}
+
 	return Restore_Complete;
 }
 




More information about the Boxbackup-commit mailing list