Skip to content

Commit

Permalink
Elevation wasn't working during symlinks copying & few minor things
Browse files Browse the repository at this point in the history
  • Loading branch information
alabuzhev committed Oct 23, 2017
1 parent 911f94c commit f87065f
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 26 deletions.
4 changes: 2 additions & 2 deletions far/FarEng.hlf.m4
Expand Up @@ -3572,8 +3572,8 @@ will not be analyzed, and only file attributes will be taken into account.

- it has none of the excluded attributes.

The Compressed, Encrypted, Not indexed, Sparse, Temporary attributes and
Symbolic links are valid for NTFS drives only. The #Integrity stream# and
The Compressed, Encrypted, Not indexed, Sparse, Temporary and Reparse point
attributes are valid for NTFS drives only. The #Integrity stream# and
#No scrub data# attributes only supported on ReFS voumes starting from
Windows Server 2012.

Expand Down
2 changes: 1 addition & 1 deletion far/FarRus.hlf.m4
Expand Up @@ -3645,7 +3645,7 @@ $ #Раскраска файлов и группы сортировки: ред
- он не имеет атрибутов исключения.

Атрибуты "Сжатый", "Зашифрованный", "Неиндексируемый", "Разрежённый",
"Временный", "Символическая ссылка", "Автономный" и "Виртуальный" используются
"Временный", "Точка повторной обработки", "Автономный" и "Виртуальный" используются
только на дисках с файловой системой NTFS. Атрибут "Виртуальный" не используется
в Windows 2000/XP/2003. Атрибуты #Поток целостности# и #Нет данных очистки#
поддерживаются только на ReFS томах, начиная с Windows Server 2012.
Expand Down
6 changes: 6 additions & 0 deletions far/changelog
@@ -1,3 +1,9 @@
drkns 23.10.2017 20:20:30 +0100 - build 5070

1. Не работал запрос прав при копировании симлинков.

2. Пара мелочей.

zg 20.10.2017 17:09:22 +0300 - build 5069

1. с форума: Ошибка перерисовки диалога в Просмотрщике.
Expand Down
20 changes: 10 additions & 10 deletions far/common/string_utils.hpp
Expand Up @@ -33,23 +33,22 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#include "preprocessor.hpp"
#include "placement.hpp"

/*
Helper class to safely pass string_view to low level C or platform API.
Builds a compatible null-terminated std::basic_string if the given view is not null-terminated,
otherwise uses the same data.
*/

