Skip to content

Commit d1ec48b

Browse files
authored
Use actual sudo when NO_NEW_PRIVS is not set
1 parent 0ba1534 commit d1ec48b

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

component/client.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,14 @@ def restore_console
1212
def runas_client(argv)
1313
$mode = :client
1414

15+
if File.read('/proc/self/status') =~ /^NoNewPrivs:[[:blank:]]+0$/
16+
message 'Sudo is usable, falling back to sudo...'
17+
exec('/usr/bin/sudo', *ARGV)
18+
end
19+
1520
unless Process.euid == 1000
1621
message 'Client executed by non-chronos user, falling back to sudo...'
17-
exec($0, *ARGV)
22+
exec('/usr/bin/sudo', *ARGV)
1823
end
1924

2025
is_tty = $stdin.isatty && $stdout.isatty && $stderr.isatty
@@ -79,4 +84,4 @@ def runas_client(argv)
7984
ensure
8085
restore_console if is_tty
8186
socket&.close
82-
end
87+
end

0 commit comments

Comments
 (0)