}
if (flags & OPT_SET_SECURITY_CONTEXT) {
selinux_or_die();
- if (setfscreatecon(scontext) < 0) {
- bb_error_msg_and_die("setfscreatecon(%s)", scontext); // perror?
- }
+ setfscreatecon_or_die(scontext);
use_default_selinux_context = 0;
copy_flags |= FILEUTILS_SET_SECURITY_CONTEXT;
}
#if ENABLE_SELINUX
if (opt & 2) {
selinux_or_die();
- if (setfscreatecon(scontext)) {
- bb_error_msg_and_die("cannot set default file creation context "
- "to %s", scontext);
- }
+ setfscreatecon_or_die(scontext);
}
#endif
#if ENABLE_SELINUX
if (opt & 4) {
selinux_or_die();
- if (setfscreatecon(scontext)) {
- bb_error_msg_and_die("cannot set default file creation context "
- "to %s", scontext);
- }
+ setfscreatecon_or_die(scontext);
}
#endif
extern void set_current_security_context(security_context_t sid);
extern context_t set_security_context_component(security_context_t cur_context,
char *user, char *role, char *type, char *range);
+extern void setfscreatecon_or_die(security_context_t scontext);
#endif
extern void selinux_or_die(void);
extern int restricted_shell(const char *shell);
}
} else {
if (errno == ENOTSUP || errno == ENODATA) {
- setfscreatecon(NULL);
+ setfscreatecon_or_die(NULL);
} else {
bb_perror_msg("cannot lgetfilecon %s", source);
return -1;
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);
+ }
+}
execvp(argv[0], argv);
- bb_perror_msg_and_die("cannot execute '%s'", command);
+ bb_perror_msg_and_die("cannot execute '%s'", argv[0]);
return 1;
}