summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/shared/creds-util.c11
-rw-r--r--src/shared/creds-util.h2
2 files changed, 13 insertions, 0 deletions
diff --git a/src/shared/creds-util.c b/src/shared/creds-util.c
index 7cc8889595..0026da5b48 100644
--- a/src/shared/creds-util.c
+++ b/src/shared/creds-util.c
@@ -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;
diff --git a/src/shared/creds-util.h b/src/shared/creds-util.h
index 5e39a6a022..36ca0fb610 100644
--- a/src/shared/creds-util.h
+++ b/src/shared/creds-util.h
@@ -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"