There's no reason to use a pointer here. Setting name to NULL already
marks that an id is to be used.
}
enum nss_status _nss_cash_getgrgid_r(gid_t gid, struct group *result, char *buffer, size_t buflen, int *errnop) {
}
enum nss_status _nss_cash_getgrgid_r(gid_t gid, struct group *result, char *buffer, size_t buflen, int *errnop) {
- uint64_t id = (uint64_t)gid;
struct search_key key = {
struct search_key key = {
.offset = offsetof(struct group_entry, gid),
};
return internal_getgr(&key, result, buffer, buflen, errnop);
.offset = offsetof(struct group_entry, gid),
};
return internal_getgr(&key, result, buffer, buflen, errnop);
}
enum nss_status _nss_cash_getpwuid_r(uid_t uid, struct passwd *result, char *buffer, size_t buflen, int *errnop) {
}
enum nss_status _nss_cash_getpwuid_r(uid_t uid, struct passwd *result, char *buffer, size_t buflen, int *errnop) {
- uint64_t id = (uint64_t)uid;
struct search_key key = {
struct search_key key = {
.offset = offsetof(struct passwd_entry, uid),
};
return internal_getpw(&key, result, buffer, buflen, errnop);
.offset = offsetof(struct passwd_entry, uid),
};
return internal_getpw(&key, result, buffer, buflen, errnop);
return strcmp(key->name, name);
// Lookup by ID (uint64_t)
return strcmp(key->name, name);
// Lookup by ID (uint64_t)
- } else if (key->id != NULL) {
const uint64_t *id = member;
const uint64_t *id = member;
- } else if (*key->id == *id) {
+ } else if (key->id == *id) {
return 0;
} else {
return +1;
}
return 0;
} else {
return +1;
}
struct search_key {
const char *name; // if name != NULL search for a string
struct search_key {
const char *name; // if name != NULL search for a string
- const uint64_t *id; // if name == NULL search for an id
+ const uint64_t id; // if name == NULL search for an id
// The actual data with all entries; this is where the full entry
// including name/id is located (the index holds an offset into data for
// The actual data with all entries; this is where the full entry
// including name/id is located (the index holds an offset into data for