r17509: same for old woody packaging stuff
[Samba.git] / source / nsswitch / winbindd_nss.h
blob4a95a3cf42c015cea5c720dfcb541ca0a9999205
1 /*
2 Unix SMB/CIFS implementation.
4 Winbind daemon for ntdom nss module
6 Copyright (C) Tim Potter 2000
7 Copyright (C) Gerald Carter 2006
9 You are free to use this interface definition in any way you see
10 fit, including without restriction, using this header in your own
11 products. You do not need to give any attribution.
15 #ifndef CONST_DISCARD
16 #define CONST_DISCARD(type, ptr) ((type) ((void *) (ptr)))
17 #endif
19 #ifndef CONST_ADD
20 #define CONST_ADD(type, ptr) ((type) ((const void *) (ptr)))
21 #endif
23 #ifndef SAFE_FREE
24 #define SAFE_FREE(x) do { if(x) {free(x); x=NULL;} } while(0)
25 #endif
27 #ifndef _WINBINDD_NTDOM_H
28 #define _WINBINDD_NTDOM_H
30 #define WINBINDD_SOCKET_NAME "pipe" /* Name of PF_UNIX socket */
31 #define WINBINDD_SOCKET_DIR "/tmp/.winbindd" /* Name of PF_UNIX dir */
32 #define WINBINDD_PRIV_SOCKET_SUBDIR "winbindd_privileged" /* name of subdirectory of lp_lockdir() to hold the 'privileged' pipe */
33 #define WINBINDD_DOMAIN_ENV "WINBINDD_DOMAIN" /* Environment variables */
34 #define WINBINDD_DONT_ENV "_NO_WINBINDD"
36 /* Update this when you change the interface. */
38 #define WINBIND_INTERFACE_VERSION 16
40 /* Have to deal with time_t being 4 or 8 bytes due to structure alignment.
41 On a 64bit Linux box, we have to support a constant structure size
42 between /lib/libnss_winbind.so.2 and /li64/libnss_winbind.so.2.
43 The easiest way to do this is to always use 8byte values for time_t. */
45 #if defined(uint64)
46 # define SMB_TIME_T uint64
47 #else
48 # define SMB_TIME_T time_t
49 #endif
51 /* Socket commands */
53 enum winbindd_cmd {
55 WINBINDD_INTERFACE_VERSION, /* Always a well known value */
57 /* Get users and groups */
59 WINBINDD_GETPWNAM,
60 WINBINDD_GETPWUID,
61 WINBINDD_GETGRNAM,
62 WINBINDD_GETGRGID,
63 WINBINDD_GETGROUPS,
65 /* Enumerate users and groups */
67 WINBINDD_SETPWENT,
68 WINBINDD_ENDPWENT,
69 WINBINDD_GETPWENT,
70 WINBINDD_SETGRENT,
71 WINBINDD_ENDGRENT,
72 WINBINDD_GETGRENT,
74 /* PAM authenticate and password change */
76 WINBINDD_PAM_AUTH,
77 WINBINDD_PAM_AUTH_CRAP,
78 WINBINDD_PAM_CHAUTHTOK,
79 WINBINDD_PAM_LOGOFF,
80 WINBINDD_PAM_CHNG_PSWD_AUTH_CRAP,
82 /* List various things */
84 WINBINDD_LIST_USERS, /* List w/o rid->id mapping */
85 WINBINDD_LIST_GROUPS, /* Ditto */
86 WINBINDD_LIST_TRUSTDOM,
88 /* SID conversion */
90 WINBINDD_LOOKUPSID,
91 WINBINDD_LOOKUPNAME,
92 WINBINDD_LOOKUPRIDS,
94 /* Lookup functions */
96 WINBINDD_SID_TO_UID,
97 WINBINDD_SID_TO_GID,
98 WINBINDD_UID_TO_SID,
99 WINBINDD_GID_TO_SID,
101 WINBINDD_ALLOCATE_UID,
102 WINBINDD_ALLOCATE_GID,
104 /* Miscellaneous other stuff */
106 WINBINDD_CHECK_MACHACC, /* Check machine account pw works */
107 WINBINDD_PING, /* Just tell me winbind is running */
108 WINBINDD_INFO, /* Various bit of info. Currently just tidbits */
109 WINBINDD_DOMAIN_NAME, /* The domain this winbind server is a member of (lp_workgroup()) */
111 WINBINDD_DOMAIN_INFO, /* Most of what we know from
112 struct winbindd_domain */
113 WINBINDD_GETDCNAME, /* Issue a GetDCName Request */
115 WINBINDD_SHOW_SEQUENCE, /* display sequence numbers of domains */
117 /* WINS commands */
119 WINBINDD_WINS_BYIP,
120 WINBINDD_WINS_BYNAME,
122 /* this is like GETGRENT but gives an empty group list */
123 WINBINDD_GETGRLST,
125 WINBINDD_NETBIOS_NAME, /* The netbios name of the server */
127 /* find the location of our privileged pipe */
128 WINBINDD_PRIV_PIPE_DIR,
130 /* return a list of group sids for a user sid */
131 WINBINDD_GETUSERSIDS,
133 /* Various group queries */
134 WINBINDD_GETUSERDOMGROUPS,
136 /* Initialize connection in a child */
137 WINBINDD_INIT_CONNECTION,
139 /* Blocking calls that are not allowed on the main winbind pipe, only
140 * between parent and children */
141 WINBINDD_DUAL_SID2UID,
142 WINBINDD_DUAL_SID2GID,
143 WINBINDD_DUAL_UID2SID,
144 WINBINDD_DUAL_GID2SID,
145 WINBINDD_DUAL_IDMAPSET,
147 /* Wrapper around possibly blocking unix nss calls */
148 WINBINDD_DUAL_UID2NAME,
149 WINBINDD_DUAL_NAME2UID,
150 WINBINDD_DUAL_GID2NAME,
151 WINBINDD_DUAL_NAME2GID,
153 WINBINDD_DUAL_USERINFO,
154 WINBINDD_DUAL_GETSIDALIASES,
156 WINBINDD_NUM_CMDS
159 typedef struct winbindd_pw {
160 fstring pw_name;
161 fstring pw_passwd;
162 uid_t pw_uid;
163 gid_t pw_gid;
164 fstring pw_gecos;
165 fstring pw_dir;
166 fstring pw_shell;
167 } WINBINDD_PW;
170 typedef struct winbindd_gr {
171 fstring gr_name;
172 fstring gr_passwd;
173 gid_t gr_gid;
174 uint32 num_gr_mem;
175 uint32 gr_mem_ofs; /* offset to group membership */
176 } WINBINDD_GR;
179 #define WBFLAG_PAM_INFO3_NDR 0x0001
180 #define WBFLAG_PAM_INFO3_TEXT 0x0002
181 #define WBFLAG_PAM_USER_SESSION_KEY 0x0004
182 #define WBFLAG_PAM_LMKEY 0x0008
183 #define WBFLAG_PAM_CONTACT_TRUSTDOM 0x0010
184 #define WBFLAG_QUERY_ONLY 0x0020
185 #define WBFLAG_PAM_UNIX_NAME 0x0080
186 #define WBFLAG_PAM_AFS_TOKEN 0x0100
187 #define WBFLAG_PAM_NT_STATUS_SQUASH 0x0200
189 /* This is a flag that can only be sent from parent to child */
190 #define WBFLAG_IS_PRIVILEGED 0x0400
191 /* Flag to say this is a winbindd internal send - don't recurse. */
192 #define WBFLAG_RECURSE 0x0800
194 #define WBFLAG_PAM_KRB5 0x1000
195 #define WBFLAG_PAM_FALLBACK_AFTER_KRB5 0x2000
196 #define WBFLAG_PAM_CACHED_LOGIN 0x4000
197 #define WBFLAG_PAM_GET_PWD_POLICY 0x8000
199 #define WINBINDD_MAX_EXTRA_DATA (128*1024)
201 /* Winbind request structure */
203 /*******************************************************************************
204 * This structure MUST be the same size in the 32bit and 64bit builds
205 * for compatibility between /lib64/libnss_winbind.so and /lib/libnss_winbind.so
207 * DO NOT CHANGE THIS STRUCTURE WITHOUT TESTING THE 32BIT NSS LIB AGAINST
208 * A 64BIT WINBINDD --jerry
209 ******************************************************************************/
211 struct winbindd_request {
212 uint32 length;
213 enum winbindd_cmd cmd; /* Winbindd command to execute */
214 pid_t pid; /* pid of calling process */
215 uint32 flags; /* flags relavant to a given request */
216 fstring domain_name; /* name of domain for which the request applies */
218 union {
219 fstring winsreq; /* WINS request */
220 fstring username; /* getpwnam */
221 fstring groupname; /* getgrnam */
222 uid_t uid; /* getpwuid, uid_to_sid */
223 gid_t gid; /* getgrgid, gid_to_sid */
224 struct {
225 /* We deliberatedly don't split into domain/user to
226 avoid having the client know what the separator
227 character is. */
228 fstring user;
229 fstring pass;
230 fstring require_membership_of_sid;
231 fstring krb5_cc_type;
232 uid_t uid;
233 } auth; /* pam_winbind auth module */
234 struct {
235 unsigned char chal[8];
236 uint32 logon_parameters;
237 fstring user;
238 fstring domain;
239 fstring lm_resp;
240 uint32 lm_resp_len;
241 fstring nt_resp;
242 uint32 nt_resp_len;
243 fstring workstation;
244 fstring require_membership_of_sid;
245 } auth_crap;
246 struct {
247 fstring user;
248 fstring oldpass;
249 fstring newpass;
250 } chauthtok; /* pam_winbind passwd module */
251 struct {
252 fstring user;
253 fstring domain;
254 unsigned char new_nt_pswd[516];
255 uint16 new_nt_pswd_len;
256 unsigned char old_nt_hash_enc[16];
257 uint16 old_nt_hash_enc_len;
258 unsigned char new_lm_pswd[516];
259 uint16 new_lm_pswd_len;
260 unsigned char old_lm_hash_enc[16];
261 uint16 old_lm_hash_enc_len;
262 } chng_pswd_auth_crap;/* pam_winbind passwd module */
263 struct {
264 fstring user;
265 fstring krb5ccname;
266 uid_t uid;
267 } logoff; /* pam_winbind session module */
268 fstring sid; /* lookupsid, sid_to_[ug]id */
269 struct {
270 fstring dom_name; /* lookupname */
271 fstring name;
272 } name;
273 uint32 num_entries; /* getpwent, getgrent */
274 struct {
275 fstring username;
276 fstring groupname;
277 } acct_mgt;
278 struct {
279 BOOL is_primary;
280 fstring dcname;
281 } init_conn;
282 struct {
283 fstring sid;
284 fstring name;
285 BOOL alloc;
286 } dual_sid2id;
287 struct {
288 int type;
289 uid_t uid;
290 gid_t gid;
291 fstring sid;
292 } dual_idmapset;
293 BOOL list_all_domains;
295 /* padding -- needed to fix alignment between 32bit and 64bit libs.
296 The size if the sizeof the union without the padding aligned on
297 an 8 byte boundary. --jerry */
299 char padding[1560];
300 } data;
301 union {
302 SMB_TIME_T padding;
303 char *data;
304 } extra_data;
305 uint32 extra_len;
306 char null_term;
309 /* Response values */
311 enum winbindd_result {
312 WINBINDD_ERROR,
313 WINBINDD_PENDING,
314 WINBINDD_OK
317 /* Winbind response structure */
319 /*******************************************************************************
320 * This structure MUST be the same size in the 32bit and 64bit builds
321 * for compatibility between /lib64/libnss_winbind.so and /lib/libnss_winbind.so
323 * DO NOT CHANGE THIS STRUCTURE WITHOUT TESTING THE 32BIT NSS LIB AGAINST
324 * A 64BIT WINBINDD --jerry
325 ******************************************************************************/
327 struct winbindd_response {
329 /* Header information */
331 uint32 length; /* Length of response */
332 enum winbindd_result result; /* Result code */
334 /* Fixed length return data */
336 union {
337 int interface_version; /* Try to ensure this is always in the same spot... */
339 fstring winsresp; /* WINS response */
341 /* getpwnam, getpwuid */
343 struct winbindd_pw pw;
345 /* getgrnam, getgrgid */
347 struct winbindd_gr gr;
349 uint32 num_entries; /* getpwent, getgrent */
350 struct winbindd_sid {
351 fstring sid; /* lookupname, [ug]id_to_sid */
352 int type;
353 } sid;
354 struct winbindd_name {
355 fstring dom_name; /* lookupsid */
356 fstring name;
357 int type;
358 } name;
359 uid_t uid; /* sid_to_uid */
360 gid_t gid; /* sid_to_gid */
361 struct winbindd_info {
362 char winbind_separator;
363 fstring samba_version;
364 } info;
365 fstring domain_name;
366 fstring netbios_name;
367 fstring dc_name;
369 struct auth_reply {
370 uint32 nt_status;
371 fstring nt_status_string;
372 fstring error_string;
373 int pam_error;
374 char user_session_key[16];
375 char first_8_lm_hash[8];
376 fstring krb5ccname;
377 uint32 reject_reason;
378 uint32 padding;
379 struct policy_settings {
380 uint32 min_length_password;
381 uint32 password_history;
382 uint32 password_properties;
383 uint32 padding;
384 SMB_TIME_T expire;
385 SMB_TIME_T min_passwordage;
386 } policy;
387 struct info3_text {
388 SMB_TIME_T logon_time;
389 SMB_TIME_T logoff_time;
390 SMB_TIME_T kickoff_time;
391 SMB_TIME_T pass_last_set_time;
392 SMB_TIME_T pass_can_change_time;
393 SMB_TIME_T pass_must_change_time;
394 uint32 logon_count;
395 uint32 bad_pw_count;
396 uint32 user_rid;
397 uint32 group_rid;
398 uint32 num_groups;
399 uint32 user_flgs;
400 uint32 acct_flags;
401 uint32 num_other_sids;
402 fstring dom_sid;
403 fstring user_name;
404 fstring full_name;
405 fstring logon_script;
406 fstring profile_path;
407 fstring home_dir;
408 fstring dir_drive;
409 fstring logon_srv;
410 fstring logon_dom;
411 } info3;
412 } auth;
413 struct {
414 fstring name;
415 fstring alt_name;
416 fstring sid;
417 BOOL native_mode;
418 BOOL active_directory;
419 BOOL primary;
420 uint32 sequence_number;
421 } domain_info;
422 struct {
423 fstring acct_name;
424 fstring full_name;
425 fstring homedir;
426 fstring shell;
427 uint32 group_rid;
428 } user_info;
429 } data;
431 /* Variable length return data */
433 union {
434 SMB_TIME_T padding;
435 void *data;
436 } extra_data;
439 struct WINBINDD_CCACHE_ENTRY {
440 const char *principal_name;
441 const char *ccname;
442 const char *service;
443 const char *username;
444 const char *sid_string;
445 char *pass;
446 uid_t uid;
447 time_t create_time;
448 time_t renew_until;
449 BOOL refresh_tgt;
450 time_t refresh_time;
451 struct timed_event *event;
452 struct WINBINDD_CCACHE_ENTRY *next, *prev;
455 #endif