5ab4f4d7c549913d13d789985c1e8313ff012071
[ira/wip.git] / source3 / nsswitch / winbindd_nss.h
1 /* 
2    Unix SMB/Netbios implementation.
3    Version 2.0
4
5    Winbind daemon for ntdom nss module
6
7    Copyright (C) Tim Potter 2000
8    
9    This library is free software; you can redistribute it and/or
10    modify it under the terms of the GNU Library General Public
11    License as published by the Free Software Foundation; either
12    version 2 of the License, or (at your option) any later version.
13    
14    This library is distributed in the hope that it will be useful,
15    but WITHOUT ANY WARRANTY; without even the implied warranty of
16    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17    Library General Public License for more details.
18    
19    You should have received a copy of the GNU Library General Public
20    License along with this library; if not, write to the
21    Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22    Boston, MA  02111-1307, USA.   
23 */
24
25 #ifndef SAFE_FREE
26 #define SAFE_FREE(x) do { if(x) {free(x); x=NULL;} } while(0)
27 #endif
28
29 #ifndef _WINBINDD_NTDOM_H
30 #define _WINBINDD_NTDOM_H
31
32 #define WINBINDD_SOCKET_NAME "pipe"            /* Name of PF_UNIX socket */
33 #define WINBINDD_SOCKET_DIR  "/tmp/.winbindd"  /* Name of PF_UNIX dir */
34
35 #define WINBINDD_DOMAIN_ENV  "WINBINDD_DOMAIN" /* Environment variables */
36 #define WINBINDD_DONT_ENV    "_NO_WINBINDD"
37
38 /* Update this when you change the interface.  */
39
40 #define WINBIND_INTERFACE_VERSION 3
41
42 /* Socket commands */
43
44 enum winbindd_cmd {
45
46         WINBINDD_INTERFACE_VERSION,    /* Always a well known value */
47
48         /* Get users and groups */
49
50         WINBINDD_GETPWNAM,
51         WINBINDD_GETPWUID,
52         WINBINDD_GETGRNAM,
53         WINBINDD_GETGRGID,
54         WINBINDD_GETGROUPS,
55
56         /* Enumerate users and groups */
57
58         WINBINDD_SETPWENT,
59         WINBINDD_ENDPWENT,
60         WINBINDD_GETPWENT,
61         WINBINDD_SETGRENT,
62         WINBINDD_ENDGRENT,
63         WINBINDD_GETGRENT,
64
65         /* PAM authenticate and password change */
66
67         WINBINDD_PAM_AUTH,
68         WINBINDD_PAM_AUTH_CRAP,
69         WINBINDD_PAM_CHAUTHTOK,
70
71         /* List various things */
72
73         WINBINDD_LIST_USERS,         /* List w/o rid->id mapping */
74         WINBINDD_LIST_GROUPS,        /* Ditto */
75         WINBINDD_LIST_TRUSTDOM,
76
77         /* SID conversion */
78
79         WINBINDD_LOOKUPSID,
80         WINBINDD_LOOKUPNAME,
81
82         /* Lookup functions */
83
84         WINBINDD_SID_TO_UID,       
85         WINBINDD_SID_TO_GID,
86         WINBINDD_UID_TO_SID,
87         WINBINDD_GID_TO_SID,
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         /* Placeholder for end of cmd list */
97
98         WINBINDD_NUM_CMDS
99 };
100
101 /* Winbind request structure */
102
103 struct winbindd_request {
104         uint32 length;
105         enum winbindd_cmd cmd;   /* Winbindd command to execute */
106         pid_t pid;               /* pid of calling process */
107
108         union {
109                 fstring username;    /* getpwnam */
110                 fstring groupname;   /* getgrnam */
111                 uid_t uid;           /* getpwuid, uid_to_sid */
112                 gid_t gid;           /* getgrgid, gid_to_sid */
113                 struct {
114                         fstring user;
115                         fstring pass;
116                 } auth;              /* pam_winbind auth module */
117                 struct {
118                         unsigned char chal[8];
119                         fstring user;
120                         fstring domain;
121                         fstring lm_resp;
122                         uint16 lm_resp_len;
123                         fstring nt_resp;
124                         uint16 nt_resp_len;
125                 } auth_crap;
126                 struct {
127                     fstring user;
128                     fstring oldpass;
129                     fstring newpass;
130                 } chauthtok;         /* pam_winbind passwd module */
131                 fstring sid;         /* lookupsid, sid_to_[ug]id */
132                 struct {
133                         fstring dom_name;       /* lookupname */
134                         fstring name;       
135                 } name;
136                 uint32 num_entries;  /* getpwent, getgrent */
137         } data;
138         fstring domain;      /* {set,get,end}{pw,gr}ent() */
139 };
140
141 /* Response values */
142
143 enum winbindd_result {
144         WINBINDD_ERROR,
145         WINBINDD_OK
146 };
147
148 /* Winbind response structure */
149
150 struct winbindd_response {
151     
152         /* Header information */
153
154         uint32 length;                        /* Length of response */
155         enum winbindd_result result;          /* Result code */
156
157         /* Fixed length return data */
158         
159         union {
160                 int interface_version;  /* Try to ensure this is always in the same spot... */
161                 
162                 /* getpwnam, getpwuid */
163                 
164                 struct winbindd_pw {
165                         fstring pw_name;
166                         fstring pw_passwd;
167                         uid_t pw_uid;
168                         gid_t pw_gid;
169                         fstring pw_gecos;
170                         fstring pw_dir;
171                         fstring pw_shell;
172                 } pw;
173
174                 /* getgrnam, getgrgid */
175
176                 struct winbindd_gr {
177                         fstring gr_name;
178                         fstring gr_passwd;
179                         gid_t gr_gid;
180                         int num_gr_mem;
181                         int gr_mem_ofs;   /* offset to group membership */
182                 } gr;
183
184                 uint32 num_entries; /* getpwent, getgrent */
185                 struct winbindd_sid {
186                         fstring sid;        /* lookupname, [ug]id_to_sid */
187                         int type;
188                 } sid;
189                 struct winbindd_name {
190                         fstring dom_name;       /* lookupsid */
191                         fstring name;       
192                         int type;
193                 } name;
194                 uid_t uid;          /* sid_to_uid */
195                 gid_t gid;          /* sid_to_gid */
196                 struct winbindd_info {
197                         char winbind_separator;
198                         fstring samba_version;
199                 } info;
200                 fstring domain_name;
201         } data;
202
203         /* Variable length return data */
204
205         void *extra_data;               /* getgrnam, getgrgid, getgrent */
206 };
207
208 #endif