mirror of
https://github.com/samba-team/samba.git
synced 2025-01-11 05:18:09 +03:00
winbindd: remove unused WINBINDD_DUMP_MAPS support
Also the design of this function was really bad,
instead do the dump into a file, the client should get
back the list of mappings.
metze
(This used to be commit ce7fe8acf4
)
This commit is contained in:
parent
3728c8b6d9
commit
38f8d32d10
@ -405,24 +405,6 @@ bool winbind_sids_to_unixids(struct id_map *ids, int num_ids)
|
||||
return (result == NSS_STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
bool winbind_idmap_dump_maps(TALLOC_CTX *memctx, const char *file)
|
||||
{
|
||||
struct winbindd_request request;
|
||||
struct winbindd_response response;
|
||||
int result;
|
||||
|
||||
ZERO_STRUCT(request);
|
||||
ZERO_STRUCT(response);
|
||||
|
||||
request.extra_data.data = SMB_STRDUP(file);
|
||||
request.extra_len = strlen(request.extra_data.data) + 1;
|
||||
|
||||
result = winbindd_request_response(WINBINDD_DUMP_MAPS, &request, &response);
|
||||
|
||||
SAFE_FREE(request.extra_data.data);
|
||||
return (result == NSS_STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
bool winbind_allocate_uid(uid_t *uid)
|
||||
{
|
||||
struct winbindd_request request;
|
||||
|
@ -108,8 +108,6 @@ enum winbindd_cmd {
|
||||
|
||||
/* Miscellaneous other stuff */
|
||||
|
||||
WINBINDD_DUMP_MAPS,
|
||||
|
||||
WINBINDD_CHECK_MACHACC, /* Check machine account pw works */
|
||||
WINBINDD_PING, /* Just tell me winbind is running */
|
||||
WINBINDD_INFO, /* Various bit of info. Currently just tidbits */
|
||||
@ -153,7 +151,6 @@ enum winbindd_cmd {
|
||||
WINBINDD_DUAL_GID2SID,
|
||||
WINBINDD_DUAL_SET_MAPPING,
|
||||
WINBINDD_DUAL_SET_HWM,
|
||||
WINBINDD_DUAL_DUMP_MAPS,
|
||||
|
||||
/* Wrapper around possibly blocking unix nss calls */
|
||||
WINBINDD_DUAL_USERINFO,
|
||||
|
@ -1486,73 +1486,6 @@ done:
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
Dump backend status.
|
||||
**************************************************************************/
|
||||
|
||||
void idmap_dump_maps(const char *logfile)
|
||||
{
|
||||
NTSTATUS ret;
|
||||
struct unixid allid;
|
||||
struct id_map *maps;
|
||||
int num_maps;
|
||||
FILE *dump;
|
||||
int i;
|
||||
|
||||
if (! NT_STATUS_IS_OK(ret = idmap_init())) {
|
||||
return;
|
||||
}
|
||||
|
||||
dump = fopen(logfile, "w");
|
||||
if ( ! dump) {
|
||||
DEBUG(0, ("Unable to open open stream for file [%s], "
|
||||
"errno: %d\n", logfile, errno));
|
||||
return;
|
||||
}
|
||||
|
||||
if (NT_STATUS_IS_OK(ret = idmap_alloc_init())) {
|
||||
allid.type = ID_TYPE_UID;
|
||||
allid.id = 0;
|
||||
idmap_alloc_ctx->methods->get_id_hwm(&allid);
|
||||
fprintf(dump, "USER HWM %lu\n", (unsigned long)allid.id);
|
||||
|
||||
allid.type = ID_TYPE_GID;
|
||||
allid.id = 0;
|
||||
idmap_alloc_ctx->methods->get_id_hwm(&allid);
|
||||
fprintf(dump, "GROUP HWM %lu\n", (unsigned long)allid.id);
|
||||
}
|
||||
|
||||
maps = talloc(idmap_ctx, struct id_map);
|
||||
num_maps = 0;
|
||||
|
||||
for (i = 0; i < num_domains; i++) {
|
||||
if (idmap_domains[i]->methods->dump_data) {
|
||||
idmap_domains[i]->methods->dump_data(idmap_domains[i],
|
||||
&maps, &num_maps);
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < num_maps; i++) {
|
||||
switch (maps[i].xid.type) {
|
||||
case ID_TYPE_UID:
|
||||
fprintf(dump, "UID %lu %s\n",
|
||||
(unsigned long)maps[i].xid.id,
|
||||
sid_string_static(maps[i].sid));
|
||||
break;
|
||||
case ID_TYPE_GID:
|
||||
fprintf(dump, "GID %lu %s\n",
|
||||
(unsigned long)maps[i].xid.id,
|
||||
sid_string_static(maps[i].sid));
|
||||
break;
|
||||
case ID_TYPE_NOT_SPECIFIED:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
fflush(dump);
|
||||
fclose(dump);
|
||||
}
|
||||
|
||||
char *idmap_fetch_secret(const char *backend, bool alloc,
|
||||
const char *domain, const char *identity)
|
||||
{
|
||||
|
@ -331,8 +331,6 @@ static struct winbindd_dispatch_table {
|
||||
|
||||
/* Miscellaneous */
|
||||
|
||||
{ WINBINDD_DUMP_MAPS, winbindd_dump_maps, "DUMP_MAPS" },
|
||||
|
||||
{ WINBINDD_CHECK_MACHACC, winbindd_check_machine_acct, "CHECK_MACHACC" },
|
||||
{ WINBINDD_PING, winbindd_ping, "PING" },
|
||||
{ WINBINDD_INFO, winbindd_info, "INFO" },
|
||||
|
@ -511,51 +511,6 @@ enum winbindd_result winbindd_dual_gid2sid(struct winbindd_domain *domain,
|
||||
return WINBINDD_ERROR;
|
||||
}
|
||||
|
||||
static void winbindd_dump_id_maps_recv(TALLOC_CTX *mem_ctx, bool success,
|
||||
struct winbindd_response *response,
|
||||
void *c, void *private_data)
|
||||
{
|
||||
void (*cont)(void *priv, bool succ) =
|
||||
(void (*)(void *, bool))c;
|
||||
|
||||
if (!success) {
|
||||
DEBUG(5, ("Could not trigger a map dump\n"));
|
||||
cont(private_data, False);
|
||||
return;
|
||||
}
|
||||
|
||||
if (response->result != WINBINDD_OK) {
|
||||
DEBUG(5, ("idmap dump maps returned an error\n"));
|
||||
cont(private_data, False);
|
||||
return;
|
||||
}
|
||||
|
||||
cont(private_data, True);
|
||||
}
|
||||
|
||||
void winbindd_dump_maps_async(TALLOC_CTX *mem_ctx, const char *logfile,
|
||||
void (*cont)(void *private_data, bool success),
|
||||
void *private_data)
|
||||
{
|
||||
struct winbindd_request request;
|
||||
ZERO_STRUCT(request);
|
||||
request.cmd = WINBINDD_DUAL_DUMP_MAPS;
|
||||
request.extra_data.data = discard_const(logfile);
|
||||
request.extra_len = strlen(logfile)+1;
|
||||
do_async(mem_ctx, idmap_child(), &request, winbindd_dump_id_maps_recv,
|
||||
(void *)cont, private_data);
|
||||
}
|
||||
|
||||
enum winbindd_result winbindd_dual_dump_maps(struct winbindd_domain *domain,
|
||||
struct winbindd_cli_state *state)
|
||||
{
|
||||
DEBUG(3, ("[%5lu]: dual dump maps\n", (unsigned long)state->pid));
|
||||
|
||||
idmap_dump_maps((char *)state->request.extra_data.data);
|
||||
|
||||
return WINBINDD_OK;
|
||||
}
|
||||
|
||||
static const struct winbindd_child_dispatch_table idmap_dispatch_table[] = {
|
||||
{
|
||||
.name = "DUAL_SID2UID",
|
||||
@ -587,10 +542,6 @@ static const struct winbindd_child_dispatch_table idmap_dispatch_table[] = {
|
||||
.name = "DUAL_SET_HWMS",
|
||||
.struct_cmd = WINBINDD_DUAL_SET_HWM,
|
||||
.struct_fn = winbindd_dual_set_hwm,
|
||||
},{
|
||||
.name = "DUAL_DUMP_MAPS",
|
||||
.struct_cmd = WINBINDD_DUAL_DUMP_MAPS,
|
||||
.struct_fn = winbindd_dual_dump_maps,
|
||||
},{
|
||||
.name = "ALLOCATE_UID",
|
||||
.struct_cmd = WINBINDD_ALLOCATE_UID,
|
||||
|
@ -515,42 +515,3 @@ enum winbindd_result winbindd_dual_allocate_gid(struct winbindd_domain *domain,
|
||||
state->response.data.gid = xid.id;
|
||||
return WINBINDD_OK;
|
||||
}
|
||||
|
||||
static void dump_maps_recv(void *private_data, bool success)
|
||||
{
|
||||
struct winbindd_cli_state *state =
|
||||
talloc_get_type_abort(private_data, struct winbindd_cli_state);
|
||||
|
||||
if (!success) {
|
||||
DEBUG(5, ("Could not dump maps\n"));
|
||||
request_error(state);
|
||||
return;
|
||||
}
|
||||
|
||||
request_ok(state);
|
||||
}
|
||||
|
||||
void winbindd_dump_maps(struct winbindd_cli_state *state)
|
||||
{
|
||||
const char *logfile;
|
||||
|
||||
if ( ! state->privileged) {
|
||||
DEBUG(0, ("Only root is allowed to ask for an idmap dump!\n"));
|
||||
request_error(state);
|
||||
return;
|
||||
}
|
||||
|
||||
DEBUG(3, ("[%5lu]: dump maps\n", (unsigned long)state->pid));
|
||||
|
||||
logfile = talloc_strndup(state->mem_ctx,
|
||||
(const char *)state->request.extra_data.data,
|
||||
state->request.extra_len);
|
||||
if (!logfile) {
|
||||
request_error(state);
|
||||
return;
|
||||
}
|
||||
|
||||
winbindd_dump_maps_async(state->mem_ctx, logfile,
|
||||
dump_maps_recv, state);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user