aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Gilbert <floppym@gentoo.org>2019-05-22 10:31:01 -0400
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2019-05-23 09:36:50 +0200
commitbcb846f30f9ca8f42e79d109706aee9f2032261b (patch)
tree33af9bdf0e9db52172c871c266f2ae740460bfe6
parentMerge pull request #12618 from yuwata/test-network-improvements (diff)
downloadsystemd-bcb846f30f9ca8f42e79d109706aee9f2032261b.tar.xz
systemd-bcb846f30f9ca8f42e79d109706aee9f2032261b.zip
shared/machine-image: avoid passing NULL to log_debug_errno
Fixes: https://github.com/systemd/systemd/issues/12534
-rw-r--r--src/shared/machine-image.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/shared/machine-image.c b/src/shared/machine-image.c
index 6b9d8fb97a6..6a6d952b424 100644
--- a/src/shared/machine-image.c
+++ b/src/shared/machine-image.c
@@ -201,11 +201,13 @@ static int image_make(
Image **ret) {
_cleanup_free_ char *pretty_buffer = NULL;
+ _cleanup_free_ char *cwd = NULL;
struct stat stbuf;
bool read_only;
int r;
assert(dfd >= 0 || dfd == AT_FDCWD);
+ assert(path || dfd == AT_FDCWD);
assert(filename);
/* We explicitly *do* follow symlinks here, since we want to allow symlinking trees, raw files and block
@@ -221,6 +223,9 @@ static int image_make(
st = &stbuf;
}
+ if (!path)
+ safe_getcwd(&cwd);
+
read_only =
(path && path_startswith(path, "/usr")) ||
(faccessat(dfd, filename, W_OK, AT_EACCESS) < 0 && errno == EROFS);
@@ -359,7 +364,7 @@ static int image_make(
block_fd = openat(dfd, filename, O_RDONLY|O_NONBLOCK|O_CLOEXEC|O_NOCTTY);
if (block_fd < 0)
- log_debug_errno(errno, "Failed to open block device %s/%s, ignoring: %m", path, filename);
+ log_debug_errno(errno, "Failed to open block device %s/%s, ignoring: %m", path ?: strnull(cwd), filename);
else {
/* Refresh stat data after opening the node */
if (fstat(block_fd, &stbuf) < 0)
@@ -373,13 +378,13 @@ static int image_make(
int state = 0;
if (ioctl(block_fd, BLKROGET, &state) < 0)
- log_debug_errno(errno, "Failed to issue BLKROGET on device %s/%s, ignoring: %m", path, filename);
+ log_debug_errno(errno, "Failed to issue BLKROGET on device %s/%s, ignoring: %m", path ?: strnull(cwd), filename);
else if (state)
read_only = true;
}
if (ioctl(block_fd, BLKGETSIZE64, &size) < 0)
- log_debug_errno(errno, "Failed to issue BLKGETSIZE64 on device %s/%s, ignoring: %m", path, filename);
+ log_debug_errno(errno, "Failed to issue BLKGETSIZE64 on device %s/%s, ignoring: %m", path ?: strnull(cwd), filename);
block_fd = safe_close(block_fd);
}