SHARE
TWEET

Untitled

a guest Aug 10th, 2019 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. From f30fc44b365a99f7a784f10d15054b0a661f626d Mon Sep 17 00:00:00 2001
  2. From: gitfib <gitfib@users.noreply.github.com>
  3. Date: Sat, 10 Aug 2019 14:00:50 +0300
  4. Subject: [PATCH] Add pkexec support
  5.  
  6. ---
  7. src/FAL.cpp | 22 +++++++++++++++-------
  8.  1 file changed, 15 insertions(+), 7 deletions(-)
  9.  
  10. diff --git a/src/FAL.cpp b/src/FAL.cpp
  11. index cccb6fa..fb48e6d 100644
  12. --- a/src/FAL.cpp
  13. +++ b/src/FAL.cpp
  14. @@ -247,18 +247,22 @@ bool FAL::OSDependedOpen(wxFileName& myfilename, FileAccessMode FAM, unsigned Fo
  15.         //Changing owner of file...
  16.         //I think it's better than changing permissions directly. Doesn't it?
  17.         //Will restore owner on file close.
  18. -       wxString cmd;
  19. -       if( wxFile::Exists( wxT("/usr/bin/gnomesu")))
  20. +       wxString cmd, spacer = wxT(" ");
  21. +       if ( wxFile::Exists( wxT("/usr/bin/pkexec"))){
  22. +         cmd = wxT("pkexec --user root chown \"");
  23. +         spacer = wxT("\" \"");
  24. +       }
  25. +       else if( wxFile::Exists( wxT("/usr/bin/gnomesu")))
  26.             cmd = wxT("gnomesu -u root -c \"chown ");
  27.         else if( wxFile::Exists( wxT("/usr/bin/gksu")))
  28.             cmd = wxT("gksu -u root \"chown ");
  29.         else if( wxFile::Exists( wxT("/usr/bin/gksudo")))
  30.             cmd = wxT("gksudo -u root \"chown ");
  31.         else{
  32. -           wxMessageBox(_("For using this function, please install \"gnomesu\" or \"gksu\" tools first."),_("Error"), wxOK|wxCANCEL|wxICON_ERROR);
  33. +           wxMessageBox(_("For using this function, please install \"pkexec\", \"gnomesu\" or \"gksu\" tools first."),_("Error"), wxOK|wxCANCEL|wxICON_ERROR);
  34.             return false;
  35.             }
  36. -       cmd+=wxGetUserId() + wxT(" ")+ myfilename.GetFullPath() +wxT("\"");
  37. +       cmd+=wxGetUserId() + spacer + myfilename.GetFullPath() +wxT("\"");
  38.     #ifdef _DEBUG_
  39.         std::cout << "Changing permission of " << myfilename.GetFullPath().ToAscii() << std::endl;
  40.         std::cout << cmd.ToAscii() << std::endl;
  41. @@ -358,14 +362,18 @@ FAL::~FAL(){
  42.  #ifndef __WXMSW__
  43.     if(!oldOwner.IsEmpty() ){
  44.         //Will restore owner on file close.
  45. -       wxString cmd;
  46. -       if( wxFile::Exists( wxT("/usr/bin/gnomesu")))
  47. +       wxString cmd, spacer = wxT(" ");
  48. +       if ( wxFile::Exists( wxT("/usr/bin/pkexec"))){
  49. +         cmd = wxT("pkexec --user root chown \"");
  50. +         spacer = wxT("\" \"");
  51. +       }
  52. +       else if( wxFile::Exists( wxT("/usr/bin/gnomesu")))
  53.             cmd = wxT("gnomesu -c \"chown ");
  54.         else if( wxFile::Exists( wxT("/usr/bin/gksu")))
  55.             cmd = wxT("gksu -u root \"chown ");
  56.         else if( wxFile::Exists( wxT("/usr/bin/gksudo")))
  57.             cmd = wxT("gksudo -u root \"chown ");
  58. -       cmd += oldOwner + wxT(" ")+ the_file.GetFullPath() +wxT("\"");
  59. +       cmd += oldOwner + spacer + the_file.GetFullPath() +wxT("\"");
  60.  #ifdef _DEBUG_
  61.         std::cout << "Changing permission of " << the_file.GetFullPath().ToAscii() << std::endl;
  62.         std::cout << cmd.ToAscii() << std::endl;
  63. --
  64. 2.22.0
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top