]> granicus.if.org Git - shadow/commitdiff
* src/passwd.c: Do not freecon strings duplicated with strdup.
authornekral-guest <nekral-guest@5a98b0ae-9ef6-0310-add3-de5d479b70d7>
Sun, 26 Apr 2009 16:44:54 +0000 (16:44 +0000)
committernekral-guest <nekral-guest@5a98b0ae-9ef6-0310-add3-de5d479b70d7>
Sun, 26 Apr 2009 16:44:54 +0000 (16:44 +0000)
Also avoid allocation of memory.
* src/passwd.c: Use SYSLOG instead of syslog.

ChangeLog
src/passwd.c

index c4cc096b3529546ecbc53269a156956c9a638911..4d5d7e2955742d50bd59892478a28ba77fb64279 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -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>
 
        * po/cs.po: Updated to 352T7f8u
index 721cb4ec59423adf20319a8df979a271cd4144a4..3465802de6b7535e9466c0dd8df039c925b5cfa5 100644 (file)
@@ -991,17 +991,20 @@ int main (int argc, char **argv)
           changing a password without entering the old one */
        if ((is_selinux_enabled() > 0) && (getuid() == 0) &&
            (check_selinux_access (name, pw->pw_uid, PASSWD__PASSWD) != 0)) {
-               security_context_t user_context;
-               if (getprevcon(&user_context) < 0) {
-                       user_context = strdup("Unknown user context");
+               security_context_t user_context = NULL;
+               const char *user = "Unknown user context";
+               if (getprevcon (&user_context) == 0) {
+                       user = user_context;
                }
-               syslog(LOG_ALERT,
-                      "%s is not authorized to change the password of %s",
-                      user_context, name);
+               SYSLOG ((LOG_ALERT,
+                        "%s is not authorized to change the password of %s",
+                        user, name));
                fprintf(stderr,
                        _("%s: %s is not authorized to change the password of %s\n"),
-                       Prog, user_context, name);
-               freecon(user_context);
+                       Prog, user, name);
+               if (NULL != user_context) {
+                       freecon (user_context);
+               }
                exit(1);
        }
 #endif /* WITH_SELINUX */