1 /* $NetBSD: nslcd.h,v 1.1.1.1 2010/12/12 15:19:12 adam Exp $ */ 2 3 /* 4 nslcd.h - file describing client/server protocol 5 6 Copyright (C) 2006 West Consulting 7 Copyright (C) 2006, 2007, 2009, 2010 Arthur de Jong 8 9 This library is free software; you can redistribute it and/or 10 modify it under the terms of the GNU Lesser General Public 11 License as published by the Free Software Foundation; either 12 version 2.1 of the License, or (at your option) any later version. 13 14 This library is distributed in the hope that it will be useful, 15 but WITHOUT ANY WARRANTY; without even the implied warranty of 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 Lesser General Public License for more details. 18 19 You should have received a copy of the GNU Lesser General Public 20 License along with this library; if not, write to the Free Software 21 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 22 02110-1301 USA 23 */ 24 25 #ifndef _NSLCD_H 26 #define _NSLCD_H 1 27 28 /* 29 The protocol used between the nslcd client and server is a simple binary 30 protocol. It is request/response based where the client initiates a 31 connection, does a single request and closes the connection again. Any 32 mangled or not understood messages will be silently ignored by the server. 33 34 A request looks like: 35 INT32 NSLCD_VERSION 36 INT32 NSLCD_ACTION_* 37 [request parameters if any] 38 A response looks like: 39 INT32 NSLCD_VERSION 40 INT32 NSLCD_ACTION_* (the original request type) 41 [result(s)] 42 INT32 NSLCD_RESULT_END 43 A single result entry looks like: 44 INT32 NSLCD_RESULT_BEGIN 45 [result value(s)] 46 If a response would return multiple values (e.g. for NSLCD_ACTION_*_ALL 47 functions) each return value will be preceded by a NSLCD_RESULT_BEGIN 48 value. After the last returned result the server sends 49 NSLCD_RESULT_END. If some error occurs (e.g. LDAP server unavailable, 50 error in the request, etc) the server terminates the connection to signal 51 an error condition (breaking the protocol). 52 53 These are the available basic data types: 54 INT32 - 32-bit integer value 55 TYPE - a typed field that is transferred using sizeof() 56 STRING - a string length (32bit) followed by the string value (not 57 null-terminted) the string itself is assumed to be UTF-8 58 STRINGLIST - a 32-bit number noting the number of strings followed by 59 the strings one at a time 60 61 Furthermore the ADDRESS compound data type is defined as: 62 INT32 type of address: e.g. AF_INET or AF_INET6 63 INT32 lenght of address 64 RAW the address itself in network byte order 65 With the ADDRESSLIST using the same construct as with STRINGLIST. 66 67 The protocol uses host-byte order for all types (except in the raw 68 address above). 69 */ 70 71 /* The current version of the protocol. Note that version 1 72 is experimental and this version will be used until a 73 1.0 release of nss-pam-ldapd is made. */ 74 #define NSLCD_VERSION 1 75 76 /* Email alias (/etc/aliases) NSS requests. The result values for a 77 single entry are: 78 STRING alias name 79 STRINGLIST alias rcpts */ 80 #define NSLCD_ACTION_ALIAS_BYNAME 4001 81 #define NSLCD_ACTION_ALIAS_ALL 4002 82 83 /* Ethernet address/name mapping NSS requests. The result values for a 84 single entry are: 85 STRING ether name 86 TYPE(uint8_t[6]) ether address */ 87 #define NSLCD_ACTION_ETHER_BYNAME 3001 88 #define NSLCD_ACTION_ETHER_BYETHER 3002 89 #define NSLCD_ACTION_ETHER_ALL 3005 90 91 /* Group and group membership related NSS requests. The result values 92 for a single entry are: 93 STRING group name 94 STRING group password 95 TYPE(gid_t) group id 96 STRINGLIST members (usernames) of the group 97 (not that the BYMEMER call returns an emtpy members list) */ 98 #define NSLCD_ACTION_GROUP_BYNAME 5001 99 #define NSLCD_ACTION_GROUP_BYGID 5002 100 #define NSLCD_ACTION_GROUP_BYMEMBER 5003 101 #define NSLCD_ACTION_GROUP_ALL 5004 102 103 /* Hostname (/etc/hosts) lookup NSS requests. The result values 104 for an entry are: 105 STRING host name 106 STRINGLIST host aliases 107 ADDRESSLIST host addresses */ 108 #define NSLCD_ACTION_HOST_BYNAME 6001 109 #define NSLCD_ACTION_HOST_BYADDR 6002 110 #define NSLCD_ACTION_HOST_ALL 6005 111 112 /* Netgroup NSS request return a number of results. Result values 113 can be either a reference to another netgroup: 114 INT32 NSLCD_NETGROUP_TYPE_NETGROUP 115 STRING other netgroup name 116 or a netgroup triple: 117 INT32 NSLCD_NETGROUP_TYPE_TRIPLE 118 STRING host 119 STRING user 120 STRING domain */ 121 #define NSLCD_ACTION_NETGROUP_BYNAME 12001 122 #define NSLCD_NETGROUP_TYPE_NETGROUP 123 123 #define NSLCD_NETGROUP_TYPE_TRIPLE 456 124 125 /* Network name (/etc/networks) NSS requests. Result values for a single 126 entry are: 127 STRING network name 128 STRINGLIST network aliases 129 ADDRESSLIST network addresses */ 130 #define NSLCD_ACTION_NETWORK_BYNAME 8001 131 #define NSLCD_ACTION_NETWORK_BYADDR 8002 132 #define NSLCD_ACTION_NETWORK_ALL 8005 133 134 /* User account (/etc/passwd) NSS requests. Result values are: 135 STRING user name 136 STRING user password 137 TYPE(uid_t) user id 138 TYPE(gid_t) group id 139 STRING gecos information 140 STRING home directory 141 STRING login shell */ 142 #define NSLCD_ACTION_PASSWD_BYNAME 1001 143 #define NSLCD_ACTION_PASSWD_BYUID 1002 144 #define NSLCD_ACTION_PASSWD_ALL 1004 145 146 /* Protocol information requests. Result values are: 147 STRING protocol name 148 STRINGLIST protocol aliases 149 INT32 protocol number */ 150 #define NSLCD_ACTION_PROTOCOL_BYNAME 9001 151 #define NSLCD_ACTION_PROTOCOL_BYNUMBER 9002 152 #define NSLCD_ACTION_PROTOCOL_ALL 9003 153 154 /* RPC information requests. Result values are: 155 STRING rpc name 156 STRINGLIST rpc aliases 157 INT32 rpc number */ 158 #define NSLCD_ACTION_RPC_BYNAME 10001 159 #define NSLCD_ACTION_RPC_BYNUMBER 10002 160 #define NSLCD_ACTION_RPC_ALL 10003 161 162 /* Service (/etc/services) information requests. Result values are: 163 STRING service name 164 STRINGLIST service aliases 165 INT32 service (port) number 166 STRING service protocol */ 167 #define NSLCD_ACTION_SERVICE_BYNAME 11001 168 #define NSLCD_ACTION_SERVICE_BYNUMBER 11002 169 #define NSLCD_ACTION_SERVICE_ALL 11005 170 171 /* Extended user account (/etc/shadow) information requests. Result 172 values for a single entry are: 173 STRING user name 174 STRING user password 175 INT32 last password change 176 INT32 mindays 177 INT32 maxdays 178 INT32 warn 179 INT32 inact 180 INT32 expire 181 INT32 flag */ 182 #define NSLCD_ACTION_SHADOW_BYNAME 2001 183 #define NSLCD_ACTION_SHADOW_ALL 2005 184 185 /* PAM-related requests. The request parameters for all these requests 186 begin with: 187 STRING user name 188 STRING DN (if value is known already, otherwise empty) 189 STRING service name 190 all requests, except the SESSION requests start the result value with: 191 STRING user name (cannonical name) 192 STRING DN (can be used to speed up requests) */ 193 194 /* PAM authentication check request. The extra request values are: 195 STRING password 196 and the result value ends with: 197 INT32 authc NSLCD_PAM_* result code 198 INT32 authz NSLCD_PAM_* result code 199 STRING authorisation error message 200 If the username is empty in this request an attempt is made to 201 authenticate as the administrator (set using rootpwmoddn). The returned DN 202 is that of the administrator. */ 203 #define NSLCD_ACTION_PAM_AUTHC 20001 204 205 /* PAM authorisation check request. The extra request values are: 206 STRING ruser 207 STRING rhost 208 STRING tty 209 and the result value ends with: 210 INT32 authz NSLCD_PAM_* result code 211 STRING authorisation error message */ 212 #define NSLCD_ACTION_PAM_AUTHZ 20002 213 214 /* PAM session open and close requests. These requests have the following 215 extra request values: 216 STRING tty 217 STRING rhost 218 STRING ruser 219 INT32 session id (ignored for SESS_O) 220 and these calls only return the session ID: 221 INT32 session id 222 The SESS_C must contain the ID that is retured by SESS_O to close the 223 correct session. */ 224 #define NSLCD_ACTION_PAM_SESS_O 20003 225 #define NSLCD_ACTION_PAM_SESS_C 20004 226 227 /* PAM password modification request. This requests has the following extra 228 request values: 229 STRING old password 230 STRING new password 231 and returns there extra result values: 232 INT32 authz NSLCD_PAM_* result code 233 STRING authorisation error message 234 In this request the DN may be set to the administrator's DN. In this 235 case old password should be the administrator's password. This allows 236 the administrator to change any user's password. */ 237 #define NSLCD_ACTION_PAM_PWMOD 20005 238 239 /* Request result codes. */ 240 #define NSLCD_RESULT_BEGIN 0 241 #define NSLCD_RESULT_END 3 242 243 /* Partial list of PAM result codes. */ 244 #define NSLCD_PAM_SUCCESS 0 /* everything ok */ 245 #define NSLCD_PAM_PERM_DENIED 6 /* Permission denied */ 246 #define NSLCD_PAM_AUTH_ERR 7 /* Authc failure */ 247 #define NSLCD_PAM_CRED_INSUFFICIENT 8 /* Cannot access authc data */ 248 #define NSLCD_PAM_AUTHINFO_UNAVAIL 9 /* Cannot retrieve authc info */ 249 #define NSLCD_PAM_USER_UNKNOWN 10 /* User not known */ 250 #define NSLCD_PAM_MAXTRIES 11 /* Retry limit reached */ 251 #define NSLCD_PAM_NEW_AUTHTOK_REQD 12 /* Password expired */ 252 #define NSLCD_PAM_ACCT_EXPIRED 13 /* Account expired */ 253 #define NSLCD_PAM_SESSION_ERR 14 /* Cannot make/remove session record */ 254 #define NSLCD_PAM_AUTHTOK_DISABLE_AGING 23 /* Password aging disabled */ 255 #define NSLCD_PAM_IGNORE 25 /* Ignore module */ 256 #define NSLCD_PAM_ABORT 26 /* Fatal error */ 257 258 #endif /* not _NSLCD_H */ 259