Skip to content
Permalink
Browse files

Pass access rights through elevation

  • Loading branch information...
alabuzhev committed Aug 2, 2019
1 parent 50aba0b commit 97ad6d6eef992152ea5b0c4391fe7fb1b1330a7c
Showing with 375 additions and 113 deletions.
  1. +4 −0 far/changelog
  2. +4 −0 far/changelog_eng
  3. +0 −1 far/config.cpp
  4. +16 −17 far/copy.cpp
  5. +2 −2 far/copy.hpp
  6. +1 −1 far/drivemix.cpp
  7. +226 −28 far/elevation.cpp
  8. +5 −0 far/elevation.hpp
  9. +0 −13 far/farlang.templ.m4
  10. +2 −6 far/fileowner.cpp
  11. +92 −20 far/platform.fs.cpp
  12. +18 −2 far/platform.fs.hpp
  13. +2 −19 far/platform.security.cpp
  14. +2 −3 far/platform.security.hpp
  15. +1 −1 far/vbuild.m4
@@ -1,3 +1,7 @@
drkns 02.08.2019 01:32:31 +0100 - build 5441

1. Права доступа должны корректно протаскиваться через elevation.

zg 31.07.2019 14:28:50 +0300 - build 5440

1. с форума: Косметические дефекты позиционирования в отфильтрованном списке.
@@ -3,6 +3,10 @@ This file is a translation of the main russian changelog and is provided by volu
It might not always be as up to date as the main changelog.
=======================================================================================

drkns 02.08.2019 01:32:31 +0100 - build 5441

1. It should be possible to pass access rights through elevation.

drkns 31.07.2019 01:27:30 +0100 - build 5439

