File: tst-pam_mkargv.c

package info (click to toggle)
pam 1.3.1-5
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 13,084 kB
  • sloc: ansic: 31,022; xml: 21,835; sh: 12,645; makefile: 1,606; perl: 904; yacc: 408; lex: 72; sed: 16
file content (54 lines) | stat: -rw-r--r-- 1,160 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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;
}