aboutsummaryrefslogtreecommitdiff
path: root/src/utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils.c')
-rw-r--r--src/utils.c22
1 files changed, 10 insertions, 12 deletions
diff --git a/src/utils.c b/src/utils.c
index aa62beb..41fc7d4 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -8,7 +8,6 @@
#include <pwd.h>
#include <grp.h>
#include <sys/types.h>
-#undef makedev
#include <sys/sysmacros.h>
#include <sys/stat.h>
#include <sys/wait.h>
@@ -77,7 +76,7 @@ pid_t daemonize(int stay_foreground)
/* On success: The child process becomes session leader */
if (!stay_foreground && setsid() < 0) {
- E_STRERR("setsid");
+ E_STRERR("%s", "setsid");
exit(EXIT_FAILURE);
}
@@ -95,7 +94,7 @@ pid_t daemonize(int stay_foreground)
}
if (!stay_foreground && setpgrp()) {
- E_STRERR("setpgrp");
+ E_STRERR("%s", "setpgrp");
exit(EXIT_FAILURE);
}
@@ -123,7 +122,7 @@ int close_fds_except(int fds, ...)
size_t i, except_count, found;
va_list ap;
- max_fd = sysconf(_SC_OPEN_MAX);
+ max_fd = sysconf(_SC_OPEN_MAX) - 1;
if (max_fd <= 0)
return 1;
@@ -212,19 +211,19 @@ int safe_chroot(const char *newroot)
s = chdir(newroot);
if (s) {
- E_STRERR("Change directory");
+ E_STRERR("Change directory to '%s'", newroot);
return 1;
}
s = chroot(".");
if (s) {
- E_STRERR("Change root directory");
+ E_STRERR("Change root directory to '%s'", ".");
return 1;
}
s = chdir("/");
if (s) {
- E_STRERR("Change directory inside new root");
+ E_STRERR("Change directory inside new root to '%s'", "/");
return 1;
}
@@ -250,7 +249,7 @@ int dir_is_mountpoint(const char *path)
return current.st_dev != parent.st_dev;
error:
- W_STRERR("Mountpoint check");
+ W_STRERR("Mountpoint check for '%s'", path);
return -1;
}
@@ -285,7 +284,7 @@ int mount_dev(const char *mount_path)
MS_NOEXEC|MS_REC,
"size=4k,mode=755,gid=0");
if (s) {
- E_STRERR("Mount devtmpfs filesystem");
+ E_STRERR("Mount devtmpfs filesystem to %s", mount_path);
return 1;
}
@@ -301,7 +300,7 @@ int mount_pts(const char *mount_path)
"newinstance,gid=5,mode=620,ptmxmode=0666");
if (s) {
- E_STRERR("Mount devpts filesystem");
+ E_STRERR("Mount devpts filesystem to %s", mount_path);
return 1;
}
@@ -333,8 +332,7 @@ int create_device_file_checked(const char *mount_path, const char *device_file,
defmode = 0;
s = mknod(devpath, defmode|mode, dev);
if (s) {
- E2("Device file creation '%s' failed", devpath);
- E_STRERR("Device creation");
+ E_STRERR("Device creation '%s'", devpath);
return 1;
}