diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2016-04-18 22:16:30 +0900 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2016-04-18 22:17:41 +0900 |
| commit | 1126722bd3e21dec8ecc84b9129c8998ac2bb661 (patch) | |
| tree | 356c64bc20c3f8d08cf14b2ad5be64caef39d002 /src/FallocFileAllocationIterator.cc | |
| parent | c9e2223741f9627f27b3d2befef48acdd79d504d (diff) | |
mingw: Defer the falloc warning until falloc is specified by option
Diffstat (limited to 'src/FallocFileAllocationIterator.cc')
| -rw-r--r-- | src/FallocFileAllocationIterator.cc | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/FallocFileAllocationIterator.cc b/src/FallocFileAllocationIterator.cc index febcf19b..04590557 100644 --- a/src/FallocFileAllocationIterator.cc +++ b/src/FallocFileAllocationIterator.cc @@ -34,14 +34,33 @@ /* copyright --> */ #include "FallocFileAllocationIterator.h" #include "DlAbortEx.h" +#include "util.h" +#include "LogFactory.h" namespace aria2 { +#ifdef __MINGW32__ +bool FallocFileAllocationIterator::gainPrivilegeAttempted_ = false; +#endif // __MINGW32__ + FallocFileAllocationIterator::FallocFileAllocationIterator(BinaryStream* stream, int64_t offset, int64_t totalLength) : stream_(stream), offset_(offset), totalLength_(totalLength) { +#ifdef __MINGW32__ + // Windows build: --file-allocation=falloc uses SetFileValidData + // which requires SE_MANAGE_VOLUME_NAME privilege. SetFileValidData + // has security implications (see + // https://msdn.microsoft.com/en-us/library/windows/desktop/aa365544%28v=vs.85%29.aspx). + if (!gainPrivilegeAttempted_) { + if (!util::gainPrivilege(SE_MANAGE_VOLUME_NAME)) { + A2_LOG_WARN("--file-allocation=falloc will not work properly."); + } + + gainPrivilegeAttempted_ = true; + } +#endif // __MINGW32__ } void FallocFileAllocationIterator::allocateChunk() |