#include "placement.hpp"
template<typename T>
class null_terminated_t
{
public:

WARNING_PUSH()
WARNING_DISABLE_MSC(4582) // no page '%$S': constructor is not implicitly called
WARNING_DISABLE_MSC(4583) // no page '%$S': destructor is not implicitly called

template<typename T>
class null_terminated_t
{
public:
explicit null_terminated_t(const basic_string_view<T>& Str):
m_Terminated(!Str.raw_data()[Str.size()])
{
Expand All @@ -67,6 +66,8 @@ class null_terminated_t
placement::destruct(m_Str);
}

WARNING_POP()

auto data() const
{
return m_Terminated? m_View.raw_data() : m_Str.data();
Expand All @@ -86,10 +87,9 @@ class null_terminated_t
bool m_Terminated;
};

WARNING_POP()

using null_terminated = null_terminated_t<wchar_t>;


namespace detail
{
inline void append_one(string& Str, wchar_t Arg, size_t) { Str += Arg; }
Expand Down Expand Up @@ -284,12 +284,12 @@ inline bool equal(const string_view& Str1, const string_view& Str2)

inline bool starts_with(const string_view& Str, const string_view& Prefix)
{
return Str.size() >= Prefix.size() && equal({ Str.raw_data(), Prefix.size() }, Prefix);
return Str.size() >= Prefix.size() && Str.substr(0, Prefix.size()) == Prefix;
}

inline bool ends_with(const string_view& Str, const string_view& Suffix)
{
return Str.size() >= Suffix.size() && equal({ Str.raw_data() + Str.size() - Suffix.size(), Suffix.size() }, Suffix);
return Str.size() >= Suffix.size() && Str.substr(Str.size() - Suffix.size()) == Suffix;
}

inline bool contains(const string_view& Str, const string_view& Token)
Expand Down
4 changes: 2 additions & 2 deletions far/copy.cpp
Expand Up @@ -1828,7 +1828,7 @@ COPY_CODES ShellCopy::ShellCopyOneFile(

if (Rename)
{
CmpCode = equal(PointToName(Src), PointToName(strDestPath));
CmpCode = PointToName(Src) == PointToName(strDestPath);
}

if (CmpCode==1)
Expand Down Expand Up @@ -2204,7 +2204,7 @@ COPY_CODES ShellCopy::ShellCopyOneFile(

if (Rename)
{
CmpCode = equal(PointToName(Src), PointToName(strDestPath));
CmpCode = PointToName(Src) == PointToName(strDestPath);
}

if (CmpCode==1 && !Rename)
Expand Down
2 changes: 1 addition & 1 deletion far/copy_progress.cpp
@@ -1,4 +1,4 @@
/*
/*
copy_progress.cpp
*/
/*
Expand Down
7 changes: 0 additions & 7 deletions far/main.cpp
Expand Up @@ -810,13 +810,6 @@ static int mainImpl(const range<wchar_t**>& Args)

static int wmain_seh(int Argc, wchar_t *Argv[])
{
FILETIME f;
GetSystemTimeAsFileTime(&f);
SYSTEMTIME s;
FileTimeToSystemTime(&f, &s);
FILETIME f2;
SystemTimeToFileTime(&s, &f2);

#if defined(SYSLOG)
atexit(PrintSysLogStat);
#endif
Expand Down
2 changes: 1 addition & 1 deletion far/platform.chrono.hpp
Expand Up @@ -3,7 +3,7 @@
#pragma once

/*
chrono.hpp
platform.chrono.hpp
*/
/*
Expand Down
10 changes: 9 additions & 1 deletion far/platform.fs.cpp
Expand Up @@ -1376,6 +1376,14 @@ namespace os::fs
FlagsAndAttributes |= FILE_FLAG_POSIX_SEMANTICS;
}

const auto& create_elevated = [&]
{
return handle(elevation::instance().create_file(strObject, DesiredAccess, ShareMode, SecurityAttributes, CreationDistribution, FlagsAndAttributes, TemplateFile));
};

if (ForceElevation)
return create_elevated();

if (auto Handle = handle(low::create_file(strObject.data(), DesiredAccess, ShareMode, SecurityAttributes, CreationDistribution, FlagsAndAttributes, TemplateFile)))
return Handle;

Expand All @@ -1395,7 +1403,7 @@ namespace os::fs
}

if (ElevationRequired(DesiredAccess & (GENERIC_ALL | GENERIC_WRITE | WRITE_OWNER | WRITE_DAC | DELETE | FILE_WRITE_DATA | FILE_ADD_FILE | FILE_APPEND_DATA | FILE_ADD_SUBDIRECTORY | FILE_CREATE_PIPE_INSTANCE | FILE_WRITE_EA | FILE_DELETE_CHILD | FILE_WRITE_ATTRIBUTES)? ELEVATION_MODIFY_REQUEST : ELEVATION_READ_REQUEST) || ForceElevation)
return handle(elevation::instance().create_file(strObject, DesiredAccess, ShareMode, SecurityAttributes, CreationDistribution, FlagsAndAttributes, TemplateFile));
return create_elevated();

return nullptr;
}
Expand Down
2 changes: 1 addition & 1 deletion far/vbuild.m4
@@ -1 +1 @@
m4_define(BUILD,5069)m4_dnl
m4_define(BUILD,5070)m4_dnl

0 comments on commit f87065f

Please sign in to comment.