diff options
author | Robert Fairley <rfairley@users.noreply.github.com> | 2018-11-21 02:46:02 -0500 |
---|---|---|
committer | Tomáš Mráz <t8m@users.noreply.github.com> | 2018-11-21 08:46:02 +0100 |
commit | 8eaf5570cf011148a0b55c53570df5edaafebdb0 (patch) | |
tree | ca73af7e2b7eeb5a6a2dbf42af96c2db3b3f7795 /xtests/tst-pam_motd4.sh | |
parent | f9c9c72121eada731e010ab3620762bcf63db08f (diff) | |
download | pam-8eaf5570cf011148a0b55c53570df5edaafebdb0.tar.gz pam-8eaf5570cf011148a0b55c53570df5edaafebdb0.tar.bz2 pam-8eaf5570cf011148a0b55c53570df5edaafebdb0.zip |
pam_motd: Fix segmentation fault when no motd_dir specified (#76)
This fixes a regression introduced by #69, where motd_path was set
to NULL and passed into strdup() if the motd_dir argument was
not specified in the configuration file. This caused a segmentation
fault.
* modules/pam_motd/pam_motd.c: fix checks for NULL in arguments
* xtests/Makefile.am: add test scripts and config file
* xtests/tst-pam_motd.sh: add running tst-pam_motd4.sh
* xtests/tst-pam_motd4.pamd: create
* xtests/tst-pam_motd4.sh: create
Diffstat (limited to 'xtests/tst-pam_motd4.sh')
-rwxr-xr-x | xtests/tst-pam_motd4.sh | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/xtests/tst-pam_motd4.sh b/xtests/tst-pam_motd4.sh new file mode 100755 index 00000000..6022177f --- /dev/null +++ b/xtests/tst-pam_motd4.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +TST_DIR="tst-pam_motd4.d" + +function tst_cleanup() { + rm -rf "${TST_DIR}" + rm -f tst-pam_motd4.out +} + +mkdir -p ${TST_DIR}/etc + +# Verify the case of single motd with no motd_dir given in tst-pam_motd4.pamd +echo "motd: /etc/motd" > ${TST_DIR}/etc/motd + +./tst-pam_motd tst-pam_motd4 > tst-pam_motd4.out + +RET=$? + +motd_to_show_output=$(cat tst-pam_motd4.out | grep "motd: /etc/motd") +if [ -z "${motd_to_show_output}" ]; +then + tst_cleanup + exit 1 +fi + +tst_cleanup +exit $RET |