summaryrefslogtreecommitdiff
path: root/xtests/tst-pam_dispatch4.c
diff options
context:
space:
mode:
authorThorsten Kukuk <kukuk@thkukuk.de>2006-08-24 08:49:19 +0000
committerThorsten Kukuk <kukuk@thkukuk.de>2006-08-24 08:49:19 +0000
commit46fa42001831ce7868bbe335129c690fec5546a8 (patch)
tree706f035a5c996fc547964b143c8f61772634953f /xtests/tst-pam_dispatch4.c
parentc317d5f86baaffcd8adf45c20757fafe6c190694 (diff)
Relevant BUGIDs:
Purpose of commit: new feature Commit summary: --------------- Add test for [...] control sequences. 2006-08-24 Thorsten Kukuk <kukuk@thkukuk.de> * xtests/tst-pam_dispatch4.c: New test. * xtests/tst-pam_dispatch4.pamd: PAM config for new test.
Diffstat (limited to 'xtests/tst-pam_dispatch4.c')
-rw-r--r--xtests/tst-pam_dispatch4.c59
1 files changed, 59 insertions, 0 deletions
diff --git a/xtests/tst-pam_dispatch4.c b/xtests/tst-pam_dispatch4.c
new file mode 100644
index 00000000..fc05c8b9
--- /dev/null
+++ b/xtests/tst-pam_dispatch4.c
@@ -0,0 +1,59 @@
+
+#include <stdio.h>
+#include <string.h>
+#include <security/pam_appl.h>
+#include <security/pam_misc.h>
+
+static struct pam_conv conv = {
+ misc_conv,
+ NULL
+};
+
+
+/* Check that errors of optional modules are ignored and that
+ required modules after a sufficient one are not executed. */
+
+int
+main(int argc, char *argv[])
+{
+ pam_handle_t *pamh=NULL;
+ const char *user="nobody";
+ int retval;
+ int debug = 0;
+
+ if (argc > 1 && strcmp (argv[1], "-d") == 0)
+ debug = 1;
+
+ retval = pam_start("tst-pam_dispatch4", user, &conv, &pamh);
+ if (retval != PAM_SUCCESS)
+ {
+ if (debug)
+ fprintf (stderr, "test4: pam_start returned %d\n", retval);
+ return 1;
+ }
+
+ retval = pam_authenticate (pamh, 0);
+ if (retval != PAM_SUCCESS)
+ {
+ if (debug)
+ fprintf (stderr, "test4: pam_authenticate returned %d\n", retval);
+ return 1;
+ }
+
+ retval = pam_acct_mgmt (pamh, 0);
+ if (retval == PAM_SUCCESS)
+ {
+ if (debug)
+ fprintf (stderr, "test4: pam_authenticate returned %d\n", retval);
+ return 1;
+ }
+
+ retval = pam_end (pamh,retval);
+ if (retval != PAM_SUCCESS)
+ {
+ if (debug)
+ fprintf (stderr, "test4: pam_end returned %d\n", retval);
+ return 1;
+ }
+ return 0;
+}