diff options
author | Greg Hudson <ghudson@mit.edu> | 2023-07-28 18:07:34 -0400 |
---|---|---|
committer | Greg Hudson <ghudson@mit.edu> | 2023-10-03 12:42:01 -0400 |
commit | 03c7df6fc683c68975db46c7afaa24f1a9a05fae (patch) | |
tree | e8df21b77c6a9ad01b8702a3b0e1fdfe0180453b | |
parent | 036f861b657f63852732a4c19d84a4f18a3938ec (diff) | |
download | krb5-03c7df6fc683c68975db46c7afaa24f1a9a05fae.zip krb5-03c7df6fc683c68975db46c7afaa24f1a9a05fae.tar.gz krb5-03c7df6fc683c68975db46c7afaa24f1a9a05fae.tar.bz2 |
Properly mirror child exit status in ksu
ksu attempts to exit with the same status as its child process, but
does not do so correctly. Use WEXITSTATUS() to extract the exit code.
Reported by Todd Lubin.
ticket: 8618
-rw-r--r-- | src/clients/ksu/main.c | 2 | ||||
-rw-r--r-- | src/clients/ksu/t_ksu.py | 8 |
2 files changed, 6 insertions, 4 deletions
diff --git a/src/clients/ksu/main.c b/src/clients/ksu/main.c index 7298436..80a9c07 100644 --- a/src/clients/ksu/main.c +++ b/src/clients/ksu/main.c @@ -780,7 +780,7 @@ main(int argc, char ** argv) com_err(prog_name, errno, _("while calling waitpid")); } sweep_up(ksu_context, cc_target); - exit (statusp); + exit (WIFEXITED(statusp) ? WEXITSTATUS(statusp) : 1); case -1: com_err(prog_name, errno, _("while trying to fork.")); sweep_up(ksu_context, cc_target); diff --git a/src/clients/ksu/t_ksu.py b/src/clients/ksu/t_ksu.py index 9740972..ab52b4b 100644 --- a/src/clients/ksu/t_ksu.py +++ b/src/clients/ksu/t_ksu.py @@ -244,7 +244,7 @@ mark('principal heuristic (no authorization)') realm.run([ksu, '.', '-e', klist], expected_msg='Default principal: alice@KRBTEST.COM') be_root() -realm.run([ksu, 'ksutest', '-e', klist], +realm.run([ksu, 'ksutest', '-e', klist], expected_code=1, expected_msg='No credentials cache found') be_caller() realm.kinit('ksutest', 'pwksutest') @@ -253,7 +253,8 @@ realm.run([ksu, 'ksutest', '-e', klist], expected_msg='Default principal: ksutest@KRBTEST.COM') be_caller() realm.run([kdestroy]) -realm.run([ksu, '.', '-e', klist], expected_msg='No credentials cache found') +realm.run([ksu, '.', '-e', klist], expected_code=1, + expected_msg='No credentials cache found') mark('authentication without authorization') realm.run([ksu, '.', '-n', 'ksutest', '-e', klist], input='pwksutest\n', @@ -266,6 +267,7 @@ realm.kinit(caller_username, 'pwcaller') realm.run([ksu, '.', '-z', '-e', klist], expected_msg='Default principal: ' + caller_username) -realm.run([ksu, '.', '-Z', '-e', klist]) +realm.run([ksu, '.', '-Z', '-e', klist], expected_code=1, + expected_msg='No credentials cache found') success('ksu tests') |