tst-pam_mkargv.c 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*
  2. Copyright (C) Thorsten Kukuk <kukuk@suse.de> 2009
  3. This program is free software; you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation in version 2 of the License.
  6. */
  7. #ifdef HAVE_CONFIG_H
  8. # include <config.h>
  9. #endif
  10. #include <stdio.h>
  11. #include <string.h>
  12. #include "pam_misc.c"
  13. /* Simple program to see if _pam_mkargv() would succeed. */
  14. int main(void)
  15. {
  16. static const char argvstring[] = "user = XENDT\\userα user=XENDT\\user1";
  17. static const char * const argvresult[] = {"user", "=", "XENDT\\userα",
  18. "user=XENDT\\user1"};
  19. int myargc;
  20. char **myargv;
  21. int argvlen;
  22. int explen;
  23. int i;
  24. explen = sizeof(argvstring) * ((sizeof(char)) + sizeof(char *));
  25. argvlen = _pam_mkargv(argvstring, &myargv, &myargc);
  26. #if 0
  27. printf ("argvlen=%i, argc=%i", argvlen, myargc);
  28. for (i = 0; i < myargc; i++) {
  29. printf(", argv[%d]=%s", i, myargv[i]);
  30. }
  31. printf ("\n");
  32. #endif
  33. if (argvlen != explen)
  34. return 1;
  35. if (myargc != 4)
  36. return 1;
  37. for (i = 0; i < 4; i++)
  38. {
  39. if (strcmp (myargv[i], argvresult[i]) != 0)
  40. return 1;
  41. }
  42. return 0;
  43. }