util-lib: wrap personality() to fix up broken glibc error handling (#6766)

glibc appears to propagate different errors in different ways, let's fix
this up, so that our own code doesn't get confused by this.

See #6752 + #6737 for details.

Fixes: #6755
This commit is contained in:
Lennart Poettering
2017-09-08 17:16:29 +03:00
committed by Evgeny Vereshchagin
parent 5463fa0a88
commit 21022b9dde
5 changed files with 53 additions and 57 deletions
+6 -4
View File
@@ -2267,11 +2267,13 @@ static int inner_child(
setup_hostname();
if (arg_personality != PERSONALITY_INVALID) {
if (personality(arg_personality) < 0)
return log_error_errno(errno, "personality() failed: %m");
r = safe_personality(arg_personality);
if (r < 0)
return log_error_errno(r, "personality() failed: %m");
} else if (secondary) {
if (personality(PER_LINUX32) < 0)
return log_error_errno(errno, "personality() failed: %m");
r = safe_personality(PER_LINUX32);
if (r < 0)
return log_error_errno(r, "personality() failed: %m");
}
#ifdef HAVE_SELINUX