creds-util: add helper for opening the credentials directory

This commit is contained in:
Lennart Poettering
2023-11-22 10:57:20 +01:00
parent 68f74b0af2
commit 58982cf0cb
2 changed files with 13 additions and 0 deletions

View File

@@ -100,6 +100,17 @@ int get_encrypted_credentials_dir(const char **ret) {
return get_credentials_dir_internal("ENCRYPTED_CREDENTIALS_DIRECTORY", ret);
}
int open_credentials_dir(void) {
const char *d;
int r;
r = get_credentials_dir(&d);
if (r < 0)
return r;
return RET_NERRNO(open(d, O_CLOEXEC|O_DIRECTORY));
}
int read_credential(const char *name, void **ret, size_t *ret_size) {
_cleanup_free_ char *fn = NULL;
const char *d;

View File

@@ -31,6 +31,8 @@ bool credential_glob_valid(const char *s);
int get_credentials_dir(const char **ret);
int get_encrypted_credentials_dir(const char **ret);
int open_credentials_dir(void);
/* Where creds have been passed to the system */
#define SYSTEM_CREDENTIALS_DIRECTORY "/run/credentials/@system"
#define ENCRYPTED_SYSTEM_CREDENTIALS_DIRECTORY "/run/credentials/@encrypted"