New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mmap_cache: add SID and type to struct sss_mc_rec #413
Closed
Closed
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
8317576
mmap_cache: use record size not header size
sumit-bose 0ea5754
mmap_cache: add SID and type to struct sss_mc_rec
sumit-bose 09fcfc9
mmap_cache: add link record to handle alias names
sumit-bose 7913da9
sss_client: add additional data to getpw{nam|uid} results
sumit-bose File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,3 +36,76 @@ nss_get_pwfield(struct nss_ctx *nctx, | |
|
||
return nctx->pwfield; | ||
} | ||
|
||
errno_t get_extra_data(TALLOC_CTX *mem_ctx, | ||
struct sss_domain_info *domain, | ||
const char override_space, | ||
struct ldb_message *msg, | ||
struct sized_data *extra_data) | ||
{ | ||
const char *name; | ||
char *short_name; | ||
size_t len = 0; | ||
size_t pos = 0; | ||
uint8_t *data; | ||
const char *flat_name; | ||
const char *sid_str; | ||
|
||
if (domain == NULL || domain->name == NULL) { | ||
DEBUG(SSSDBG_CRIT_FAILURE, "Missing domain name."); | ||
return EINVAL; | ||
} | ||
|
||
/* Use domain->name if domain->flat_name is undefined */ | ||
/* FIXME: or should it be better "" ? */ | ||
flat_name = domain->flat_name != NULL ? domain->flat_name : domain->name; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove "!= NULL" if you are using this kind of short expression you may optimize that out as well |
||
|
||
name = sss_get_name_from_msg(domain, msg); | ||
if (name == NULL) { | ||
DEBUG(SSSDBG_OP_FAILURE, "Object has no name.\n"); | ||
return EINVAL; | ||
} | ||
|
||
short_name = sss_output_name(mem_ctx, name, domain->case_preserve, | ||
override_space); | ||
if (short_name == NULL) { | ||
DEBUG(SSSDBG_OP_FAILURE, "sss_output_name failed.\n"); | ||
return ENOMEM; | ||
} | ||
|
||
/* If a SID cannot be found add an empty string */ | ||
sid_str = ldb_msg_find_attr_as_string(msg, SYSDB_SID_STR, ""); | ||
|
||
len = strlen(short_name) + strlen(domain->name) + strlen(flat_name) | ||
+ strlen(sid_str) + 4 + 2 * sizeof(uint32_t); | ||
data = talloc_size(mem_ctx, len); | ||
if (data == NULL) { | ||
talloc_free(short_name); | ||
DEBUG(SSSDBG_OP_FAILURE, "talloc_size failed.\n"); | ||
return ENOMEM; | ||
} | ||
|
||
/* overall length of the extra data including the length itself */ | ||
SAFEALIGN_COPY_UINT32(data + pos, &len, &pos); | ||
/* 4 0-terminated strings will follow */ | ||
SAFEALIGN_SET_UINT32(data + pos, 4, &pos); | ||
|
||
memcpy(data + pos, short_name, strlen(short_name) + 1); | ||
pos += strlen(short_name) + 1; | ||
talloc_free(short_name); | ||
|
||
memcpy(data + pos, domain->name, strlen(domain->name) + 1); | ||
pos += strlen(domain->name) + 1; | ||
|
||
memcpy(data + pos, flat_name, strlen(flat_name) + 1); | ||
pos += strlen(flat_name) + 1; | ||
|
||
memcpy(data + pos, sid_str, strlen(sid_str) + 1); | ||
pos += strlen(sid_str) + 1; | ||
|
||
extra_data->data = data; | ||
extra_data->len = len; | ||
|
||
return EOK; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are you formatting this information as an additional structure, instead of simply adding these fileds one by one in the current structure ?