summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbeber <beber>2006-01-12 02:55:23 +0000
committerbeber <beber>2006-01-12 02:55:23 +0000
commit4ff461451d280dfd29c87ad6d7558fb152290a91 (patch)
tree1159057dba3af26292da4de9b90397c9220681f0
parent(no commit message) (diff)
downloadelock-master.tar.gz
Add missing file for git-importHEADmaster
-rw-r--r--epam.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/epam.c b/epam.c
new file mode 100644
index 0000000..6bc40ab
--- /dev/null
+++ b/epam.c
@@ -0,0 +1,54 @@
+/* gcc -o epam -lpam -lpam_misc epam.c -g */
+
+#include <security/pam_appl.h>
+#include <security/pam_misc.h>
+#include <stdio.h>
+
+static struct pam_conv conv = {
+ misc_conv,
+ NULL
+};
+
+int main (int argc, char *argv[])
+{
+ pam_handle_t *pamh = NULL;
+ int retval;
+ const char *user = "nobody";
+
+ if (argc == 2)
+ user = argv[1];
+
+ if (argc > 2)
+ {
+ fprintf (stderr, "Usage: check_user [username]\n");
+ exit (1);
+ }
+
+ retval = pam_start ("elock", user, &conv, &pamh);
+
+ printf (":%s\n", pam_strerror (pamh, retval));
+
+ if (retval == PAM_SUCCESS)
+ retval = pam_authenticate (pamh, 0);
+ printf (":%s\n", pam_strerror (pamh, retval));
+
+ if (retval == PAM_SUCCESS)
+ retval = pam_acct_mgmt (pamh, 0);
+ printf (":%s\n", pam_strerror (pamh, retval));
+
+ if (retval == PAM_SUCCESS)
+ fprintf (stdout, "Authenticated\n");
+ else
+ fprintf (stdout, "Not Authenticated\n");
+ printf (":%s\n", pam_strerror (pamh, retval));
+
+ if (pam_end (pamh, retval) != PAM_SUCCESS)
+ {
+ pamh = NULL;
+ fprintf (stderr, "check_user: failed to release authenticator\n");
+ exit (1);
+ }
+ printf (":%s\n", pam_strerror (pamh, retval));
+
+ return (retval == PAM_SUCCESS ? 0 : 1);
+}