From 05ac2de0df78d22ad5afb42ea5c72ba17bef8395 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 3 Dec 2005 18:34:13 +0000 Subject: r12051: Merge across the lookup_name and lookup_sid work. Lets see how the build farm reacts :-) Volker (This used to be commit 9f99d04a54588cd9d1a1ab163ebb304437f932f7) --- source3/passdb/util_wellknown.c | 149 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 149 insertions(+) create mode 100644 source3/passdb/util_wellknown.c (limited to 'source3/passdb/util_wellknown.c') diff --git a/source3/passdb/util_wellknown.c b/source3/passdb/util_wellknown.c new file mode 100644 index 0000000000..b1eb8b4237 --- /dev/null +++ b/source3/passdb/util_wellknown.c @@ -0,0 +1,149 @@ +/* + Unix SMB/CIFS implementation. + Lookup routines for well-known SIDs + Copyright (C) Andrew Tridgell 1992-1998 + Copyright (C) Luke Kenneth Caseson Leighton 1998-1999 + Copyright (C) Jeremy Allison 1999 + 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 2 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, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "includes.h" + +struct rid_name_map { + uint32 rid; + const char *name; +}; + +struct sid_name_map_info +{ + const DOM_SID *sid; + const char *name; + const struct rid_name_map *known_users; +}; + +static const struct rid_name_map everyone_users[] = { + { 0, "Everyone" }, + { 0, NULL}}; + +static const struct rid_name_map creator_owner_users[] = { + { 0, "Creator Owner" }, + { 1, "Creator Group" }, + { 0, NULL}}; + +static const struct rid_name_map nt_authority_users[] = { + { 1, "Dialup" }, + { 2, "Network"}, + { 3, "Batch"}, + { 4, "Interactive"}, + { 6, "Service"}, + { 7, "AnonymousLogon"}, + { 8, "Proxy"}, + { 9, "ServerLogon"}, + { 10, "Self"}, + { 11, "Authenticated Users"}, + { 12, "Restricted"}, + { 13, "Terminal Server User"}, + { 14, "Remote Interactive Logon"}, + { 15, "This Organization"}, + { 18, "SYSTEM"}, + { 19, "Local Service"}, + { 20, "Network Service"}, + { 0, NULL}}; + +static struct sid_name_map_info special_domains[] = { + { &global_sid_World_Domain, "", everyone_users }, + { &global_sid_Creator_Owner_Domain, "", creator_owner_users }, + { &global_sid_NT_Authority, "NT Authority", nt_authority_users }, + { NULL, NULL, NULL }}; + +/************************************************************************** + Looks up a known username from one of the known domains. +***************************************************************************/ + +BOOL lookup_wellknown_sid(TALLOC_CTX *mem_ctx, const DOM_SID *sid, + char **domain, char **name) +{ + int i; + DOM_SID dom_sid; + uint32 rid; + const struct rid_name_map *users = NULL; + + sid_copy(&dom_sid, sid); + if (!sid_split_rid(&dom_sid, &rid)) { + DEBUG(2, ("Could not split rid from SID\n")); + return False; + } + + for (i=0; special_domains[i].sid != NULL; i++) { + if (sid_equal(&dom_sid, special_domains[i].sid)) { + *domain = talloc_strdup(mem_ctx, + special_domains[i].name); + users = special_domains[i].known_users; + break; + } + } + + if (users == NULL) { + DEBUG(10, ("SID %s is no special sid\n", + sid_string_static(sid))); + return False; + } + + for (i=0; users[i].name != NULL; i++) { + if (rid == users[i].rid) { + *name = talloc_strdup(mem_ctx, users[i].name); + return True; + } + } + + DEBUG(10, ("RID of special SID %s not found\n", + sid_string_static(sid))); + + return False; +} + +/************************************************************************** + Try and map a name to one of the well known SIDs. +***************************************************************************/ + +BOOL lookup_wellknown_name(TALLOC_CTX *mem_ctx, const char *name, + DOM_SID *sid, char **domain) +{ + int i, j; + + DEBUG(10,("map_name_to_wellknown_sid: looking up %s\n", name)); + + for (i=0; special_domains[i].sid != NULL; i++) { + const struct rid_name_map *users = + special_domains[i].known_users; + + if (users == NULL) + continue; + + for (j=0; users[j].name != NULL; j++) { + if ( strequal(users[j].name, name) ) { + sid_copy(sid, special_domains[i].sid); + sid_append_rid(sid, users[j].rid); + *domain = talloc_strdup( + mem_ctx, special_domains[i].name); + return True; + } + } + } + + return False; +} -- cgit From 661c5c741a5285a5ddf8c1fc74ba50335f1c1931 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 10 Dec 2005 11:22:01 +0000 Subject: r12163: Change lookup_sid and lookup_name to return const char * instead of char *, use a temporary talloc_ctx for clarity. Volker (This used to be commit b15815c804bf3e558ed6357b5e9a6e3e0fac777f) --- source3/passdb/util_wellknown.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/passdb/util_wellknown.c') diff --git a/source3/passdb/util_wellknown.c b/source3/passdb/util_wellknown.c index b1eb8b4237..8caae3b2a0 100644 --- a/source3/passdb/util_wellknown.c +++ b/source3/passdb/util_wellknown.c @@ -75,7 +75,7 @@ static struct sid_name_map_info special_domains[] = { ***************************************************************************/ BOOL lookup_wellknown_sid(TALLOC_CTX *mem_ctx, const DOM_SID *sid, - char **domain, char **name) + const char **domain, const char **name) { int i; DOM_SID dom_sid; @@ -121,7 +121,7 @@ BOOL lookup_wellknown_sid(TALLOC_CTX *mem_ctx, const DOM_SID *sid, ***************************************************************************/ BOOL lookup_wellknown_name(TALLOC_CTX *mem_ctx, const char *name, - DOM_SID *sid, char **domain) + DOM_SID *sid, const char **domain) { int i, j; -- cgit From 0af1500fc0bafe61019f1b2ab1d9e1d369221240 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 3 Feb 2006 22:19:41 +0000 Subject: r13316: Let the carnage begin.... Sync with trunk as off r13315 (This used to be commit 17e63ac4ed8325c0d44fe62b2442449f3298559f) --- source3/passdb/util_wellknown.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'source3/passdb/util_wellknown.c') diff --git a/source3/passdb/util_wellknown.c b/source3/passdb/util_wellknown.c index 8caae3b2a0..be3cf37446 100644 --- a/source3/passdb/util_wellknown.c +++ b/source3/passdb/util_wellknown.c @@ -70,6 +70,21 @@ static struct sid_name_map_info special_domains[] = { { &global_sid_NT_Authority, "NT Authority", nt_authority_users }, { NULL, NULL, NULL }}; +BOOL sid_check_is_wellknown_domain(const DOM_SID *sid, const char **name) +{ + int i; + + for (i=0; special_domains[i].sid != NULL; i++) { + if (sid_equal(sid, special_domains[i].sid)) { + if (name != NULL) { + *name = special_domains[i].name; + } + return True; + } + } + return False; +} + /************************************************************************** Looks up a known username from one of the known domains. ***************************************************************************/ -- cgit From 30675b36f5e6072fbc4f93270c846e0c5d764254 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Thu, 2 Mar 2006 18:33:43 +0000 Subject: r13791: Having S-1-1-0 show up in winbind lookupsid does not really make sense. Volker (This used to be commit ae9614ce019e25fb29dad8429d93f3140c2f84ad) --- source3/passdb/util_wellknown.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'source3/passdb/util_wellknown.c') diff --git a/source3/passdb/util_wellknown.c b/source3/passdb/util_wellknown.c index be3cf37446..9a6fa7def5 100644 --- a/source3/passdb/util_wellknown.c +++ b/source3/passdb/util_wellknown.c @@ -85,6 +85,17 @@ BOOL sid_check_is_wellknown_domain(const DOM_SID *sid, const char **name) return False; } +BOOL sid_check_is_in_wellknown_domain(const DOM_SID *sid) +{ + DOM_SID dom_sid; + uint32 rid; + + sid_copy(&dom_sid, sid); + sid_split_rid(&dom_sid, &rid); + + return sid_check_is_wellknown_domain(&dom_sid, NULL); +} + /************************************************************************** Looks up a known username from one of the known domains. ***************************************************************************/ -- cgit From d824b98f80ba186030cbb70b3a1e5daf80469ecd Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 9 Jul 2007 19:25:36 +0000 Subject: r23779: Change from v2 or later to v3 or later. Jeremy. (This used to be commit 407e6e695b8366369b7c76af1ff76869b45347b3) --- source3/passdb/util_wellknown.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/passdb/util_wellknown.c') diff --git a/source3/passdb/util_wellknown.c b/source3/passdb/util_wellknown.c index 9a6fa7def5..91e538e192 100644 --- a/source3/passdb/util_wellknown.c +++ b/source3/passdb/util_wellknown.c @@ -8,7 +8,7 @@ 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 2 of the License, or + 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, -- cgit From 5e54558c6dea67b56bbfaba5698f3a434d3dffb6 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 00:52:41 +0000 Subject: r23784: use the GPLv3 boilerplate as recommended by the FSF and the license text (This used to be commit b0132e94fc5fef936aa766fb99a306b3628e9f07) --- source3/passdb/util_wellknown.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source3/passdb/util_wellknown.c') diff --git a/source3/passdb/util_wellknown.c b/source3/passdb/util_wellknown.c index 91e538e192..f4595709d8 100644 --- a/source3/passdb/util_wellknown.c +++ b/source3/passdb/util_wellknown.c @@ -17,8 +17,7 @@ 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, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + along with this program. If not, see . */ #include "includes.h" -- cgit From 30191d1a5704ad2b158386b511558972d539ce47 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 18 Oct 2007 17:40:25 -0700 Subject: RIP BOOL. Convert BOOL -> bool. I found a few interesting bugs in various places whilst doing this (places that assumed BOOL == int). I also need to fix the Samba4 pidl generation (next checkin). Jeremy. (This used to be commit f35a266b3cbb3e5fa6a86be60f34fe340a3ca71f) --- source3/passdb/util_wellknown.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source3/passdb/util_wellknown.c') diff --git a/source3/passdb/util_wellknown.c b/source3/passdb/util_wellknown.c index f4595709d8..3ac8c1453c 100644 --- a/source3/passdb/util_wellknown.c +++ b/source3/passdb/util_wellknown.c @@ -69,7 +69,7 @@ static struct sid_name_map_info special_domains[] = { { &global_sid_NT_Authority, "NT Authority", nt_authority_users }, { NULL, NULL, NULL }}; -BOOL sid_check_is_wellknown_domain(const DOM_SID *sid, const char **name) +bool sid_check_is_wellknown_domain(const DOM_SID *sid, const char **name) { int i; @@ -84,7 +84,7 @@ BOOL sid_check_is_wellknown_domain(const DOM_SID *sid, const char **name) return False; } -BOOL sid_check_is_in_wellknown_domain(const DOM_SID *sid) +bool sid_check_is_in_wellknown_domain(const DOM_SID *sid) { DOM_SID dom_sid; uint32 rid; @@ -99,7 +99,7 @@ BOOL sid_check_is_in_wellknown_domain(const DOM_SID *sid) Looks up a known username from one of the known domains. ***************************************************************************/ -BOOL lookup_wellknown_sid(TALLOC_CTX *mem_ctx, const DOM_SID *sid, +bool lookup_wellknown_sid(TALLOC_CTX *mem_ctx, const DOM_SID *sid, const char **domain, const char **name) { int i; @@ -145,7 +145,7 @@ BOOL lookup_wellknown_sid(TALLOC_CTX *mem_ctx, const DOM_SID *sid, Try and map a name to one of the well known SIDs. ***************************************************************************/ -BOOL lookup_wellknown_name(TALLOC_CTX *mem_ctx, const char *name, +bool lookup_wellknown_name(TALLOC_CTX *mem_ctx, const char *name, DOM_SID *sid, const char **domain) { int i, j; -- cgit From 900288a2b86abd247f9eb4cd15dc5617a17cfef1 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 15 Dec 2007 21:11:36 +0100 Subject: Replace sid_string_static by sid_string_dbg in DEBUGs (This used to be commit bb35e794ec129805e874ceba882bcc1e84791a09) --- source3/passdb/util_wellknown.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'source3/passdb/util_wellknown.c') diff --git a/source3/passdb/util_wellknown.c b/source3/passdb/util_wellknown.c index 3ac8c1453c..3a30ab0a65 100644 --- a/source3/passdb/util_wellknown.c +++ b/source3/passdb/util_wellknown.c @@ -123,8 +123,7 @@ bool lookup_wellknown_sid(TALLOC_CTX *mem_ctx, const DOM_SID *sid, } if (users == NULL) { - DEBUG(10, ("SID %s is no special sid\n", - sid_string_static(sid))); + DEBUG(10, ("SID %s is no special sid\n", sid_string_dbg(sid))); return False; } @@ -135,8 +134,7 @@ bool lookup_wellknown_sid(TALLOC_CTX *mem_ctx, const DOM_SID *sid, } } - DEBUG(10, ("RID of special SID %s not found\n", - sid_string_static(sid))); + DEBUG(10, ("RID of special SID %s not found\n", sid_string_dbg(sid))); return False; } -- cgit