introduce and use setfscreatecon_or_die
(patch by Yuichi Nakamura <ynakam@hitachisoft.jp>)
runcon: *yet another* fix for vda's brainfart :(
diff --git a/libbb/copy_file.c b/libbb/copy_file.c
index 6391824..07564af 100644
--- a/libbb/copy_file.c
+++ b/libbb/copy_file.c
@@ -74,7 +74,7 @@
}
} else {
if (errno == ENOTSUP || errno == ENODATA) {
- setfscreatecon(NULL);
+ setfscreatecon_or_die(NULL);
} else {
bb_perror_msg("cannot lgetfilecon %s", source);
return -1;
diff --git a/libbb/selinux_common.c b/libbb/selinux_common.c
index 70d63a4..d506f06 100644
--- a/libbb/selinux_common.c
+++ b/libbb/selinux_common.c
@@ -28,3 +28,13 @@
context_free(con);
return NULL;
}
+
+void setfscreatecon_or_die(security_context_t scontext)
+{
+ if (setfscreatecon(scontext) < 0) {
+ /* Can be NULL. All known printf implementations
+ * display "(null)", "<null>" etc */
+ bb_perror_msg_and_die("cannot set default "
+ "file creation context to %s", scontext);
+ }
+}