データ構造 | |
struct | idmap_rid_context |
関数 | |
static NTSTATUS | idmap_rid_initialize (struct idmap_domain *dom) |
static NTSTATUS | idmap_rid_id_to_sid (TALLOC_CTX *memctx, struct idmap_rid_context *ctx, struct id_map *map) |
static NTSTATUS | idmap_rid_sid_to_id (TALLOC_CTX *memctx, struct idmap_rid_context *ctx, struct id_map *map) |
static NTSTATUS | idmap_rid_unixids_to_sids (struct idmap_domain *dom, struct id_map **ids) |
static NTSTATUS | idmap_rid_sids_to_unixids (struct idmap_domain *dom, struct id_map **ids) |
static NTSTATUS | idmap_rid_close (struct idmap_domain *dom) |
NTSTATUS | idmap_rid_init (void) |
変数 | |
static struct idmap_methods | rid_methods |
static NTSTATUS idmap_rid_initialize | ( | struct idmap_domain * | dom | ) | [static] |
idmap_rid.c の 40 行で定義されています。
参照先 ctx・failed・idmap_domain::initialized・lp_idmap_gid()・lp_idmap_uid()・lp_parm_const_string()・lp_parm_int()・idmap_domain::name・idmap_domain::private_data・talloc_asprintf()・talloc_free()・talloc_strdup().
参照元 idmap_rid_sids_to_unixids()・idmap_rid_unixids_to_sids().
00041 { 00042 NTSTATUS ret; 00043 struct idmap_rid_context *ctx; 00044 char *config_option = NULL; 00045 const char *range; 00046 uid_t low_uid = 0; 00047 uid_t high_uid = 0; 00048 gid_t low_gid = 0; 00049 gid_t high_gid = 0; 00050 00051 if ( (ctx = TALLOC_ZERO_P(dom, struct idmap_rid_context)) == NULL ) { 00052 DEBUG(0, ("Out of memory!\n")); 00053 return NT_STATUS_NO_MEMORY; 00054 } 00055 00056 config_option = talloc_asprintf(ctx, "idmap config %s", dom->name); 00057 if ( ! config_option) { 00058 DEBUG(0, ("Out of memory!\n")); 00059 ret = NT_STATUS_NO_MEMORY; 00060 goto failed; 00061 } 00062 00063 range = lp_parm_const_string(-1, config_option, "range", NULL); 00064 if ( !range || 00065 (sscanf(range, "%u - %u", &ctx->low_id, &ctx->high_id) != 2) || 00066 (ctx->low_id > ctx->high_id)) 00067 { 00068 ctx->low_id = 0; 00069 ctx->high_id = 0; 00070 } 00071 00072 /* lets see if the range is defined by the old idmap uid/idmap gid */ 00073 if (!ctx->low_id && !ctx->high_id) { 00074 if (lp_idmap_uid(&low_uid, &high_uid)) { 00075 ctx->low_id = low_uid; 00076 ctx->high_id = high_uid; 00077 } 00078 00079 if (lp_idmap_gid(&low_gid, &high_gid)) { 00080 if ((ctx->low_id != low_gid) || 00081 (ctx->high_id != high_uid)) { 00082 DEBUG(1, ("ERROR: idmap uid irange must match idmap gid range\n")); 00083 ret = NT_STATUS_UNSUCCESSFUL; 00084 goto failed; 00085 } 00086 } 00087 } 00088 00089 if (!ctx->low_id || !ctx->high_id) { 00090 DEBUG(1, ("ERROR: Invalid configuration, ID range missing or invalid\n")); 00091 ret = NT_STATUS_UNSUCCESSFUL; 00092 goto failed; 00093 } 00094 00095 ctx->base_rid = lp_parm_int(-1, config_option, "base_rid", 0); 00096 ctx->domain_name = talloc_strdup( ctx, dom->name ); 00097 00098 dom->private_data = ctx; 00099 dom->initialized = True; 00100 00101 talloc_free(config_option); 00102 return NT_STATUS_OK; 00103 00104 failed: 00105 talloc_free(ctx); 00106 return ret; 00107 }
static NTSTATUS idmap_rid_id_to_sid | ( | TALLOC_CTX * | memctx, | |
struct idmap_rid_context * | ctx, | |||
struct id_map * | map | |||
) | [static] |
idmap_rid.c の 109 行で定義されています。
参照先 ctx・find_domain_from_name_noinit()・unixid::id・ID_MAPPED・winbindd_domain::sid・id_map::sid・sid_compose()・id_map::status・id_map::xid.
参照元 idmap_rid_unixids_to_sids().
00110 { 00111 struct winbindd_domain *domain; 00112 00113 /* apply filters before checking */ 00114 if ((map->xid.id < ctx->low_id) || (map->xid.id > ctx->high_id)) { 00115 DEBUG(5, ("Requested id (%u) out of range (%u - %u). Filtered!\n", 00116 map->xid.id, ctx->low_id, ctx->high_id)); 00117 return NT_STATUS_NONE_MAPPED; 00118 } 00119 00120 if ( (domain = find_domain_from_name_noinit(ctx->domain_name)) == NULL ) { 00121 return NT_STATUS_NO_SUCH_DOMAIN; 00122 } 00123 00124 sid_compose(map->sid, &domain->sid, map->xid.id - ctx->low_id + ctx->base_rid); 00125 00126 /* We **really** should have some way of validating 00127 the SID exists and is the correct type here. But 00128 that is a deficiency in the idmap_rid design. */ 00129 00130 map->status = ID_MAPPED; 00131 00132 return NT_STATUS_OK; 00133 }
static NTSTATUS idmap_rid_sid_to_id | ( | TALLOC_CTX * | memctx, | |
struct idmap_rid_context * | ctx, | |||
struct id_map * | map | |||
) | [static] |
idmap_rid.c の 139 行で定義されています。
参照先 ctx・unixid::id・ID_MAPPED・ID_UNMAPPED・id_map::sid・sid_peek_rid()・id_map::status・id_map::xid.
参照元 idmap_rid_sids_to_unixids().
00140 { 00141 uint32_t rid; 00142 00143 sid_peek_rid(map->sid, &rid); 00144 map->xid.id = rid - ctx->base_rid + ctx->low_id; 00145 00146 /* apply filters before returning result */ 00147 00148 if ((map->xid.id < ctx->low_id) || (map->xid.id > ctx->high_id)) { 00149 DEBUG(5, ("Requested id (%u) out of range (%u - %u). Filtered!\n", 00150 map->xid.id, ctx->low_id, ctx->high_id)); 00151 map->status = ID_UNMAPPED; 00152 return NT_STATUS_NONE_MAPPED; 00153 } 00154 00155 /* We **really** should have some way of validating 00156 the SID exists and is the correct type here. But 00157 that is a deficiency in the idmap_rid design. */ 00158 00159 map->status = ID_MAPPED; 00160 00161 return NT_STATUS_OK; 00162 }
static NTSTATUS idmap_rid_unixids_to_sids | ( | struct idmap_domain * | dom, | |
struct id_map ** | ids | |||
) | [static] |
idmap_rid.c の 168 行で定義されています。
参照先 ctx・idmap_rid_id_to_sid()・idmap_rid_initialize()・idmap_domain::initialized・idmap_domain::private_data・talloc_free().
00169 { 00170 struct idmap_rid_context *ridctx; 00171 TALLOC_CTX *ctx; 00172 NTSTATUS ret; 00173 int i; 00174 00175 /* Initilization my have been deferred because of an error, retry or fail */ 00176 if ( ! dom->initialized) { 00177 ret = idmap_rid_initialize(dom); 00178 if ( ! NT_STATUS_IS_OK(ret)) { 00179 return ret; 00180 } 00181 } 00182 00183 ridctx = talloc_get_type(dom->private_data, struct idmap_rid_context); 00184 00185 ctx = talloc_new(dom); 00186 if ( ! ctx) { 00187 DEBUG(0, ("Out of memory!\n")); 00188 return NT_STATUS_NO_MEMORY; 00189 } 00190 00191 for (i = 0; ids[i]; i++) { 00192 00193 ret = idmap_rid_id_to_sid(ctx, ridctx, ids[i]); 00194 00195 if (( ! NT_STATUS_IS_OK(ret)) && 00196 ( ! NT_STATUS_EQUAL(ret, NT_STATUS_NONE_MAPPED))) { 00197 /* some fatal error occurred, log it */ 00198 DEBUG(3, ("Unexpected error resolving an ID (%d)\n", ids[i]->xid.id)); 00199 } 00200 } 00201 00202 talloc_free(ctx); 00203 return NT_STATUS_OK; 00204 }
static NTSTATUS idmap_rid_sids_to_unixids | ( | struct idmap_domain * | dom, | |
struct id_map ** | ids | |||
) | [static] |
idmap_rid.c の 210 行で定義されています。
参照先 ctx・idmap_rid_initialize()・idmap_rid_sid_to_id()・idmap_domain::initialized・idmap_domain::private_data・sid_string_static()・talloc_free().
00211 { 00212 struct idmap_rid_context *ridctx; 00213 TALLOC_CTX *ctx; 00214 NTSTATUS ret; 00215 int i; 00216 00217 /* Initilization my have been deferred because of an error, retry or fail */ 00218 if ( ! dom->initialized) { 00219 ret = idmap_rid_initialize(dom); 00220 if ( ! NT_STATUS_IS_OK(ret)) { 00221 return ret; 00222 } 00223 } 00224 00225 ridctx = talloc_get_type(dom->private_data, struct idmap_rid_context); 00226 00227 ctx = talloc_new(dom); 00228 if ( ! ctx) { 00229 DEBUG(0, ("Out of memory!\n")); 00230 return NT_STATUS_NO_MEMORY; 00231 } 00232 00233 for (i = 0; ids[i]; i++) { 00234 00235 ret = idmap_rid_sid_to_id(ctx, ridctx, ids[i]); 00236 00237 if (( ! NT_STATUS_IS_OK(ret)) && 00238 ( ! NT_STATUS_EQUAL(ret, NT_STATUS_NONE_MAPPED))) { 00239 /* some fatal error occurred, log it */ 00240 DEBUG(3, ("Unexpected error resolving a SID (%s)\n", 00241 sid_string_static(ids[i]->sid))); 00242 } 00243 } 00244 00245 talloc_free(ctx); 00246 return NT_STATUS_OK; 00247 }
static NTSTATUS idmap_rid_close | ( | struct idmap_domain * | dom | ) | [static] |
idmap_rid.c の 249 行で定義されています。
参照先 idmap_domain::private_data.
00250 { 00251 if (dom->private_data) { 00252 TALLOC_FREE(dom->private_data); 00253 } 00254 return NT_STATUS_OK; 00255 }
NTSTATUS idmap_rid_init | ( | void | ) |
idmap_rid.c の 264 行で定義されています。
参照先 rid_methods・smb_register_idmap().
00265 { 00266 return smb_register_idmap(SMB_IDMAP_INTERFACE_VERSION, "rid", &rid_methods); 00267 }
struct idmap_methods rid_methods [static] |
初期値:
{ .init = idmap_rid_initialize, .unixids_to_sids = idmap_rid_unixids_to_sids, .sids_to_unixids = idmap_rid_sids_to_unixids, .close_fn = idmap_rid_close }
idmap_rid.c の 257 行で定義されています。
参照元 idmap_rid_init().