[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

DRB: can't run subshell in drb server?

Ittay Dror

10/21/2008 11:11:00 AM

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)
....

--
--
Ittay Dror <ittay.dror@gmail.com>



1 Answer

Ittay Dror

10/21/2008 11:28:00 AM

0

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

Ittay Dror wrote:

> 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)
> ....
>

--
--
Ittay Dror <ittay.dror@gmail.com>