File tree Expand file tree Collapse file tree 3 files changed +19
-1
lines changed
src/main/ruby/truffleruby/core Expand file tree Collapse file tree 3 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ Compatibility:
25
25
* Implement ` rb_imemo_tmpbuf ` allocation for ` ripper ` (@aardvark179 ).
26
26
* Implement ` inherit ` argument for ` Module#class_variables ` (#2653 , @bjfish ).
27
27
* Fix ` Float#/ ` when dividing by ` Rational ` (@bjfish ).
28
+ * ` Process.euid= ` should accept String (#2615 , @ngtban ).
28
29
29
30
Performance:
30
31
Original file line number Diff line number Diff line change 21
21
-> { Process . euid = Object . new } . should raise_error ( TypeError )
22
22
end
23
23
24
+ it "sets the effective user id to its own uid if given the username corresponding to its own uid" do
25
+ raise unless Process . uid == Process . euid
26
+
27
+ require "etc"
28
+ user = Etc . getpwuid ( Process . uid ) . name
29
+
30
+ Process . euid = user
31
+ Process . euid . should == Process . uid
32
+ end
33
+
24
34
as_user do
25
35
it "raises Errno::ERPERM if run by a non superuser trying to set the superuser id" do
26
36
-> { ( Process . euid = 0 ) } . should raise_error ( Errno ::EPERM )
Original file line number Diff line number Diff line change @@ -403,7 +403,14 @@ def self.euid=(uid)
403
403
# the 4 rescue clauses below are needed
404
404
# until respond_to? can be used to query the implementation of methods attached via FFI
405
405
# atm respond_to returns true if a method is attached but not implemented on the platform
406
- uid = Truffle ::Type . coerce_to uid , Integer , :to_int
406
+ uid =
407
+ if uid . kind_of? ( String )
408
+ require 'etc'
409
+ Etc . getpwnam ( uid ) . uid
410
+ else
411
+ Truffle ::Type . coerce_to uid , Integer , :to_int
412
+ end
413
+
407
414
begin
408
415
ret = Truffle ::POSIX . setresuid ( -1 , uid , -1 )
409
416
rescue NotImplementedError
You can’t perform that action at this time.
0 commit comments