no groups during init - Linux

This is a discussion on no groups during init - Linux ; I have a process that I'm trying to autostart with an init script. I have added it to /etc/init.d/ and set it to start with chkconfig. It starts up fine. But for the application to work correctly, root has to ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: no groups during init

  1. no groups during init

    I have a process that I'm trying to autostart with an init script. I
    have added it to /etc/init.d/ and set it to start with chkconfig. It
    starts up fine. But for the application to work correctly, root has to
    be part of two groups. It is. But it appears that during the init
    process root hasn't been assigned to its groups yet. So my application
    is starting without root having it's proper group membership. Does
    anyone have any idea what I can do to get around this.

  2. Re: no groups during init

    slbentley@hotmail.com (Scooter) wrote in message news:...
    > I have a process that I'm trying to autostart with an init script. I
    > have added it to /etc/init.d/ and set it to start with chkconfig. It
    > starts up fine. But for the application to work correctly, root has to
    > be part of two groups. It is. But it appears that during the init
    > process root hasn't been assigned to its groups yet. So my application
    > is starting without root having it's proper group membership. Does
    > anyone have any idea what I can do to get around this.



    This is because when a process runs, it gets the current groups
    when it's invoked. The data structure is a simple array which
    keeps the groups, and this does not change during the execution
    of the process.

    Spawning shells won't work since they will inherit the parent.
    "newgrp" won't help since you have more than one group, and it also
    modifies the primary group.

    I would recommend you make the initscript a wrapper for the real
    one. And use "su -c" to execute the real one. "su" will get the
    new group assignments.

    Tolga Ceylan

  3. Re: no groups during init

    Tolga Ceylan wrote:

    > slbentley@hotmail.com (Scooter) wrote in message news:...
    >
    >>I have a process that I'm trying to autostart with an init script. I
    >>have added it to /etc/init.d/ and set it to start with chkconfig. It
    >>starts up fine. But for the application to work correctly, root has to
    >>be part of two groups. It is. But it appears that during the init
    >>process root hasn't been assigned to its groups yet. So my application
    >>is starting without root having it's proper group membership. Does
    >>anyone have any idea what I can do to get around this.


    > This is because when a process runs, it gets the current groups
    > when it's invoked. The data structure is a simple array which
    > keeps the groups, and this does not change during the execution
    > of the process.
    >
    > Spawning shells won't work since they will inherit the parent.
    > "newgrp" won't help since you have more than one group, and it also
    > modifies the primary group.


    I don't see why newgrp won't work. Any shell will inherit the current
    status of the groups, and it is the status of the primary group which is
    causing the trouble.

    I would recommend that he use newgrp in the initialization script to
    switch, then start the application. That should work, I would think.

    There's no way for root to have two primary groups; only one can be
    active at a time.

+ Reply to Thread