[Box Backup-commit] COMMIT r1635 - box/chris/general/lib/backupclient
boxbackup-dev at fluffy.co.uk
boxbackup-dev at fluffy.co.uk
Wed May 9 11:29:21 BST 2007
Author: chris
Date: 2007-05-09 11:29:21 +0100 (Wed, 09 May 2007)
New Revision: 1635
Modified:
box/chris/general/lib/backupclient/BackupClientFileAttributes.cpp
box/chris/general/lib/backupclient/BackupClientFileAttributes.h
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.
(merges [1618])
Modified: box/chris/general/lib/backupclient/BackupClientFileAttributes.cpp
===================================================================
--- box/chris/general/lib/backupclient/BackupClientFileAttributes.cpp 2007-05-09 10:28:40 UTC (rev 1634)
+++ box/chris/general/lib/backupclient/BackupClientFileAttributes.cpp 2007-05-09 10:29:21 UTC (rev 1635)
@@ -578,7 +578,8 @@
// 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 @@
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)
{
Modified: box/chris/general/lib/backupclient/BackupClientFileAttributes.h
===================================================================
--- box/chris/general/lib/backupclient/BackupClientFileAttributes.h 2007-05-09 10:28:40 UTC (rev 1634)
+++ box/chris/general/lib/backupclient/BackupClientFileAttributes.h 2007-05-09 10:29:21 UTC (rev 1635)
@@ -45,7 +45,8 @@
void ReadAttributes(const char *Filename, bool ZeroModificationTimes = false,
box_time_t *pModTime = 0, box_time_t *pAttrModTime = 0, int64_t *pFileSize = 0,
InodeRefType *pInodeNumber = 0, bool *pHasMultipleLinks = 0);
- void WriteAttributes(const char *Filename) const;
+ void WriteAttributes(const char *Filename,
+ bool MakeUserWritable = false) const;
bool IsSymLink() const;
More information about the Boxbackup-commit
mailing list