From e96601981b6357e447a60055f3905449a1c01fd5 Mon Sep 17 00:00:00 2001 From: Patrick J Cherry Date: Sat, 18 Jan 2014 07:08:19 +0000 Subject: [PATCH 1/3] Tidied up warnings in nlsocket --- lib/linux/netlink/nlsocket.rb | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/linux/netlink/nlsocket.rb b/lib/linux/netlink/nlsocket.rb index 47c70c3..6533992 100644 --- a/lib/linux/netlink/nlsocket.rb +++ b/lib/linux/netlink/nlsocket.rb @@ -25,7 +25,8 @@ module Netlink # Check the sockaddr on a received message. Raises an error if the AF # is not AF_NETLINK or the PID is not 0 (this is important for security) def self.check_sockaddr(str) - af, pad, pid, groups = str.unpack(SOCKADDR_PACK) + # af, pad, pid, groups = str.unpack(SOCKADDR_PACK) + af, pid = str.unpack(SOCKADDR_PACK).values_at(0,2) raise "Bad AF #{af}!" if af != Socket::AF_NETLINK raise "Bad PID #{pid}!" if pid != 0 end @@ -135,8 +136,8 @@ module Netlink # (Compare: rtnl_talk in lib/libnetlink.c, with answer=NULL) def cmd(type, msg, flags=NLM_F_REQUEST, resp_type=NLMSG_ERROR, timeout=@timeout, sockaddr=SOCKADDR_DEFAULT) send_request(type, msg, flags|NLM_F_ACK, sockaddr) - receive_responses(true, timeout) do |type,msg| - return msg if type == resp_type + receive_responses(true, timeout) do |rtype,rmsg| + return rmsg if rtype == resp_type false end end @@ -144,7 +145,8 @@ module Netlink # Discard all waiting messages def drain while select([@socket], nil, nil, 0) - mesg, sender, rflags, controls = @socket.recvmsg + # mesg, sender, rflags, controls = @socket.recvmsg + mesg = @socket.recvmsg.first raise EOFError unless mesg end end @@ -209,7 +211,8 @@ module Netlink # kernel closes the socket. def recvmsg(timeout=@timeout) if select([@socket], nil, nil, timeout) - mesg, sender, rflags, controls = @socket.recvmsg + # mesg, sender, rflags, controls = @socket.recvmsg + mesg, sender = @socket.recvmsg.first(2) raise EOFError unless mesg sender = sender.to_sockaddr if sender.respond_to? :to_sockaddr NLSocket.check_sockaddr(sender) From e0aae9c67c7115c6d7d02721a2b84d6e3aaa0045 Mon Sep 17 00:00:00 2001 From: Patrick J Cherry Date: Tue, 21 Jan 2014 09:51:37 +0000 Subject: [PATCH 2/3] re-tidied up warnings. --- lib/linux/netlink/nlsocket.rb | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/lib/linux/netlink/nlsocket.rb b/lib/linux/netlink/nlsocket.rb index 6533992..5f6ba45 100644 --- a/lib/linux/netlink/nlsocket.rb +++ b/lib/linux/netlink/nlsocket.rb @@ -25,8 +25,7 @@ module Netlink # Check the sockaddr on a received message. Raises an error if the AF # is not AF_NETLINK or the PID is not 0 (this is important for security) def self.check_sockaddr(str) - # af, pad, pid, groups = str.unpack(SOCKADDR_PACK) - af, pid = str.unpack(SOCKADDR_PACK).values_at(0,2) + af, _, pid, _ = str.unpack(SOCKADDR_PACK) raise "Bad AF #{af}!" if af != Socket::AF_NETLINK raise "Bad PID #{pid}!" if pid != 0 end @@ -145,8 +144,7 @@ module Netlink # Discard all waiting messages def drain while select([@socket], nil, nil, 0) - # mesg, sender, rflags, controls = @socket.recvmsg - mesg = @socket.recvmsg.first + mesg, _, _, _ = @socket.recvmsg raise EOFError unless mesg end end @@ -211,8 +209,7 @@ module Netlink # kernel closes the socket. def recvmsg(timeout=@timeout) if select([@socket], nil, nil, timeout) - # mesg, sender, rflags, controls = @socket.recvmsg - mesg, sender = @socket.recvmsg.first(2) + mesg, sender, _, _ = @socket.recvmsg raise EOFError unless mesg sender = sender.to_sockaddr if sender.respond_to? :to_sockaddr NLSocket.check_sockaddr(sender) From 6cbda4bb58fdb359d9a396eb1fa6f229ed8e6dcd Mon Sep 17 00:00:00 2001 From: Patrick J Cherry Date: Tue, 21 Jan 2014 09:59:32 +0000 Subject: [PATCH 3/3] Added tag 0.15 for changeset 3dae37c40d73