Added another authentication interface to winbindd. The Challenge Response
[abartlet/samba.git/.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 _WINBINDD_NTDOM_H
26 #define _WINBINDD_NTDOM_H
27
28 #define WINBINDD_SOCKET_NAME "pipe"            /* Name of PF_UNIX socket */
29 #define WINBINDD_SOCKET_DIR  "/tmp/.winbindd"  /* Name of PF_UNIX dir */
30
31 #define WINBINDD_DOMAIN_ENV  "WINBINDD_DOMAIN" /* Environment variables */
32 #define WINBINDD_DONT_ENV    "_NO_WINBINDD"
33
34 /* Socket commands */
35
36 enum winbindd_cmd {
37
38         /* Get users and groups */
39
40         WINBINDD_GETPWNAM_FROM_USER,
41         WINBINDD_GETPWNAM_FROM_UID,
42         WINBINDD_GETGRNAM_FROM_GROUP,
43         WINBINDD_GETGRNAM_FROM_GID,
44         WINBINDD_GETGROUPS,
45
46         /* Enumerate users and groups */
47
48         WINBINDD_SETPWENT,
49         WINBINDD_ENDPWENT,
50         WINBINDD_GETPWENT,
51         WINBINDD_SETGRENT,
52         WINBINDD_ENDGRENT,
53         WINBINDD_GETGRENT,
54
55         /* PAM authenticate and password change */
56
57         WINBINDD_PAM_AUTH,
58         WINBINDD_PAM_AUTH_CRAP,
59         WINBINDD_PAM_CHAUTHTOK,
60
61         /* List various things */
62
63         WINBINDD_LIST_USERS,         /* List w/o rid->id mapping */
64         WINBINDD_LIST_GROUPS,        /* Ditto */
65         WINBINDD_LIST_TRUSTDOM,
66
67         /* SID conversion */
68
69         WINBINDD_LOOKUPSID,
70         WINBINDD_LOOKUPNAME,
71
72         /* S*RS functions */
73
74         WINBINDD_SID_TO_UID,       
75         WINBINDD_SID_TO_GID,
76         WINBINDD_UID_TO_SID,
77         WINBINDD_GID_TO_SID,
78
79         /* Miscellaneous other stuff */
80
81         WINBINDD_CHECK_MACHACC,     /* Check machine account pw works */
82
83         /* Placeholder for end of cmd list */
84
85         WINBINDD_NUM_CMDS
86 };
87
88 /* Winbind request structure */
89
90 struct winbindd_request {
91         enum winbindd_cmd cmd;   /* Winbindd command to execute */
92         pid_t pid;               /* pid of calling process */
93
94         union {
95                 fstring username;    /* getpwnam */
96                 fstring groupname;   /* getgrnam */
97                 uid_t uid;           /* getpwuid, uid_to_sid */
98                 gid_t gid;           /* getgrgid, gid_to_sid */
99                 struct {
100                         fstring user;
101                         fstring pass;
102                 } auth;              /* pam_winbind auth module */
103                 struct {
104                         char chal[8];
105                         fstring user;
106                         fstring lm_resp;
107                         uint16 lm_resp_len;
108                         fstring nt_resp;
109                         uint16 nt_resp_len;
110                 } auth_crap;
111                 struct {
112                     fstring user;
113                     fstring oldpass;
114                     fstring newpass;
115                 } chauthtok;         /* pam_winbind passwd module */
116                 fstring sid;         /* lookupsid, sid_to_[ug]id */
117                 fstring name;        /* lookupname */
118                 uint32 num_entries;  /* getpwent, getgrent */
119         } data;
120         fstring domain;      /* {set,get,end}{pw,gr}ent() */
121 };
122
123 /* Response values */
124
125 enum winbindd_result {
126         WINBINDD_ERROR,
127         WINBINDD_OK
128 };
129
130 /* Winbind response structure */
131
132 struct winbindd_response {
133     
134         /* Header information */
135
136         int length;                           /* Length of response */
137         enum winbindd_result result;          /* Result code */
138
139         /* Fixed length return data */
140         
141         union {
142                 
143                 /* getpwnam, getpwuid */
144                 
145                 struct winbindd_pw {
146                         fstring pw_name;
147                         fstring pw_passwd;
148                         uid_t pw_uid;
149                         gid_t pw_gid;
150                         fstring pw_gecos;
151                         fstring pw_dir;
152                         fstring pw_shell;
153                 } pw;
154
155                 /* getgrnam, getgrgid */
156
157                 struct winbindd_gr {
158                         fstring gr_name;
159                         fstring gr_passwd;
160                         gid_t gr_gid;
161                         int num_gr_mem;
162                         int gr_mem_ofs;   /* offset to group membership */
163                 } gr;
164
165                 uint32 num_entries; /* getpwent, getgrent */
166                 struct {
167                         fstring sid;        /* lookupname, [ug]id_to_sid */
168                         int type;
169                 } sid;
170                 struct {
171                         fstring name;       /* lookupsid */
172                         int type;
173                 } name;
174                 uid_t uid;          /* sid_to_uid */
175                 gid_t gid;          /* sid_to_gid */
176         } data;
177
178         /* Variable length return data */
179
180         void *extra_data;               /* getgrnam, getgrgid, getgrent */
181 };
182
183 #endif