Deal with c_req send errors asynchronously
[Samba/vfs_proxy.git] / source4 / nsswitch / winbind_struct_protocol.h
blob8003ea9585a08b11da17545fe51e8031cb4f9245
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.
14 #ifndef SAFE_FREE
15 #define SAFE_FREE(x) do { if(x) {free(x); x=NULL;} } while(0)
16 #endif
18 #ifndef _WINBINDD_NTDOM_H
19 #define _WINBINDD_NTDOM_H
21 #define _PSTRING
22 #define FSTRING_LEN 256
24 typedef char fstring[FSTRING_LEN];
26 #define fstrcpy(d,s) safe_strcpy((d),(s),sizeof(fstring)-1)
27 #define fstrcat(d,s) safe_strcat((d),(s),sizeof(fstring)-1)
29 #define WINBINDD_SOCKET_NAME "pipe" /* Name of PF_UNIX socket */
31 /* Let the build environment override the public winbindd socket location. This
32 * is needed for launchd support -- jpeach.
34 #ifndef WINBINDD_SOCKET_DIR
35 #define WINBINDD_SOCKET_DIR "/tmp/.winbindd" /* Name of PF_UNIX dir */
36 #endif
39 * when compiled with socket_wrapper support
40 * the location of the WINBINDD_SOCKET_DIR
41 * can be overwritten via an environment variable
43 #define WINBINDD_SOCKET_DIR_ENVVAR "WINBINDD_SOCKET_DIR"
45 #define WINBINDD_DOMAIN_ENV "WINBINDD_DOMAIN" /* Environment variables */
46 #define WINBINDD_DONT_ENV "_NO_WINBINDD"
47 #define WINBINDD_LOCATOR_KDC_ADDRESS "WINBINDD_LOCATOR_KDC_ADDRESS"
49 /* Update this when you change the interface. */
51 #define WINBIND_INTERFACE_VERSION 19
53 /* Have to deal with time_t being 4 or 8 bytes due to structure alignment.
54 On a 64bit Linux box, we have to support a constant structure size
55 between /lib/libnss_winbind.so.2 and /li64/libnss_winbind.so.2.
56 The easiest way to do this is to always use 8byte values for time_t. */
58 #define SMB_TIME_T int64_t
60 /* Socket commands */
62 enum winbindd_cmd {
64 WINBINDD_INTERFACE_VERSION, /* Always a well known value */
66 /* Get users and groups */
68 WINBINDD_GETPWNAM,
69 WINBINDD_GETPWUID,
70 WINBINDD_GETGRNAM,
71 WINBINDD_GETGRGID,
72 WINBINDD_GETGROUPS,
74 /* Enumerate users and groups */
76 WINBINDD_SETPWENT,
77 WINBINDD_ENDPWENT,
78 WINBINDD_GETPWENT,
79 WINBINDD_SETGRENT,
80 WINBINDD_ENDGRENT,
81 WINBINDD_GETGRENT,
83 /* PAM authenticate and password change */
85 WINBINDD_PAM_AUTH,
86 WINBINDD_PAM_AUTH_CRAP,
87 WINBINDD_PAM_CHAUTHTOK,
88 WINBINDD_PAM_LOGOFF,
89 WINBINDD_PAM_CHNG_PSWD_AUTH_CRAP,
91 /* List various things */
93 WINBINDD_LIST_USERS, /* List w/o rid->id mapping */
94 WINBINDD_LIST_GROUPS, /* Ditto */
95 WINBINDD_LIST_TRUSTDOM,
97 /* SID conversion */
99 WINBINDD_LOOKUPSID,
100 WINBINDD_LOOKUPNAME,
101 WINBINDD_LOOKUPRIDS,
103 /* Lookup functions */
105 WINBINDD_SID_TO_UID,
106 WINBINDD_SID_TO_GID,
107 WINBINDD_SIDS_TO_XIDS,
108 WINBINDD_UID_TO_SID,
109 WINBINDD_GID_TO_SID,
111 WINBINDD_ALLOCATE_UID,
112 WINBINDD_ALLOCATE_GID,
113 WINBINDD_SET_MAPPING,
114 WINBINDD_SET_HWM,
116 /* Miscellaneous other stuff */
118 WINBINDD_DUMP_MAPS,
120 WINBINDD_CHECK_MACHACC, /* Check machine account pw works */
121 WINBINDD_PING, /* Just tell me winbind is running */
122 WINBINDD_INFO, /* Various bit of info. Currently just tidbits */
123 WINBINDD_DOMAIN_NAME, /* The domain this winbind server is a member of (lp_workgroup()) */
125 WINBINDD_DOMAIN_INFO, /* Most of what we know from
126 struct winbindd_domain */
127 WINBINDD_GETDCNAME, /* Issue a GetDCName Request */
128 WINBINDD_DSGETDCNAME, /* Issue a DsGetDCName Request */
130 WINBINDD_SHOW_SEQUENCE, /* display sequence numbers of domains */
132 /* WINS commands */
134 WINBINDD_WINS_BYIP,
135 WINBINDD_WINS_BYNAME,
137 /* this is like GETGRENT but gives an empty group list */
138 WINBINDD_GETGRLST,
140 WINBINDD_NETBIOS_NAME, /* The netbios name of the server */
142 /* find the location of our privileged pipe */
143 WINBINDD_PRIV_PIPE_DIR,
145 /* return a list of group sids for a user sid */
146 WINBINDD_GETUSERSIDS,
148 /* Various group queries */
149 WINBINDD_GETUSERDOMGROUPS,
151 /* Initialize connection in a child */
152 WINBINDD_INIT_CONNECTION,
154 /* Blocking calls that are not allowed on the main winbind pipe, only
155 * between parent and children */
156 WINBINDD_DUAL_SID2UID,
157 WINBINDD_DUAL_SID2GID,
158 WINBINDD_DUAL_SIDS2XIDS,
159 WINBINDD_DUAL_UID2SID,
160 WINBINDD_DUAL_GID2SID,
161 WINBINDD_DUAL_SET_MAPPING,
162 WINBINDD_DUAL_SET_HWM,
163 WINBINDD_DUAL_DUMP_MAPS,
165 /* Wrapper around possibly blocking unix nss calls */
166 WINBINDD_DUAL_UID2NAME,
167 WINBINDD_DUAL_NAME2UID,
168 WINBINDD_DUAL_GID2NAME,
169 WINBINDD_DUAL_NAME2GID,
171 WINBINDD_DUAL_USERINFO,
172 WINBINDD_DUAL_GETSIDALIASES,
174 /* Complete the challenge phase of the NTLM authentication
175 protocol using cached password. */
176 WINBINDD_CCACHE_NTLMAUTH,
178 WINBINDD_NUM_CMDS
181 typedef struct winbindd_pw {
182 fstring pw_name;
183 fstring pw_passwd;
184 uid_t pw_uid;
185 gid_t pw_gid;
186 fstring pw_gecos;
187 fstring pw_dir;
188 fstring pw_shell;
189 } WINBINDD_PW;
192 typedef struct winbindd_gr {
193 fstring gr_name;
194 fstring gr_passwd;
195 gid_t gr_gid;
196 uint32_t num_gr_mem;
197 uint32_t gr_mem_ofs; /* offset to group membership */
198 } WINBINDD_GR;
200 /* PAM specific request flags */
201 #define WBFLAG_PAM_INFO3_NDR 0x00000001
202 #define WBFLAG_PAM_INFO3_TEXT 0x00000002
203 #define WBFLAG_PAM_USER_SESSION_KEY 0x00000004
204 #define WBFLAG_PAM_LMKEY 0x00000008
205 #define WBFLAG_PAM_CONTACT_TRUSTDOM 0x00000010
206 #define WBFLAG_PAM_UNIX_NAME 0x00000080
207 #define WBFLAG_PAM_AFS_TOKEN 0x00000100
208 #define WBFLAG_PAM_NT_STATUS_SQUASH 0x00000200
209 #define WBFLAG_PAM_KRB5 0x00001000
210 #define WBFLAG_PAM_FALLBACK_AFTER_KRB5 0x00002000
211 #define WBFLAG_PAM_CACHED_LOGIN 0x00004000
212 #define WBFLAG_PAM_GET_PWD_POLICY 0x00008000 /* not used */
214 /* generic request flags */
215 #define WBFLAG_QUERY_ONLY 0x00000020 /* not used */
216 /* This is a flag that can only be sent from parent to child */
217 #define WBFLAG_IS_PRIVILEGED 0x00000400 /* not used */
218 /* Flag to say this is a winbindd internal send - don't recurse. */
219 #define WBFLAG_RECURSE 0x00000800
222 #define WINBINDD_MAX_EXTRA_DATA (128*1024)
224 /* Winbind request structure */
226 /*******************************************************************************
227 * This structure MUST be the same size in the 32bit and 64bit builds
228 * for compatibility between /lib64/libnss_winbind.so and /lib/libnss_winbind.so
230 * DO NOT CHANGE THIS STRUCTURE WITHOUT TESTING THE 32BIT NSS LIB AGAINST
231 * A 64BIT WINBINDD --jerry
232 ******************************************************************************/
234 struct winbindd_request {
235 uint32_t length;
236 enum winbindd_cmd cmd; /* Winbindd command to execute */
237 enum winbindd_cmd original_cmd; /* Original Winbindd command
238 issued to parent process */
239 pid_t pid; /* pid of calling process */
240 uint32_t wb_flags; /* generic flags */
241 uint32_t flags; /* flags relevant *only* to a given request */
242 fstring domain_name; /* name of domain for which the request applies */
244 union {
245 fstring winsreq; /* WINS request */
246 fstring username; /* getpwnam */
247 fstring groupname; /* getgrnam */
248 uid_t uid; /* getpwuid, uid_to_sid */
249 gid_t gid; /* getgrgid, gid_to_sid */
250 struct {
251 /* We deliberatedly don't split into domain/user to
252 avoid having the client know what the separator
253 character is. */
254 fstring user;
255 fstring pass;
256 char require_membership_of_sid[1024];
257 fstring krb5_cc_type;
258 uid_t uid;
259 } auth; /* pam_winbind auth module */
260 struct {
261 uint8_t chal[8];
262 uint32_t logon_parameters;
263 fstring user;
264 fstring domain;
265 fstring lm_resp;
266 uint32_t lm_resp_len;
267 fstring nt_resp;
268 uint32_t nt_resp_len;
269 fstring workstation;
270 fstring require_membership_of_sid;
271 } auth_crap;
272 struct {
273 fstring user;
274 fstring oldpass;
275 fstring newpass;
276 } chauthtok; /* pam_winbind passwd module */
277 struct {
278 fstring user;
279 fstring domain;
280 uint8_t new_nt_pswd[516];
281 uint16_t new_nt_pswd_len;
282 uint8_t old_nt_hash_enc[16];
283 uint16_t old_nt_hash_enc_len;
284 uint8_t new_lm_pswd[516];
285 uint16_t new_lm_pswd_len;
286 uint8_t old_lm_hash_enc[16];
287 uint16_t old_lm_hash_enc_len;
288 } chng_pswd_auth_crap;/* pam_winbind passwd module */
289 struct {
290 fstring user;
291 fstring krb5ccname;
292 uid_t uid;
293 } logoff; /* pam_winbind session module */
294 fstring sid; /* lookupsid, sid_to_[ug]id */
295 struct {
296 fstring dom_name; /* lookupname */
297 fstring name;
298 } name;
299 uint32_t num_entries; /* getpwent, getgrent */
300 struct {
301 fstring username;
302 fstring groupname;
303 } acct_mgt;
304 struct {
305 bool is_primary;
306 fstring dcname;
307 } init_conn;
308 struct {
309 fstring sid;
310 fstring name;
311 } dual_sid2id;
312 struct {
313 fstring sid;
314 uint32_t type;
315 uint32_t id;
316 } dual_idmapset;
317 bool list_all_domains;
319 struct {
320 uid_t uid;
321 fstring user;
322 /* the effective uid of the client, must be the uid for 'user'.
323 This is checked by the main daemon, trusted by children. */
324 /* if the blobs are length zero, then this doesn't
325 produce an actual challenge response. It merely
326 succeeds if there are cached credentials available
327 that could be used. */
328 uint32_t initial_blob_len; /* blobs in extra_data */
329 uint32_t challenge_blob_len;
330 } ccache_ntlm_auth;
332 /* padding -- needed to fix alignment between 32bit and 64bit libs.
333 The size is the sizeof the union without the padding aligned on
334 an 8 byte boundary. --jerry */
336 char padding[1800];
337 } data;
338 union {
339 SMB_TIME_T padding;
340 char *data;
341 } extra_data;
342 uint32_t extra_len;
343 char null_term;
346 /* Response values */
348 enum winbindd_result {
349 WINBINDD_ERROR,
350 WINBINDD_PENDING,
351 WINBINDD_OK
354 /* Winbind response structure */
356 /*******************************************************************************
357 * This structure MUST be the same size in the 32bit and 64bit builds
358 * for compatibility between /lib64/libnss_winbind.so and /lib/libnss_winbind.so
360 * DO NOT CHANGE THIS STRUCTURE WITHOUT TESTING THE 32BIT NSS LIB AGAINST
361 * A 64BIT WINBINDD --jerry
362 ******************************************************************************/
364 struct winbindd_response {
366 /* Header information */
368 uint32_t length; /* Length of response */
369 enum winbindd_result result; /* Result code */
371 /* Fixed length return data */
373 union {
374 int interface_version; /* Try to ensure this is always in the same spot... */
376 fstring winsresp; /* WINS response */
378 /* getpwnam, getpwuid */
380 struct winbindd_pw pw;
382 /* getgrnam, getgrgid */
384 struct winbindd_gr gr;
386 uint32_t num_entries; /* getpwent, getgrent */
387 struct winbindd_sid {
388 fstring sid; /* lookupname, [ug]id_to_sid */
389 int type;
390 } sid;
391 struct winbindd_name {
392 fstring dom_name; /* lookupsid */
393 fstring name;
394 int type;
395 } name;
396 uid_t uid; /* sid_to_uid */
397 gid_t gid; /* sid_to_gid */
398 struct winbindd_info {
399 char winbind_separator;
400 fstring samba_version;
401 } info;
402 fstring domain_name;
403 fstring netbios_name;
404 fstring dc_name;
406 struct auth_reply {
407 uint32_t nt_status;
408 fstring nt_status_string;
409 fstring error_string;
410 int pam_error;
411 char user_session_key[16];
412 char first_8_lm_hash[8];
413 fstring krb5ccname;
414 uint32_t reject_reason;
415 uint32_t padding;
416 struct policy_settings {
417 uint32_t min_length_password;
418 uint32_t password_history;
419 uint32_t password_properties;
420 uint32_t padding;
421 SMB_TIME_T expire;
422 SMB_TIME_T min_passwordage;
423 } policy;
424 struct info3_text {
425 SMB_TIME_T logon_time;
426 SMB_TIME_T logoff_time;
427 SMB_TIME_T kickoff_time;
428 SMB_TIME_T pass_last_set_time;
429 SMB_TIME_T pass_can_change_time;
430 SMB_TIME_T pass_must_change_time;
431 uint32_t logon_count;
432 uint32_t bad_pw_count;
433 uint32_t user_rid;
434 uint32_t group_rid;
435 uint32_t num_groups;
436 uint32_t user_flgs;
437 uint32_t acct_flags;
438 uint32_t num_other_sids;
439 fstring dom_sid;
440 fstring user_name;
441 fstring full_name;
442 fstring logon_script;
443 fstring profile_path;
444 fstring home_dir;
445 fstring dir_drive;
446 fstring logon_srv;
447 fstring logon_dom;
448 } info3;
449 } auth;
450 struct {
451 fstring name;
452 fstring alt_name;
453 fstring sid;
454 bool native_mode;
455 bool active_directory;
456 bool primary;
457 } domain_info;
458 uint32_t sequence_number;
459 struct {
460 fstring acct_name;
461 fstring full_name;
462 fstring homedir;
463 fstring shell;
464 uint32_t primary_gid;
465 uint32_t group_rid;
466 } user_info;
467 struct {
468 uint32_t auth_blob_len; /* blob in extra_data */
469 } ccache_ntlm_auth;
470 } data;
472 /* Variable length return data */
474 union {
475 SMB_TIME_T padding;
476 void *data;
477 } extra_data;
480 struct WINBINDD_MEMORY_CREDS {
481 struct WINBINDD_MEMORY_CREDS *next, *prev;
482 const char *username; /* lookup key. */
483 uid_t uid;
484 int ref_count;
485 size_t len;
486 uint8_t *nt_hash; /* Base pointer for the following 2 */
487 uint8_t *lm_hash;
488 char *pass;
491 struct WINBINDD_CCACHE_ENTRY {
492 struct WINBINDD_CCACHE_ENTRY *next, *prev;
493 const char *principal_name;
494 const char *ccname;
495 const char *service;
496 const char *username;
497 const char *realm;
498 struct WINBINDD_MEMORY_CREDS *cred_ptr;
499 int ref_count;
500 uid_t uid;
501 time_t create_time;
502 time_t renew_until;
503 time_t refresh_time;
504 struct timed_event *event;
507 #endif