1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Check for the privileges by the current process groups

Group membership of login user is not activated until login after
adding to the group.
This commit is contained in:
Nobuyoshi Nakada 2019-06-30 21:12:15 +09:00
parent 3b86ec2251
commit b89f6ac843
No known key found for this signature in database
GPG key ID: 4BC7D6DF58D8DF60

View file

@ -19,9 +19,7 @@ if RUBY_PLATFORM =~ /linux/
impl = :stap
begin
require 'etc'
login = Etc.getlogin
ok = Etc.getgrnam('stapusr').mem.include?(login) &&
Etc.getgrnam('stapdev').mem.include?(login)
ok = (%w[stapusr stapdev].map {|g|Etc.getgrnam(g).gid} & Process.groups).size == 2
rescue LoadError, ArgumentError
end unless ok
end