mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-03 09:01:54 -05:00
conf: improve state directory access checks
We only need RW permission on the last directory.
This commit is contained in:
parent
bf062e455a
commit
c0d8edeb5a
1 changed files with 7 additions and 3 deletions
|
|
@ -106,7 +106,7 @@ static int get_read_path(char *path, size_t size, const char *prefix, const char
|
||||||
|
|
||||||
static int ensure_path(char *path, int size, const char *paths[])
|
static int ensure_path(char *path, int size, const char *paths[])
|
||||||
{
|
{
|
||||||
int i, len, res;
|
int i, len, res, mode;
|
||||||
char *p = path;
|
char *p = path;
|
||||||
|
|
||||||
for (i = 0; paths[i] != NULL; i++) {
|
for (i = 0; paths[i] != NULL; i++) {
|
||||||
|
|
@ -119,14 +119,18 @@ static int ensure_path(char *path, int size, const char *paths[])
|
||||||
p += len;
|
p += len;
|
||||||
size -= len;
|
size -= len;
|
||||||
|
|
||||||
if ((res = access(path, R_OK | W_OK | X_OK)) < 0) {
|
mode = X_OK;
|
||||||
|
if (paths[i+1] == NULL)
|
||||||
|
mode |= R_OK | W_OK;
|
||||||
|
|
||||||
|
if ((res = access(path, mode)) < 0) {
|
||||||
if (errno != ENOENT)
|
if (errno != ENOENT)
|
||||||
return -errno;
|
return -errno;
|
||||||
if ((res = mkdir(path, 0700)) < 0) {
|
if ((res = mkdir(path, 0700)) < 0) {
|
||||||
pw_log_info("Can't create directory %s: %m", path);
|
pw_log_info("Can't create directory %s: %m", path);
|
||||||
return -errno;
|
return -errno;
|
||||||
}
|
}
|
||||||
if ((res = access(path, R_OK | W_OK | X_OK)) < 0)
|
if ((res = access(path, mode)) < 0)
|
||||||
return -errno;
|
return -errno;
|
||||||
|
|
||||||
pw_log_info("created directory %s", path);
|
pw_log_info("created directory %s", path);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue