2 Unix SMB/CIFS implementation.
3 Main winbindd samba3 server routines
5 Copyright (C) Stefan Metzmacher 2005
6 Copyright (C) Volker Lendecke 2005
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program 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
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 #include "nsswitch/winbindd_nss.h"
25 #include "winbind/wb_server.h"
26 #include "winbind/wb_samba3_protocol.h"
28 uint32_t wbsrv_samba3_packet_length(DATA_BLOB blob)
30 uint32_t *len = (uint32_t *)blob.data;
34 NTSTATUS wbsrv_samba3_pull_request(DATA_BLOB blob, TALLOC_CTX *mem_ctx,
35 struct wbsrv_call **_call)
37 struct wbsrv_call *call;
38 struct wbsrv_samba3_call *s3_call;
40 if (blob.length != sizeof(s3_call->request)) {
41 DEBUG(0,("wbsrv_samba3_pull_request: invalid blob length %lu should be %lu\n"
42 " make sure you use the correct winbind client tools!\n",
43 (long)blob.length, (long)sizeof(s3_call->request)));
44 return NT_STATUS_INVALID_PARAMETER;
47 call = talloc_zero(mem_ctx, struct wbsrv_call);
48 NT_STATUS_HAVE_NO_MEMORY(call);
50 s3_call = talloc_zero(call, struct wbsrv_samba3_call);
51 NT_STATUS_HAVE_NO_MEMORY(s3_call);
54 /* the packet layout is the same as the in memory layout of the request, so just copy it */
55 memcpy(&s3_call->request, blob.data, sizeof(s3_call->request));
57 call->private_data = s3_call;
63 NTSTATUS wbsrv_samba3_handle_call(struct wbsrv_call *call)
65 struct wbsrv_samba3_call *s3call = talloc_get_type(call->private_data,
66 struct wbsrv_samba3_call);
68 DEBUG(10, ("Got winbind samba3 request %d\n", s3call->request.cmd));
70 s3call->response.length = sizeof(s3call->response);
72 switch(s3call->request.cmd) {
73 case WINBINDD_INTERFACE_VERSION:
74 return wbsrv_samba3_interface_version(s3call);
77 case WINBINDD_CHECK_MACHACC:
78 return wbsrv_samba3_check_machacc(s3call);
82 return wbsrv_samba3_ping(s3call);
85 return wbsrv_samba3_info(s3call);
87 case WINBINDD_DOMAIN_NAME:
88 return wbsrv_samba3_domain_name(s3call);
90 case WINBINDD_NETBIOS_NAME:
91 return wbsrv_samba3_netbios_name(s3call);
93 case WINBINDD_PRIV_PIPE_DIR:
94 return wbsrv_samba3_priv_pipe_dir(s3call);
96 case WINBINDD_LOOKUPNAME:
97 return wbsrv_samba3_lookupname(s3call);
99 case WINBINDD_LOOKUPSID:
100 return wbsrv_samba3_lookupsid(s3call);
102 case WINBINDD_PAM_AUTH:
103 return wbsrv_samba3_pam_auth(s3call);
105 case WINBINDD_PAM_AUTH_CRAP:
106 return wbsrv_samba3_pam_auth_crap(s3call);
108 case WINBINDD_GETDCNAME:
109 return wbsrv_samba3_getdcname(s3call);
111 case WINBINDD_GETUSERDOMGROUPS:
112 return wbsrv_samba3_userdomgroups(s3call);
114 case WINBINDD_GETUSERSIDS:
115 return wbsrv_samba3_usersids(s3call);
117 case WINBINDD_LIST_TRUSTDOM:
118 return wbsrv_samba3_list_trustdom(s3call);
120 /* Unimplemented commands */
122 case WINBINDD_GETPWNAM:
123 case WINBINDD_GETPWUID:
124 case WINBINDD_GETGRNAM:
125 case WINBINDD_GETGRGID:
126 case WINBINDD_GETGROUPS:
127 case WINBINDD_SETPWENT:
128 case WINBINDD_ENDPWENT:
129 case WINBINDD_GETPWENT:
130 case WINBINDD_SETGRENT:
131 case WINBINDD_ENDGRENT:
132 case WINBINDD_GETGRENT:
133 case WINBINDD_PAM_CHAUTHTOK:
134 case WINBINDD_LIST_USERS:
135 case WINBINDD_LIST_GROUPS:
136 case WINBINDD_SID_TO_UID:
137 case WINBINDD_SID_TO_GID:
138 case WINBINDD_UID_TO_SID:
139 case WINBINDD_GID_TO_SID:
140 case WINBINDD_ALLOCATE_RID:
141 case WINBINDD_ALLOCATE_RID_AND_GID:
142 case WINBINDD_CHECK_MACHACC:
143 case WINBINDD_DOMAIN_INFO:
144 case WINBINDD_SHOW_SEQUENCE:
145 case WINBINDD_WINS_BYIP:
146 case WINBINDD_WINS_BYNAME:
147 case WINBINDD_GETGRLST:
148 case WINBINDD_INIT_CONNECTION:
149 case WINBINDD_DUAL_SID2UID:
150 case WINBINDD_DUAL_SID2GID:
151 case WINBINDD_DUAL_IDMAPSET:
152 case WINBINDD_DUAL_UID2NAME:
153 case WINBINDD_DUAL_NAME2UID:
154 case WINBINDD_DUAL_GID2NAME:
155 case WINBINDD_DUAL_NAME2GID:
156 case WINBINDD_DUAL_USERINFO:
157 case WINBINDD_DUAL_GETSIDALIASES:
158 case WINBINDD_NUM_CMDS:
159 DEBUG(10, ("Unimplemented winbind samba3 request %d\n",
160 s3call->request.cmd));
164 s3call->response.result = WINBINDD_ERROR;
168 NTSTATUS wbsrv_samba3_push_reply(struct wbsrv_call *call, TALLOC_CTX *mem_ctx, DATA_BLOB *_blob)
170 struct wbsrv_samba3_call *s3call = talloc_get_type(call->private_data,
171 struct wbsrv_samba3_call);
174 size_t extra_data_len = 0;
176 extra_data = s3call->response.extra_data;
178 extra_data_len = s3call->response.length -
179 sizeof(s3call->response);
182 blob = data_blob_talloc(mem_ctx, NULL, s3call->response.length);
183 NT_STATUS_HAVE_NO_MEMORY(blob.data);
185 /* don't push real pointer values into sockets */
187 s3call->response.extra_data = (void *)0xFFFFFFFF;
189 memcpy(blob.data, &s3call->response, sizeof(s3call->response));
190 /* set back the pointer */
191 s3call->response.extra_data = extra_data;
194 memcpy(blob.data + sizeof(s3call->response), extra_data, extra_data_len);