diff options
author | Volker Lendecke <vlendec@samba.org> | 2004-03-02 14:49:06 +0000 |
---|---|---|
committer | Volker Lendecke <vlendec@samba.org> | 2004-03-02 14:49:06 +0000 |
commit | b5c98c295c1131e805cccbbfbf061cf723b221c3 (patch) | |
tree | aef2482ea467b64297095a45ba98f11169c0d389 /source3/nsswitch/winbindd_acct.c | |
parent | 923a0bed5c6062e620ed3d4ba57c01e6eb86b5b6 (diff) | |
download | samba-b5c98c295c1131e805cccbbfbf061cf723b221c3.tar.gz samba-b5c98c295c1131e805cccbbfbf061cf723b221c3.tar.bz2 samba-b5c98c295c1131e805cccbbfbf061cf723b221c3.zip |
This adds winbind-generated groups showing up in 'getent group'. It is not
very efficient though, it only does one group at a time. Needs improving, but
the structures are not particularly easy to set up, so check in the basically
working part for others to review.
I'm close to saying that I would like to remove aliases from general group
mapping. These can not be reflected correctly in /etc/group, winbind could do
a better job here.
And having aliases only on machines with nss_winbind at least for me is not a
too severe limitation.
Comments?
Volker
(This used to be commit 6cad5bcc280c2964473346cc467423a44cc6a5c2)
Diffstat (limited to 'source3/nsswitch/winbindd_acct.c')
-rw-r--r-- | source3/nsswitch/winbindd_acct.c | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/source3/nsswitch/winbindd_acct.c b/source3/nsswitch/winbindd_acct.c index e8d647614b..28434496ce 100644 --- a/source3/nsswitch/winbindd_acct.c +++ b/source3/nsswitch/winbindd_acct.c @@ -1356,5 +1356,55 @@ enum winbindd_result winbindd_delete_group(struct winbindd_cli_state *state) return ( ret ? WINBINDD_OK : WINBINDD_ERROR ); } +static void add_string_to_array(char *name, char ***names, int *num_names) +{ + *names = Realloc(*names, (*num_names + 1) * sizeof(char **)); + + if (*names == NULL) + return; + + (*names)[*num_names] = name; + *num_names += 1; +} + +/********************************************************************** + List all group names locally defined +**********************************************************************/ + +void wb_list_group_names(char ***names, int *num_names) +{ + TDB_LIST_NODE *nodes, *node; + + if (!winbindd_accountdb_init()) + return; + nodes = tdb_search_keys(account_tdb, acct_groupkey_byname("*")); + node = nodes; + + while (node != NULL) { + char *name = (char *)node->node_key.dptr; + + DEBUG(10, ("Found key %s\n", name)); + + node = node->next; + + /* Skip WBA_GROUP */ + name = strchr(name, '/'); + if (name == NULL) + continue; + name += 1; + + /* Skip NAME */ + name = strchr(name, '/'); + if (name == NULL) + continue; + name += 1; + + DEBUG(10, ("adding %s\n", name)); + + add_string_to_array(strdup(name), names, num_names); + } + + tdb_search_list_free(nodes); +} |