Updates to the NTLMSSP code again - moving the base64 decode fuctionality out
[sfrench/samba-autobuild/.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    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
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 7
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
88         /* Miscellaneous other stuff */
89
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()) */
94
95         WINBINDD_SHOW_SEQUENCE, /* display sequence numbers of domains */
96
97         /* WINS commands */
98
99         WINBINDD_WINS_BYIP,
100         WINBINDD_WINS_BYNAME,
101
102         /* this is like GETGRENT but gives an empty group list */
103         WINBINDD_GETGRLST,
104
105         WINBINDD_NETBIOS_NAME,       /* The netbios name of the server */
106         /* Placeholder for end of cmd list */
107
108         WINBINDD_NUM_CMDS
109 };
110
111 #define WINBIND_PAM_INFO3_NDR  0x0001
112 #define WINBIND_PAM_INFO3_TEXT 0x0002
113 #define WINBIND_PAM_NTKEY      0x0004
114 #define WINBIND_PAM_LMKEY      0x0008
115 #define WINBIND_PAM_CONTACT_TRUSTDOM 0x0010
116
117 /* Winbind request structure */
118
119 struct winbindd_request {
120         uint32 length;
121         enum winbindd_cmd cmd;   /* Winbindd command to execute */
122         pid_t pid;               /* pid of calling process */
123
124         union {
125                 fstring winsreq;     /* WINS request */
126                 fstring username;    /* getpwnam */
127                 fstring groupname;   /* getgrnam */
128                 uid_t uid;           /* getpwuid, uid_to_sid */
129                 gid_t gid;           /* getgrgid, gid_to_sid */
130                 struct {
131                         /* We deliberatedly don't split into domain/user to
132                            avoid having the client know what the separator
133                            character is. */     
134                         fstring user;
135                         fstring pass;
136                 } auth;              /* pam_winbind auth module */
137                 struct {
138                         unsigned char chal[8];
139                         fstring user;
140                         fstring domain;
141                         fstring lm_resp;
142                         uint16 lm_resp_len;
143                         fstring nt_resp;
144                         uint16 nt_resp_len;
145                         fstring workstation;
146                         uint32 flags;
147                 } auth_crap;
148                 struct {
149                     fstring user;
150                     fstring oldpass;
151                     fstring newpass;
152                 } chauthtok;         /* pam_winbind passwd module */
153                 fstring sid;         /* lookupsid, sid_to_[ug]id */
154                 struct {
155                         fstring dom_name;       /* lookupname */
156                         fstring name;       
157                 } name;
158                 uint32 num_entries;  /* getpwent, getgrent */
159         } data;
160         char null_term;
161 };
162
163 /* Response values */
164
165 enum winbindd_result {
166         WINBINDD_ERROR,
167         WINBINDD_OK
168 };
169
170 /* Winbind response structure */
171
172 struct winbindd_response {
173     
174         /* Header information */
175
176         uint32 length;                        /* Length of response */
177         enum winbindd_result result;          /* Result code */
178
179         /* Fixed length return data */
180         
181         union {
182                 int interface_version;  /* Try to ensure this is always in the same spot... */
183                 
184                 fstring winsresp;               /* WINS response */
185
186                 /* getpwnam, getpwuid */
187                 
188                 struct winbindd_pw {
189                         fstring pw_name;
190                         fstring pw_passwd;
191                         uid_t pw_uid;
192                         gid_t pw_gid;
193                         fstring pw_gecos;
194                         fstring pw_dir;
195                         fstring pw_shell;
196                 } pw;
197
198                 /* getgrnam, getgrgid */
199
200                 struct winbindd_gr {
201                         fstring gr_name;
202                         fstring gr_passwd;
203                         gid_t gr_gid;
204                         int num_gr_mem;
205                         int gr_mem_ofs;   /* offset to group membership */
206                 } gr;
207
208                 uint32 num_entries; /* getpwent, getgrent */
209                 struct winbindd_sid {
210                         fstring sid;        /* lookupname, [ug]id_to_sid */
211                         int type;
212                 } sid;
213                 struct winbindd_name {
214                         fstring dom_name;       /* lookupsid */
215                         fstring name;       
216                         int type;
217                 } name;
218                 uid_t uid;          /* sid_to_uid */
219                 gid_t gid;          /* sid_to_gid */
220                 struct winbindd_info {
221                         char winbind_separator;
222                         fstring samba_version;
223                 } info;
224                 fstring domain_name;
225                 fstring netbios_name;
226
227                 struct auth_reply {
228                         uint32 nt_status;
229                         fstring nt_status_string;
230                         fstring error_string;
231                         int pam_error;
232                         char nt_session_key[16];
233                         char first_8_lm_hash[8];
234                 } auth;
235         } data;
236
237         /* Variable length return data */
238
239         void *extra_data;               /* getgrnam, getgrgid, getgrent */
240 };
241
242 #endif