summaryrefslogtreecommitdiffstats
path: root/tests/tst-pam_mkargv.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 14:22:51 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 14:22:51 +0000
commit9ada0093e92388590c7368600ca4e9e3e376f0d0 (patch)
treea56fe41110023676d7082028cbaa47ca4b6e6164 /tests/tst-pam_mkargv.c
parentInitial commit. (diff)
downloadpam-9ada0093e92388590c7368600ca4e9e3e376f0d0.tar.xz
pam-9ada0093e92388590c7368600ca4e9e3e376f0d0.zip
Adding upstream version 1.5.2.upstream/1.5.2upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--tests/tst-pam_mkargv.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/tests/tst-pam_mkargv.c b/tests/tst-pam_mkargv.c
new file mode 100644
index 0000000..cb005e5
--- /dev/null
+++ b/tests/tst-pam_mkargv.c
@@ -0,0 +1,54 @@
+/*
+ Copyright (C) Thorsten Kukuk <kukuk@suse.de> 2009
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation in version 2 of the License.
+*/
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <stdio.h>
+#include <string.h>
+
+#include "pam_misc.c"
+
+/* Simple program to see if _pam_mkargv() would succeed. */
+int main(void)
+{
+ static const char argvstring[] = "user = XENDT\\userĪ± user=XENDT\\user1";
+ static const char * const argvresult[] = {"user", "=", "XENDT\\userĪ±",
+ "user=XENDT\\user1"};
+ int myargc;
+ char **myargv;
+ int argvlen;
+ int explen;
+ int i;
+
+ explen = sizeof(argvstring) * ((sizeof(char)) + sizeof(char *));
+ argvlen = _pam_mkargv(argvstring, &myargv, &myargc);
+
+#if 0
+ printf ("argvlen=%i, argc=%i", argvlen, myargc);
+ for (i = 0; i < myargc; i++) {
+ printf(", argv[%d]=%s", i, myargv[i]);
+ }
+ printf ("\n");
+#endif
+
+ if (argvlen != explen)
+ return 1;
+
+ if (myargc != 4)
+ return 1;
+
+ for (i = 0; i < 4; i++)
+ {
+ if (strcmp (myargv[i], argvresult[i]) != 0)
+ return 1;
+ }
+
+ return 0;
+}