proc/get_seclabel: catch the error when no security module is active
In this case, reading from the attr file will return -EINVAL, which
we will handle gracefully by treating it as the empty label (in the
same way as we do for the sockopt).
@@ -30,11 +30,20 @@ int proc_get_seclabel(char **labelp, size_t *lenp) {
if (!fgets(buffer, sizeof(buffer), f)) {
if (ferror(f)) {
- if (errno > 0)
+ if (errno > 0) {
+ if (errno == EINVAL) {
+ if (labelp)
+ *labelp = NULL;
+ if (lenp)
+ *lenp = 0;
+ return 0;
+ }
+
return error_origin(-errno);
- else
+ } else {
return error_origin(-ENOTRECOVERABLE);
}
+ }
c = buffer;
} else {
