summaryrefslogtreecommitdiff
path: root/lib/backupclient/BackupClientFileAttributes.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/backupclient/BackupClientFileAttributes.cpp')
-rw-r--r--lib/backupclient/BackupClientFileAttributes.cpp49
1 files changed, 36 insertions, 13 deletions
diff --git a/lib/backupclient/BackupClientFileAttributes.cpp b/lib/backupclient/BackupClientFileAttributes.cpp
index 6e875cda..84639b0d 100644
--- a/lib/backupclient/BackupClientFileAttributes.cpp
+++ b/lib/backupclient/BackupClientFileAttributes.cpp
@@ -1,4 +1,4 @@
-// distribution boxbackup-0.10 (svn version: 494)
+// distribution boxbackup-0.11rc1 (svn version: 2023_2024)
//
// Copyright (c) 2003 - 2006
// Ben Summers and contributors. All rights reserved.
@@ -286,7 +286,9 @@ bool BackupClientFileAttributes::Compare(const BackupClientFileAttributes &rAttr
if(!IgnoreModTime)
{
- if(a1->ModificationTime != a2->ModificationTime)
+ int t1 = a1->ModificationTime / 1000000;
+ int t2 = a2->ModificationTime / 1000000;
+ if(t1 != t2)
{
return false;
}
@@ -294,7 +296,9 @@ bool BackupClientFileAttributes::Compare(const BackupClientFileAttributes &rAttr
if(!IgnoreAttrModTime)
{
- if(a1->AttrModificationTime != a2->AttrModificationTime)
+ int t1 = a1->AttrModificationTime / 1000000;
+ int t2 = a2->AttrModificationTime / 1000000;
+ if(t1 != t2)
{
return false;
}
@@ -382,8 +386,8 @@ void BackupClientFileAttributes::ReadAttributes(const char *Filename, bool ZeroM
// to be true (still aborts), but it can at least hold 2^32.
if (winTime >= 0x100000000LL || _gmtime64(&winTime) == 0)
{
- ::syslog(LOG_ERR, "Invalid Modification Time "
- "caught for file: %s", Filename);
+ BOX_ERROR("Invalid Modification Time caught for "
+ "file: '" << Filename << "'");
pattr->ModificationTime = 0;
}
@@ -393,8 +397,8 @@ void BackupClientFileAttributes::ReadAttributes(const char *Filename, bool ZeroM
if (winTime > 0x100000000LL || _gmtime64(&winTime) == 0)
{
- ::syslog(LOG_ERR, "Invalid Attribute Modification "
- "Time caught for file: %s", Filename);
+ BOX_ERROR("Invalid Attribute Modification Time "
+ "caught for file: '" << Filename << "'");
pattr->AttrModificationTime = 0;
}
#endif
@@ -616,7 +620,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)
@@ -664,9 +669,8 @@ void BackupClientFileAttributes::WriteAttributes(const char *Filename) const
}
#ifdef WIN32
- ::syslog(LOG_WARNING,
- "Cannot create symbolic links on Windows: %s",
- Filename);
+ BOX_WARNING("Cannot create symbolic links on Windows: '" <<
+ Filename << "'");
#else
// Make a symlink, first deleting anything in the way
::unlink(Filename);
@@ -717,10 +721,24 @@ void BackupClientFileAttributes::WriteAttributes(const char *Filename) const
{
// Work out times as timevals
struct timeval times[2];
+
+ #ifdef WIN32
+ BoxTimeToTimeval(box_ntoh64(pattr->ModificationTime),
+ times[1]);
+ BoxTimeToTimeval(box_ntoh64(pattr->AttrModificationTime),
+ times[0]);
+ // Because stat() returns the creation time in the ctime
+ // field under Windows, and this gets saved in the
+ // AttrModificationTime field of the serialised attributes,
+ // we subvert the first parameter of emu_utimes() to allow
+ // it to be reset to the right value on the restored file.
+ #else
BoxTimeToTimeval(modtime, times[1]);
// Copy access time as well, why not, got to set it to something
times[0] = times[1];
- // Attr modification time will be changed anyway, nothing that can be done about it
+ // Attr modification time will be changed anyway,
+ // nothing that can be done about it
+ #endif
// Try to apply
if(::utimes(Filename, times) != 0)
@@ -728,7 +746,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)
{