nsswitch/idmap_passdb.c

説明を見る。
00001 /* 
00002    Unix SMB/CIFS implementation.
00003 
00004    idmap PASSDB backend
00005 
00006    Copyright (C) Simo Sorce 2006
00007    
00008    This program is free software; you can redistribute it and/or modify
00009    it under the terms of the GNU General Public License as published by
00010    the Free Software Foundation; either version 2 of the License, or
00011    (at your option) any later version.
00012    
00013    This program is distributed in the hope that it will be useful,
00014    but WITHOUT ANY WARRANTY; without even the implied warranty of
00015    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016    GNU General Public License for more details.
00017    
00018    You should have received a copy of the GNU General Public License
00019    along with this program; if not, write to the Free Software
00020    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00021 */
00022 
00023 #include "includes.h"
00024 
00025 #undef DBGC_CLASS
00026 #define DBGC_CLASS DBGC_IDMAP
00027 
00028 /*****************************
00029  Initialise idmap database. 
00030 *****************************/
00031 
00032 static NTSTATUS idmap_pdb_init(struct idmap_domain *dom)
00033 {       
00034         dom->initialized = True;
00035         return NT_STATUS_OK;
00036 }
00037 
00038 /**********************************
00039  lookup a set of unix ids. 
00040 **********************************/
00041 
00042 static NTSTATUS idmap_pdb_unixids_to_sids(struct idmap_domain *dom, struct id_map **ids)
00043 {
00044         int i;
00045 
00046         if (! dom->initialized) {
00047                 return NT_STATUS_UNSUCCESSFUL;
00048         }
00049 
00050         for (i = 0; ids[i]; i++) {
00051 
00052                 /* unmapped by default */
00053                 ids[i]->status = ID_UNMAPPED;
00054 
00055                 switch (ids[i]->xid.type) {
00056                 case ID_TYPE_UID:
00057                         if (pdb_uid_to_sid((uid_t)ids[i]->xid.id, ids[i]->sid)) {
00058                                 ids[i]->status = ID_MAPPED;
00059                         }
00060                         break;
00061                 case ID_TYPE_GID:
00062                         if (pdb_gid_to_sid((gid_t)ids[i]->xid.id, ids[i]->sid)) {
00063                                 ids[i]->status = ID_MAPPED;
00064                         }
00065                         break;
00066                 default: /* ?? */
00067                         ids[i]->status = ID_UNKNOWN;
00068                 }
00069         }
00070 
00071         return NT_STATUS_OK;
00072 }
00073 
00074 /**********************************
00075  lookup a set of sids. 
00076 **********************************/
00077 
00078 static NTSTATUS idmap_pdb_sids_to_unixids(struct idmap_domain *dom, struct id_map **ids)
00079 {
00080         int i;
00081 
00082         if (! dom->initialized) {
00083                 return NT_STATUS_UNSUCCESSFUL;
00084         }
00085 
00086         for (i = 0; ids[i]; i++) {
00087                 enum lsa_SidType type;
00088                 union unid_t id;
00089                 
00090                 if (pdb_sid_to_id(ids[i]->sid, &id, &type)) {
00091                         switch (type) {
00092                         case SID_NAME_USER:
00093                                 ids[i]->xid.id = id.uid;
00094                                 ids[i]->xid.type = ID_TYPE_UID;
00095                                 ids[i]->status = ID_MAPPED;
00096                                 break;
00097 
00098                         case SID_NAME_DOM_GRP:
00099                         case SID_NAME_ALIAS:
00100                         case SID_NAME_WKN_GRP:
00101                                 ids[i]->xid.id = id.gid;
00102                                 ids[i]->xid.type = ID_TYPE_GID;
00103                                 ids[i]->status = ID_MAPPED;
00104                                 break;
00105 
00106                         default: /* ?? */
00107                                 /* make sure it is marked as unmapped */
00108                                 ids[i]->status = ID_UNKNOWN;
00109                                 break;
00110                         }
00111                 } else {
00112                         /* Query Failed */
00113                         ids[i]->status = ID_UNMAPPED;
00114                 }
00115         }
00116 
00117         return NT_STATUS_OK;
00118 }
00119 
00120 /**********************************
00121  Close the idmap tdb instance
00122 **********************************/
00123 
00124 static NTSTATUS idmap_pdb_close(struct idmap_domain *dom)
00125 {
00126         return NT_STATUS_OK;
00127 }
00128 
00129 static struct idmap_methods passdb_methods = {
00130 
00131         .init = idmap_pdb_init,
00132         .unixids_to_sids = idmap_pdb_unixids_to_sids,
00133         .sids_to_unixids = idmap_pdb_sids_to_unixids,
00134         .close_fn =idmap_pdb_close
00135 };
00136 
00137 NTSTATUS idmap_passdb_init(void)
00138 {
00139         return smb_register_idmap(SMB_IDMAP_INTERFACE_VERSION, "passdb", &passdb_methods);
00140 }

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