summaryrefslogtreecommitdiff
path: root/modules/pam_tty_audit/pam_tty_audit.c
diff options
context:
space:
mode:
authorTomas Mraz <tmraz@fedoraproject.org>2013-10-14 14:04:23 +0200
committerTomas Mraz <tmraz@fedoraproject.org>2013-10-14 14:04:23 +0200
commit7d0a74fbab4e413dd115592962e1ae68adbe9e2c (patch)
treee5b8b549bfa1889b98ce48dd45de4cba06d45692 /modules/pam_tty_audit/pam_tty_audit.c
parentc5f829931a22c65feffee16570efdae036524bee (diff)
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@redhat.com>
Diffstat (limited to 'modules/pam_tty_audit/pam_tty_audit.c')
-rw-r--r--modules/pam_tty_audit/pam_tty_audit.c9
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 cc862550..b6f53be6 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;
}