commit 7d0a74fbab4e413dd115592962e1ae68adbe9e2c
Author: Tomas Mraz <tmraz(a)fedoraproject.org>
Date: Mon Oct 14 14:04:23 2013 +0200
Make pam_tty_audit work with old kernels not supporting log_passwd.
modules/pam_tty_audit/pam_tty_audit.c(nl_recv): Pad result with zeros
if message is short from older kernel.
Signed-off-by: Richard Guy Briggs <rgb(a)redhat.com>
modules/pam_tty_audit/pam_tty_audit.c | 9 +++++++--
1 files changed, 7 insertions(+), 2 deletions(-)
---
diff --git a/modules/pam_tty_audit/pam_tty_audit.c
b/modules/pam_tty_audit/pam_tty_audit.c
index cc86255..b6f53be 100644
--- a/modules/pam_tty_audit/pam_tty_audit.c
+++ b/modules/pam_tty_audit/pam_tty_audit.c
@@ -109,7 +109,7 @@ nl_recv (int fd, unsigned type, void *buf, size_t size)
struct msghdr msg;
struct nlmsghdr nlm;
struct iovec iov[2];
- ssize_t res;
+ ssize_t res, resdiff;
again:
iov[0].iov_base = &nlm;
@@ -161,12 +161,17 @@ nl_recv (int fd, unsigned type, void *buf, size_t size)
res = recvmsg (fd, &msg, 0);
if (res == -1)
return -1;
- if ((size_t)res != NLMSG_LENGTH (size)
+ resdiff = NLMSG_LENGTH(size) - (size_t)res;
+ if (resdiff < 0
|| nlm.nlmsg_type != type)
{
errno = EIO;
return -1;
}
+ else if (resdiff > 0)
+ {
+ memset((char *)buf + size - resdiff, 0, resdiff);
+ }
return 0;
}
Show replies by thread