bc058b4c4210884f8134e5285325973e3bb7fa73
[sfrench/samba-autobuild/.git] / source3 / winbindd / winbindd_sid.c
1 /* 
2    Unix SMB/CIFS implementation.
3
4    Winbind daemon - sid related functions
5
6    Copyright (C) Tim Potter 2000
7    
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.
12    
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.
17    
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/>.
20 */
21
22 #include "includes.h"
23 #include "winbindd.h"
24
25 #undef DBGC_CLASS
26 #define DBGC_CLASS DBGC_WINBIND
27
28 static void set_hwm_recv(void *private_data, bool success)
29 {
30         struct winbindd_cli_state *state =
31                 talloc_get_type_abort(private_data, struct winbindd_cli_state);
32
33         if (!success) {
34                 DEBUG(5, ("Could not set sid mapping\n"));
35                 request_error(state);
36                 return;
37         }
38
39         request_ok(state);
40 }
41
42 void winbindd_set_hwm(struct winbindd_cli_state *state)
43 {
44         struct unixid xid;
45
46         DEBUG(3, ("[%5lu]: set hwm\n", (unsigned long)state->pid));
47
48         if ( ! state->privileged) {
49                 DEBUG(0, ("Only root is allowed to set mappings!\n"));
50                 request_error(state);
51                 return;
52         }
53
54         xid.id = state->request->data.dual_idmapset.id;
55         xid.type = state->request->data.dual_idmapset.type;
56
57         winbindd_set_hwm_async(state->mem_ctx, &xid, set_hwm_recv, state);
58 }