diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2016-05-22 20:57:33 +0900 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2016-05-22 20:57:33 +0900 |
| commit | 9d40c47799bbec12bb02f7579736fbc1fcc35c08 (patch) | |
| tree | 0ef02a9f17d6550667aa745829ff5146b1ccf6a6 /src/RequestGroup.cc | |
| parent | 9727b5b256bb12cff42e6aa230ba2020a933562f (diff) | |
| parent | 0b906f40f1204e79cb43af3867468ab02a371075 (diff) | |
Merge branch 'master' into dynamic-select-file
Diffstat (limited to 'src/RequestGroup.cc')
| -rw-r--r-- | src/RequestGroup.cc | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/RequestGroup.cc b/src/RequestGroup.cc index 4a75e3a1..6faa3551 100644 --- a/src/RequestGroup.cc +++ b/src/RequestGroup.cc @@ -604,6 +604,35 @@ void RequestGroup::initPieceStorage() segmentMan_ = std::make_shared<SegmentMan>(downloadContext_, tempPieceStorage); pieceStorage_ = tempPieceStorage; + +#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). + static auto gainPrivilegeAttempted = false; + + if (!gainPrivilegeAttempted && + pieceStorage_->getDiskAdaptor()->getFileAllocationMethod() == + DiskAdaptor::FILE_ALLOC_FALLOC && + isFileAllocationEnabled()) { + if (!util::gainPrivilege(SE_MANAGE_VOLUME_NAME)) { + A2_LOG_WARN("--file-allocation=falloc will not work properly."); + } + else { + A2_LOG_DEBUG("SE_MANAGE_VOLUME_NAME privilege acquired"); + + A2_LOG_WARN( + "--file-allocation=falloc will use SetFileValidData() API, and " + "aria2 uses uninitialized disk space which may contain " + "confidential data as the download file space. If it is " + "undesirable, --file-allocation=prealloc is slower, but safer " + "option."); + } + + gainPrivilegeAttempted = true; + } +#endif // __MINGW32__ } void RequestGroup::dropPieceStorage() |
