r15634: Prevent passwords of winbindd's list of credential caches from beeing
[Samba/nascimento.git] / source3 / nsswitch / winbindd_nss.h
blob34e0d09721968bc0ac5a8598f991af5fc78cc633
1 /*
2 Unix SMB/CIFS implementation.
4 Winbind daemon for ntdom nss module
6 Copyright (C) Tim Potter 2000
8 You are free to use this interface definition in any way you see
9 fit, including without restriction, using this header in your own
10 products. You do not need to give any attribution.
14 #ifndef CONST_DISCARD
15 #define CONST_DISCARD(type, ptr) ((type) ((void *) (ptr)))
16 #endif
18 #ifndef CONST_ADD
19 #define CONST_ADD(type, ptr) ((type) ((const void *) (ptr)))
20 #endif
22 #ifndef SAFE_FREE
23 #define SAFE_FREE(x) do { if(x) {free(x); x=NULL;} } while(0)
24 #endif
26 #ifndef _WINBINDD_NTDOM_H
27 #define _WINBINDD_NTDOM_H
29 #define WINBINDD_SOCKET_NAME "pipe" /* Name of PF_UNIX socket */
30 #define WINBINDD_SOCKET_DIR "/tmp/.winbindd" /* Name of PF_UNIX dir */
31 #define WINBINDD_PRIV_SOCKET_SUBDIR "winbindd_privileged" /* name of subdirectory of lp_lockdir() to hold the 'privileged' pipe */
32 #define WINBINDD_DOMAIN_ENV "WINBINDD_DOMAIN" /* Environment variables */
33 #define WINBINDD_DONT_ENV "_NO_WINBINDD"
35 /* Update this when you change the interface. */
37 #define WINBIND_INTERFACE_VERSION 14
39 /* Socket commands */
41 enum winbindd_cmd {
43 WINBINDD_INTERFACE_VERSION, /* Always a well known value */
45 /* Get users and groups */
47 WINBINDD_GETPWNAM,
48 WINBINDD_GETPWUID,
49 WINBINDD_GETGRNAM,
50 WINBINDD_GETGRGID,
51 WINBINDD_GETGROUPS,
53 /* Enumerate users and groups */
55 WINBINDD_SETPWENT,
56 WINBINDD_ENDPWENT,
57 WINBINDD_GETPWENT,
58 WINBINDD_SETGRENT,
59 WINBINDD_ENDGRENT,
60 WINBINDD_GETGRENT,
62 /* PAM authenticate and password change */
64 WINBINDD_PAM_AUTH,
65 WINBINDD_PAM_AUTH_CRAP,
66 WINBINDD_PAM_CHAUTHTOK,
67 WINBINDD_PAM_LOGOFF,
69 /* List various things */
71 WINBINDD_LIST_USERS, /* List w/o rid->id mapping */
72 WINBINDD_LIST_GROUPS, /* Ditto */
73 WINBINDD_LIST_TRUSTDOM,
75 /* SID conversion */
77 WINBINDD_LOOKUPSID,
78 WINBINDD_LOOKUPNAME,
80 /* Lookup functions */
82 WINBINDD_SID_TO_UID,
83 WINBINDD_SID_TO_GID,
84 WINBINDD_UID_TO_SID,
85 WINBINDD_GID_TO_SID,
87 WINBINDD_ALLOCATE_UID,
88 WINBINDD_ALLOCATE_GID,
90 /* Miscellaneous other stuff */
92 WINBINDD_CHECK_MACHACC, /* Check machine account pw works */
93 WINBINDD_PING, /* Just tell me winbind is running */
94 WINBINDD_INFO, /* Various bit of info. Currently just tidbits */
95 WINBINDD_DOMAIN_NAME, /* The domain this winbind server is a member of (lp_workgroup()) */
97 WINBINDD_DOMAIN_INFO, /* Most of what we know from
98 struct winbindd_domain */
99 WINBINDD_GETDCNAME, /* Issue a GetDCName Request */
101 WINBINDD_SHOW_SEQUENCE, /* display sequence numbers of domains */
103 /* WINS commands */
105 WINBINDD_WINS_BYIP,
106 WINBINDD_WINS_BYNAME,
108 /* this is like GETGRENT but gives an empty group list */
109 WINBINDD_GETGRLST,
111 WINBINDD_NETBIOS_NAME, /* The netbios name of the server */
113 /* find the location of our privileged pipe */
114 WINBINDD_PRIV_PIPE_DIR,
116 /* return a list of group sids for a user sid */
117 WINBINDD_GETUSERSIDS,
119 /* Various group queries */
120 WINBINDD_GETUSERDOMGROUPS,
122 /* Initialize connection in a child */
123 WINBINDD_INIT_CONNECTION,
125 /* Blocking calls that are not allowed on the main winbind pipe, only
126 * between parent and children */
127 WINBINDD_DUAL_SID2UID,
128 WINBINDD_DUAL_SID2GID,
129 WINBINDD_DUAL_IDMAPSET,
131 /* Wrapper around possibly blocking unix nss calls */
132 WINBINDD_DUAL_UID2NAME,
133 WINBINDD_DUAL_NAME2UID,
134 WINBINDD_DUAL_GID2NAME,
135 WINBINDD_DUAL_NAME2GID,
137 WINBINDD_DUAL_USERINFO,
138 WINBINDD_DUAL_GETSIDALIASES,
140 WINBINDD_NUM_CMDS
143 typedef struct winbindd_pw {
144 fstring pw_name;
145 fstring pw_passwd;
146 uid_t pw_uid;
147 gid_t pw_gid;
148 fstring pw_gecos;
149 fstring pw_dir;
150 fstring pw_shell;
151 } WINBINDD_PW;
154 typedef struct winbindd_gr {
155 fstring gr_name;
156 fstring gr_passwd;
157 gid_t gr_gid;
158 uint32 num_gr_mem;
159 uint32 gr_mem_ofs; /* offset to group membership */
160 } WINBINDD_GR;
163 #define WBFLAG_PAM_INFO3_NDR 0x0001
164 #define WBFLAG_PAM_INFO3_TEXT 0x0002
165 #define WBFLAG_PAM_USER_SESSION_KEY 0x0004
166 #define WBFLAG_PAM_LMKEY 0x0008
167 #define WBFLAG_PAM_CONTACT_TRUSTDOM 0x0010
168 #define WBFLAG_QUERY_ONLY 0x0020
169 #define WBFLAG_PAM_UNIX_NAME 0x0080
170 #define WBFLAG_PAM_AFS_TOKEN 0x0100
171 #define WBFLAG_PAM_NT_STATUS_SQUASH 0x0200
173 /* This is a flag that can only be sent from parent to child */
174 #define WBFLAG_IS_PRIVILEGED 0x0400
175 /* Flag to say this is a winbindd internal send - don't recurse. */
176 #define WBFLAG_RECURSE 0x0800
178 #define WBFLAG_PAM_KRB5 0x1000
179 #define WBFLAG_PAM_FALLBACK_AFTER_KRB5 0x2000
180 #define WBFLAG_PAM_CACHED_LOGIN 0x4000
181 #define WBFLAG_PAM_GET_PWD_POLICY 0x8000
183 #define WINBINDD_MAX_EXTRA_DATA (128*1024)
185 /* Winbind request structure */
187 struct winbindd_request {
188 uint32 length;
189 enum winbindd_cmd cmd; /* Winbindd command to execute */
190 pid_t pid; /* pid of calling process */
191 uint32 flags; /* flags relavant to a given request */
192 fstring domain_name; /* name of domain for which the request applies */
194 union {
195 fstring winsreq; /* WINS request */
196 fstring username; /* getpwnam */
197 fstring groupname; /* getgrnam */
198 uid_t uid; /* getpwuid, uid_to_sid */
199 gid_t gid; /* getgrgid, gid_to_sid */
200 struct {
201 /* We deliberatedly don't split into domain/user to
202 avoid having the client know what the separator
203 character is. */
204 fstring user;
205 fstring pass;
206 fstring require_membership_of_sid;
207 fstring krb5_cc_type;
208 uid_t uid;
209 } auth; /* pam_winbind auth module */
210 struct {
211 unsigned char chal[8];
212 uint32 logon_parameters;
213 fstring user;
214 fstring domain;
215 fstring lm_resp;
216 uint16 lm_resp_len;
217 fstring nt_resp;
218 uint16 nt_resp_len;
219 fstring workstation;
220 fstring require_membership_of_sid;
221 } auth_crap;
222 struct {
223 fstring user;
224 fstring oldpass;
225 fstring newpass;
226 } chauthtok; /* pam_winbind passwd module */
227 struct {
228 fstring user;
229 fstring krb5ccname;
230 uid_t uid;
231 } logoff; /* pam_winbind session module */
232 fstring sid; /* lookupsid, sid_to_[ug]id */
233 struct {
234 fstring dom_name; /* lookupname */
235 fstring name;
236 } name;
237 uint32 num_entries; /* getpwent, getgrent */
238 struct {
239 fstring username;
240 fstring groupname;
241 } acct_mgt;
242 struct {
243 BOOL is_primary;
244 fstring dcname;
245 } init_conn;
246 struct {
247 fstring sid;
248 fstring name;
249 BOOL alloc;
250 } dual_sid2id;
251 struct {
252 int type;
253 uid_t uid;
254 gid_t gid;
255 fstring sid;
256 } dual_idmapset;
257 BOOL list_all_domains;
258 } data;
259 union {
260 #if defined(uint64)
261 uint64 z;
262 #endif
263 char *data;
264 } extra_data;
265 uint32 extra_len;
266 char null_term;
269 /* Response values */
271 enum winbindd_result {
272 WINBINDD_ERROR,
273 WINBINDD_PENDING,
274 WINBINDD_OK
277 /* Winbind response structure */
279 struct winbindd_response {
281 /* Header information */
283 uint32 length; /* Length of response */
284 enum winbindd_result result; /* Result code */
286 /* Fixed length return data */
288 union {
289 int interface_version; /* Try to ensure this is always in the same spot... */
291 fstring winsresp; /* WINS response */
293 /* getpwnam, getpwuid */
295 struct winbindd_pw pw;
297 /* getgrnam, getgrgid */
299 struct winbindd_gr gr;
301 uint32 num_entries; /* getpwent, getgrent */
302 struct winbindd_sid {
303 fstring sid; /* lookupname, [ug]id_to_sid */
304 int type;
305 } sid;
306 struct winbindd_name {
307 fstring dom_name; /* lookupsid */
308 fstring name;
309 int type;
310 } name;
311 uid_t uid; /* sid_to_uid */
312 gid_t gid; /* sid_to_gid */
313 struct winbindd_info {
314 char winbind_separator;
315 fstring samba_version;
316 } info;
317 fstring domain_name;
318 fstring netbios_name;
319 fstring dc_name;
321 struct auth_reply {
322 uint32 nt_status;
323 fstring nt_status_string;
324 fstring error_string;
325 int pam_error;
326 char user_session_key[16];
327 char first_8_lm_hash[8];
328 fstring krb5ccname;
329 struct policy_settings {
330 uint16 min_length_password;
331 uint16 password_history;
332 uint32 password_properties;
333 uint32 expire;
334 uint32 min_passwordage;
335 } policy;
336 uint32 reject_reason;
337 struct info3_text {
338 uint32 logon_time;
339 uint32 logoff_time;
340 uint32 kickoff_time;
341 uint32 pass_last_set_time;
342 uint32 pass_can_change_time;
343 uint32 pass_must_change_time;
344 uint16 logon_count;
345 uint16 bad_pw_count;
346 uint32 user_rid;
347 uint32 group_rid;
348 fstring dom_sid;
349 uint32 num_groups;
350 uint32 user_flgs;
351 uint32 acct_flags;
352 uint32 num_other_sids;
353 fstring user_name;
354 fstring full_name;
355 fstring logon_script;
356 fstring profile_path;
357 fstring home_dir;
358 fstring dir_drive;
359 fstring logon_srv;
360 fstring logon_dom;
361 } info3;
362 } auth;
363 struct {
364 fstring name;
365 fstring alt_name;
366 fstring sid;
367 BOOL native_mode;
368 BOOL active_directory;
369 BOOL primary;
370 uint32 sequence_number;
371 } domain_info;
372 struct {
373 fstring acct_name;
374 fstring full_name;
375 fstring homedir;
376 fstring shell;
377 uint32 group_rid;
378 } user_info;
379 } data;
381 /* Variable length return data */
383 union {
384 #if defined(uint64)
385 uint64 z;
386 #endif
387 void *data;
388 } extra_data;
391 struct WINBINDD_CCACHE_ENTRY {
392 const char *principal_name;
393 const char *ccname;
394 const char *service;
395 const char *username;
396 const char *sid_string;
397 char *pass;
398 uid_t uid;
399 time_t create_time;
400 time_t renew_until;
401 BOOL refresh_tgt;
402 time_t refresh_time;
403 struct timed_event *event;
404 struct WINBINDD_CCACHE_ENTRY *next, *prev;
407 #endif