From a22a53ea44c18378481d3a432fb0e667117da5bd Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 23 Mar 2011 14:57:08 +0100 Subject: s3-passdb: move util_builtin.c out of passdb. Guenther --- source3/Makefile.in | 2 +- source3/lib/util_builtin.c | 124 +++++++++++++++++++++++++++++++++++++++++ source3/passdb/util_builtin.c | 125 ------------------------------------------ source3/wscript_build | 2 +- 4 files changed, 126 insertions(+), 127 deletions(-) create mode 100644 source3/lib/util_builtin.c delete mode 100644 source3/passdb/util_builtin.c diff --git a/source3/Makefile.in b/source3/Makefile.in index e6d2d249bc..7544cc1d8c 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -759,7 +759,7 @@ PRIVILEGES_OBJ = lib/privileges.o PASSDB_GET_SET_OBJ = passdb/pdb_get_set.o PASSDB_OBJ = $(PASSDB_GET_SET_OBJ) passdb/passdb.o passdb/pdb_interface.o \ - lib/util_wellknown.o passdb/util_builtin.o passdb/pdb_compat.o \ + lib/util_wellknown.o lib/util_builtin.o passdb/pdb_compat.o \ lib/util_unixsids.o passdb/lookup_sid.o \ passdb/login_cache.o @PDB_STATIC@ \ passdb/account_pol.o $(PRIVILEGES_OBJ) \ diff --git a/source3/lib/util_builtin.c b/source3/lib/util_builtin.c new file mode 100644 index 0000000000..e1b990619b --- /dev/null +++ b/source3/lib/util_builtin.c @@ -0,0 +1,124 @@ +/* + Unix SMB/CIFS implementation. + Translate BUILTIN names to SIDs and vice versa + Copyright (C) Volker Lendecke 2005 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "includes.h" +#include "passdb.h" +#include "../libcli/security/security.h" + +struct rid_name_map { + uint32 rid; + const char *name; +}; + +static const struct rid_name_map builtin_aliases[] = { + { BUILTIN_RID_ADMINISTRATORS, "Administrators" }, + { BUILTIN_RID_USERS, "Users" }, + { BUILTIN_RID_GUESTS, "Guests" }, + { BUILTIN_RID_POWER_USERS, "Power Users" }, + { BUILTIN_RID_ACCOUNT_OPERATORS, "Account Operators" }, + { BUILTIN_RID_SERVER_OPERATORS, "Server Operators" }, + { BUILTIN_RID_PRINT_OPERATORS, "Print Operators" }, + { BUILTIN_RID_BACKUP_OPERATORS, "Backup Operators" }, + { BUILTIN_RID_REPLICATOR, "Replicator" }, + { BUILTIN_RID_RAS_SERVERS, "RAS Servers" }, + { BUILTIN_RID_PRE_2K_ACCESS, + "Pre-Windows 2000 Compatible Access" }, + { BUILTIN_RID_REMOTE_DESKTOP_USERS, + "Remote Desktop Users" }, + { BUILTIN_RID_NETWORK_CONF_OPERATORS, + "Network Configuration Operators" }, + { BUILTIN_RID_INCOMING_FOREST_TRUST, + "Incoming Forest Trust Builders" }, + { BUILTIN_RID_PERFMON_USERS, + "Performance Monitor Users" }, + { BUILTIN_RID_PERFLOG_USERS, + "Performance Log Users" }, + { BUILTIN_RID_AUTH_ACCESS, + "Windows Authorization Access Group" }, + { BUILTIN_RID_TS_LICENSE_SERVERS, + "Terminal Server License Servers" }, + { 0, NULL}}; + +/******************************************************************* + Look up a rid in the BUILTIN domain + ********************************************************************/ +bool lookup_builtin_rid(TALLOC_CTX *mem_ctx, uint32 rid, const char **name) +{ + const struct rid_name_map *aliases = builtin_aliases; + + while (aliases->name != NULL) { + if (rid == aliases->rid) { + *name = talloc_strdup(mem_ctx, aliases->name); + return True; + } + aliases++; + } + + return False; +} + +/******************************************************************* + Look up a name in the BUILTIN domain + ********************************************************************/ +bool lookup_builtin_name(const char *name, uint32 *rid) +{ + const struct rid_name_map *aliases = builtin_aliases; + + while (aliases->name != NULL) { + if (strequal(name, aliases->name)) { + *rid = aliases->rid; + return True; + } + aliases++; + } + + return False; +} + +/***************************************************************** + Return the name of the BUILTIN domain +*****************************************************************/ + +const char *builtin_domain_name(void) +{ + return "BUILTIN"; +} + +/***************************************************************** + Check if the SID is the builtin SID (S-1-5-32). +*****************************************************************/ + +bool sid_check_is_builtin(const struct dom_sid *sid) +{ + return dom_sid_equal(sid, &global_sid_Builtin); +} + +/***************************************************************** + Check if the SID is one of the builtin SIDs (S-1-5-32-a). +*****************************************************************/ + +bool sid_check_is_in_builtin(const struct dom_sid *sid) +{ + struct dom_sid dom_sid; + + sid_copy(&dom_sid, sid); + sid_split_rid(&dom_sid, NULL); + + return sid_check_is_builtin(&dom_sid); +} diff --git a/source3/passdb/util_builtin.c b/source3/passdb/util_builtin.c deleted file mode 100644 index d37b8edff4..0000000000 --- a/source3/passdb/util_builtin.c +++ /dev/null @@ -1,125 +0,0 @@ -/* - Unix SMB/CIFS implementation. - Translate BUILTIN names to SIDs and vice versa - Copyright (C) Volker Lendecke 2005 - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "includes.h" -#include "passdb.h" -#include "../libcli/security/security.h" - -struct rid_name_map { - uint32 rid; - const char *name; -}; - -static const struct rid_name_map builtin_aliases[] = { - { BUILTIN_RID_ADMINISTRATORS, "Administrators" }, - { BUILTIN_RID_USERS, "Users" }, - { BUILTIN_RID_GUESTS, "Guests" }, - { BUILTIN_RID_POWER_USERS, "Power Users" }, - { BUILTIN_RID_ACCOUNT_OPERATORS, "Account Operators" }, - { BUILTIN_RID_SERVER_OPERATORS, "Server Operators" }, - { BUILTIN_RID_PRINT_OPERATORS, "Print Operators" }, - { BUILTIN_RID_BACKUP_OPERATORS, "Backup Operators" }, - { BUILTIN_RID_REPLICATOR, "Replicator" }, - { BUILTIN_RID_RAS_SERVERS, "RAS Servers" }, - { BUILTIN_RID_PRE_2K_ACCESS, - "Pre-Windows 2000 Compatible Access" }, - { BUILTIN_RID_REMOTE_DESKTOP_USERS, - "Remote Desktop Users" }, - { BUILTIN_RID_NETWORK_CONF_OPERATORS, - "Network Configuration Operators" }, - { BUILTIN_RID_INCOMING_FOREST_TRUST, - "Incoming Forest Trust Builders" }, - { BUILTIN_RID_PERFMON_USERS, - "Performance Monitor Users" }, - { BUILTIN_RID_PERFLOG_USERS, - "Performance Log Users" }, - { BUILTIN_RID_AUTH_ACCESS, - "Windows Authorization Access Group" }, - { BUILTIN_RID_TS_LICENSE_SERVERS, - "Terminal Server License Servers" }, - { 0, NULL}}; - -/******************************************************************* - Look up a rid in the BUILTIN domain - ********************************************************************/ -bool lookup_builtin_rid(TALLOC_CTX *mem_ctx, uint32 rid, const char **name) -{ - const struct rid_name_map *aliases = builtin_aliases; - - while (aliases->name != NULL) { - if (rid == aliases->rid) { - *name = talloc_strdup(mem_ctx, aliases->name); - return True; - } - aliases++; - } - - return False; -} - -/******************************************************************* - Look up a name in the BUILTIN domain - ********************************************************************/ -bool lookup_builtin_name(const char *name, uint32 *rid) -{ - const struct rid_name_map *aliases = builtin_aliases; - - while (aliases->name != NULL) { - if (strequal(name, aliases->name)) { - *rid = aliases->rid; - return True; - } - aliases++; - } - - return False; -} - -/***************************************************************** - Return the name of the BUILTIN domain -*****************************************************************/ - -const char *builtin_domain_name(void) -{ - return "BUILTIN"; -} - -/***************************************************************** - Check if the SID is the builtin SID (S-1-5-32). -*****************************************************************/ - -bool sid_check_is_builtin(const struct dom_sid *sid) -{ - return dom_sid_equal(sid, &global_sid_Builtin); -} - -/***************************************************************** - Check if the SID is one of the builtin SIDs (S-1-5-32-a). -*****************************************************************/ - -bool sid_check_is_in_builtin(const struct dom_sid *sid) -{ - struct dom_sid dom_sid; - - sid_copy(&dom_sid, sid); - sid_split_rid(&dom_sid, NULL); - - return sid_check_is_builtin(&dom_sid); -} - diff --git a/source3/wscript_build b/source3/wscript_build index c03a6737bb..9a3c88a9e6 100755 --- a/source3/wscript_build +++ b/source3/wscript_build @@ -227,7 +227,7 @@ PRIVILEGES_SRC = '''lib/privileges.c''' PASSDB_GET_SET_SRC = '''passdb/pdb_get_set.c''' PASSDB_SRC = '''${PASSDB_GET_SET_SRC} passdb/passdb.c - lib/util_wellknown.c passdb/util_builtin.c passdb/pdb_compat.c + lib/util_wellknown.c lib/util_builtin.c passdb/pdb_compat.c lib/util_unixsids.c passdb/lookup_sid.c passdb/login_cache.c passdb/account_pol.c ${PRIVILEGES_SRC} -- cgit