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.
16 #define CONST_DISCARD(type, ptr) ((type) ((void *) (ptr)))
20 #define CONST_ADD(type, ptr) ((type) ((const void *) (ptr)))
24 #define SAFE_FREE(x) do { if(x) {free(x); x=NULL;} } while(0)
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. */
46 # define SMB_TIME_T uint64
48 # define SMB_TIME_T time_t
55 WINBINDD_INTERFACE_VERSION
, /* Always a well known value */
57 /* Get users and groups */
65 /* Enumerate users and groups */
74 /* PAM authenticate and password change */
77 WINBINDD_PAM_AUTH_CRAP
,
78 WINBINDD_PAM_CHAUTHTOK
,
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
,
94 /* Lookup functions */
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 */
120 WINBINDD_WINS_BYNAME
,
122 /* this is like GETGRENT but gives an empty group list */
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
,
159 typedef struct winbindd_pw
{
170 typedef struct winbindd_gr
{
175 uint32 gr_mem_ofs
; /* offset to group membership */
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
{
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 */
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 */
225 /* We deliberatedly don't split into domain/user to
226 avoid having the client know what the separator
230 fstring require_membership_of_sid
;
231 fstring krb5_cc_type
;
233 } auth
; /* pam_winbind auth module */
235 unsigned char chal
[8];
236 uint32 logon_parameters
;
244 fstring require_membership_of_sid
;
250 } chauthtok
; /* pam_winbind passwd module */
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 */
267 } logoff
; /* pam_winbind session module */
268 fstring sid
; /* lookupsid, sid_to_[ug]id */
270 fstring dom_name
; /* lookupname */
273 uint32 num_entries
; /* getpwent, getgrent */
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 */
309 /* Response values */
311 enum winbindd_result
{
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 */
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 */
354 struct winbindd_name
{
355 fstring dom_name
; /* lookupsid */
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
;
366 fstring netbios_name
;
371 fstring nt_status_string
;
372 fstring error_string
;
374 char user_session_key
[16];
375 char first_8_lm_hash
[8];
377 uint32 reject_reason
;
379 struct policy_settings
{
380 uint32 min_length_password
;
381 uint32 password_history
;
382 uint32 password_properties
;
385 SMB_TIME_T min_passwordage
;
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
;
401 uint32 num_other_sids
;
405 fstring logon_script
;
406 fstring profile_path
;
418 BOOL active_directory
;
420 uint32 sequence_number
;
431 /* Variable length return data */
439 struct WINBINDD_CCACHE_ENTRY
{
440 const char *principal_name
;
443 const char *username
;
444 const char *sid_string
;
451 struct timed_event
*event
;
452 struct WINBINDD_CCACHE_ENTRY
*next
, *prev
;