diff options
author | Stefano Brivio <sbrivio@redhat.com> | 2024-06-15 00:37:11 +0200 |
---|---|---|
committer | Stefano Brivio <sbrivio@redhat.com> | 2024-06-21 15:32:43 +0200 |
commit | 92a22fef93a528030669e357a32c19f143a2d3b5 (patch) | |
tree | 37d5ff28d073c0c68601a45e8f540f9da3d7d8b3 /isolation.c | |
parent | c1140df889aeb90f944c1caabdf6f73522dbb250 (diff) | |
download | passt-92a22fef93a528030669e357a32c19f143a2d3b5.tar passt-92a22fef93a528030669e357a32c19f143a2d3b5.tar.gz passt-92a22fef93a528030669e357a32c19f143a2d3b5.tar.bz2 passt-92a22fef93a528030669e357a32c19f143a2d3b5.tar.lz passt-92a22fef93a528030669e357a32c19f143a2d3b5.tar.xz passt-92a22fef93a528030669e357a32c19f143a2d3b5.tar.zst passt-92a22fef93a528030669e357a32c19f143a2d3b5.zip |
treewide: Replace perror() calls with calls to logging functions
perror() prints directly to standard error, but in many cases standard
error might be already closed, or we might want to skip logging, based
on configuration. Our logging functions provide all that.
While at it, make errors more descriptive, replacing some of the
existing basic perror-style messages.
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Diffstat (limited to 'isolation.c')
-rw-r--r-- | isolation.c | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/isolation.c b/isolation.c index ca2c68b..c936674 100644 --- a/isolation.c +++ b/isolation.c @@ -316,34 +316,34 @@ int isolate_prefork(const struct ctx *c) flags |= CLONE_NEWPID; if (unshare(flags)) { - perror("unshare"); + err_perror("Failed to detach isolating namespaces"); return -errno; } if (mount("", "/", "", MS_UNBINDABLE | MS_REC, NULL)) { - perror("mount /"); + err_perror("Failed to remount /"); return -errno; } if (mount("", TMPDIR, "tmpfs", MS_NODEV | MS_NOEXEC | MS_NOSUID | MS_RDONLY, "nr_inodes=2,nr_blocks=0")) { - perror("mount tmpfs"); + err_perror("Failed to mount empty tmpfs for pivot_root()"); return -errno; } if (chdir(TMPDIR)) { - perror("chdir"); + err_perror("Failed to change directory into empty tmpfs"); return -errno; } if (syscall(SYS_pivot_root, ".", ".")) { - perror("pivot_root"); + err_perror("Failed to pivot_root() into empty tmpfs"); return -errno; } if (umount2(".", MNT_DETACH | UMOUNT_NOFOLLOW)) { - perror("umount2"); + err_perror("Failed to unmount original root filesystem"); return -errno; } @@ -388,8 +388,6 @@ void isolate_postfork(const struct ctx *c) } if (prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0) || - prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, &prog)) { - perror("prctl"); - exit(EXIT_FAILURE); - } + prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, &prog)) + die_perror("Failed to apply seccomp filter"); } |