passdb/util_unixsids.c

説明を見る。
00001 /* 
00002    Unix SMB/CIFS implementation.
00003    Translate unix-defined names to SIDs and vice versa
00004    Copyright (C) Volker Lendecke 2005
00005       
00006    This program is free software; you can redistribute it and/or modify
00007    it under the terms of the GNU General Public License as published by
00008    the Free Software Foundation; either version 2 of the License, or
00009    (at your option) any later version.
00010    
00011    This program is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014    GNU General Public License for more details.
00015    
00016    You should have received a copy of the GNU General Public License
00017    along with this program; if not, write to the Free Software
00018    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00019 */
00020 
00021 #include "includes.h"
00022 
00023 BOOL sid_check_is_unix_users(const DOM_SID *sid)
00024 {
00025         return sid_equal(sid, &global_sid_Unix_Users);
00026 }
00027 
00028 BOOL sid_check_is_in_unix_users(const DOM_SID *sid)
00029 {
00030         DOM_SID dom_sid;
00031         uint32 rid;
00032 
00033         sid_copy(&dom_sid, sid);
00034         sid_split_rid(&dom_sid, &rid);
00035         
00036         return sid_check_is_unix_users(&dom_sid);
00037 }
00038 
00039 BOOL uid_to_unix_users_sid(uid_t uid, DOM_SID *sid)
00040 {
00041         sid_copy(sid, &global_sid_Unix_Users);
00042         return sid_append_rid(sid, uid);
00043 }
00044 
00045 BOOL gid_to_unix_groups_sid(gid_t gid, DOM_SID *sid)
00046 {
00047         sid_copy(sid, &global_sid_Unix_Groups);
00048         return sid_append_rid(sid, gid);
00049 }
00050 
00051 const char *unix_users_domain_name(void)
00052 {
00053         return "Unix User";
00054 }
00055 
00056 BOOL lookup_unix_user_name(const char *name, DOM_SID *sid)
00057 {
00058         struct passwd *pwd;
00059 
00060         pwd = getpwnam_alloc(NULL, name);
00061         if (pwd == NULL) {
00062                 return False;
00063         }
00064 
00065         sid_copy(sid, &global_sid_Unix_Users);
00066         sid_append_rid(sid, pwd->pw_uid); /* For 64-bit uid's we have enough
00067                                           * space ... */
00068         TALLOC_FREE(pwd);
00069         return True;
00070 }
00071 
00072 BOOL sid_check_is_unix_groups(const DOM_SID *sid)
00073 {
00074         return sid_equal(sid, &global_sid_Unix_Groups);
00075 }
00076 
00077 BOOL sid_check_is_in_unix_groups(const DOM_SID *sid)
00078 {
00079         DOM_SID dom_sid;
00080         uint32 rid;
00081 
00082         sid_copy(&dom_sid, sid);
00083         sid_split_rid(&dom_sid, &rid);
00084         
00085         return sid_check_is_unix_groups(&dom_sid);
00086 }
00087 
00088 const char *unix_groups_domain_name(void)
00089 {
00090         return "Unix Group";
00091 }
00092 
00093 BOOL lookup_unix_group_name(const char *name, DOM_SID *sid)
00094 {
00095         struct group *grp;
00096 
00097         grp = getgrnam(name);
00098         if (grp == NULL) {
00099                 return False;
00100         }
00101 
00102         sid_copy(sid, &global_sid_Unix_Groups);
00103         sid_append_rid(sid, grp->gr_gid); /* For 64-bit uid's we have enough
00104                                            * space ... */
00105         return True;
00106 }

Sambaに対してSat Aug 29 21:23:13 2009に生成されました。  doxygen 1.4.7