r4348: syncing up for 3.0.11pre1
[tprouty/samba.git] / source / nsswitch / winbindd_nss.h
1 /* 
2    Unix SMB/CIFS implementation.
3
4    Winbind daemon for ntdom nss module
5
6    Copyright (C) Tim Potter 2000
7    
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.  
11 */
12
13 #ifndef SAFE_FREE
14 #define SAFE_FREE(x) do { if(x) {free(x); x=NULL;} } while(0)
15 #endif
16
17 #ifndef _WINBINDD_NTDOM_H
18 #define _WINBINDD_NTDOM_H
19
20 #define WINBINDD_SOCKET_NAME "pipe"            /* Name of PF_UNIX socket */
21 #define WINBINDD_SOCKET_DIR  "/tmp/.winbindd"  /* Name of PF_UNIX dir */
22 #define WINBINDD_PRIV_SOCKET_SUBDIR "winbindd_privileged" /* name of subdirectory of lp_lockdir() to hold the 'privileged' pipe */
23 #define WINBINDD_DOMAIN_ENV  "WINBINDD_DOMAIN" /* Environment variables */
24 #define WINBINDD_DONT_ENV    "_NO_WINBINDD"
25
26 /* Update this when you change the interface.  */
27
28 #define WINBIND_INTERFACE_VERSION 10
29
30 /* Socket commands */
31
32 enum winbindd_cmd {
33
34         WINBINDD_INTERFACE_VERSION,    /* Always a well known value */
35
36         /* Get users and groups */
37
38         WINBINDD_GETPWNAM,
39         WINBINDD_GETPWUID,
40         WINBINDD_GETGRNAM,
41         WINBINDD_GETGRGID,
42         WINBINDD_GETGROUPS,
43
44         /* Enumerate users and groups */
45
46         WINBINDD_SETPWENT,
47         WINBINDD_ENDPWENT,
48         WINBINDD_GETPWENT,
49         WINBINDD_SETGRENT,
50         WINBINDD_ENDGRENT,
51         WINBINDD_GETGRENT,
52
53         /* PAM authenticate and password change */
54
55         WINBINDD_PAM_AUTH,
56         WINBINDD_PAM_AUTH_CRAP,
57         WINBINDD_PAM_CHAUTHTOK,
58
59         /* List various things */
60
61         WINBINDD_LIST_USERS,         /* List w/o rid->id mapping */
62         WINBINDD_LIST_GROUPS,        /* Ditto */
63         WINBINDD_LIST_TRUSTDOM,
64
65         /* SID conversion */
66
67         WINBINDD_LOOKUPSID,
68         WINBINDD_LOOKUPNAME,
69
70         /* Lookup functions */
71
72         WINBINDD_SID_TO_UID,       
73         WINBINDD_SID_TO_GID,
74         WINBINDD_UID_TO_SID,
75         WINBINDD_GID_TO_SID,
76         WINBINDD_ALLOCATE_RID,
77
78         /* Miscellaneous other stuff */
79
80         WINBINDD_CHECK_MACHACC,     /* Check machine account pw works */
81         WINBINDD_PING,              /* Just tell me winbind is running */
82         WINBINDD_INFO,              /* Various bit of info.  Currently just tidbits */
83         WINBINDD_DOMAIN_NAME,       /* The domain this winbind server is a member of (lp_workgroup()) */
84
85         WINBINDD_DOMAIN_INFO,   /* Most of what we know from
86                                    struct winbindd_domain */
87
88         WINBINDD_SHOW_SEQUENCE, /* display sequence numbers of domains */
89
90         /* WINS commands */
91
92         WINBINDD_WINS_BYIP,
93         WINBINDD_WINS_BYNAME,
94
95         /* account management commands */
96
97         WINBINDD_CREATE_USER,
98         WINBINDD_CREATE_GROUP,
99         WINBINDD_ADD_USER_TO_GROUP,
100         WINBINDD_REMOVE_USER_FROM_GROUP,
101         WINBINDD_SET_USER_PRIMARY_GROUP,
102         WINBINDD_DELETE_USER,
103         WINBINDD_DELETE_GROUP,
104         
105         /* this is like GETGRENT but gives an empty group list */
106         WINBINDD_GETGRLST,
107
108         WINBINDD_NETBIOS_NAME,       /* The netbios name of the server */
109
110         /* find the location of our privileged pipe */
111         WINBINDD_PRIV_PIPE_DIR,
112
113         /* return a list of group sids for a user sid */
114         WINBINDD_GETUSERSIDS,   
115
116         /* Placeholder for end of cmd list */
117         WINBINDD_NUM_CMDS
118 };
119
120 typedef struct winbindd_pw {
121         fstring pw_name;
122         fstring pw_passwd;
123         uid_t pw_uid;
124         gid_t pw_gid;
125         fstring pw_gecos;
126         fstring pw_dir;
127         fstring pw_shell;
128 } WINBINDD_PW;
129
130
131 typedef struct winbindd_gr {
132         fstring gr_name;
133         fstring gr_passwd;
134         gid_t gr_gid;
135         int num_gr_mem;
136         int gr_mem_ofs;   /* offset to group membership */
137         char **gr_mem;
138 } WINBINDD_GR;
139
140
141 #define WBFLAG_PAM_INFO3_NDR            0x0001
142 #define WBFLAG_PAM_INFO3_TEXT           0x0002
143 #define WBFLAG_PAM_USER_SESSION_KEY     0x0004
144 #define WBFLAG_PAM_LMKEY                0x0008
145 #define WBFLAG_PAM_CONTACT_TRUSTDOM     0x0010
146 #define WBFLAG_QUERY_ONLY               0x0020
147 #define WBFLAG_ALLOCATE_RID             0x0040
148 #define WBFLAG_PAM_UNIX_NAME            0x0080
149 #define WBFLAG_PAM_AFS_TOKEN            0x0100
150 #define WBFLAG_PAM_NT_STATUS_SQUASH     0x0200
151
152 /* Winbind request structure */
153
154 struct winbindd_request {
155         uint32 length;
156         enum winbindd_cmd cmd;   /* Winbindd command to execute */
157         pid_t pid;               /* pid of calling process */
158         uint32 flags;            /* flags relavant to a given request */
159         fstring domain_name;    /* name of domain for which the request applies */
160
161         union {
162                 fstring winsreq;     /* WINS request */
163                 fstring username;    /* getpwnam */
164                 fstring groupname;   /* getgrnam */
165                 uid_t uid;           /* getpwuid, uid_to_sid */
166                 gid_t gid;           /* getgrgid, gid_to_sid */
167                 struct {
168                         /* We deliberatedly don't split into domain/user to
169                            avoid having the client know what the separator
170                            character is. */     
171                         fstring user;
172                         fstring pass;
173                         fstring require_membership_of_sid;
174                 } auth;              /* pam_winbind auth module */
175                 struct {
176                         unsigned char chal[8];
177                         fstring user;
178                         fstring domain;
179                         fstring lm_resp;
180                         uint16 lm_resp_len;
181                         fstring nt_resp;
182                         uint16 nt_resp_len;
183                         fstring workstation;
184                         fstring require_membership_of_sid;
185                 } auth_crap;
186                 struct {
187                     fstring user;
188                     fstring oldpass;
189                     fstring newpass;
190                 } chauthtok;         /* pam_winbind passwd module */
191                 fstring sid;         /* lookupsid, sid_to_[ug]id */
192                 struct {
193                         fstring dom_name;       /* lookupname */
194                         fstring name;       
195                 } name;
196                 uint32 num_entries;  /* getpwent, getgrent */
197                 struct {
198                         fstring username;
199                         fstring groupname;
200                 } acct_mgt;
201         } data;
202         char null_term;
203 };
204
205 /* Response values */
206
207 enum winbindd_result {
208         WINBINDD_ERROR,
209         WINBINDD_OK
210 };
211
212 /* Winbind response structure */
213
214 struct winbindd_response {
215     
216         /* Header information */
217
218         uint32 length;                        /* Length of response */
219         enum winbindd_result result;          /* Result code */
220
221         /* Fixed length return data */
222         
223         union {
224                 int interface_version;  /* Try to ensure this is always in the same spot... */
225                 
226                 fstring winsresp;               /* WINS response */
227
228                 /* getpwnam, getpwuid */
229                 
230                 struct winbindd_pw pw;
231
232                 /* getgrnam, getgrgid */
233
234                 struct winbindd_gr gr;
235
236                 uint32 num_entries; /* getpwent, getgrent */
237                 struct winbindd_sid {
238                         fstring sid;        /* lookupname, [ug]id_to_sid */
239                         int type;
240                 } sid;
241                 struct winbindd_name {
242                         fstring dom_name;       /* lookupsid */
243                         fstring name;       
244                         int type;
245                 } name;
246                 uid_t uid;          /* sid_to_uid */
247                 gid_t gid;          /* sid_to_gid */
248                 struct winbindd_info {
249                         char winbind_separator;
250                         fstring samba_version;
251                 } info;
252                 fstring domain_name;
253                 fstring netbios_name;
254
255                 struct auth_reply {
256                         uint32 nt_status;
257                         fstring nt_status_string;
258                         fstring error_string;
259                         int pam_error;
260                         char user_session_key[16];
261                         char first_8_lm_hash[8];
262                 } auth;
263                 uint32 rid;     /* create user or group or allocate rid */
264                 struct {
265                         fstring name;
266                         fstring alt_name;
267                         fstring sid;
268                         BOOL native_mode;
269                         BOOL active_directory;
270                         BOOL primary;
271                         uint32 sequence_number;
272                 } domain_info;
273         } data;
274
275         /* Variable length return data */
276
277         void *extra_data;               /* getgrnam, getgrgid, getgrent */
278 };
279
280 #endif