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