]> git.ipfire.org Git - thirdparty/krb5.git/commitdiff
Properly mirror child exit status in ksu 1309/head
authorGreg Hudson <ghudson@mit.edu>
Fri, 28 Jul 2023 22:07:34 +0000 (18:07 -0400)
committerGreg Hudson <ghudson@mit.edu>
Tue, 3 Oct 2023 16:42:01 +0000 (12:42 -0400)
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

src/clients/ksu/main.c
src/clients/ksu/t_ksu.py

index 72984365853b26da08ed1903f25bfdcc515ef39b..80a9c07db704d5861adf9af66e599c2bbed44649 100644 (file)
@@ -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);
index 9740972ba5a7cbecb16ebe08d4e7115ede2c4c8d..ab52b4b2dc2f4f429651177bea95083ed0490d8d 100644 (file)
@@ -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')