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