mirror of
https://github.com/systemd/systemd.git
synced 2025-01-11 09:18:07 +03:00
pam-util: add pam_get_item_many() helper that gets many PAM items at once
Just to shorten a bit of code.
This commit is contained in:
parent
6d5743c411
commit
f47d75de51
@ -202,3 +202,27 @@ void pam_cleanup_free(pam_handle_t *handle, void *data, int error_status) {
|
||||
/* A generic destructor for pam_set_data() that just frees the specified data */
|
||||
free(data);
|
||||
}
|
||||
|
||||
int pam_get_item_many_internal(pam_handle_t *handle, ...) {
|
||||
va_list ap;
|
||||
int r;
|
||||
|
||||
va_start(ap, handle);
|
||||
for (;;) {
|
||||
int item_type = va_arg(ap, int);
|
||||
|
||||
if (item_type <= 0) {
|
||||
r = PAM_SUCCESS;
|
||||
break;
|
||||
}
|
||||
|
||||
const void **value = ASSERT_PTR(va_arg(ap, const void **));
|
||||
|
||||
r = pam_get_item(handle, item_type, value);
|
||||
if (!IN_SET(r, PAM_BAD_ITEM, PAM_SUCCESS))
|
||||
break;
|
||||
}
|
||||
va_end(ap);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
@ -39,3 +39,7 @@ int pam_acquire_bus_connection(pam_handle_t *handle, const char *module_name, sd
|
||||
int pam_release_bus_connection(pam_handle_t *handle, const char *module_name);
|
||||
|
||||
void pam_cleanup_free(pam_handle_t *handle, void *data, int error_status);
|
||||
|
||||
int pam_get_item_many_internal(pam_handle_t *handle, ...);
|
||||
|
||||
#define pam_get_item_many(handle, ...) pam_get_item_many_internal(handle, __VA_ARGS__, -1)
|
||||
|
Loading…
Reference in New Issue
Block a user