mirror of
https://gitlab.freedesktop.org/libfprint/fprintd.git
synced 2025-12-26 22:50:09 +01:00
file_storage: Handle STATE_DIRECTORY containing multiple paths
As per systemd's documentation:
If multiple directories are set, then in the environment variable the
paths are concatenated with colon (":").
Handle that case by splitting the paths if there's a ":" in the
variable.
Closes: #50
This commit is contained in:
parent
6a1fffae82
commit
fd733e55be
1 changed files with 20 additions and 5 deletions
|
|
@ -42,18 +42,33 @@
|
|||
#define FILE_STORAGE_PATH "/var/lib/fprint"
|
||||
#define DIR_PERMS 0700
|
||||
|
||||
static char *storage_path = NULL;
|
||||
|
||||
static const char *get_storage_path(void)
|
||||
{
|
||||
const char *path;
|
||||
const char *path = NULL;
|
||||
|
||||
if (storage_path != NULL)
|
||||
return storage_path;
|
||||
|
||||
/* set by systemd >= 240 to an absolute path
|
||||
* taking into account the StateDirectory
|
||||
* unit file setting */
|
||||
path = g_getenv ("STATE_DIRECTORY");
|
||||
if (path != NULL)
|
||||
return path;
|
||||
if (path != NULL) {
|
||||
/* If multiple directories are set, then in the environment variable
|
||||
* the paths are concatenated with colon (":"). */
|
||||
if (strchr (path, ':')) {
|
||||
g_auto(GStrv) elems = NULL;
|
||||
elems = g_strsplit (path, ":", -1);
|
||||
storage_path = g_strdup (elems[0]);
|
||||
}
|
||||
}
|
||||
|
||||
return FILE_STORAGE_PATH;
|
||||
if (storage_path == NULL)
|
||||
storage_path = g_strdup (FILE_STORAGE_PATH);
|
||||
|
||||
return storage_path;
|
||||
}
|
||||
|
||||
static char *get_path_to_storedir(const char *driver, const char * device_id, char *base_store)
|
||||
|
|
@ -296,6 +311,6 @@ int file_storage_init(void)
|
|||
|
||||
int file_storage_deinit(void)
|
||||
{
|
||||
/* Nothing to do */
|
||||
g_clear_pointer (&storage_path, g_free);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue