File pam_loginuid-log_write_errors.diff of Package pam.14449

commit 256b50e1fce2f785f1032a1949dd2d1dbc17e250
Author: Dmitry V. Levin <ldv@altlinux.org>
Date:   Sun Jan 19 14:12:59 2014 +0000

    pam_loginuid: log significant loginuid write errors
    
    * modules/pam_loginuid/pam_loginuid.c (set_loginuid): Log those errors
    during /proc/self/loginuid update that are not ignored.

 modules/pam_loginuid/pam_loginuid.c |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)
---
diff --git a/modules/pam_loginuid/pam_loginuid.c b/modules/pam_loginuid/pam_loginuid.c
index c476f7b..73c42f9 100644
--- a/modules/pam_loginuid/pam_loginuid.c
+++ b/modules/pam_loginuid/pam_loginuid.c
@@ -75,8 +75,8 @@ static int set_loginuid(pam_handle_t *pamh, uid_t uid)
 			rc = PAM_IGNORE;
 		}
 		if (rc != PAM_IGNORE) {
-			pam_syslog(pamh, LOG_ERR,
-				   "Cannot open /proc/self/loginuid: %m");
+			pam_syslog(pamh, LOG_ERR, "Cannot open %s: %m",
+				   "/proc/self/loginuid");
 		}
 		return rc;
 	}
@@ -88,8 +88,14 @@ static int set_loginuid(pam_handle_t *pamh, uid_t uid)
 		goto done;	/* already correct */
 	}
 	if (lseek(fd, 0, SEEK_SET) == 0 && ftruncate(fd, 0) == 0 &&
-	    pam_modutil_write(fd, loginuid, count) == count)
+	    pam_modutil_write(fd, loginuid, count) == count) {
 		rc = PAM_SUCCESS;
+	} else {
+		if (rc != PAM_IGNORE) {
+			pam_syslog(pamh, LOG_ERR, "Error writing %s: %m",
+				   "/proc/self/loginuid");
+		}
+	}
  done:
 	close(fd);
 	return rc;
_______________________________________________
linux-pam-commits mailing list
linux-pam-commits@lists.fedorahosted.org
https://lists.fedorahosted.org/mailman/listinfo/linux-pam-commits
openSUSE Build Service is sponsored by