mirror of
https://github.com/samba-team/samba.git
synced 2024-12-22 13:34:15 +03:00
winbind: Expose WINBINDD_XIDS_TO_SIDS externally
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
This commit is contained in:
parent
e50c1a6648
commit
5cd5ce70a1
@ -53,8 +53,9 @@ typedef char fstring[FSTRING_LEN];
|
||||
* removed WINBINDD_REMOVE_MAPPING
|
||||
* 26: added WINBINDD_DC_INFO
|
||||
* 27: added WINBINDD_LOOKUPSIDS
|
||||
* 28: added WINBINDD_XIDS_TO_SIDS
|
||||
*/
|
||||
#define WINBIND_INTERFACE_VERSION 27
|
||||
#define WINBIND_INTERFACE_VERSION 28
|
||||
|
||||
/* Have to deal with time_t being 4 or 8 bytes due to structure alignment.
|
||||
On a 64bit Linux box, we have to support a constant structure size
|
||||
@ -113,6 +114,7 @@ enum winbindd_cmd {
|
||||
WINBINDD_SID_TO_UID,
|
||||
WINBINDD_SID_TO_GID,
|
||||
WINBINDD_SIDS_TO_XIDS,
|
||||
WINBINDD_XIDS_TO_SIDS,
|
||||
WINBINDD_UID_TO_SID,
|
||||
WINBINDD_GID_TO_SID,
|
||||
|
||||
|
@ -618,6 +618,8 @@ static struct winbindd_async_dispatch_table async_nonpriv_table[] = {
|
||||
winbindd_gid_to_sid_send, winbindd_gid_to_sid_recv },
|
||||
{ WINBINDD_SIDS_TO_XIDS, "SIDS_TO_XIDS",
|
||||
winbindd_sids_to_xids_send, winbindd_sids_to_xids_recv },
|
||||
{ WINBINDD_XIDS_TO_SIDS, "XIDS_TO_SIDS",
|
||||
winbindd_xids_to_sids_send, winbindd_xids_to_sids_recv },
|
||||
{ WINBINDD_GETPWSID, "GETPWSID",
|
||||
winbindd_getpwsid_send, winbindd_getpwsid_recv },
|
||||
{ WINBINDD_GETPWNAM, "GETPWNAM",
|
||||
|
@ -912,6 +912,12 @@ struct tevent_req *wb_xids2sids_send(TALLOC_CTX *mem_ctx,
|
||||
uint32_t num_xids);
|
||||
NTSTATUS wb_xids2sids_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
|
||||
struct dom_sid **sids);
|
||||
struct tevent_req *winbindd_xids_to_sids_send(TALLOC_CTX *mem_ctx,
|
||||
struct tevent_context *ev,
|
||||
struct winbindd_cli_state *cli,
|
||||
struct winbindd_request *request);
|
||||
NTSTATUS winbindd_xids_to_sids_recv(struct tevent_req *req,
|
||||
struct winbindd_response *response);
|
||||
struct tevent_req *winbindd_wins_byip_send(TALLOC_CTX *mem_ctx,
|
||||
struct tevent_context *ev,
|
||||
struct winbindd_cli_state *cli,
|
||||
|
136
source3/winbindd/winbindd_xids_to_sids.c
Normal file
136
source3/winbindd/winbindd_xids_to_sids.c
Normal file
@ -0,0 +1,136 @@
|
||||
/*
|
||||
Unix SMB/CIFS implementation.
|
||||
async implementation of WINBINDD_SIDS_TO_XIDS
|
||||
Copyright (C) Volker Lendecke 2011
|
||||
Copyright (C) Michael Adam 2012
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "includes.h"
|
||||
#include "winbindd.h"
|
||||
#include "../libcli/security/security.h"
|
||||
|
||||
|
||||
struct winbindd_xids_to_sids_state {
|
||||
struct tevent_context *ev;
|
||||
|
||||
struct unixid *xids;
|
||||
uint32_t num_xids;
|
||||
|
||||
struct dom_sid *sids;
|
||||
};
|
||||
|
||||
static void winbindd_xids_to_sids_done(struct tevent_req *subreq);
|
||||
|
||||
struct tevent_req *winbindd_xids_to_sids_send(TALLOC_CTX *mem_ctx,
|
||||
struct tevent_context *ev,
|
||||
struct winbindd_cli_state *cli,
|
||||
struct winbindd_request *request)
|
||||
{
|
||||
struct tevent_req *req, *subreq;
|
||||
struct winbindd_xids_to_sids_state *state;
|
||||
|
||||
req = tevent_req_create(mem_ctx, &state,
|
||||
struct winbindd_xids_to_sids_state);
|
||||
if (req == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
state->ev = ev;
|
||||
|
||||
DEBUG(3, ("xids_to_sids\n"));
|
||||
|
||||
if (request->extra_len == 0) {
|
||||
tevent_req_done(req);
|
||||
return tevent_req_post(req, ev);
|
||||
}
|
||||
if (request->extra_data.data[request->extra_len-1] != '\0') {
|
||||
DEBUG(10, ("Got invalid xids list\n"));
|
||||
tevent_req_nterror(req, NT_STATUS_INVALID_PARAMETER);
|
||||
return tevent_req_post(req, ev);
|
||||
}
|
||||
if (!parse_xidlist(state, request->extra_data.data,
|
||||
&state->xids, &state->num_xids)) {
|
||||
DEBUG(10, ("parse_sidlist failed\n"));
|
||||
tevent_req_nterror(req, NT_STATUS_INVALID_PARAMETER);
|
||||
return tevent_req_post(req, ev);
|
||||
}
|
||||
|
||||
DEBUG(10, ("num_xids: %d\n", (int)state->num_xids));
|
||||
|
||||
subreq = wb_xids2sids_send(state, ev, state->xids, state->num_xids);
|
||||
if (tevent_req_nomem(subreq, req)) {
|
||||
return tevent_req_post(req, ev);
|
||||
}
|
||||
tevent_req_set_callback(subreq, winbindd_xids_to_sids_done, req);
|
||||
return req;
|
||||
}
|
||||
|
||||
static void winbindd_xids_to_sids_done(struct tevent_req *subreq)
|
||||
{
|
||||
struct tevent_req *req = tevent_req_callback_data(
|
||||
subreq, struct tevent_req);
|
||||
struct winbindd_xids_to_sids_state *state = tevent_req_data(
|
||||
req, struct winbindd_xids_to_sids_state);
|
||||
NTSTATUS status;
|
||||
|
||||
status = wb_xids2sids_recv(subreq, state, &state->sids);
|
||||
TALLOC_FREE(subreq);
|
||||
if (tevent_req_nterror(req, status)) {
|
||||
return;
|
||||
}
|
||||
tevent_req_done(req);
|
||||
}
|
||||
|
||||
NTSTATUS winbindd_xids_to_sids_recv(struct tevent_req *req,
|
||||
struct winbindd_response *response)
|
||||
{
|
||||
struct winbindd_xids_to_sids_state *state = tevent_req_data(
|
||||
req, struct winbindd_xids_to_sids_state);
|
||||
NTSTATUS status;
|
||||
char *result = NULL;
|
||||
uint32_t i;
|
||||
|
||||
if (tevent_req_is_nterror(req, &status)) {
|
||||
DEBUG(5, ("Could not convert sids: %s\n", nt_errstr(status)));
|
||||
return status;
|
||||
}
|
||||
|
||||
result = talloc_strdup(response, "");
|
||||
if (result == NULL) {
|
||||
return NT_STATUS_NO_MEMORY;
|
||||
}
|
||||
|
||||
for (i=0; i<state->num_xids; i++) {
|
||||
char sidbuf[DOM_SID_STR_BUFLEN];
|
||||
|
||||
if (is_null_sid(&state->sids[i])) {
|
||||
strlcpy(sidbuf, "-", sizeof(sidbuf));
|
||||
} else {
|
||||
dom_sid_string_buf(&state->sids[i],
|
||||
sidbuf, sizeof(sidbuf));
|
||||
}
|
||||
|
||||
result = talloc_asprintf_append_buffer(
|
||||
result, "%s\n", sidbuf);
|
||||
if (result == NULL) {
|
||||
return NT_STATUS_NO_MEMORY;
|
||||
}
|
||||
}
|
||||
|
||||
response->extra_data.data = result;
|
||||
response->length += talloc_get_size(result);
|
||||
|
||||
return NT_STATUS_OK;
|
||||
}
|
@ -951,6 +951,7 @@ bld.SAMBA3_BINARY('winbindd/winbindd',
|
||||
winbindd/winbindd_uid_to_sid.c
|
||||
winbindd/winbindd_gid_to_sid.c
|
||||
winbindd/winbindd_sids_to_xids.c
|
||||
winbindd/winbindd_xids_to_sids.c
|
||||
winbindd/winbindd_allocate_uid.c
|
||||
winbindd/winbindd_allocate_gid.c
|
||||
winbindd/winbindd_getpwsid.c
|
||||
|
Loading…
Reference in New Issue
Block a user