s3:winbind: Convert WINBINDD_SET_MAPPING to the new API
[Samba/aatanasov.git] / source3 / winbindd / winbindd_sid.c
blob5c9bb4dba9fcca73b4ce00fa2d6d67de03ff8f38
1 /*
2 Unix SMB/CIFS implementation.
4 Winbind daemon - sid related functions
6 Copyright (C) Tim Potter 2000
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 3 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, see <http://www.gnu.org/licenses/>.
22 #include "includes.h"
23 #include "winbindd.h"
25 #undef DBGC_CLASS
26 #define DBGC_CLASS DBGC_WINBIND
28 static void remove_mapping_recv(void *private_data, bool success)
30 struct winbindd_cli_state *state =
31 talloc_get_type_abort(private_data, struct winbindd_cli_state);
33 if (!success) {
34 DEBUG(5, ("Could not remove sid mapping\n"));
35 request_error(state);
36 return;
39 request_ok(state);
42 void winbindd_remove_mapping(struct winbindd_cli_state *state)
44 struct id_map map;
45 DOM_SID sid;
47 DEBUG(3, ("[%5lu]: remove id map\n", (unsigned long)state->pid));
49 if ( ! state->privileged) {
50 DEBUG(0, ("Only root is allowed to remove mappings!\n"));
51 request_error(state);
52 return;
55 if (!string_to_sid(&sid, state->request->data.dual_idmapset.sid)) {
56 DEBUG(1, ("Could not get convert sid %s from string\n",
57 state->request->data.sid));
58 request_error(state);
59 return;
62 map.sid = &sid;
63 map.xid.id = state->request->data.dual_idmapset.id;
64 map.xid.type = state->request->data.dual_idmapset.type;
66 winbindd_remove_mapping_async(state->mem_ctx, &map,
67 remove_mapping_recv, state);
70 static void set_hwm_recv(void *private_data, bool success)
72 struct winbindd_cli_state *state =
73 talloc_get_type_abort(private_data, struct winbindd_cli_state);
75 if (!success) {
76 DEBUG(5, ("Could not set sid mapping\n"));
77 request_error(state);
78 return;
81 request_ok(state);
84 void winbindd_set_hwm(struct winbindd_cli_state *state)
86 struct unixid xid;
88 DEBUG(3, ("[%5lu]: set hwm\n", (unsigned long)state->pid));
90 if ( ! state->privileged) {
91 DEBUG(0, ("Only root is allowed to set mappings!\n"));
92 request_error(state);
93 return;
96 xid.id = state->request->data.dual_idmapset.id;
97 xid.type = state->request->data.dual_idmapset.type;
99 winbindd_set_hwm_async(state->mem_ctx, &xid, set_hwm_recv, state);