diff options
author | Chris Wilson <chris+github@qwirx.com> | 2007-04-29 13:46:22 +0000 |
---|---|---|
committer | Chris Wilson <chris+github@qwirx.com> | 2007-04-29 13:46:22 +0000 |
commit | 9ddebaa7d9534fae58cc9cca6f8fdd5139bccf69 (patch) | |
tree | dd05812c008215779b9dc611c6a3b7bd68f9b78a /lib/backupclient/BackupClientFileAttributes.cpp | |
parent | 5042e10cbb84843948a06fe3f7f45175e836a21f (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)
Diffstat (limited to 'lib/backupclient/BackupClientFileAttributes.cpp')
-rw-r--r-- | lib/backupclient/BackupClientFileAttributes.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/backupclient/BackupClientFileAttributes.cpp b/lib/backupclient/BackupClientFileAttributes.cpp index ba65d57a..9918c0d6 100644 --- a/lib/backupclient/BackupClientFileAttributes.cpp +++ b/lib/backupclient/BackupClientFileAttributes.cpp @@ -578,7 +578,8 @@ void BackupClientFileAttributes::FillExtendedAttr(StreamableMemBlock &outputBloc // Created: 2003/10/07 // // -------------------------------------------------------------------------- -void BackupClientFileAttributes::WriteAttributes(const char *Filename) const +void BackupClientFileAttributes::WriteAttributes(const char *Filename, + bool MakeUserWritable) const { // Got something loaded if(GetSize() <= 0) @@ -704,7 +705,12 @@ void BackupClientFileAttributes::WriteAttributes(const char *Filename) const THROW_EXCEPTION(CommonException, OSFileError) } } - + + if (MakeUserWritable) + { + mode |= S_IRWXU; + } + // Apply everything else... (allowable mode flags only) if(::chmod(Filename, mode & (S_IRWXU | S_IRWXG | S_IRWXO | S_ISUID | S_ISGID | S_ISVTX)) != 0) // mode must be done last (think setuid) { |