nsswitch/idmap_nss.c

ソースコードを見る。

関数

static NTSTATUS idmap_nss_int_init (struct idmap_domain *dom)
static NTSTATUS idmap_nss_unixids_to_sids (struct idmap_domain *dom, struct id_map **ids)
static NTSTATUS idmap_nss_sids_to_unixids (struct idmap_domain *dom, struct id_map **ids)
static NTSTATUS idmap_nss_close (struct idmap_domain *dom)
NTSTATUS idmap_nss_init (void)

変数

static struct idmap_methods nss_methods


関数

static NTSTATUS idmap_nss_int_init ( struct idmap_domain dom  )  [static]

idmap_nss.c33 行で定義されています。

参照先 idmap_domain::initialized.

00034 {       
00035         dom->initialized = True;
00036         return NT_STATUS_OK;
00037 }

static NTSTATUS idmap_nss_unixids_to_sids ( struct idmap_domain dom,
struct id_map **  ids 
) [static]

idmap_nss.c43 行で定義されています。

参照先 ctxID_MAPPEDID_TYPE_GIDID_TYPE_UIDID_UNKNOWNID_UNMAPPEDidmap_domain::initializedidmap_domain::namenameid_map::sidSID_NAME_ALIASSID_NAME_DOM_GRPSID_NAME_USERSID_NAME_WKN_GRPid_map::statusstatustypewinbind_lookup_name()winbind_off()winbind_on().

00044 {
00045         TALLOC_CTX *ctx;
00046         int i;
00047 
00048         if (! dom->initialized) {
00049                 return NT_STATUS_UNSUCCESSFUL;
00050         }
00051 
00052         ctx = talloc_new(dom);
00053         if ( ! ctx) {
00054                 DEBUG(0, ("Out of memory!\n"));
00055                 return NT_STATUS_NO_MEMORY;
00056         }
00057 
00058         for (i = 0; ids[i]; i++) {
00059                 struct passwd *pw;
00060                 struct group *gr;
00061                 const char *name;
00062                 enum lsa_SidType type;
00063                 BOOL ret;
00064                 
00065                 switch (ids[i]->xid.type) {
00066                 case ID_TYPE_UID:
00067                         pw = getpwuid((uid_t)ids[i]->xid.id);
00068 
00069                         if (!pw) {
00070                                 ids[i]->status = ID_UNMAPPED;
00071                                 continue;
00072                         }
00073                         name = pw->pw_name;
00074                         break;
00075                 case ID_TYPE_GID:
00076                         gr = getgrgid((gid_t)ids[i]->xid.id);
00077 
00078                         if (!gr) {
00079                                 ids[i]->status = ID_UNMAPPED;
00080                                 continue;
00081                         }
00082                         name = gr->gr_name;
00083                         break;
00084                 default: /* ?? */
00085                         ids[i]->status = ID_UNKNOWN;
00086                         continue;
00087                 }
00088 
00089                 /* by default calls to winbindd are disabled
00090                    the following call will not recurse so this is safe */
00091                 winbind_on();
00092                 /* Lookup name from PDC using lsa_lookup_names() */
00093                 ret = winbind_lookup_name(dom->name, name, ids[i]->sid, &type);
00094                 winbind_off();
00095 
00096                 if (!ret) {
00097                         /* TODO: how do we know if the name is really not mapped,
00098                          * or something just failed ? */
00099                         ids[i]->status = ID_UNMAPPED;
00100                         continue;
00101                 }
00102 
00103                 switch (type) {
00104                 case SID_NAME_USER:
00105                         if (ids[i]->xid.type == ID_TYPE_UID) {
00106                                 ids[i]->status = ID_MAPPED;
00107                         }
00108                         break;
00109 
00110                 case SID_NAME_DOM_GRP:
00111                 case SID_NAME_ALIAS:
00112                 case SID_NAME_WKN_GRP:
00113                         if (ids[i]->xid.type == ID_TYPE_GID) {
00114                                 ids[i]->status = ID_MAPPED;
00115                         }
00116                         break;
00117 
00118                 default:
00119                         ids[i]->status = ID_UNKNOWN;
00120                         break;
00121                 }
00122         }
00123 
00124 
00125         talloc_free(ctx);
00126         return NT_STATUS_OK;
00127 }

