creds-util: Add read_credential_bool()

This commit is contained in:
Daan De Meyer
2023-08-01 07:53:34 +02:00
parent dea0dc7ba2
commit 77c6add182
2 changed files with 14 additions and 0 deletions
+12
View File
@@ -22,6 +22,7 @@
#include "memory-util.h"
#include "mkdir.h"
#include "openssl-util.h"
#include "parse-util.h"
#include "path-util.h"
#include "random-util.h"
#include "sparse-endian.h"
@@ -253,6 +254,17 @@ int read_credential_strings_many_internal(
return ret;
}
int read_credential_bool(const char *name) {
_cleanup_free_ void *data = NULL;
int r;
r = read_credential(name, &data, NULL);
if (r < 0)
return IN_SET(r, -ENXIO, -ENOENT) ? 0 : r;
return parse_boolean(data);
}
int get_credential_user_password(const char *username, char **ret_password, bool *ret_is_hashed) {
_cleanup_(erase_and_freep) char *creds_password = NULL;
_cleanup_free_ char *cn = NULL;
+2
View File
@@ -43,6 +43,8 @@ int read_credential_strings_many_internal(const char *first_name, char **first_v
#define read_credential_strings_many(first_name, first_value, ...) \
read_credential_strings_many_internal(first_name, first_value, __VA_ARGS__, NULL)
int read_credential_bool(const char *name);
typedef enum CredentialSecretFlags {
CREDENTIAL_SECRET_GENERATE = 1 << 0,
CREDENTIAL_SECRET_WARN_NOT_ENCRYPTED = 1 << 1,