basic unix elevate port with credit to B. Gales
parent
7da7a1d70e
commit
7e00d6a357
|
@ -0,0 +1,2 @@
|
|||
Cat Stevens
|
||||
Barney Gale
|
|
@ -0,0 +1,8 @@
|
|||
USING: help.syntax help.markup ;
|
||||
IN: elevate
|
||||
|
||||
ABOUT: elevate
|
||||
|
||||
ARTICLE: "elevate" "Cross-platform API for elevated permissions"
|
||||
"Thanks to " { $url "https://github.com/barneygales/elevate" }
|
||||
;
|
|
@ -0,0 +1,30 @@
|
|||
USING: arrays command-line fry io.launcher kernel math namespaces
|
||||
sequences system unix.ffi ;
|
||||
IN: elevate
|
||||
|
||||
: apple-script-elevate ( x x -- ) 2drop ;
|
||||
|
||||
HOOK: elevate os ( win-console? posix-graphical? -- )
|
||||
|
||||
M: windows elevate 2drop ;
|
||||
|
||||
M: macosx elevate
|
||||
[ ! graphical (through applescript)
|
||||
t apple-script-elevate
|
||||
] [
|
||||
f linux os [ elevate ] with-variable
|
||||
] if ;
|
||||
|
||||
M: linux elevate
|
||||
getuid zero? [
|
||||
2drop ! we are already root: do nothing
|
||||
] [
|
||||
! graphical on linuxes
|
||||
nip [ { "gksudo" "kdesudo" } ] [ { } ] if
|
||||
"sudo" suffix (command-line) '[ 1array _ append ] map
|
||||
[
|
||||
run-process drop
|
||||
] each
|
||||
] if ;
|
||||
|
||||
HOOK: lower os ( relaunch? -- )
|
|
@ -0,0 +1 @@
|
|||
Cross-platform API for elevated permissions
|
Loading…
Reference in New Issue