Skip to content

Commit 1ffe5aa

Browse files
authored
Port root authentication from AppImage/AppImageKit#364
Thanks @abhay44
1 parent b465227 commit 1ffe5aa

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

main.vala

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,23 @@ static HeaderBar header_bar; // Too new to assume it is there?
88

99
static string selected_file;
1010

11+
static string root(){
12+
13+
var a = Posix.system("pkexec --disable-internal-agent echo hello to appimages");
14+
if (a == 32256){
15+
return "false";
16+
}
17+
else{
18+
return "true";
19+
}
20+
21+
}
22+
static void root_run(){
23+
if(root() == "false"){
24+
Posix.exit(0);
25+
}
26+
}
27+
1128
/* Open file */
1229
static void open_file(string filename) {
1330
selected_file = filename;
@@ -46,6 +63,7 @@ static void on_about_clicked() {
4663
}
4764

4865
static void main (string[] args) {
66+
root_run();
4967
init (ref args);
5068
if(args.length > 1){
5169
open_file(args[1]);

0 commit comments

Comments
 (0)