Controlling processes and what to "feed" other processes

Discussion in 'Ruby' started by Marc Heiler, May 24, 2009.

  1. Marc Heiler

    Marc Heiler Guest

    Hi,

    alsa-driver has a slight error in its Makefile.
    The line in question is this here:

    install -m 644 -g root -o root $f /usr/include/sound

    Obviously it uses a specific name "root", rather than the
    number 0.

    On systems which do not have a superuser name called root,
    this will produce such an error:

    install: invalid user `root'

    Now, it is trivial to fix it (use numbers instead of fixed
    names like "root", because the numbers always work. To
    reproduce sometimes odd behaviour you could alias root
    to another name, like in:

    usermod -l new_name root
    )

    But - since I am using ruby scripts for fetching source and
    compiling it already, i wondered if there was a way to completely
    control processes like the above.
    In other words, my "watchguard" script would first check if a
    command is valid, before it tries to execute it (or feed to make,
    or some other binary).

    In the above example it would simply change:

    install -m 644 -g root -o root $f /usr/include/sound

    to

    install -m 644 -g 0 -o 0 $f /usr/include/sound

    This seems like a trivial thing to do, although I have no
    real idea how to do this at all.

    PS: I already have a somewhat buggyruby script which actually
    fixes incorrect Makefiles, but I thought that a ruby script
    which can actually sanitize the input "on-the-fly" and correct
    mistakes would be smarter and more powerful. So I am at
    least in theory curious how to approach this problem.
    --
    Posted via http://www.ruby-forum.com/.
     
    Marc Heiler, May 24, 2009
    #1
    1. Advertising

  2. On 24.05.2009 18:59, Marc Heiler wrote:

    > But - since I am using ruby scripts for fetching source and
    > compiling it already, i wondered if there was a way to completely
    > control processes like the above.
    > In other words, my "watchguard" script would first check if a
    > command is valid, before it tries to execute it (or feed to make,
    > or some other binary).
    >
    > In the above example it would simply change:
    >
    > install -m 644 -g root -o root $f /usr/include/sound
    >
    > to
    >
    > install -m 644 -g 0 -o 0 $f /usr/include/sound
    >
    > This seems like a trivial thing to do, although I have no
    > real idea how to do this at all.
    >
    > PS: I already have a somewhat buggyruby script which actually
    > fixes incorrect Makefiles, but I thought that a ruby script
    > which can actually sanitize the input "on-the-fly" and correct
    > mistakes would be smarter and more powerful. So I am at
    > least in theory curious how to approach this problem.


    For full control you would have to intercept system calls because you
    would need to manipulate files while they are read. It might be
    feasible but that would certainly very OS specific and it might not work
    on all operating systems.

    If you know that all programs are started via a shell you could try to
    modify environment variable SHELL to point to a specific program which
    would be able to interpret the general syntax of the shell you are using
    and could identify files via their names (e.g. Makefile) and then do
    some manipulations. However, that approach is not without issues and
    you will certainly not be able to make it bullet proof.

    Yet another solution: replace "make" with something you have written or
    at least have control over and which treats "root" properly.

    I'm curios what others will come up with.

    Kind regards

    robert


    --
    remember.guy do |as, often| as.you_can - without end
    http://blog.rubybestpractices.com/
     
    Robert Klemme, May 24, 2009
    #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. Hein Robert

    Controlling client Java processes

    Hein Robert, Jan 27, 2004, in forum: Java
    Replies:
    1
    Views:
    295
    Thomas Weidenfeller
    Jan 27, 2004
  2. Jeff Rodriguez
    Replies:
    23
    Views:
    1,200
    David Schwartz
    Dec 9, 2003
  3. Replies:
    1
    Views:
    245
  4. tkondal
    Replies:
    0
    Views:
    245
    tkondal
    Jul 18, 2007
  5. Mehdi Karamnejad
    Replies:
    3
    Views:
    100
    Marvin Gülker
    Nov 20, 2009
Loading...

Share This Page