tree-wide: make use of path_extend() at many places

This is not a comprehensive port, but mostly some low-hanging fruit.
This commit is contained in:
Lennart Poettering
2021-05-27 17:05:38 +02:00
parent 7ae2768028
commit 4ede980249
6 changed files with 44 additions and 65 deletions
+4 -7
View File
@@ -2287,8 +2287,6 @@ static int setup_exec_directory(
goto fail;
if (exec_directory_is_private(context, type)) {
_cleanup_free_ char *private_root = NULL;
/* So, here's one extra complication when dealing with DynamicUser=1 units. In that
* case we want to avoid leaving a directory around fully accessible that is owned by
* a dynamic user whose UID is later on reused. To lock this down we use the same
@@ -2314,19 +2312,18 @@ static int setup_exec_directory(
* Also, note that we don't do this for EXEC_DIRECTORY_RUNTIME as that's often used
* for sharing files or sockets with other services. */
private_root = path_join(params->prefix[type], "private");
if (!private_root) {
pp = path_join(params->prefix[type], "private");
if (!pp) {
r = -ENOMEM;
goto fail;
}
/* First set up private root if it doesn't exist yet, with access mode 0700 and owned by root:root */
r = mkdir_safe_label(private_root, 0700, 0, 0, MKDIR_WARN_MODE);
r = mkdir_safe_label(pp, 0700, 0, 0, MKDIR_WARN_MODE);
if (r < 0)
goto fail;
pp = path_join(private_root, *rt);
if (!pp) {
if (!path_extend(&pp, *rt)) {
r = -ENOMEM;
goto fail;
}