Lines Matching refs:req

65 #define	DO_NOT_ALLOC_NEW_ID_MAPPING(req)\  argument
66 (req->flag & IDMAP_REQ_FLG_NO_NEW_ID_ALLOC)
68 #define AVOID_NAMESERVICE(req)\ argument
69 (req->flag & IDMAP_REQ_FLG_NO_NAMESERVICE)
71 #define ALLOW_WK_OR_LOCAL_SIDS_ONLY(req)\ argument
72 (req->flag & IDMAP_REQ_FLG_WK_OR_LOCAL_SIDS_ONLY)
1224 lookup_wksids_sid2pid(idmap_mapping *req, idmap_id_res *res, int *is_wksid) in lookup_wksids_sid2pid() argument
1230 assert(req->id1.idmap_id_u.sid.prefix != NULL || in lookup_wksids_sid2pid()
1231 req->id1name != NULL); in lookup_wksids_sid2pid()
1233 if (req->id1.idmap_id_u.sid.prefix != NULL) { in lookup_wksids_sid2pid()
1234 wksid = find_wksid_by_sid(req->id1.idmap_id_u.sid.prefix, in lookup_wksids_sid2pid()
1235 req->id1.idmap_id_u.sid.rid, res->id.idtype); in lookup_wksids_sid2pid()
1237 wksid = find_wksid_by_name(req->id1name, req->id1domain, in lookup_wksids_sid2pid()
1246 if (req->id1name == NULL) { in lookup_wksids_sid2pid()
1247 req->id1name = strdup(wksid->winname); in lookup_wksids_sid2pid()
1248 if (req->id1name == NULL) in lookup_wksids_sid2pid()
1253 if (req->id1.idmap_id_u.sid.prefix == NULL) { in lookup_wksids_sid2pid()
1255 req->id1.idmap_id_u.sid.prefix = in lookup_wksids_sid2pid()
1259 req->id1.idmap_id_u.sid.prefix = in lookup_wksids_sid2pid()
1263 if (req->id1.idmap_id_u.sid.prefix == NULL) in lookup_wksids_sid2pid()
1265 req->id1.idmap_id_u.sid.rid = wksid->rid; in lookup_wksids_sid2pid()
1269 if (req->id1domain == NULL) { in lookup_wksids_sid2pid()
1277 req->id1domain = strdup(dom); in lookup_wksids_sid2pid()
1279 if (req->id1domain == NULL) in lookup_wksids_sid2pid()
1284 req->direction |= _IDMAP_F_DONT_UPDATE_NAMECACHE; in lookup_wksids_sid2pid()
1286 req->id1.idtype = wksid->is_wuser ? IDMAP_USID : IDMAP_GSID; in lookup_wksids_sid2pid()
1340 lookup_wksids_pid2sid(idmap_mapping *req, idmap_id_res *res, int is_user) in lookup_wksids_pid2sid() argument
1344 wksid = find_wksid_by_pid(req->id1.idmap_id_u.uid, is_user); in lookup_wksids_pid2sid()
1369 if (req->id2name == NULL) { in lookup_wksids_pid2sid()
1370 req->id2name = strdup(wksid->winname); in lookup_wksids_pid2sid()
1371 if (req->id2name == NULL) in lookup_wksids_pid2sid()
1376 if (req->id2domain == NULL) { in lookup_wksids_pid2sid()
1384 req->id2domain = strdup(dom); in lookup_wksids_pid2sid()
1386 if (req->id2domain == NULL) in lookup_wksids_pid2sid()
1501 lookup_cache_sid2pid(sqlite *cache, idmap_mapping *req, idmap_id_res *res) in lookup_cache_sid2pid() argument
1540 if (req->id1.idmap_id_u.sid.prefix != NULL) { in lookup_cache_sid2pid()
1550 is_user_string, req->id1.idmap_id_u.sid.prefix, in lookup_cache_sid2pid()
1551 req->id1.idmap_id_u.sid.rid, curtime); in lookup_cache_sid2pid()
1552 } else if (req->id1name != NULL) { in lookup_cache_sid2pid()
1553 if ((lower_name = tolower_u8(req->id1name)) == NULL) in lookup_cache_sid2pid()
1554 lower_name = req->id1name; in lookup_cache_sid2pid()
1564 is_user_string, lower_name, req->id1domain, in lookup_cache_sid2pid()
1566 if (lower_name != req->id1name) in lookup_cache_sid2pid()
1610 if (!DO_NOT_ALLOC_NEW_ID_MAPPING(req) && in lookup_cache_sid2pid()
1611 !AVOID_NAMESERVICE(req) && in lookup_cache_sid2pid()
1617 req->direction |= is_user in lookup_cache_sid2pid()
1635 if (req->id2name != NULL) in lookup_cache_sid2pid()
1636 free(req->id2name); in lookup_cache_sid2pid()
1637 req->id2name = strdup(values[3]); in lookup_cache_sid2pid()
1638 if (req->id2name == NULL) { in lookup_cache_sid2pid()
1644 req->id1.idtype = strncmp(values[5], "0", 2) ? in lookup_cache_sid2pid()
1647 if (req->flag & IDMAP_REQ_FLG_MAPPING_INFO) { in lookup_cache_sid2pid()
1820 lookup_name_cache(sqlite *cache, idmap_mapping *req, idmap_id_res *res) in lookup_name_cache() argument
1829 if (req->id1.idmap_id_u.sid.prefix != NULL && req->id1name != NULL) { in lookup_name_cache()
1834 if (req->id1.idmap_id_u.sid.prefix != NULL) { in lookup_name_cache()
1837 req->id1.idmap_id_u.sid.prefix, in lookup_name_cache()
1838 req->id1.idmap_id_u.sid.rid, &name, &domain, &type); in lookup_name_cache()
1841 retcode = lookup_cache_name2sid(cache, req->id1name, in lookup_name_cache()
1842 req->id1domain, &name, &sidprefix, &rid, &type); in lookup_name_cache()
1847 TRACE(req, res, "Not found in name cache"); in lookup_name_cache()
1849 TRACE(req, res, "Name cache lookup error=%d", retcode); in lookup_name_cache()
1857 req->id1.idtype = type; in lookup_name_cache()
1859 req->direction |= _IDMAP_F_DONT_UPDATE_NAMECACHE; in lookup_name_cache()
1866 free(req->id1name); in lookup_name_cache()
1867 req->id1name = name; in lookup_name_cache()
1870 free(req->id1domain); in lookup_name_cache()
1871 req->id1domain = domain; in lookup_name_cache()
1874 if (req->id1.idmap_id_u.sid.prefix == NULL) { in lookup_name_cache()
1875 req->id1.idmap_id_u.sid.prefix = sidprefix; in lookup_name_cache()
1876 req->id1.idmap_id_u.sid.rid = rid; in lookup_name_cache()
1879 TRACE(req, res, "Found in name cache"); in lookup_name_cache()
1895 idmap_mapping *req; in ad_lookup_batch_int() local
1949 req = &batch->idmap_mapping_batch_val[i]; in ad_lookup_batch_int()
1954 req->id2.idtype = IDMAP_NONE; in ad_lookup_batch_int()
1955 req->id2.idmap_id_u.uid = IDMAP_SENTINEL_PID; in ad_lookup_batch_int()
1958 if (!(req->direction & _IDMAP_F_LOOKUP_AD)) in ad_lookup_batch_int()
1962 if (req->direction & _IDMAP_F_LOOKUP_OTHER_AD) in ad_lookup_batch_int()
1969 if (IS_ID_SID(req->id1)) { in ad_lookup_batch_int()
1978 req->id2name == NULL) { in ad_lookup_batch_int()
1982 unixname = &req->id2name; in ad_lookup_batch_int()
1986 unixname = &req->id2name; in ad_lookup_batch_int()
1989 unixname = &req->id2name; in ad_lookup_batch_int()
2012 pid = &req->id2.idmap_id_u.uid; in ad_lookup_batch_int()
2024 if (req->id1.idmap_id_u.sid.prefix != NULL) { in ad_lookup_batch_int()
2027 qs, req->id1.idmap_id_u.sid.prefix, in ad_lookup_batch_int()
2028 &req->id1.idmap_id_u.sid.rid, esidtype, in ad_lookup_batch_int()
2030 (req->id1name == NULL) ? in ad_lookup_batch_int()
2031 &req->id1name : NULL, in ad_lookup_batch_int()
2032 (req->id1domain == NULL) ? in ad_lookup_batch_int()
2033 &req->id1domain : NULL, in ad_lookup_batch_int()
2034 &req->id2.idtype, unixname, in ad_lookup_batch_int()
2041 assert(req->id1name != NULL); in ad_lookup_batch_int()
2043 qs, req->id1name, req->id1domain, in ad_lookup_batch_int()
2046 &req->id1name, in ad_lookup_batch_int()
2047 &req->id1.idmap_id_u.sid.prefix, in ad_lookup_batch_int()
2048 &req->id1.idmap_id_u.sid.rid, in ad_lookup_batch_int()
2049 &req->id2.idtype, unixname, in ad_lookup_batch_int()
2056 } else if (IS_ID_UID(req->id1) || IS_ID_GID(req->id1)) { in ad_lookup_batch_int()
2061 req->id2name != NULL) { in ad_lookup_batch_int()
2081 &req->id2name, in ad_lookup_batch_int()
2082 &req->id2domain, &req->id2.idtype, in ad_lookup_batch_int()
2086 } else if (req->id2name != NULL) { in ad_lookup_batch_int()
2095 qs, req->id2name, req->id2domain, in ad_lookup_batch_int()
2100 &req->id2.idtype, NULL, in ad_lookup_batch_int()
2108 assert(req->id1.idmap_id_u.uid != in ad_lookup_batch_int()
2110 is_user = IS_ID_UID(req->id1); in ad_lookup_batch_int()
2126 qs, req->id1.idmap_id_u.uid, is_user, in ad_lookup_batch_int()
2132 &req->id2name, &req->id2domain, in ad_lookup_batch_int()
2133 &req->id2.idtype, &res->retcode); in ad_lookup_batch_int()
2136 } else if (req->id1name != NULL) { in ad_lookup_batch_int()
2141 is_user = (IS_ID_UID(req->id1)) ? 1 : 0; in ad_lookup_batch_int()
2153 qs, req->id1name, is_user, is_wuser, in ad_lookup_batch_int()
2159 &req->id2name, &req->id2domain, in ad_lookup_batch_int()
2160 &req->id2.idtype, &res->retcode); in ad_lookup_batch_int()
2167 req->direction |= _IDMAP_F_LOOKUP_OTHER_AD; in ad_lookup_batch_int()
2196 req = &batch->idmap_mapping_batch_val[i]; in ad_lookup_batch_int()
2197 req->direction |= _IDMAP_F_LOOKUP_OTHER_AD; in ad_lookup_batch_int()
2219 req = &batch->idmap_mapping_batch_val[i]; in ad_lookup_batch_int()
2220 type = req->id2.idtype; in ad_lookup_batch_int()
2221 req->id2.idtype = IDMAP_NONE; in ad_lookup_batch_int()
2222 posix_id = req->id2.idmap_id_u.uid; in ad_lookup_batch_int()
2223 req->id2.idmap_id_u.uid = IDMAP_SENTINEL_PID; in ad_lookup_batch_int()
2229 if (!(req->direction & _IDMAP_F_LOOKUP_AD)) in ad_lookup_batch_int()
2236 if (req->direction & _IDMAP_F_LOOKUP_OTHER_AD) { in ad_lookup_batch_int()
2237 req->direction &= ~_IDMAP_F_LOOKUP_OTHER_AD; in ad_lookup_batch_int()
2245 req->direction &= ~(_IDMAP_F_LOOKUP_AD); in ad_lookup_batch_int()
2262 if (IS_ID_SID(req->id1)) { in ad_lookup_batch_int()
2264 TRACE(req, res, "Not found in AD"); in ad_lookup_batch_int()
2268 TRACE(req, res, "AD lookup error=%d", in ad_lookup_batch_int()
2290 req->id1.idtype = IDMAP_USID; in ad_lookup_batch_int()
2309 req->id1.idtype = IDMAP_GSID; in ad_lookup_batch_int()
2316 TRACE(req, res, "Found in AD"); in ad_lookup_batch_int()
2318 req->id1name != NULL && in ad_lookup_batch_int()
2319 (req->id2name == NULL || in ad_lookup_batch_int()
2322 req->direction |= _IDMAP_F_LOOKUP_NLDAP; in ad_lookup_batch_int()
2325 } else if (IS_ID_UID(req->id1) || IS_ID_GID(req->id1)) { in ad_lookup_batch_int()
2329 req->id2name == NULL) { in ad_lookup_batch_int()
2343 TRACE(req, res, in ad_lookup_batch_int()
2346 TRACE(req, res, in ad_lookup_batch_int()
2351 TRACE(req, res, "AD lookup error"); in ad_lookup_batch_int()
2367 TRACE(req, res, "Found in AD"); in ad_lookup_batch_int()
2385 idmap_mapping *req; in ad_lookup_batch() local
2394 req = &batch->idmap_mapping_batch_val[i]; in ad_lookup_batch()
2398 if (!(req->direction & _IDMAP_F_LOOKUP_AD) || in ad_lookup_batch()
2413 req = &batch->idmap_mapping_batch_val[i]; in ad_lookup_batch()
2415 if (!(req->direction & _IDMAP_F_LOOKUP_AD)) in ad_lookup_batch()
2417 req->direction &= ~(_IDMAP_F_LOOKUP_AD); in ad_lookup_batch()
2451 req = &batch->idmap_mapping_batch_val[j]; in ad_lookup_batch()
2453 if (!(req->direction & _IDMAP_F_LOOKUP_AD)) in ad_lookup_batch()
2455 req->direction &= ~(_IDMAP_F_LOOKUP_AD); in ad_lookup_batch()
2534 sid2pid_first_pass(lookup_state_t *state, idmap_mapping *req, in sid2pid_first_pass() argument
2541 res->id.idtype = req->id2.idtype; in sid2pid_first_pass()
2546 if (EMPTY_STRING(req->id1.idmap_id_u.sid.prefix)) { in sid2pid_first_pass()
2548 if (req->id1name == NULL) { in sid2pid_first_pass()
2554 free(req->id1.idmap_id_u.sid.prefix); in sid2pid_first_pass()
2555 req->id1.idmap_id_u.sid.prefix = NULL; in sid2pid_first_pass()
2558 if (req->id1domain == NULL) { in sid2pid_first_pass()
2560 p = strchr(req->id1name, '@'); in sid2pid_first_pass()
2563 q = req->id1name; in sid2pid_first_pass()
2564 req->id1name = uu_strndup(q, p - req->id1name); in sid2pid_first_pass()
2565 req->id1domain = strdup(p+1); in sid2pid_first_pass()
2567 if (req->id1name == NULL || in sid2pid_first_pass()
2568 req->id1domain == NULL) { in sid2pid_first_pass()
2577 retcode = lookup_wksids_sid2pid(req, res, &wksid); in sid2pid_first_pass()
2580 TRACE(req, res, "Hardwired mapping"); in sid2pid_first_pass()
2583 TRACE(req, res, in sid2pid_first_pass()
2590 TRACE(req, res, "Well-known account"); in sid2pid_first_pass()
2592 TRACE(req, res, "Not a well-known account"); in sid2pid_first_pass()
2595 retcode = lookup_localsid2pid(req, res); in sid2pid_first_pass()
2597 TRACE(req, res, "Local SID"); in sid2pid_first_pass()
2600 TRACE(req, res, in sid2pid_first_pass()
2604 TRACE(req, res, "Not a local SID"); in sid2pid_first_pass()
2606 if (ALLOW_WK_OR_LOCAL_SIDS_ONLY(req)) { in sid2pid_first_pass()
2619 if (req->id1.idmap_id_u.sid.prefix == NULL && in sid2pid_first_pass()
2620 req->id1name != NULL && req->id1domain == NULL) { in sid2pid_first_pass()
2625 req->id1domain = strdup(state->defdom); in sid2pid_first_pass()
2626 if (req->id1domain == NULL) { in sid2pid_first_pass()
2630 TRACE(req, res, "Added default domain"); in sid2pid_first_pass()
2634 retcode = lookup_cache_sid2pid(state->cache, req, res); in sid2pid_first_pass()
2636 TRACE(req, res, "Found in mapping cache"); in sid2pid_first_pass()
2639 TRACE(req, res, "Mapping cache lookup error=%d", retcode); in sid2pid_first_pass()
2642 TRACE(req, res, "Not found in mapping cache"); in sid2pid_first_pass()
2644 if (DO_NOT_ALLOC_NEW_ID_MAPPING(req) || AVOID_NAMESERVICE(req)) { in sid2pid_first_pass()
2658 retcode = lookup_name_cache(state->cache, req, res); in sid2pid_first_pass()
2661 if (req->id1.idtype == IDMAP_USID) in sid2pid_first_pass()
2675 if (req->id1.idmap_id_u.sid.prefix != NULL && in sid2pid_first_pass()
2676 req->id1name == NULL) { in sid2pid_first_pass()
2679 req->id1.idmap_id_u.sid.prefix, in sid2pid_first_pass()
2680 req->id1.idmap_id_u.sid.rid, in sid2pid_first_pass()
2681 &req->id1name, &req->id1domain, &req->id1.idtype); in sid2pid_first_pass()
2683 TRACE(req, res, "Found with LSA"); in sid2pid_first_pass()
2685 TRACE(req, res, "Not found with LSA"); in sid2pid_first_pass()
2687 TRACE(req, res, "LSA error %d", retcode); in sid2pid_first_pass()
2691 } else if (req->id1name != NULL && in sid2pid_first_pass()
2692 req->id1.idmap_id_u.sid.prefix == NULL) { in sid2pid_first_pass()
2697 req->id1name, req->id1domain, in sid2pid_first_pass()
2698 &req->id1.idmap_id_u.sid.prefix, in sid2pid_first_pass()
2699 &req->id1.idmap_id_u.sid.rid, in sid2pid_first_pass()
2701 &req->id1.idtype); in sid2pid_first_pass()
2703 free(req->id1name); in sid2pid_first_pass()
2704 req->id1name = canonname; in sid2pid_first_pass()
2705 free(req->id1domain); in sid2pid_first_pass()
2706 req->id1domain = canondomain; in sid2pid_first_pass()
2707 TRACE(req, res, "Found with LSA"); in sid2pid_first_pass()
2709 TRACE(req, res, "Not found with LSA"); in sid2pid_first_pass()
2711 TRACE(req, res, "LSA error %d", retcode); in sid2pid_first_pass()
2723 req->direction |= _IDMAP_F_NOTDONE; in sid2pid_first_pass()
2733 (!wksid && req->id2name == NULL && in sid2pid_first_pass()
2738 req->direction |= _IDMAP_F_LOOKUP_AD; in sid2pid_first_pass()
2741 req->direction |= _IDMAP_F_LOOKUP_NLDAP; in sid2pid_first_pass()
2752 if (ARE_WE_DONE(req->direction) && res->retcode != IDMAP_SUCCESS) in sid2pid_first_pass()
2764 generate_localsid(idmap_mapping *req, idmap_id_res *res, int is_user, in generate_localsid() argument
2781 req->id1.idmap_id_u.uid + LOCALRID_UID_MIN > LOCALRID_UID_MAX) in generate_localsid()
2798 (is_user) ? req->id1.idmap_id_u.uid + LOCALRID_UID_MIN : in generate_localsid()
2799 req->id1.idmap_id_u.gid + LOCALRID_GID_MIN; in generate_localsid()
2813 req->direction |= _IDMAP_F_DONT_UPDATE_NAMECACHE; in generate_localsid()
2819 lookup_localsid2pid(idmap_mapping *req, idmap_id_res *res) in lookup_localsid2pid() argument
2829 if ((sidprefix = req->id1.idmap_id_u.sid.prefix) == NULL) in lookup_localsid2pid()
2832 rid = req->id1.idmap_id_u.sid.rid; in lookup_localsid2pid()
3010 idmap_mapping *req, idmap_id_res *res) in name_based_mapping_sid2pid() argument
3023 assert(req->id1name != NULL); /* We have winname */ in name_based_mapping_sid2pid()
3024 assert(req->id2name == NULL); /* We don't have unixname */ in name_based_mapping_sid2pid()
3026 winname = req->id1name; in name_based_mapping_sid2pid()
3027 windomain = req->id1domain; in name_based_mapping_sid2pid()
3029 switch (req->id1.idtype) { in name_based_mapping_sid2pid()
3092 TRACE(req, res, "Matching rule: %s@%s -> %s", in name_based_mapping_sid2pid()
3110 TRACE(req, res, "Mapping inhibited"); in name_based_mapping_sid2pid()
3133 TRACE(req, res, in name_based_mapping_sid2pid()
3139 TRACE(req, res, in name_based_mapping_sid2pid()
3150 TRACE(req, res, "Looking up %s error=%d", in name_based_mapping_sid2pid()
3155 TRACE(req, res, "No matching rule"); in name_based_mapping_sid2pid()
3178 req->id2name = strdup(unixname); in name_based_mapping_sid2pid()
3179 if (req->id2name == NULL) { in name_based_mapping_sid2pid()
3183 TRACE(req, res, "UNIX name found"); in name_based_mapping_sid2pid()
3193 TRACE(req, res, "Rule processing error, code=%d", retcode); in name_based_mapping_sid2pid()
3338 idmap_mapping *req, idmap_id_res *res) in dynamic_ephemeral_mapping() argument
3352 get_from_sid_history(state, req->id1.idmap_id_u.sid.prefix, in dynamic_ephemeral_mapping()
3353 req->id1.idmap_id_u.sid.rid, &next_pid)) { in dynamic_ephemeral_mapping()
3373 add_to_sid_history(state, req->id1.idmap_id_u.sid.prefix, in dynamic_ephemeral_mapping()
3374 req->id1.idmap_id_u.sid.rid); in dynamic_ephemeral_mapping()
3381 idmap_mapping *req, idmap_id_res *res) in sid2pid_second_pass() argument
3387 if (ARE_WE_DONE(req->direction)) in sid2pid_second_pass()
3393 !EMPTY_STRING(req->id1.idmap_id_u.sid.prefix) && in sid2pid_second_pass()
3394 EMPTY_STRING(req->id1name)) { in sid2pid_second_pass()
3401 if (req->id1.idtype == IDMAP_SID) in sid2pid_second_pass()
3402 req->id1.idtype = IDMAP_USID; in sid2pid_second_pass()
3405 TRACE(req, res, "Assume unresolvable SID is user"); in sid2pid_second_pass()
3407 TRACE(req, res, "Must map unresolvable SID to user"); in sid2pid_second_pass()
3409 TRACE(req, res, "Must map unresolvable SID to group"); in sid2pid_second_pass()
3425 if (req->id2name == NULL) { in sid2pid_second_pass()
3433 res->id.idtype == IDMAP_UID, &req->id2name); in sid2pid_second_pass()
3435 TRACE(req, res, in sid2pid_second_pass()
3439 TRACE(req, res, "Found UNIX name"); in sid2pid_second_pass()
3450 if (req->id2name != NULL) { in sid2pid_second_pass()
3502 ((req->id1.idtype == IDMAP_USID && in sid2pid_second_pass()
3504 (req->id1.idtype == IDMAP_GSID && in sid2pid_second_pass()
3506 TRACE(req, res, "Ignoring UNIX name found in AD"); in sid2pid_second_pass()
3507 free(req->id2name); in sid2pid_second_pass()
3508 req->id2name = NULL; in sid2pid_second_pass()
3513 retcode = ns_lookup_byname(req->id2name, in sid2pid_second_pass()
3527 TRACE(req, res, in sid2pid_second_pass()
3531 TRACE(req, res, "UNIX lookup"); in sid2pid_second_pass()
3545 retcode = name_based_mapping_sid2pid(state, req, res); in sid2pid_second_pass()
3547 TRACE(req, res, "Rule-based mapping"); in sid2pid_second_pass()
3550 TRACE(req, res, "Rule-based mapping error=%d", retcode); in sid2pid_second_pass()
3556 retcode = dynamic_ephemeral_mapping(state, req, res); in sid2pid_second_pass()
3558 TRACE(req, res, "Ephemeral mapping"); in sid2pid_second_pass()
3561 TRACE(req, res, "Ephemeral mapping error=%d", retcode); in sid2pid_second_pass()
3568 req->direction = _IDMAP_F_DONE; in sid2pid_second_pass()
3571 if (!ARE_WE_DONE(req->direction)) in sid2pid_second_pass()
3578 idmap_mapping *req, idmap_id_res *res) in update_cache_pid2sid() argument
3592 if (ARE_WE_DONE(req->direction)) in update_cache_pid2sid()
3600 assert(req->id1.idmap_id_u.uid != IDMAP_SENTINEL_PID); in update_cache_pid2sid()
3616 if (req->id1name == NULL) { in update_cache_pid2sid()
3617 retcode2 = ns_lookup_bypid(req->id1.idmap_id_u.uid, in update_cache_pid2sid()
3618 req->id1.idtype == IDMAP_UID, &req->id1name); in update_cache_pid2sid()
3620 TRACE(req, res, "Found UNIX name"); in update_cache_pid2sid()
3622 TRACE(req, res, "Getting UNIX name error=%d", retcode2); in update_cache_pid2sid()
3676 req->id2domain, req->id2name, req->id1.idmap_id_u.uid, in update_cache_pid2sid()
3677 req->id1name, (req->id1.idtype == IDMAP_UID) ? 1 : 0, in update_cache_pid2sid()
3699 if (req->direction & _IDMAP_F_DONT_UPDATE_NAMECACHE) in update_cache_pid2sid()
3702 if (req->id2name == NULL) in update_cache_pid2sid()
3709 req->id2name, req->id2domain, in update_cache_pid2sid()
3728 idmap_mapping *req, idmap_id_res *res) in update_cache_sid2pid() argument
3742 if (ARE_WE_DONE(req->direction)) in update_cache_sid2pid()
3749 if (req->direction & _IDMAP_F_EXP_EPH_UID) in update_cache_sid2pid()
3751 else if (req->direction & _IDMAP_F_EXP_EPH_GID) in update_cache_sid2pid()
3762 req->id1.idmap_id_u.sid.prefix, in update_cache_sid2pid()
3763 req->id1.idmap_id_u.sid.rid, in update_cache_sid2pid()
3824 req->id1.idmap_id_u.sid.prefix, req->id1.idmap_id_u.sid.rid, in update_cache_sid2pid()
3825 (req->id1domain != NULL) ? req->id1domain : "", req->id1name, in update_cache_sid2pid()
3826 res->id.idmap_id_u.uid, req->id2name, in update_cache_sid2pid()
3828 (req->id1.idtype == IDMAP_USID) ? 1 : 0, in update_cache_sid2pid()
3849 if (req->direction & _IDMAP_F_DONT_UPDATE_NAMECACHE) in update_cache_sid2pid()
3852 if (EMPTY_STRING(req->id1name)) in update_cache_sid2pid()
3858 req->id1.idmap_id_u.sid.prefix, req->id1.idmap_id_u.sid.rid, in update_cache_sid2pid()
3859 req->id1name, req->id1domain, in update_cache_sid2pid()
3860 req->id1.idtype, state->name_cache_timeout); in update_cache_sid2pid()
3878 lookup_cache_pid2sid(sqlite *cache, idmap_mapping *req, idmap_id_res *res, in lookup_cache_pid2sid() argument
3900 if (req->id1.idmap_id_u.uid != IDMAP_SENTINEL_PID) { in lookup_cache_pid2sid()
3910 req->id1.idmap_id_u.uid, is_user, curtime); in lookup_cache_pid2sid()
3911 } else if (req->id1name != NULL) { in lookup_cache_pid2sid()
3921 req->id1name, is_user, curtime); in lookup_cache_pid2sid()
3981 req->id2name = strdup(values[2]); in lookup_cache_pid2sid()
3982 if (req->id2name == NULL) { in lookup_cache_pid2sid()
3990 req->id2domain = strdup(values[3]); in lookup_cache_pid2sid()
3991 if (req->id2domain == NULL) { in lookup_cache_pid2sid()
4002 if (req->flag & IDMAP_REQ_FLG_MAPPING_INFO) { in lookup_cache_pid2sid()
4302 idmap_mapping *req, in lookup_name2sid() argument
4317 req->direction |= _IDMAP_F_DONT_UPDATE_NAMECACHE; in lookup_name2sid()
4327 req->direction |= _IDMAP_F_DONT_UPDATE_NAMECACHE; in lookup_name2sid()
4408 int is_user, idmap_mapping *req, idmap_id_res *res) in name_based_mapping_pid2sid() argument
4425 assert(req->id2name == NULL); /* We don't have winname */ in name_based_mapping_pid2sid()
4458 TRACE(req, res, "Matching rule: %s -> %s@%s", in name_based_mapping_pid2sid()
4482 TRACE(req, res, "Mapping inhibited"); in name_based_mapping_pid2sid()
4500 TRACE(req, res, in name_based_mapping_pid2sid()
4505 TRACE(req, res, in name_based_mapping_pid2sid()
4516 &res->id.idtype, req, 0); in name_based_mapping_pid2sid()
4522 TRACE(req, res, in name_based_mapping_pid2sid()
4527 TRACE(req, res, in name_based_mapping_pid2sid()
4533 TRACE(req, res, in name_based_mapping_pid2sid()
4547 TRACE(req, res, "No matching rule"); in name_based_mapping_pid2sid()
4568 req->id2name = canonname; in name_based_mapping_pid2sid()
4569 req->id2domain = canondomain; in name_based_mapping_pid2sid()
4575 TRACE(req, res, "Windows name found"); in name_based_mapping_pid2sid()
4649 pid2sid_first_pass(lookup_state_t *state, idmap_mapping *req, in pid2sid_first_pass() argument
4657 res->id.idtype = req->id2.idtype; in pid2sid_first_pass()
4660 if (req->id2.idmap_id_u.sid.prefix != NULL) { in pid2sid_first_pass()
4662 free(req->id2.idmap_id_u.sid.prefix); in pid2sid_first_pass()
4663 req->id2.idmap_id_u.sid.prefix = NULL; in pid2sid_first_pass()
4667 if (req->id1.idmap_id_u.uid == IDMAP_SENTINEL_PID) { in pid2sid_first_pass()
4668 if (req->id1name == NULL) { in pid2sid_first_pass()
4673 retcode = ns_lookup_byname(req->id1name, NULL, &req->id1); in pid2sid_first_pass()
4675 TRACE(req, res, "Getting UNIX ID error=%d", retcode); in pid2sid_first_pass()
4679 TRACE(req, res, "Found UNIX ID"); in pid2sid_first_pass()
4683 retcode = lookup_wksids_pid2sid(req, res, is_user); in pid2sid_first_pass()
4685 TRACE(req, res, "Hardwired mapping"); in pid2sid_first_pass()
4688 TRACE(req, res, in pid2sid_first_pass()
4694 retcode = lookup_cache_pid2sid(state->cache, req, res, is_user); in pid2sid_first_pass()
4696 TRACE(req, res, "Found in mapping cache"); in pid2sid_first_pass()
4699 TRACE(req, res, in pid2sid_first_pass()
4703 TRACE(req, res, "Not found in mapping cache"); in pid2sid_first_pass()
4706 if (IDMAP_ID_IS_EPHEMERAL(req->id1.idmap_id_u.uid)) { in pid2sid_first_pass()
4708 TRACE(req, res, "Shouldn't have an ephemeral ID here"); in pid2sid_first_pass()
4712 if (DO_NOT_ALLOC_NEW_ID_MAPPING(req)) { in pid2sid_first_pass()
4717 if (AVOID_NAMESERVICE(req)) { in pid2sid_first_pass()
4725 req->direction |= _IDMAP_F_LOOKUP_AD; in pid2sid_first_pass()
4727 } else if (AD_MODE(req->id1.idtype, state)) { in pid2sid_first_pass()
4733 if (req->id1name == NULL) { in pid2sid_first_pass()
4735 retcode = ns_lookup_bypid(req->id1.idmap_id_u.uid, in pid2sid_first_pass()
4736 is_user, &req->id1name); in pid2sid_first_pass()
4738 TRACE(req, res, in pid2sid_first_pass()
4743 TRACE(req, res, "Found UNIX name"); in pid2sid_first_pass()
4745 req->direction |= _IDMAP_F_LOOKUP_AD; in pid2sid_first_pass()
4747 } else if (NLDAP_OR_MIXED_MODE(req->id1.idtype, state)) { in pid2sid_first_pass()
4753 req->direction |= _IDMAP_F_LOOKUP_NLDAP; in pid2sid_first_pass()
4762 req->direction |= _IDMAP_F_NOTDONE; in pid2sid_first_pass()
4767 if (ARE_WE_DONE(req->direction) && res->retcode != IDMAP_SUCCESS) { in pid2sid_first_pass()
4769 retcode2 = generate_localsid(req, res, is_user, TRUE); in pid2sid_first_pass()
4771 TRACE(req, res, "Generate local SID"); in pid2sid_first_pass()
4773 TRACE(req, res, in pid2sid_first_pass()
4781 pid2sid_second_pass(lookup_state_t *state, idmap_mapping *req, in pid2sid_second_pass() argument
4789 if (ARE_WE_DONE(req->direction)) in pid2sid_second_pass()
4807 if (req->id2name != NULL) { in pid2sid_second_pass()
4810 TRACE(req, res, "Windows name but no SID"); in pid2sid_second_pass()
4816 else if (AD_MODE(req->id1.idtype, state)) in pid2sid_second_pass()
4818 else if (NLDAP_MODE(req->id1.idtype, state)) in pid2sid_second_pass()
4820 else if (MIXED_MODE(req->id1.idtype, state)) in pid2sid_second_pass()
4835 if (req->id1name == NULL) { in pid2sid_second_pass()
4837 retcode = ns_lookup_bypid(req->id1.idmap_id_u.uid, is_user, in pid2sid_second_pass()
4838 &req->id1name); in pid2sid_second_pass()
4840 TRACE(req, res, in pid2sid_second_pass()
4844 TRACE(req, res, "Found UNIX name"); in pid2sid_second_pass()
4845 } else if (req->id1.idmap_id_u.uid == IDMAP_SENTINEL_PID) { in pid2sid_second_pass()
4847 retcode = ns_lookup_byname(req->id1name, NULL, &req->id1); in pid2sid_second_pass()
4849 TRACE(req, res, in pid2sid_second_pass()
4854 TRACE(req, res, "Found UNIX ID"); in pid2sid_second_pass()
4858 retcode = name_based_mapping_pid2sid(state, req->id1name, is_user, in pid2sid_second_pass()
4859 req, res); in pid2sid_second_pass()
4861 retcode = generate_localsid(req, res, is_user, FALSE); in pid2sid_second_pass()
4863 TRACE(req, res, "Generated local SID"); in pid2sid_second_pass()
4865 TRACE(req, res, in pid2sid_second_pass()
4874 req->direction = _IDMAP_F_DONE; in pid2sid_second_pass()
4875 free(req->id2name); in pid2sid_second_pass()
4876 req->id2name = NULL; in pid2sid_second_pass()
4877 free(req->id2domain); in pid2sid_second_pass()
4878 req->id2domain = NULL; in pid2sid_second_pass()
4880 retcode2 = generate_localsid(req, res, is_user, TRUE); in pid2sid_second_pass()
4882 TRACE(req, res, "Generate local SID"); in pid2sid_second_pass()
4884 TRACE(req, res, in pid2sid_second_pass()
4890 if (!ARE_WE_DONE(req->direction)) in pid2sid_second_pass()