Forum: Ruby DRB: can't run subshell in drb server?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Bde9493348770b4f6bf0f632ef91fc1c?d=identicon&s=25 Ittay Dror (ittayd)
on 2008-10-21 13:12
(Received via mailing list)
Hi,


I have a script with

puts %x{echo hi}


When run normally it works.


When run under a drb server that was started with the root user (sudo),
it works.


But when run under a drb server that was started with a normal user, it
doesn't work.


Stracing shows that the subprocess is started, but 'echo' is never
executed (executing '/bin/echo' from a bash shell works). (Below see the
relevant parts of strace as root and as normal user)


Can someone shed some light on this?


Thanks,

Ittay


strace as root:

[pid 27075] stat64("/usr/local/sbin", {st_mode=S_IFDIR|0755,
st_size=4096, ...}) = 0
[pid 27075] stat64("/usr/local", {st_mode=S_IFDIR|0755, st_size=4096,
...}) = 0
[pid 27075] stat64("/usr", {st_mode=S_IFDIR|0755, st_size=4096, ...}) =
0
[pid 27075] stat64("/usr/local/bin", {st_mode=S_IFDIR|0755,
st_size=4096, ...}) = 0
[pid 27075] stat64("/usr/local", {st_mode=S_IFDIR|0755, st_size=4096,
...}) = 0
[pid 27075] stat64("/usr", {st_mode=S_IFDIR|0755, st_size=4096, ...}) =
0
[pid 27075] stat64("/usr/sbin", {st_mode=S_IFDIR|0755, st_size=12288,
...}) = 0
[pid 27075] stat64("/usr", {st_mode=S_IFDIR|0755, st_size=4096, ...}) =
0
[pid 27075] stat64("/usr/bin", {st_mode=S_IFDIR|0755, st_size=77824,
...}) = 0
[pid 27075] stat64("/usr", {st_mode=S_IFDIR|0755, st_size=4096, ...}) =
0
[pid 27075] stat64("/sbin", {st_mode=S_IFDIR|0755, st_size=12288, ...})
= 0
[pid 27075] stat64("/bin", {st_mode=S_IFDIR|0755, st_size=4096, ...}) =
0
[pid 27075] stat64("/usr/X11R6/bin", {st_mode=S_IFDIR|0755,
st_size=77824, ...}) = 0
[pid 27075] stat64("/usr/X11R6", {st_mode=S_IFDIR|0755, st_size=4096,
...}) = 0
[pid 27075] stat64("/usr", {st_mode=S_IFDIR|0755, st_size=4096, ...}) =
0
[pid 27075] setitimer(ITIMER_VIRTUAL, {it_interval={0, 0}, it_value={0,
0}}, NULL) = 0
[pid 27075] execve("/bin/echo", ["/bin/echo", "hi"], [/* 17 vars */]) =
0

...


strace as user:

[pid 27093] stat64("/home/ittayd/bin", {st_mode=S_IFDIR|0755,
st_size=4096, ...}) = 0
[pid 27093] stat64("/home/ittayd", {st_mode=S_IFDIR|0755, st_size=4096,
...}) = 0
[pid 27093] stat64("/home", {st_mode=S_IFDIR|0755, st_size=4096, ...}) =
0
[pid 27093] stat64("/home/ittayd/bin", {st_mode=S_IFDIR|0755,
st_size=4096, ...}) = 0
[pid 27093] stat64("/home/ittayd", {st_mode=S_IFDIR|0755, st_size=4096,
...}) = 0
[pid 27093] stat64("/home", {st_mode=S_IFDIR|0755, st_size=4096, ...}) =
0
[pid 27093] stat64("/usr/local/sbin", {st_mode=S_IFDIR|0755,
st_size=4096, ...}) = 0
[pid 27093] stat64("/usr/local", {st_mode=S_IFDIR|0755, st_size=4096,
...}) = 0
[pid 27093] stat64("/usr", {st_mode=S_IFDIR|0755, st_size=4096, ...}) =
0
[pid 27093] stat64("/usr/local/bin", {st_mode=S_IFDIR|0755,
st_size=4096, ...}) = 0
[pid 27093] stat64("/usr/local", {st_mode=S_IFDIR|0755, st_size=4096,
...}) = 0
[pid 27093] stat64("/usr", {st_mode=S_IFDIR|0755, st_size=4096, ...}) =
0
[pid 27093] stat64("/usr/sbin", {st_mode=S_IFDIR|0755, st_size=12288,
...}) = 0
[pid 27093] stat64("/usr", {st_mode=S_IFDIR|0755, st_size=4096, ...}) =
0
[pid 27093] stat64("/usr/bin", {st_mode=S_IFDIR|0755, st_size=77824,
...}) = 0
[pid 27093] stat64("/usr", {st_mode=S_IFDIR|0755, st_size=4096, ...}) =
0
[pid 27093] stat64("/sbin", {st_mode=S_IFDIR|0755, st_size=12288, ...})
= 0
[pid 27093] stat64("/bin", {st_mode=S_IFDIR|0755, st_size=4096, ...}) =
0
[pid 27093] stat64("/usr/games", {st_mode=S_IFDIR|0755, st_size=4096,
...}) = 0
[pid 27093] stat64("/usr", {st_mode=S_IFDIR|0755, st_size=4096, ...}) =
0
[pid 27093] stat64("/opt/maven/bin", {st_mode=S_IFDIR|0755,
st_size=4096, ...}) = 0
[pid 27093] stat64("/opt/maven", {st_mode=S_IFDIR|0755, st_size=4096,
...}) = 0
[pid 27093] stat64("/opt", {st_mode=S_IFDIR|0777, st_size=4096, ...}) =
0
[pid 27093] clock_gettime(CLOCK_MONOTONIC, {133977, 363841305}) = 0
[pid 27093] clock_gettime(CLOCK_MONOTONIC, {133977, 363869662}) = 0
[pid 27093] select(7, [3 5], [], [], {0, 0}) = -1 EBADF (Bad file
descriptor)
[pid 27093] select(7, [3], [5], [], NULL) = -1 EBADF (Bad file
descriptor)
....
Bde9493348770b4f6bf0f632ef91fc1c?d=identicon&s=25 Ittay Dror (ittayd)
on 2008-10-21 13:30
(Received via mailing list)
Further analysis shows that the reason is that my path contains a
world-writable directory. Ruby tries to complain about this but since
the code runs under DRB this is sent over the network, but apparently
the code is not correct when run in a subprocess and fails resulting in
the whole subprocess failing.


I've opened a bug (22495) in Ruby.


Ittay
This topic is locked and can not be replied to.