[OpenWrt-Devel] [PATCH procd 1/2] instance: provide error feedback if ujail binary is missing
Petr Štetiar
ynezz at true.cz
Tue Jan 21 03:35:08 EST 2020
Otherwise it's quite hard to track such issues. While at it, be DRY and
use UJAIL_BIN_PATH constant for ujail binary.
Signed-off-by: Petr Štetiar <ynezz at true.cz>
---
service/instance.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/service/instance.c b/service/instance.c
index 14da86247c70..e5615d5c2f02 100644
--- a/service/instance.c
+++ b/service/instance.c
@@ -36,6 +36,7 @@
#include "service.h"
#include "instance.h"
+#define UJAIL_BIN_PATH "/sbin/ujail"
enum {
INSTANCE_ATTR_COMMAND,
@@ -205,7 +206,7 @@ jail_run(struct service_instance *in, char **argv)
struct jail *jail = &in->jail;
int argc = 0;
- argv[argc++] = "/sbin/ujail";
+ argv[argc++] = UJAIL_BIN_PATH;
if (jail->name) {
argv[argc++] = "-n";
@@ -795,9 +796,13 @@ instance_jail_parse(struct service_instance *in, struct blob_attr *attr)
struct blob_attr *tb[__JAIL_ATTR_MAX];
struct jail *jail = &in->jail;
struct stat s;
+ int r;
- if (stat("/sbin/ujail", &s))
+ r = stat(UJAIL_BIN_PATH, &s);
+ if (r < 0) {
+ ERROR("unable to find %s: %m (%d)\n", UJAIL_BIN_PATH, r);
return 0;
+ }
blobmsg_parse(jail_attr, __JAIL_ATTR_MAX, tb,
blobmsg_data(attr), blobmsg_data_len(attr));
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel
More information about the openwrt-devel
mailing list