diff options
author | Steve Langasek <vorlon@debian.org> | 2009-08-24 03:06:11 -0700 |
---|---|---|
committer | Steve Langasek <vorlon@debian.org> | 2019-01-08 21:25:43 -0800 |
commit | 78915f5a06936cc24cf7776c8b53d08b6ea3616c (patch) | |
tree | 6325216d4660f2a33d2161d71302b8c3f47c76e5 /tests/tst-pam_mkargv.c | |
parent | fdd6439782a15a1abe342044e07e5f7501ae73de (diff) | |
parent | 212b52cf29c06cc209bc8ac0540dbab1acdf1464 (diff) | |
download | pam-78915f5a06936cc24cf7776c8b53d08b6ea3616c.tar.gz pam-78915f5a06936cc24cf7776c8b53d08b6ea3616c.tar.bz2 pam-78915f5a06936cc24cf7776c8b53d08b6ea3616c.zip |
merge upstream version 1.1.0
Diffstat (limited to 'tests/tst-pam_mkargv.c')
-rw-r--r-- | tests/tst-pam_mkargv.c | 54 |
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 00000000..d3e7a616 --- /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) +{ + char *argvstring = "user = XENDT\\userα user=XENDT\\user1"; + const char *argvresult[] = {"user", "=", "XENDT\\userα", + "user=XENDT\\user1"}; + int myargc; + char **myargv; + int argvlen; + int explen; + int i; + + explen = (strlen(argvstring) + 1) * ((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; +} |