diff options
| author | Pavel Březina <pbrezina@redhat.com> | 2016-10-05 14:05:45 +0200 |
|---|---|---|
| committer | Lukas Slebodnik <lslebodn@redhat.com> | 2016-12-19 23:28:55 +0100 |
| commit | 4049b63f8c67ada17b453463b0451ca6be3d5de4 (patch) | |
| tree | 1c0d014c7b63ec9d17eca6bd2891f76072abe92b /src/util | |
| parent | a5a3bbb0bbaeb8946c228c2fb7f0cf450595dd3e (diff) | |
| download | sssd-4049b63f8c67ada17b453463b0451ca6be3d5de4.tar.gz sssd-4049b63f8c67ada17b453463b0451ca6be3d5de4.tar.xz sssd-4049b63f8c67ada17b453463b0451ca6be3d5de4.zip | |
nss: rewrite nss responder so it uses cache_req
Given the size of the current nss responder it was quite impossible
to simply switch into using the cache_req interface, especially
because most of the code was duplication of cache lookups.
This patch completely rewrites the responder from scratch. The amount
of code was reduced to less than a half lines of code with no code duplication,
better documentation and better maintainability and readability.
All functionality should be intact.
*Code organization*
All protocol (parsing input message and send a reply) is placed
in nss_protocol.c. Functions that deals with creating a reply
packet are placed into their specific nss_protocol_$object.c files.
All supported commands are placed into nss_cmd.c. Functions that
deals with cache req are in nss_get_object.c and nss_enum.c.
*Code flow for non-enumeration*
An nss_getby_$input-type is called for each non-enumeration command.
This function parses the input message, creates a cache_req_data
structure and issues nss_get_object that calls cache_req. When
this request is done nss_getby_done make sure a reply is sent to
the client.
*Comments on enumeration*
I made some effort to make sure enumeration shares the same code
for users, groups, services and netgroups. Netgroups now uses
nss negative cache instead of implementing its own.
Resolves:
https://fedorahosted.org/sssd/ticket/3151
Reviewed-by: Lukáš Slebodník <lslebodn@redhat.com>
Diffstat (limited to 'src/util')
| -rw-r--r-- | src/util/sss_ptr_hash.c | 4 | ||||
| -rw-r--r-- | src/util/util_safealign.h | 6 |
2 files changed, 8 insertions, 2 deletions
diff --git a/src/util/sss_ptr_hash.c b/src/util/sss_ptr_hash.c index e34b9b2c1..4827e1e98 100644 --- a/src/util/sss_ptr_hash.c +++ b/src/util/sss_ptr_hash.c @@ -170,7 +170,7 @@ hash_table_t *sss_ptr_hash_create(TALLOC_CTX *mem_ctx, hash_table_t *table; errno_t ret; - data = talloc_zero(mem_ctx, struct sss_ptr_hash_delete_data); + data = talloc_zero(NULL, struct sss_ptr_hash_delete_data); if (data == NULL) { return NULL; } @@ -178,7 +178,7 @@ hash_table_t *sss_ptr_hash_create(TALLOC_CTX *mem_ctx, data->callback = del_cb; data->pvt = del_cb_pvt; - ret = sss_hash_create_ex(NULL, 10, &table, 0, 0, 0, 0, + ret = sss_hash_create_ex(mem_ctx, 10, &table, 0, 0, 0, 0, sss_ptr_hash_delete_cb, data); if (ret != EOK) { DEBUG(SSSDBG_CRIT_FAILURE, "Unable to create hash table [%d]: %s\n", diff --git a/src/util/util_safealign.h b/src/util/util_safealign.h index b1c9f8a0c..a2cd4dd0d 100644 --- a/src/util/util_safealign.h +++ b/src/util/util_safealign.h @@ -119,11 +119,17 @@ safealign_memcpy(void *dest, const void *src, size_t n, size_t *counter) safealign_memcpy(dest, src, sizeof(uint16_t), pctr); \ } while(0) +#define SAFEALIGN_SETMEM_STRING(dest, value, length, pctr) do { \ + const char *CV_MACRO_val = (const char *)(value); \ + safealign_memcpy(dest, CV_MACRO_val, sizeof(char) * length, pctr); \ +} while(0) + /* Aliases for backward compatibility. */ #define SAFEALIGN_SET_VALUE SAFEALIGN_SETMEM_VALUE #define SAFEALIGN_SET_INT64 SAFEALIGN_SETMEM_INT64 #define SAFEALIGN_SET_UINT32 SAFEALIGN_SETMEM_UINT32 #define SAFEALIGN_SET_INT32 SAFEALIGN_SETMEM_INT32 #define SAFEALIGN_SET_UINT16 SAFEALIGN_SETMEM_UINT16 +#define SAFEALIGN_SET_STRING SAFEALIGN_SETMEM_STRING #endif /* _UTIL_SAFEALIGN_H */ |
