DRB: can't run subshell in drb server?

Discussion in 'Ruby' started by Ittay Dror, Oct 21, 2008.

  1. Ittay Dror

    Ittay Dror Guest

    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, Oct 21, 2008
    #1
    1. Advertising

  2. Ittay Dror

    Ittay Dror Guest

    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, Oct 21, 2008
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Miles Keaton
    Replies:
    3
    Views:
    185
    Miles Keaton
    Mar 30, 2005
  2. Kirk Haines

    More DRb; SSL & DRB & errors

    Kirk Haines, Jul 1, 2005, in forum: Ruby
    Replies:
    0
    Views:
    134
    Kirk Haines
    Jul 1, 2005
  3. Noah Easterly

    backtick subshell

    Noah Easterly, Nov 14, 2006, in forum: Ruby
    Replies:
    5
    Views:
    180
    powlow
    Nov 23, 2006
  4. Luke Kanies

    UID/EUID subshell solutions

    Luke Kanies, Dec 12, 2006, in forum: Ruby
    Replies:
    2
    Views:
    143
    Luke Kanies
    Dec 19, 2006
  5. J. Wook
    Replies:
    16
    Views:
    290
    Robert Klemme
    May 16, 2007
Loading...

Share This Page