1 /* $OpenBSD: npppd_auth_local.h,v 1.9 2024/02/26 10:42:05 yasuoka Exp $ */ 2 3 /*- 4 * Copyright (c) 2009 Internet Initiative Japan Inc. 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 * SUCH DAMAGE. 27 */ 28 29 struct _npppd_auth_base { 30 /** name of realm */ 31 char name[NPPPD_GENERIC_NAME_LEN]; 32 /** reference indicated to parent npppd */ 33 npppd *npppd; 34 /** type of authentication realm */ 35 int type; 36 /** PPP suffix */ 37 char pppsuffix[64]; 38 uint32_t 39 /** whether initialized or not */ 40 initialized:1, 41 /** in disposing */ 42 disposing:1, 43 /** Is the radius configuration ready */ 44 radius_ready:1, 45 /** whether EAP capable or not */ 46 eap_capable:1, 47 /** whether force to strip Windows-NT domain or not */ 48 strip_nt_domain:1, 49 /** whether force to strip after the '@' of PPP username or not */ 50 strip_atmark_realm:1, 51 /** has users list */ 52 has_users_file:1, 53 reserved:25; 54 55 /** path name of account list */ 56 char users_file_path[64]; 57 /** last load time */ 58 time_t last_load; 59 /**counter of sessions from this auth */ 60 int user_max_session; 61 }; 62 63 #ifdef USE_NPPPD_RADIUS 64 struct _npppd_auth_radius { 65 /** parent of npppd_auth_base */ 66 npppd_auth_base nar_base; 67 68 /** RADIUS authentication server setting */ 69 radius_req_setting *rad_auth_setting; 70 71 /** RADIUS accounting server setting */ 72 radius_req_setting *rad_acct_setting; 73 74 /** Whether RADIUS accounting-on is noticed */ 75 int rad_acct_on; 76 }; 77 #endif 78 79 /** type of local authentication realm */ 80 struct _npppd_auth_local { 81 /* parent npppd_auth_base */ 82 npppd_auth_base nal_base; 83 }; 84 85 static npppd_auth_user *npppd_auth_get_user (npppd_auth_base *, const char *); 86 static int npppd_auth_base_log (npppd_auth_base *, int, const char *, ...); 87 88 #ifdef USE_NPPPD_RADIUS 89 enum RADIUS_SERVER_TYPE { 90 RADIUS_SERVER_TYPE_AUTH, 91 RADIUS_SERVER_TYPE_ACCT 92 }; 93 94 static int npppd_auth_radius_reload (npppd_auth_base *, struct authconf *); 95 #endif 96 97 #ifdef NPPPD_AUTH_DEBUG 98 #define NPPPD_AUTH_DBG(x) npppd_auth_base_log x 99 #define NPPPD_AUTH_ASSERT(x) ASSERT(x) 100 #else 101 #define NPPPD_AUTH_DBG(x) 102 #define NPPPD_AUTH_ASSERT(x) 103 #endif 104 105 #define DEFAULT_RADIUS_AUTH_PORT 1812 106 #define DEFAULT_RADIUS_ACCT_PORT 1813 107 #define DEFAULT_RADIUS_TIMEOUT 9 108 #define DEFAULT_RADIUS_MAX_TRIES 3 109 #define DEFAULT_RADIUS_MAX_FAILOVERS 1 110 111