This commit was manufactured by cvs2svn to create branch 'SAMBA_3_0'.(This used to...
[kai/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
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 4
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         /* Placeholder for end of cmd list */
103
104         WINBINDD_NUM_CMDS
105 };
106
107 /* Winbind request structure */
108
109 struct winbindd_request {
110         uint32 length;
111         enum winbindd_cmd cmd;   /* Winbindd command to execute */
112         pid_t pid;               /* pid of calling process */
113
114         union {
115                 fstring winsreq;     /* WINS request */
116                 fstring username;    /* getpwnam */
117                 fstring groupname;   /* getgrnam */
118                 uid_t uid;           /* getpwuid, uid_to_sid */
119                 gid_t gid;           /* getgrgid, gid_to_sid */
120                 struct {
121                         fstring user;
122                         fstring pass;
123                 } auth;              /* pam_winbind auth module */
124                 struct {
125                         unsigned char chal[8];
126                         fstring user;
127                         fstring domain;
128                         fstring lm_resp;
129                         uint16 lm_resp_len;
130                         fstring nt_resp;
131                         uint16 nt_resp_len;
132                 } auth_crap;
133                 struct {
134                     fstring user;
135                     fstring oldpass;
136                     fstring newpass;
137                 } chauthtok;         /* pam_winbind passwd module */
138                 fstring sid;         /* lookupsid, sid_to_[ug]id */
139                 struct {
140                         fstring dom_name;       /* lookupname */
141                         fstring name;       
142                 } name;
143                 uint32 num_entries;  /* getpwent, getgrent */
144         } data;
145         fstring domain;      /* {set,get,end}{pw,gr}ent() */
146 };
147
148 /* Response values */
149
150 enum winbindd_result {
151         WINBINDD_ERROR,
152         WINBINDD_OK
153 };
154
155 /* Winbind response structure */
156
157 struct winbindd_response {
158     
159         /* Header information */
160
161         uint32 length;                        /* Length of response */
162         enum winbindd_result result;          /* Result code */
163
164         /* Fixed length return data */
165         
166         union {
167                 int interface_version;  /* Try to ensure this is always in the same spot... */
168                 
169                 fstring winsresp;               /* WINS response */
170
171                 /* getpwnam, getpwuid */
172                 
173                 struct winbindd_pw {
174                         fstring pw_name;
175                         fstring pw_passwd;
176                         uid_t pw_uid;
177                         gid_t pw_gid;
178                         fstring pw_gecos;
179                         fstring pw_dir;
180                         fstring pw_shell;
181                 } pw;
182
183                 /* getgrnam, getgrgid */
184
185                 struct winbindd_gr {
186                         fstring gr_name;
187                         fstring gr_passwd;
188                         gid_t gr_gid;
189                         int num_gr_mem;
190                         int gr_mem_ofs;   /* offset to group membership */
191                 } gr;
192
193                 uint32 num_entries; /* getpwent, getgrent */
194                 struct winbindd_sid {
195                         fstring sid;        /* lookupname, [ug]id_to_sid */
196                         int type;
197                 } sid;
198                 struct winbindd_name {
199                         fstring dom_name;       /* lookupsid */
200                         fstring name;       
201                         int type;
202                 } name;
203                 uid_t uid;          /* sid_to_uid */
204                 gid_t gid;          /* sid_to_gid */
205                 struct winbindd_info {
206                         char winbind_separator;
207                         fstring samba_version;
208                 } info;
209                 fstring domain_name;
210
211                 struct auth_reply {
212                         uint32 nt_status;
213                         fstring nt_status_string;
214                         fstring error_string;
215                         int pam_error;
216                 } auth;
217         } data;
218
219         /* Variable length return data */
220
221         void *extra_data;               /* getgrnam, getgrgid, getgrent */
222 };
223
224 #endif