summaryrefslogtreecommitdiffstats
path: root/src/resolve
diff options
context:
space:
mode:
authorSteven Luo <stevenhelpme@gmail.com>2023-06-27 10:11:38 +0200
committerGitHub <noreply@github.com>2023-06-27 10:11:38 +0200
commitb89531159a0e63a7f56976dbdd73c09e41d3be6c (patch)
treee7cdf35387d9d5be43e6833652bc23553199cd36 /src/resolve
parentMerge pull request #28064 from bluca/test_oomd_swap (diff)
downloadsystemd-b89531159a0e63a7f56976dbdd73c09e41d3be6c.tar.xz
systemd-b89531159a0e63a7f56976dbdd73c09e41d3be6c.zip
replace basename() with path_extract_filename() in resolved-resolv-conf.c (#28114)
Diffstat (limited to 'src/resolve')
-rw-r--r--src/resolve/resolved-resolv-conf.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/resolve/resolved-resolv-conf.c b/src/resolve/resolved-resolv-conf.c
index 52e31d2fd3..1da0ac8995 100644
--- a/src/resolve/resolved-resolv-conf.c
+++ b/src/resolve/resolved-resolv-conf.c
@@ -12,6 +12,7 @@
#include "fs-util.h"
#include "label-util.h"
#include "ordered-set.h"
+#include "path-util.h"
#include "resolved-conf.h"
#include "resolved-dns-server.h"
#include "resolved-resolv-conf.h"
@@ -371,7 +372,12 @@ int manager_write_resolv_conf(Manager *m) {
temp_path_stub = mfree(temp_path_stub); /* free the string explicitly, so that we don't unlink anymore */
} else {
- r = symlink_atomic_label(basename(PRIVATE_UPLINK_RESOLV_CONF), PRIVATE_STUB_RESOLV_CONF);
+ _cleanup_free_ char *fname = NULL;
+ r = path_extract_filename(PRIVATE_UPLINK_RESOLV_CONF, &fname);
+ if (r < 0)
+ return log_warning_errno(r, "Failed to extract filename from path '" PRIVATE_UPLINK_RESOLV_CONF "', ignoring: %m");
+
+ r = symlink_atomic_label(fname, PRIVATE_STUB_RESOLV_CONF);
if (r < 0)
log_warning_errno(r, "Failed to symlink %s, ignoring: %m", PRIVATE_STUB_RESOLV_CONF);
}