diff options
author | DJ Delorie <dj@redhat.com> | 2020-11-09 22:06:57 -0500 |
---|---|---|
committer | DJ Delorie <dj@redhat.com> | 2020-12-04 17:15:53 -0500 |
commit | f8847d83e17774ed5e9c0f75ef693680b91bcae4 (patch) | |
tree | e67c662ee3cc09742242c19a253b5b62bbaa3ee7 /nss/nss_database.c | |
parent | fa78feca47fdc226b46e7f6fea4c08c10fccd182 (diff) | |
download | glibc-f8847d83e17774ed5e9c0f75ef693680b91bcae4.tar.gz glibc-f8847d83e17774ed5e9c0f75ef693680b91bcae4.tar.xz glibc-f8847d83e17774ed5e9c0f75ef693680b91bcae4.zip |
nsswitch: use new internal API (core)
Core changes to switch the NSS internals to use the new API. Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
Diffstat (limited to 'nss/nss_database.c')
-rw-r--r-- | nss/nss_database.c | 40 |
1 files changed, 38 insertions, 2 deletions
diff --git a/nss/nss_database.c b/nss/nss_database.c index 329bfb1262..e8c307d1f3 100644 --- a/nss/nss_database.c +++ b/nss/nss_database.c @@ -226,6 +226,39 @@ process_line (struct nss_database_data *data, char *line) return true; } +int +__nss_configure_lookup (const char *dbname, const char *service_line) +{ + int db; + nss_action_list result; + struct nss_database_state *local; + + /* Convert named database to index. */ + db = name_to_database_index (dbname); + if (db < 0) + /* Not our database (e.g., sudoers). */ + return -1; + + /* Force any load/cache/read whatever to happen, so we can override + it. */ + __nss_database_get (db, &result); + + local = nss_database_state_get (); + + result = __nss_action_parse (service_line); + if (result == NULL) + return -1; + + atomic_store_release (&local->data.reload_disabled, 1); + local->data.services[db] = result; + +#ifdef USE_NSCD + __nss_database_custom[db] = true; +#endif + + return 0; +} + /* Iterate over the lines in FP, parse them, and store them in DATA. Return false on memory allocation failure, true on success. */ static bool @@ -326,8 +359,11 @@ nss_database_check_reload_and_get (struct nss_database_state *local, may have loaded the configuration first, so synchronize with the Release MO store there. */ if (atomic_load_acquire (&local->data.reload_disabled)) - /* No reload, so there is no error. */ - return true; + { + *result = local->data.services[database_index]; + /* No reload, so there is no error. */ + return true; + } struct file_change_detection initial; if (!__file_change_detection_for_path (&initial, _PATH_NSSWITCH_CONF)) |