* src/passwd.c: Do not freecon strings duplicated with strdup.

Also avoid allocation of memory.
	* src/passwd.c: Use SYSLOG instead of syslog.
This commit is contained in:
nekral-guest 2009-04-26 16:44:54 +00:00
parent 8fa9bedcf7
commit fca3b5cdc9
2 changed files with 17 additions and 8 deletions

View File

@ -1,3 +1,9 @@
2009-04-26 Nicolas François <nicolas.francois@centraliens.net>
* src/passwd.c: Do not freecon strings duplicated with strdup.
Also avoid allocation of memory.
* src/passwd.c: Use SYSLOG instead of syslog.
2009-04-25 Miroslav Kure <kurem@upcase.inf.upol.cz> 2009-04-25 Miroslav Kure <kurem@upcase.inf.upol.cz>
* po/cs.po: Updated to 352T7f8u * po/cs.po: Updated to 352T7f8u

View File

@ -991,17 +991,20 @@ int main (int argc, char **argv)
changing a password without entering the old one */ changing a password without entering the old one */
if ((is_selinux_enabled() > 0) && (getuid() == 0) && if ((is_selinux_enabled() > 0) && (getuid() == 0) &&
(check_selinux_access (name, pw->pw_uid, PASSWD__PASSWD) != 0)) { (check_selinux_access (name, pw->pw_uid, PASSWD__PASSWD) != 0)) {
security_context_t user_context; security_context_t user_context = NULL;
if (getprevcon(&user_context) < 0) { const char *user = "Unknown user context";
user_context = strdup("Unknown user context"); if (getprevcon (&user_context) == 0) {
user = user_context;
} }
syslog(LOG_ALERT, SYSLOG ((LOG_ALERT,
"%s is not authorized to change the password of %s", "%s is not authorized to change the password of %s",
user_context, name); user, name));
fprintf(stderr, fprintf(stderr,
_("%s: %s is not authorized to change the password of %s\n"), _("%s: %s is not authorized to change the password of %s\n"),
Prog, user_context, name); Prog, user, name);
freecon(user_context); if (NULL != user_context) {
freecon (user_context);
}
exit(1); exit(1);
} }
#endif /* WITH_SELINUX */ #endif /* WITH_SELINUX */