X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Flabel.c;h=5157b790d284de06a50306d1216c7c31999edb12;hb=0843f2d65ea978b09f12da9ba61ee157d39ee237;hp=09ded642fb1d51003230b09e41e484ae0dd48209;hpb=c904f64d84db8c4eebedf210ba10893f19ba05ed;p=elogind.git diff --git a/src/label.c b/src/label.c index 09ded642f..5157b790d 100644 --- a/src/label.c +++ b/src/label.c @@ -47,6 +47,7 @@ int label_init(void) { int r = 0; #ifdef HAVE_SELINUX + usec_t n; if (!use_selinux()) return 0; @@ -54,12 +55,20 @@ int label_init(void) { if (label_hnd) return 0; + n = now(CLOCK_MONOTONIC); label_hnd = selabel_open(SELABEL_CTX_FILE, NULL, 0); if (!label_hnd) { log_full(security_getenforce() == 1 ? LOG_ERR : LOG_DEBUG, "Failed to initialize SELinux context: %m"); r = security_getenforce() == 1 ? -errno : 0; + } else { + char buf[FORMAT_TIMESPAN_MAX]; + + n = now(CLOCK_MONOTONIC) - n; + log_info("Successfully loaded SELinux database in %s.", + format_timespan(buf, sizeof(buf), n)); } + #endif return r; @@ -90,14 +99,14 @@ int label_fix(const char *path, bool ignore_enoent) { /* If the FS doesn't support labels, then exit without warning */ if (r < 0 && errno == ENOTSUP) return 0; - - /* Ignore ENOENT in some cases */ - if (r < 0 && ignore_enoent && errno == ENOENT) - return 0; } } if (r < 0) { + /* Ignore ENOENT in some cases */ + if (ignore_enoent && errno == ENOENT) + return 0; + log_full(security_getenforce() == 1 ? LOG_ERR : LOG_DEBUG, "Unable to fix label of %s: %m", path); r = security_getenforce() == 1 ? -errno : 0;