[sudo-workers] execve() failure & closefrom() in fork_cmnd()

Daniel Kopecek dkopecek at redhat.com
Tue Nov 29 11:47:46 EST 2011

  it seems that the usage of closefrom() in the fork_cmnd() function 
(http://www.sudo.ws/repos/sudo/file/ec0f2beaad36/src/exec.c#l140) should 
take into consideration that the execve() call might fail and ensure 
that the sv[1] descriptor used for sending the cstat structure back to 
the parent process stays open. In the current state and with 
def_closefrom not set to some higher number than sv[1], the descriptor 
gets closed and sudo doesn't report an error.

Proposed change:

    closefrom(def_closefrom < sv[1] ? sv[1] + 1 : def_closefrom);

Dan K.

More information about the sudo-workers mailing list