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_unixsids.c | 94 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 source3/passdb/util_unixsids.c (limited to 'source3/passdb/util_unixsids.c') diff --git a/source3/passdb/util_unixsids.c b/source3/passdb/util_unixsids.c new file mode 100644 index 0000000000..ee8cf2d8f0 --- /dev/null +++ b/source3/passdb/util_unixsids.c @@ -0,0 +1,94 @@ +/* + Unix SMB/CIFS implementation. + Translate unix-defined 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 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" + +BOOL sid_check_is_unix_users(const DOM_SID *sid) +{ + return sid_equal(sid, &global_sid_Unix_Users); +} + +BOOL sid_check_is_in_unix_users(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_unix_users(&dom_sid); +} + +const char *unix_users_domain_name(void) +{ + return "Unix User"; +} + +BOOL lookup_unix_user_name(const char *name, DOM_SID *sid) +{ + struct passwd *pwd; + + pwd = getpwnam_alloc(NULL, name); + if (pwd == NULL) { + return False; + } + + sid_copy(sid, &global_sid_Unix_Users); + sid_append_rid(sid, pwd->pw_uid); /* For 64-bit uid's we have enough + * space ... */ + talloc_free(pwd); + return True; +} + +BOOL sid_check_is_unix_groups(const DOM_SID *sid) +{ + return sid_equal(sid, &global_sid_Unix_Groups); +} + +BOOL sid_check_is_in_unix_groups(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_unix_groups(&dom_sid); +} + +const char *unix_groups_domain_name(void) +{ + return "Unix Group"; +} + +BOOL lookup_unix_group_name(const char *name, DOM_SID *sid) +{ + struct group *grp; + + grp = getgrnam(name); + if (grp == NULL) { + return False; + } + + sid_copy(sid, &global_sid_Unix_Groups); + sid_append_rid(sid, grp->gr_gid); /* For 64-bit uid's we have enough + * space ... */ + return True; +} -- cgit From fb5362c069b5b6548478b2217a0519c56d856705 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Mon, 20 Feb 2006 17:59:58 +0000 Subject: r13571: Replace all calls to talloc_free() with thye TALLOC_FREE() macro which sets the freed pointer to NULL. (This used to be commit b65be8874a2efe5a4b167448960a4fcf6bd995e2) --- source3/passdb/util_unixsids.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/passdb/util_unixsids.c') diff --git a/source3/passdb/util_unixsids.c b/source3/passdb/util_unixsids.c index ee8cf2d8f0..2a4818e3ae 100644 --- a/source3/passdb/util_unixsids.c +++ b/source3/passdb/util_unixsids.c @@ -53,7 +53,7 @@ BOOL lookup_unix_user_name(const char *name, DOM_SID *sid) sid_copy(sid, &global_sid_Unix_Users); sid_append_rid(sid, pwd->pw_uid); /* For 64-bit uid's we have enough * space ... */ - talloc_free(pwd); + TALLOC_FREE(pwd); return True; } -- cgit From 3899f95e1f44a4dfe31b42119ad5e14304d8a4b4 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Fri, 7 Jul 2006 18:53:19 +0000 Subject: r16865: This is a proposal to fix bug 3915. Before sending patches around, this is what svn is for. The idea is that we fall back to a pure unix user with S-1-22 SIDs in the token in case anything weird is going on with the 'force user'. Volker (This used to be commit 9ec5ccfe851ac8a1f88b88c8c8461a5cf75b4c57) --- source3/passdb/util_unixsids.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'source3/passdb/util_unixsids.c') diff --git a/source3/passdb/util_unixsids.c b/source3/passdb/util_unixsids.c index 2a4818e3ae..d3f0999d6a 100644 --- a/source3/passdb/util_unixsids.c +++ b/source3/passdb/util_unixsids.c @@ -36,6 +36,12 @@ BOOL sid_check_is_in_unix_users(const DOM_SID *sid) return sid_check_is_unix_users(&dom_sid); } +BOOL uid_to_unix_users_sid(uid_t uid, DOM_SID *sid) +{ + sid_copy(sid, &global_sid_Unix_Users); + return sid_append_rid(sid, uid); +} + const char *unix_users_domain_name(void) { return "Unix User"; -- cgit From c9f9c6505091aa1bf469c06c779040689c0737f7 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Mon, 21 Aug 2006 20:04:01 +0000 Subject: r17669: Remove RID algorithm support from unmapped users and groups when using smbpasswd (This used to be commit dde552336c732ddd6076a6a32575a37cb51aa94c) --- source3/passdb/util_unixsids.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'source3/passdb/util_unixsids.c') diff --git a/source3/passdb/util_unixsids.c b/source3/passdb/util_unixsids.c index d3f0999d6a..80d22a314f 100644 --- a/source3/passdb/util_unixsids.c +++ b/source3/passdb/util_unixsids.c @@ -42,6 +42,12 @@ BOOL uid_to_unix_users_sid(uid_t uid, DOM_SID *sid) return sid_append_rid(sid, uid); } +BOOL uid_to_unix_groups_sid(gid_t gid, DOM_SID *sid) +{ + sid_copy(sid, &global_sid_Unix_Groups); + return sid_append_rid(sid, gid); +} + const char *unix_users_domain_name(void) { return "Unix User"; -- cgit From d190f71b8374be5bf8e521154328ae8a4ded54fd Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Tue, 22 Aug 2006 15:18:13 +0000 Subject: r17709: Fix cut-n-paste error with the name of gid_to_unix_group_sid(). (This used to be commit dda0b8bce6b7e0146badd8aeb52b5cce6289de21) --- source3/passdb/util_unixsids.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/passdb/util_unixsids.c') diff --git a/source3/passdb/util_unixsids.c b/source3/passdb/util_unixsids.c index 80d22a314f..a885d970ae 100644 --- a/source3/passdb/util_unixsids.c +++ b/source3/passdb/util_unixsids.c @@ -42,7 +42,7 @@ BOOL uid_to_unix_users_sid(uid_t uid, DOM_SID *sid) return sid_append_rid(sid, uid); } -BOOL uid_to_unix_groups_sid(gid_t gid, DOM_SID *sid) +BOOL gid_to_unix_groups_sid(gid_t gid, DOM_SID *sid) { sid_copy(sid, &global_sid_Unix_Groups); return sid_append_rid(sid, gid); -- 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_unixsids.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/passdb/util_unixsids.c') diff --git a/source3/passdb/util_unixsids.c b/source3/passdb/util_unixsids.c index a885d970ae..1c4610770b 100644 --- a/source3/passdb/util_unixsids.c +++ b/source3/passdb/util_unixsids.c @@ -5,7 +5,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_unixsids.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source3/passdb/util_unixsids.c') diff --git a/source3/passdb/util_unixsids.c b/source3/passdb/util_unixsids.c index 1c4610770b..59ad4e708d 100644 --- a/source3/passdb/util_unixsids.c +++ b/source3/passdb/util_unixsids.c @@ -14,8 +14,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_unixsids.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'source3/passdb/util_unixsids.c') diff --git a/source3/passdb/util_unixsids.c b/source3/passdb/util_unixsids.c index 59ad4e708d..8c92f95778 100644 --- a/source3/passdb/util_unixsids.c +++ b/source3/passdb/util_unixsids.c @@ -19,12 +19,12 @@ #include "includes.h" -BOOL sid_check_is_unix_users(const DOM_SID *sid) +bool sid_check_is_unix_users(const DOM_SID *sid) { return sid_equal(sid, &global_sid_Unix_Users); } -BOOL sid_check_is_in_unix_users(const DOM_SID *sid) +bool sid_check_is_in_unix_users(const DOM_SID *sid) { DOM_SID dom_sid; uint32 rid; @@ -35,13 +35,13 @@ BOOL sid_check_is_in_unix_users(const DOM_SID *sid) return sid_check_is_unix_users(&dom_sid); } -BOOL uid_to_unix_users_sid(uid_t uid, DOM_SID *sid) +bool uid_to_unix_users_sid(uid_t uid, DOM_SID *sid) { sid_copy(sid, &global_sid_Unix_Users); return sid_append_rid(sid, uid); } -BOOL gid_to_unix_groups_sid(gid_t gid, DOM_SID *sid) +bool gid_to_unix_groups_sid(gid_t gid, DOM_SID *sid) { sid_copy(sid, &global_sid_Unix_Groups); return sid_append_rid(sid, gid); @@ -52,7 +52,7 @@ const char *unix_users_domain_name(void) return "Unix User"; } -BOOL lookup_unix_user_name(const char *name, DOM_SID *sid) +bool lookup_unix_user_name(const char *name, DOM_SID *sid) { struct passwd *pwd; @@ -68,12 +68,12 @@ BOOL lookup_unix_user_name(const char *name, DOM_SID *sid) return True; } -BOOL sid_check_is_unix_groups(const DOM_SID *sid) +bool sid_check_is_unix_groups(const DOM_SID *sid) { return sid_equal(sid, &global_sid_Unix_Groups); } -BOOL sid_check_is_in_unix_groups(const DOM_SID *sid) +bool sid_check_is_in_unix_groups(const DOM_SID *sid) { DOM_SID dom_sid; uint32 rid; @@ -89,7 +89,7 @@ const char *unix_groups_domain_name(void) return "Unix Group"; } -BOOL lookup_unix_group_name(const char *name, DOM_SID *sid) +bool lookup_unix_group_name(const char *name, DOM_SID *sid) { struct group *grp; -- cgit From a4932d66576be2a514c534131ae09614e061c621 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 24 Jul 2008 11:56:49 -0700 Subject: Use sys_getgrnam not getgrnam. Pointed out by Herb. Jeremy. (This used to be commit 43eec6517023e7865618791c231e54cc1b800ceb) --- source3/passdb/util_unixsids.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/passdb/util_unixsids.c') diff --git a/source3/passdb/util_unixsids.c b/source3/passdb/util_unixsids.c index 8c92f95778..83a5f5cab4 100644 --- a/source3/passdb/util_unixsids.c +++ b/source3/passdb/util_unixsids.c @@ -93,7 +93,7 @@ bool lookup_unix_group_name(const char *name, DOM_SID *sid) { struct group *grp; - grp = getgrnam(name); + grp = sys_getgrnam(name); if (grp == NULL) { return False; } -- cgit From 61859a18f0996eef8300e59788773d5f11ed9c0d Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 24 Jul 2008 12:01:46 -0700 Subject: Add casts to uint32_t to match prototype for sid_append_rid(). Jeremy. (This used to be commit 15004019676a5d860f9d5fbfbecbd31fcec8bf5b) --- source3/passdb/util_unixsids.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source3/passdb/util_unixsids.c') diff --git a/source3/passdb/util_unixsids.c b/source3/passdb/util_unixsids.c index 83a5f5cab4..1b674d02a2 100644 --- a/source3/passdb/util_unixsids.c +++ b/source3/passdb/util_unixsids.c @@ -38,13 +38,13 @@ bool sid_check_is_in_unix_users(const DOM_SID *sid) bool uid_to_unix_users_sid(uid_t uid, DOM_SID *sid) { sid_copy(sid, &global_sid_Unix_Users); - return sid_append_rid(sid, uid); + return sid_append_rid(sid, (uint32_t)uid); } bool gid_to_unix_groups_sid(gid_t gid, DOM_SID *sid) { sid_copy(sid, &global_sid_Unix_Groups); - return sid_append_rid(sid, gid); + return sid_append_rid(sid, (uint32_t)gid); } const char *unix_users_domain_name(void) @@ -62,7 +62,7 @@ bool lookup_unix_user_name(const char *name, DOM_SID *sid) } sid_copy(sid, &global_sid_Unix_Users); - sid_append_rid(sid, pwd->pw_uid); /* For 64-bit uid's we have enough + sid_append_rid(sid, (uint32_t)pwd->pw_uid); /* For 64-bit uid's we have enough * space ... */ TALLOC_FREE(pwd); return True; @@ -99,7 +99,7 @@ bool lookup_unix_group_name(const char *name, DOM_SID *sid) } sid_copy(sid, &global_sid_Unix_Groups); - sid_append_rid(sid, grp->gr_gid); /* For 64-bit uid's we have enough + sid_append_rid(sid, (uint32_t)grp->gr_gid); /* For 64-bit uid's we have enough * space ... */ return True; } -- cgit