1
0
Fork 0
pam/tests/tst-pam_mkargv.c
Daniel Baumann 82f0236850
Adding upstream version 1.7.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
2025-06-21 06:53:43 +02:00

54 lines
1.2 KiB
C
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
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.
*/
#include <config.h>
#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;
}
free(myargv);
return 0;
}