r7703: Fix the problem with MAP_PRIVATE not updating the file.
[Samba.git] / source3 / nsswitch / winbindd_nss.h
blobb249b62d69eed3dd14252ed12fe7b2e350ea1acc
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 11
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,
68 /* List various things */
70 WINBINDD_LIST_USERS, /* List w/o rid->id mapping */
71 WINBINDD_LIST_GROUPS, /* Ditto */
72 WINBINDD_LIST_TRUSTDOM,
74 /* SID conversion */
76 WINBINDD_LOOKUPSID,
77 WINBINDD_LOOKUPNAME,
79 /* Lookup functions */
81 WINBINDD_SID_TO_UID,
82 WINBINDD_SID_TO_GID,
83 WINBINDD_UID_TO_SID,
84 WINBINDD_GID_TO_SID,
85 WINBINDD_ALLOCATE_RID,
86 WINBINDD_ALLOCATE_RID_AND_GID,
88 /* Miscellaneous other stuff */
90 WINBINDD_CHECK_MACHACC, /* Check machine account pw works */
91 WINBINDD_PING, /* Just tell me winbind is running */
92 WINBINDD_INFO, /* Various bit of info. Currently just tidbits */
93 WINBINDD_DOMAIN_NAME, /* The domain this winbind server is a member of (lp_workgroup()) */
95 WINBINDD_DOMAIN_INFO, /* Most of what we know from
96 struct winbindd_domain */
97 WINBINDD_GETDCNAME, /* Issue a GetDCName Request */
99 WINBINDD_SHOW_SEQUENCE, /* display sequence numbers of domains */
101 /* WINS commands */
103 WINBINDD_WINS_BYIP,
104 WINBINDD_WINS_BYNAME,
106 /* this is like GETGRENT but gives an empty group list */
107 WINBINDD_GETGRLST,
109 WINBINDD_NETBIOS_NAME, /* The netbios name of the server */
111 /* find the location of our privileged pipe */
112 WINBINDD_PRIV_PIPE_DIR,
114 /* return a list of group sids for a user sid */
115 WINBINDD_GETUSERSIDS,
117 /* Return the domain groups a user is in */
118 WINBINDD_GETUSERDOMGROUPS,
120 /* Initialize connection in a child */
121 WINBINDD_INIT_CONNECTION,
123 /* Blocking calls that are not allowed on the main winbind pipe, only
124 * between parent and children */
125 WINBINDD_DUAL_SID2UID,
126 WINBINDD_DUAL_SID2GID,
127 WINBINDD_DUAL_IDMAPSET,
129 /* Wrapper around possibly blocking unix nss calls */
130 WINBINDD_DUAL_UID2NAME,
131 WINBINDD_DUAL_NAME2UID,
132 WINBINDD_DUAL_GID2NAME,
133 WINBINDD_DUAL_NAME2GID,
135 WINBINDD_DUAL_USERINFO,
136 WINBINDD_DUAL_GETSIDALIASES,
138 WINBINDD_NUM_CMDS
141 typedef struct winbindd_pw {
142 fstring pw_name;
143 fstring pw_passwd;
144 uid_t pw_uid;
145 gid_t pw_gid;
146 fstring pw_gecos;
147 fstring pw_dir;
148 fstring pw_shell;
149 } WINBINDD_PW;
152 typedef struct winbindd_gr {
153 fstring gr_name;
154 fstring gr_passwd;
155 gid_t gr_gid;
156 int num_gr_mem;
157 int gr_mem_ofs; /* offset to group membership */
158 char **gr_mem;
159 } WINBINDD_GR;
162 #define WBFLAG_PAM_INFO3_NDR 0x0001
163 #define WBFLAG_PAM_INFO3_TEXT 0x0002
164 #define WBFLAG_PAM_USER_SESSION_KEY 0x0004
165 #define WBFLAG_PAM_LMKEY 0x0008
166 #define WBFLAG_PAM_CONTACT_TRUSTDOM 0x0010
167 #define WBFLAG_QUERY_ONLY 0x0020
168 #define WBFLAG_ALLOCATE_RID 0x0040
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
176 /* Winbind request structure */
178 struct winbindd_request {
179 uint32 length;
180 enum winbindd_cmd cmd; /* Winbindd command to execute */
181 pid_t pid; /* pid of calling process */
182 uint32 flags; /* flags relavant to a given request */
183 fstring domain_name; /* name of domain for which the request applies */
184 int msgid;
186 union {
187 fstring winsreq; /* WINS request */
188 fstring username; /* getpwnam */
189 fstring groupname; /* getgrnam */
190 uid_t uid; /* getpwuid, uid_to_sid */
191 gid_t gid; /* getgrgid, gid_to_sid */
192 struct {
193 /* We deliberatedly don't split into domain/user to
194 avoid having the client know what the separator
195 character is. */
196 fstring user;
197 fstring pass;
198 fstring require_membership_of_sid;
199 } auth; /* pam_winbind auth module */
200 struct {
201 unsigned char chal[8];
202 fstring user;
203 fstring domain;
204 fstring lm_resp;
205 uint16 lm_resp_len;
206 fstring nt_resp;
207 uint16 nt_resp_len;
208 fstring workstation;
209 fstring require_membership_of_sid;
210 } auth_crap;
211 struct {
212 fstring user;
213 fstring oldpass;
214 fstring newpass;
215 } chauthtok; /* pam_winbind passwd module */
216 fstring sid; /* lookupsid, sid_to_[ug]id */
217 struct {
218 fstring dom_name; /* lookupname */
219 fstring name;
220 } name;
221 uint32 num_entries; /* getpwent, getgrent */
222 struct {
223 fstring username;
224 fstring groupname;
225 } acct_mgt;
226 struct {
227 BOOL is_primary;
228 fstring dcname;
229 } init_conn;
230 struct {
231 fstring sid;
232 fstring name;
233 BOOL alloc;
234 } dual_sid2id;
235 struct {
236 int type;
237 uid_t uid;
238 gid_t gid;
239 fstring sid;
240 } dual_idmapset;
241 struct {
242 fstring cache_key;
243 } dual_sidaliases;
244 } data;
245 char null_term;
248 /* Response values */
250 enum winbindd_result {
251 WINBINDD_ERROR,
252 WINBINDD_PENDING,
253 WINBINDD_OK
256 /* Winbind response structure */
258 struct winbindd_response {
260 /* Header information */
262 uint32 length; /* Length of response */
263 enum winbindd_result result; /* Result code */
265 /* Fixed length return data */
267 union {
268 int interface_version; /* Try to ensure this is always in the same spot... */
270 fstring winsresp; /* WINS response */
272 /* getpwnam, getpwuid */
274 struct winbindd_pw pw;
276 /* getgrnam, getgrgid */
278 struct winbindd_gr gr;
280 uint32 num_entries; /* getpwent, getgrent */
281 struct winbindd_sid {
282 fstring sid; /* lookupname, [ug]id_to_sid */
283 int type;
284 } sid;
285 struct winbindd_name {
286 fstring dom_name; /* lookupsid */
287 fstring name;
288 int type;
289 } name;
290 uid_t uid; /* sid_to_uid */
291 gid_t gid; /* sid_to_gid */
292 struct winbindd_info {
293 char winbind_separator;
294 fstring samba_version;
295 } info;
296 fstring domain_name;
297 fstring netbios_name;
298 fstring dc_name;
300 struct auth_reply {
301 uint32 nt_status;
302 fstring nt_status_string;
303 fstring error_string;
304 int pam_error;
305 char user_session_key[16];
306 char first_8_lm_hash[8];
307 } auth;
308 uint32 rid; /* create user or group or allocate rid */
309 struct {
310 uint32 rid;
311 gid_t gid;
312 } rid_and_gid;
313 struct {
314 fstring name;
315 fstring alt_name;
316 fstring sid;
317 BOOL native_mode;
318 BOOL active_directory;
319 BOOL primary;
320 uint32 sequence_number;
321 } domain_info;
322 struct {
323 fstring acct_name;
324 fstring full_name;
325 uint32 group_rid;
326 } user_info;
327 } data;
329 /* Variable length return data */
331 void *extra_data; /* getgrnam, getgrgid, getgrent */
334 #endif