summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris+github@qwirx.com>2007-04-29 13:47:03 +0000
committerChris Wilson <chris+github@qwirx.com>2007-04-29 13:47:03 +0000
commit649214baa3166aec940f17a8f93dd234111f2044 (patch)
treeb11ac34dafc6d18e759b44fab651e77befef133d
parent9ddebaa7d9534fae58cc9cca6f8fdd5139bccf69 (diff)
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)
-rw-r--r--lib/backupclient/BackupClientRestore.cpp27
1 files changed, 26 insertions, 1 deletions
diff --git a/lib/backupclient/BackupClientRestore.cpp b/lib/backupclient/BackupClientRestore.cpp
index ec4ca681..0b2b6d84 100644
--- a/lib/backupclient/BackupClientRestore.cpp
+++ b/lib/backupclient/BackupClientRestore.cpp
@@ -412,7 +412,7 @@ static int BackupClientRestoreDir(BackupProtocolClient &rConnection, int64_t Dir
try
{
- dirAttr.WriteAttributes(rLocalDirectoryName.c_str());
+ dirAttr.WriteAttributes(rLocalDirectoryName.c_str(), true);
}
catch (BoxException &e)
{
@@ -591,6 +591,7 @@ static int BackupClientRestoreDir(BackupProtocolClient &rConnection, int64_t Dir
}
}
+
// Make sure the restore info has been saved
if(bytesWrittenSinceLastRestoreInfoSave != 0)
{
@@ -663,6 +664,30 @@ static int BackupClientRestoreDir(BackupProtocolClient &rConnection, int64_t Dir
}
}
+ // 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;
}