1. Continuation of 5438 - improve error handling.
@@ -2405,7 +2405,6 @@ intptr_t Options::AdvancedConfigDlgProc(Dialog* Dlg, intptr_t Msg, intptr_t Para
break;

case DN_CLOSE:
// 0 == "OK", 1 == "Reset"
if (Param1 == 0 || Param1 == 1)
{
FarListInfo ListInfo = {sizeof(ListInfo)};
@@ -1875,15 +1875,15 @@ COPY_CODES ShellCopy::ShellCopyOneFile(

case operation::skip:
{
os::fs::security_descriptor tmpsd;
os::security::descriptor tmpsd;
if (m_CopySecurity == security::copy && !GetSecurity(Src, tmpsd))
return COPY_CANCEL;

SECURITY_ATTRIBUTES TmpSecAttr{ sizeof(TmpSecAttr), m_CopySecurity == security::copy? tmpsd.get() : nullptr, FALSE };
SECURITY_ATTRIBUTES TmpSecAttr{ sizeof(TmpSecAttr), tmpsd? tmpsd.get() : nullptr };

for (;;)
{
if (os::fs::create_directory(strDestPath, m_CopySecurity == security::copy? &TmpSecAttr : nullptr))
if (os::fs::create_directory(strDestPath, tmpsd? &TmpSecAttr : nullptr))
break;

const auto CreateDirectoryErrorState = error_state::fetch();
@@ -1929,19 +1929,20 @@ COPY_CODES ShellCopy::ShellCopyOneFile(
return SameName? COPY_SKIPPED : COPY_SUCCESS_MOVE;
}

os::fs::security_descriptor sd;
os::security::descriptor sd;

if (m_CopySecurity == security::copy && !GetSecurity(Src, sd))
return COPY_CANCEL;

SECURITY_ATTRIBUTES SecAttr = {sizeof(SecAttr), m_CopySecurity == security::copy? sd.get() : nullptr, FALSE};
SECURITY_ATTRIBUTES SecAttr = { sizeof(SecAttr), sd? sd.get() : nullptr };
if (RPT!=RP_SYMLINKFILE && SrcData.Attributes&FILE_ATTRIBUTE_DIRECTORY)
{
while (!os::fs::create_directory(
// CreateDirectoryEx preserves reparse points,
// so we shouldn't use template when copying with content
os::fs::is_directory_symbolic_link(SrcData) && (Flags & FCOPY_COPYSYMLINKCONTENTS)? L""s : Src,
strDestPath, m_CopySecurity == security::copy? &SecAttr : nullptr))
strDestPath,
sd? &SecAttr : nullptr))
{
const auto ErrorState = error_state::fetch();
const int MsgCode = Message(MSG_WARNING, ErrorState,
@@ -2529,7 +2530,7 @@ int ShellCopy::ShellCopyFile(const string& SrcName,const os::fs::find_data &SrcD
}
}

os::fs::security_descriptor sd;
os::security::descriptor sd;
if (m_CopySecurity == security::copy && !GetSecurity(SrcName, sd))
return COPY_CANCEL;

@@ -2564,9 +2565,7 @@ int ShellCopy::ShellCopyFile(const string& SrcName,const os::fs::find_data &SrcD
{
//if (DestAttr!=INVALID_FILE_ATTRIBUTES && !Append) //вот это портит копирование поверх хардлинков
//api::DeleteFile(DestName);
SECURITY_ATTRIBUTES SecAttr = {sizeof(SecAttr)};
if (m_CopySecurity == security::copy)
SecAttr.lpSecurityDescriptor = sd.get();
SECURITY_ATTRIBUTES SecAttr = { sizeof(SecAttr), sd? sd.get() : nullptr };

flags_attrs = SrcData.Attributes&(~((Flags&(FCOPY_DECRYPTED_DESTINATION))?FILE_ATTRIBUTE_ENCRYPTED|FILE_FLAG_SEQUENTIAL_SCAN:FILE_FLAG_SEQUENTIAL_SCAN));

@@ -2576,7 +2575,7 @@ int ShellCopy::ShellCopyFile(const string& SrcName,const os::fs::find_data &SrcD
strDestName,
GENERIC_WRITE,
FILE_SHARE_READ,
m_CopySecurity == security::copy? &SecAttr : nullptr,
sd? &SecAttr : nullptr,
Append? OPEN_EXISTING : CREATE_ALWAYS,
flags_attrs))
{
@@ -3339,11 +3338,11 @@ bool ShellCopy::AskOverwrite(const os::fs::find_data &SrcData,



bool ShellCopy::GetSecurity(const string& FileName, os::fs::security_descriptor& sd)
bool ShellCopy::GetSecurity(const string& FileName, os::security::descriptor& sd)
{
for (;;)
{
sd = os::fs::get_file_security(NTPath(FileName), DACL_SECURITY_INFORMATION);
sd = os::fs::get_file_security(FileName, DACL_SECURITY_INFORMATION);
if (sd)
return true;

@@ -3370,11 +3369,11 @@ bool ShellCopy::GetSecurity(const string& FileName, os::fs::security_descriptor&
}
}

bool ShellCopy::SetSecurity(const string& FileName, const os::fs::security_descriptor& sd)
bool ShellCopy::SetSecurity(const string& FileName, const os::security::descriptor& sd)
{
for (;;)
{
if (os::fs::set_file_security(NTPath(FileName), DACL_SECURITY_INFORMATION, sd))
if (os::fs::set_file_security(FileName, DACL_SECURITY_INFORMATION, sd))
return true;

if (SkipSecurityErrors)
@@ -3507,7 +3506,7 @@ bool ShellCopy::ResetSecurityRecursively(const string& FileName)

int ShellCopy::ShellSystemCopy(const string& SrcName,const string& DestName,const os::fs::find_data &SrcData)
{
os::fs::security_descriptor sd;
os::security::descriptor sd;

if (m_CopySecurity == security::copy && !GetSecurity(SrcName, sd))
return COPY_CANCEL;
@@ -3548,7 +3547,7 @@ int ShellCopy::ShellSystemCopy(const string& SrcName,const string& DestName,cons

Flags&=~FCOPY_DECRYPTED_DESTINATION;

if (m_CopySecurity == security::copy && !SetSecurity(DestName, sd))
if (sd && !SetSecurity(DestName, sd))
return COPY_CANCEL;

return COPY_SUCCESS;
@@ -80,8 +80,8 @@ class ShellCopy: noncopyable
int ShellSystemCopy(const string& SrcName,const string& DestName,const os::fs::find_data &SrcData);
int DeleteAfterMove(const string& Name,DWORD Attr);
bool AskOverwrite(const os::fs::find_data &SrcData,const string& SrcName,const string& DestName, DWORD DestAttr,int SameName,int Rename,int AskAppend, int &Append,string &strNewName,int &RetCode);
bool GetSecurity(const string& FileName, os::fs::security_descriptor& sd);
bool SetSecurity(const string& FileName, const os::fs::security_descriptor& sd);
bool GetSecurity(const string& FileName, os::security::descriptor& sd);
bool SetSecurity(const string& FileName, const os::security::descriptor& sd);
bool ResetSecurity(const string& FileName);
bool ResetSecurityRecursively(const string& FileName);
bool CalcTotalSize() const;
@@ -69,7 +69,7 @@ os::fs::drives_set allowed_drives_mask()
{
return Global->Opt->Policies.ShowHiddenDrives?
os::fs::drives_set{}.set() :
os::security::allowed_drives_mask();
os::fs::allowed_drives_mask();
}

os::fs::drives_set os::fs::get_logical_drives()

0 comments on commit 97ad6d6

Please sign in to comment.
You can’t perform that action at this time.