]> git.samba.org - samba.git/blob - source3/winbindd/winbindd_async.c
8e53892bd83603db3b01d51ae4a72b4c1fc167d9
[samba.git] / source3 / winbindd / winbindd_async.c
1 /* 
2    Unix SMB/CIFS implementation.
3
4    Async helpers for blocking functions
5
6    Copyright (C) Volker Lendecke 2005
7    Copyright (C) Gerald Carter 2006
8
9    This program is free software; you can redistribute it and/or modify
10    it under the terms of the GNU General Public License as published by
11    the Free Software Foundation; either version 3 of the License, or
12    (at your option) any later version.
13
14    This program is distributed in the hope that it will be useful,
15    but WITHOUT ANY WARRANTY; without even the implied warranty of
16    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17    GNU General Public License for more details.
18
19    You should have received a copy of the GNU General Public License
20    along with this program.  If not, see <http://www.gnu.org/licenses/>.
21 */
22
23 #include "includes.h"
24 #include "winbindd.h"
25 #include "../libcli/security/security.h"
26
27 #undef DBGC_CLASS
28 #define DBGC_CLASS DBGC_WINBIND
29
30 bool print_sidlist(TALLOC_CTX *mem_ctx, const struct dom_sid *sids,
31                    uint32_t num_sids, char **result, ssize_t *len)
32 {
33         size_t i;
34         size_t buflen = 0;
35
36         *len = 0;
37         *result = NULL;
38         for (i=0; i<num_sids; i++) {
39                 fstring tmp;
40                 sprintf_append(mem_ctx, result, len, &buflen,
41                                "%s\n", sid_to_fstring(tmp, &sids[i]));
42         }
43
44         if ((num_sids != 0) && (*result == NULL)) {
45                 return False;
46         }
47
48         return True;
49 }
50
51 bool parse_sidlist(TALLOC_CTX *mem_ctx, const char *sidstr,
52                    struct dom_sid **sids, uint32_t *num_sids)
53 {
54         const char *p, *q;
55
56         p = sidstr;
57         if (p == NULL)
58                 return False;
59
60         while (p[0] != '\0') {
61                 fstring tmp;
62                 size_t sidlen;
63                 struct dom_sid sid;
64                 q = strchr(p, '\n');
65                 if (q == NULL) {
66                         DEBUG(0, ("Got invalid sidstr: %s\n", p));
67                         return False;
68                 }
69                 sidlen = PTR_DIFF(q, p);
70                 if (sidlen >= sizeof(tmp)-1) {
71                         return false;
72                 }
73                 memcpy(tmp, p, sidlen);
74                 tmp[sidlen] = '\0';
75                 q += 1;
76                 if (!string_to_sid(&sid, tmp)) {
77                         DEBUG(0, ("Could not parse sid %s\n", p));
78                         return False;
79                 }
80                 if (!NT_STATUS_IS_OK(add_sid_to_array(mem_ctx, &sid, sids,
81                                                       num_sids)))
82                 {
83                         return False;
84                 }
85                 p = q;
86         }
87         return True;
88 }
89
90 enum winbindd_result winbindd_dual_ping(struct winbindd_domain *domain,
91                                         struct winbindd_cli_state *state)
92 {
93         return WINBINDD_OK;
94 }