Use W_EXITCODE to construct the wait status if sudo could not execute
the command. Fixes the sudo exit value for exec(3) failure.
This commit is contained in:
@@ -284,6 +284,11 @@ extern int errno;
|
|||||||
# define WCOREDUMP(x) ((x) & 0x80)
|
# define WCOREDUMP(x) ((x) & 0x80)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* W_EXITCODE is not POSIX but the encoding of wait status is. */
|
||||||
|
#ifndef W_EXITCODE
|
||||||
|
# define W_EXITCODE(ret, sig) ((ret) << 8 | (sig))
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Number of bits in a byte. */
|
/* Number of bits in a byte. */
|
||||||
#ifndef NBBY
|
#ifndef NBBY
|
||||||
# ifdef __NBBY
|
# ifdef __NBBY
|
||||||
|
@@ -1130,13 +1130,14 @@ done:
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Run the command and wait for it to complete.
|
* Run the command and wait for it to complete.
|
||||||
|
* Returns wait status suitable for use with the wait(2) macros.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
run_command(struct command_details *details)
|
run_command(struct command_details *details)
|
||||||
{
|
{
|
||||||
struct plugin_container *plugin;
|
struct plugin_container *plugin;
|
||||||
struct command_status cstat;
|
struct command_status cstat;
|
||||||
int status = 1;
|
int status = W_EXITCODE(1, 0);
|
||||||
debug_decl(run_command, SUDO_DEBUG_EXEC)
|
debug_decl(run_command, SUDO_DEBUG_EXEC)
|
||||||
|
|
||||||
cstat.type = CMD_INVALID;
|
cstat.type = CMD_INVALID;
|
||||||
@@ -1155,7 +1156,6 @@ run_command(struct command_details *details)
|
|||||||
"calling I/O close with errno %d", cstat.val);
|
"calling I/O close with errno %d", cstat.val);
|
||||||
iolog_close(plugin, 0, cstat.val);
|
iolog_close(plugin, 0, cstat.val);
|
||||||
}
|
}
|
||||||
status = 1;
|
|
||||||
break;
|
break;
|
||||||
case CMD_WSTATUS:
|
case CMD_WSTATUS:
|
||||||
/* Command ran, exited or was killed. */
|
/* Command ran, exited or was killed. */
|
||||||
|
Reference in New Issue
Block a user