I have an application that uses wall and doing that in an a way that
I find unsatisfactory. Follows a mixture of real and pseudo code of the
app in question with an emphasize towards the problematic code.


    static void wall(const char *text)
    {
        FILE    *wf;
    
        wf = popen("wall", "w");
    
        if (!wf) {
            upslog(LOG_NOTICE, "Can't invoke wall");
            return;
        }
    
        fprintf(wf, "%s\n", text);
        pclose(wf);
    } 

    
    int main(void)
    {
        Do some initializations with root privileges;
        Become a daemon;
        fork;
        if (parent) { sleep until shutdown; }
        if (child)
            do {
                euid = nut;
                Communicate over the network to obtain essential info;
                wall("critical information was obtained");
            } until (forever);
        return 0;
    }


  The problem with the wall usage is that if users have mesg is n then
they won't be alerted about the critical information. Possible solutions
are:

  1. Modify the internal wall to have
         poepn("nut_wall", "w")
     where nut_wall is a copy of the system wall executable, only that
         that copy is 
             rws--x---    root  nut

  2. Wrap wall's
         poepn("nut_wall", "w")
     with gaining back and dropping the root privileges.

  3. Like 2 with the addition that whole wall activation will be a 
     grandchild process.


  The upstream author is reluctant to modify the code. He claims that
root privileges should be used only when necessary, in particular in
network aware applications. He also want the source lines that will get
executed with root privileges to be structurally separated from the other
source lines.

  Any comment will be appreciated.

  If you are curious, the app in question is the NUT, Network
uninterruptible-power-supply Tools. The main site is at
http://www.exploits.org/nut.
-- 

    Shaul Karl, [EMAIL PROTECTED] e t

=================================================================
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]

Reply via email to