static NTSTATUS idmap_nss_sids_to_unixids ( struct idmap_domain dom,
struct id_map **  ids 
) [static]

idmap_nss.c133 行で定義されています。

参照先 ctxGet_Pwnam()unixid::idID_MAPPEDID_TYPE_GIDID_TYPE_UIDID_UNKNOWNID_UNMAPPEDidmap_domain::initializednameSID_NAME_ALIASSID_NAME_DOM_GRPSID_NAME_USERSID_NAME_WKN_GRPid_map::statustalloc_free()unixid::typetypewinbind_lookup_sid()winbind_off()winbind_on()id_map::xid.

00134 {
00135         TALLOC_CTX *ctx;
00136         int i;
00137 
00138         if (! dom->initialized) {
00139                 return NT_STATUS_UNSUCCESSFUL;
00140         }
00141 
00142         ctx = talloc_new(dom);
00143         if ( ! ctx) {
00144                 DEBUG(0, ("Out of memory!\n"));
00145                 return NT_STATUS_NO_MEMORY;
00146         }
00147 
00148         for (i = 0; ids[i]; i++) {
00149                 struct passwd *pw;
00150                 struct group *gr;
00151                 enum lsa_SidType type;
00152                 const char *dom_name = NULL;
00153                 const char *name = NULL;
00154                 BOOL ret;
00155 
00156                 /* by default calls to winbindd are disabled
00157                    the following call will not recurse so this is safe */
00158                 winbind_on();
00159                 ret = winbind_lookup_sid(ctx, ids[i]->sid, &dom_name, &name, &type);
00160                 winbind_off();
00161 
00162                 if (!ret) {
00163                         /* TODO: how do we know if the name is really not mapped,
00164                          * or something just failed ? */
00165                         ids[i]->status = ID_UNMAPPED;
00166                         continue;
00167                 }
00168 
00169                 switch (type) {
00170                 case SID_NAME_USER:
00171 
00172                         /* this will find also all lower case name and use username level */
00173                         
00174                         pw = Get_Pwnam(name);
00175                         if (pw) {
00176                                 ids[i]->xid.id = pw->pw_uid;
00177                                 ids[i]->xid.type = ID_TYPE_UID;
00178                                 ids[i]->status = ID_MAPPED;
00179                         }
00180                         break;
00181 
00182                 case SID_NAME_DOM_GRP:
00183                 case SID_NAME_ALIAS:
00184                 case SID_NAME_WKN_GRP:
00185 
00186                         gr = getgrnam(name);
00187                         if (gr) {
00188                                 ids[i]->xid.id = gr->gr_gid;
00189                                 ids[i]->xid.type = ID_TYPE_GID;
00190                                 ids[i]->status = ID_MAPPED;
00191                         }
00192                         break;
00193 
00194                 default:
00195                         ids[i]->status = ID_UNKNOWN;
00196                         break;
00197                 }
00198         }
00199 
00200         talloc_free(ctx);
00201         return NT_STATUS_OK;
00202 }

static NTSTATUS idmap_nss_close ( struct idmap_domain dom  )  [static]

idmap_nss.c208 行で定義されています。

00209 {
00210         return NT_STATUS_OK;
00211 }

NTSTATUS idmap_nss_init ( void   ) 

idmap_nss.c221 行で定義されています。

参照先 nss_methodssmb_register_idmap().

00222 {
00223         return smb_register_idmap(SMB_IDMAP_INTERFACE_VERSION, "nss", &nss_methods);
00224 }


変数

struct idmap_methods nss_methods [static]

初期値:

 {

        .init = idmap_nss_int_init,
        .unixids_to_sids = idmap_nss_unixids_to_sids,
        .sids_to_unixids = idmap_nss_sids_to_unixids,
        .close_fn = idmap_nss_close
}

idmap_nss.c213 行で定義されています。

参照元 idmap_nss_init().


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