summarylogtreecommitdiffstats
path: root/01-add-pkexec-support.patch
blob: 81edf8b0c6da640cc7cc7fbe5588ea346e1241e5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
From f30fc44b365a99f7a784f10d15054b0a661f626d Mon Sep 17 00:00:00 2001
From: gitfib <gitfib@users.noreply.github.com>
Date: Sat, 10 Aug 2019 14:00:50 +0300
Subject: [PATCH] Add pkexec support

---
 src/FAL.cpp | 22 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/src/FAL.cpp b/src/FAL.cpp
index cccb6fa..fb48e6d 100644
--- a/src/FAL.cpp
+++ b/src/FAL.cpp
@@ -247,18 +247,22 @@ bool FAL::OSDependedOpen(wxFileName& myfilename, FileAccessMode FAM, unsigned Fo
 		//Changing owner of file...
 		//I think it's better than changing permissions directly. Doesn't it?
 		//Will restore owner on file close.
-		wxString cmd;
-		if( wxFile::Exists( wxT("/usr/bin/gnomesu")))
+		wxString cmd, spacer = wxT(" ");
+		if ( wxFile::Exists( wxT("/usr/bin/pkexec"))){
+		  cmd = wxT("pkexec --user root chown \"");
+		  spacer = wxT("\" \"");
+		}
+		else if( wxFile::Exists( wxT("/usr/bin/gnomesu")))
 			cmd = wxT("gnomesu -u root -c \"chown ");
 		else if( wxFile::Exists( wxT("/usr/bin/gksu")))
 			cmd = wxT("gksu -u root \"chown ");
 		else if( wxFile::Exists( wxT("/usr/bin/gksudo")))
 			cmd = wxT("gksudo -u root \"chown ");
 		else{
-			wxMessageBox(_("For using this function, please install \"gnomesu\" or \"gksu\" tools first."),_("Error"), wxOK|wxCANCEL|wxICON_ERROR);
+			wxMessageBox(_("For using this function, please install \"pkexec\", \"gnomesu\" or \"gksu\" tools first."),_("Error"), wxOK|wxCANCEL|wxICON_ERROR);
 			return false;
 			}
-		cmd+=wxGetUserId() + wxT(" ")+ myfilename.GetFullPath() +wxT("\"");
+		cmd+=wxGetUserId() + spacer + myfilename.GetFullPath() +wxT("\"");
 	#ifdef _DEBUG_
 		std::cout << "Changing permission of " << myfilename.GetFullPath().ToAscii() << std::endl;
 		std::cout << cmd.ToAscii() << std::endl;
@@ -358,14 +362,18 @@ FAL::~FAL(){
 #ifndef __WXMSW__
 	if(!oldOwner.IsEmpty() ){
 		//Will restore owner on file close.
-		wxString cmd;
-		if( wxFile::Exists( wxT("/usr/bin/gnomesu")))
+		wxString cmd, spacer = wxT(" ");
+		if ( wxFile::Exists( wxT("/usr/bin/pkexec"))){
+		  cmd = wxT("pkexec --user root chown \"");
+		  spacer = wxT("\" \"");
+		}
+		else if( wxFile::Exists( wxT("/usr/bin/gnomesu")))
 			cmd = wxT("gnomesu -c \"chown ");
 		else if( wxFile::Exists( wxT("/usr/bin/gksu")))
 			cmd = wxT("gksu -u root \"chown ");
 		else if( wxFile::Exists( wxT("/usr/bin/gksudo")))
 			cmd = wxT("gksudo -u root \"chown ");
-		cmd += oldOwner + wxT(" ")+ the_file.GetFullPath() +wxT("\"");
+		cmd += oldOwner + spacer + the_file.GetFullPath() +wxT("\"");
 #ifdef _DEBUG_
 		std::cout << "Changing permission of " << the_file.GetFullPath().ToAscii() << std::endl;
 		std::cout << cmd.ToAscii() << std::endl;
-- 
2.22.0