@@ -44,6 +44,33 @@
static struct selabel_handle *sehandle;
#endif
+#ifdef WITH_LIBSELINUX
+DPKG_ATTR_PRINTF(2)
+static int log_callback(int type, const char *fmt, ...)
+{
+ char *msg;
+ va_list ap;
+
+ switch (type) {
+ case SELINUX_ERROR:
+ case SELINUX_WARNING:
+ case SELINUX_AVC:
+ break;
+ default:
+ return 0;
+ }
+
+ va_start(ap, fmt);
+ m_vasprintf(&msg, fmt, ap);
+ va_end(ap);
+
+ warning("libselinux: %s", msg);
+ free(msg);
+
+ return 0;
+}
+#endif
+
void
dpkg_selabel_load(void)
{
@@ -65,9 +92,7 @@ dpkg_selabel_load(void)
if (rc < 0)
ohshit(_("cannot open security status notification channel"));
- /* XXX: We could use selinux_set_callback() to redirect the
- * errors from the other SELinux calls, but that does not seem
- * worth it right now. */
+ selinux_set_callback(SELINUX_CB_LOG, (union selinux_callback) { .func_log = log_callback });
} else if (selinux_enabled && selinux_status_updated()) {
/* The SELinux policy got updated in the kernel, usually after
* upgrading the package shipping it, we need to reload. */