1*77513ecfSchristos /*-
2*77513ecfSchristos * Copyright (c) 2019 Dag-Erling Smørgrav
3*77513ecfSchristos * All rights reserved.
4*77513ecfSchristos *
5*77513ecfSchristos * Redistribution and use in source and binary forms, with or without
6*77513ecfSchristos * modification, are permitted provided that the following conditions
7*77513ecfSchristos * are met:
8*77513ecfSchristos * 1. Redistributions of source code must retain the above copyright
9*77513ecfSchristos * notice, this list of conditions and the following disclaimer.
10*77513ecfSchristos * 2. Redistributions in binary form must reproduce the above copyright
11*77513ecfSchristos * notice, this list of conditions and the following disclaimer in the
12*77513ecfSchristos * documentation and/or other materials provided with the distribution.
13*77513ecfSchristos * 3. The name of the author may not be used to endorse or promote
14*77513ecfSchristos * products derived from this software without specific prior written
15*77513ecfSchristos * permission.
16*77513ecfSchristos *
17*77513ecfSchristos * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18*77513ecfSchristos * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19*77513ecfSchristos * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20*77513ecfSchristos * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21*77513ecfSchristos * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22*77513ecfSchristos * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23*77513ecfSchristos * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24*77513ecfSchristos * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25*77513ecfSchristos * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26*77513ecfSchristos * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27*77513ecfSchristos * SUCH DAMAGE.
28*77513ecfSchristos */
29*77513ecfSchristos
30*77513ecfSchristos #ifdef HAVE_CONFIG_H
31*77513ecfSchristos # include "config.h"
32*77513ecfSchristos #endif
33*77513ecfSchristos
34*77513ecfSchristos #include <stdint.h>
35*77513ecfSchristos #include <unistd.h>
36*77513ecfSchristos
37*77513ecfSchristos #include <cryb/test.h>
38*77513ecfSchristos
39*77513ecfSchristos #include <security/pam_appl.h>
40*77513ecfSchristos #include <security/openpam.h>
41*77513ecfSchristos
42*77513ecfSchristos #include "openpam_impl.h"
43*77513ecfSchristos
44*77513ecfSchristos #include "t_pam_err.h"
45*77513ecfSchristos
46*77513ecfSchristos int
t_compare_pam_err(int expected,int received)47*77513ecfSchristos t_compare_pam_err(int expected, int received)
48*77513ecfSchristos {
49*77513ecfSchristos
50*77513ecfSchristos if (expected == received)
51*77513ecfSchristos return (1);
52*77513ecfSchristos if (expected >= 0 && expected < PAM_NUM_ERRORS)
53*77513ecfSchristos t_printv("expected %s, ", pam_err_name[expected]);
54*77513ecfSchristos else
55*77513ecfSchristos t_printv("expected %d, ", expected);
56*77513ecfSchristos if (received >= 0 && received < PAM_NUM_ERRORS)
57*77513ecfSchristos t_printv("received %s\n", pam_err_name[received]);
58*77513ecfSchristos else
59*77513ecfSchristos t_printv("received %d\n", received);
60*77513ecfSchristos return (0);
61*77513ecfSchristos }
62