Advertisement
Guest User

Untitled

a guest
Nov 30th, 2014
287
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 2.05 KB | None | 0 0
  1. diff --git a/src/nm-netlink-monitor.c b/src/nm-netlink-monitor.c
  2. index 593dec9..5ac39d3 100644
  3. --- a/src/nm-netlink-monitor.c
  4. +++ b/src/nm-netlink-monitor.c
  5. @@ -177,40 +177,15 @@ link_msg_handler (struct nl_object *obj, void *arg)
  6.  static int
  7.  event_msg_recv (struct nl_msg *msg, void *arg)
  8.  {
  9. -   struct nl_sock *nlh = arg;
  10. -   struct nlmsghdr *hdr = nlmsg_hdr (msg);
  11.     struct ucred *creds = nlmsg_get_creds (msg);
  12. -   const struct sockaddr_nl *snl;
  13. -   guint32 local_port;
  14. -   gboolean accept_msg = FALSE;
  15. -
  16. -   /* Only messages sent from the kernel */
  17. -   if (!creds || creds->uid != 0) {
  18. -       nm_log_dbg (LOGD_HW, "ignoring netlink message from UID %d",
  19. -                   creds ? creds->uid : -1);
  20. -       return NL_SKIP;
  21. -   }
  22. -
  23. -   snl = nlmsg_get_src (msg);
  24. -   g_assert (snl);
  25. -
  26. -   /* Accept any messages from the kernel */
  27. -   if (hdr->nlmsg_pid == 0 || snl->nl_pid == 0)
  28. -       accept_msg = TRUE;
  29.  
  30. -   /* And any multicast message directed to our netlink PID, since multicast
  31. -    * currently requires CAP_ADMIN to use.
  32. -    */
  33. -   local_port = nl_socket_get_local_port (nlh);
  34. -   if ((hdr->nlmsg_pid == local_port) && snl->nl_groups)
  35. -       accept_msg = TRUE;
  36. -
  37. -   if (accept_msg == FALSE) {
  38. -       nm_log_dbg (LOGD_HW, "ignoring netlink message from PID %d (local PID %d, multicast %d)",
  39. -                   hdr->nlmsg_pid,
  40. -                   local_port,
  41. -                   (hdr->nlmsg_flags & NLM_F_MULTI));
  42. -       return NL_SKIP;
  43. +   if (!creds || creds->pid || creds->uid || creds->gid) {
  44. +       if (creds)
  45. +           nm_log_dbg (LOGD_HW, "netlink: received non-kernel message (pid %d uid %d gid %d)",
  46. +                       creds->pid, creds->uid, creds->gid);
  47. +       else
  48. +           nm_log_dbg (LOGD_HW, "netlink: received message without credentials");
  49. +       return NL_STOP;
  50.     }
  51.  
  52.     return NL_OK;
  53. @@ -285,7 +260,7 @@ nlh_setup (struct nl_sock *nlh,
  54.  {
  55.     int err;
  56.  
  57. -   nl_socket_modify_cb (nlh, NL_CB_MSG_IN, NL_CB_CUSTOM, event_msg_recv, cb_data);
  58. +   nl_socket_modify_cb (nlh, NL_CB_MSG_IN, NL_CB_CUSTOM, event_msg_recv, NULL);
  59.  
  60.     if (valid_func)
  61.         nl_socket_modify_cb (nlh, NL_CB_VALID, NL_CB_CUSTOM, valid_func, cb_data);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement