[NETFILTER]: x_tables: remove unused size argument to check/destroy functions
[linux-2.6.22.y-op.git] / net / ipv4 / netfilter / ipt_owner.c
blob78c336f12a9eee5ed3841b12375c92a9238c18c3
1 /* Kernel module to match various things tied to sockets associated with
2 locally generated outgoing packets. */
4 /* (C) 2000 Marc Boucher <marc@mbsi.ca>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
11 #include <linux/module.h>
12 #include <linux/skbuff.h>
13 #include <linux/file.h>
14 #include <linux/rcupdate.h>
15 #include <net/sock.h>
17 #include <linux/netfilter_ipv4/ipt_owner.h>
18 #include <linux/netfilter_ipv4/ip_tables.h>
20 MODULE_LICENSE("GPL");
21 MODULE_AUTHOR("Marc Boucher <marc@mbsi.ca>");
22 MODULE_DESCRIPTION("iptables owner match");
24 static int
25 match(const struct sk_buff *skb,
26 const struct net_device *in,
27 const struct net_device *out,
28 const struct xt_match *match,
29 const void *matchinfo,
30 int offset,
31 unsigned int protoff,
32 int *hotdrop)
34 const struct ipt_owner_info *info = matchinfo;
36 if (!skb->sk || !skb->sk->sk_socket || !skb->sk->sk_socket->file)
37 return 0;
39 if(info->match & IPT_OWNER_UID) {
40 if ((skb->sk->sk_socket->file->f_uid != info->uid) ^
41 !!(info->invert & IPT_OWNER_UID))
42 return 0;
45 if(info->match & IPT_OWNER_GID) {
46 if ((skb->sk->sk_socket->file->f_gid != info->gid) ^
47 !!(info->invert & IPT_OWNER_GID))
48 return 0;
51 return 1;
54 static int
55 checkentry(const char *tablename,
56 const void *ip,
57 const struct xt_match *match,
58 void *matchinfo,
59 unsigned int hook_mask)
61 const struct ipt_owner_info *info = matchinfo;
63 if (info->match & (IPT_OWNER_PID|IPT_OWNER_SID|IPT_OWNER_COMM)) {
64 printk("ipt_owner: pid, sid and command matching "
65 "not supported anymore\n");
66 return 0;
68 return 1;
71 static struct ipt_match owner_match = {
72 .name = "owner",
73 .match = match,
74 .matchsize = sizeof(struct ipt_owner_info),
75 .hooks = (1 << NF_IP_LOCAL_OUT) | (1 << NF_IP_POST_ROUTING),
76 .checkentry = checkentry,
77 .me = THIS_MODULE,
80 static int __init ipt_owner_init(void)
82 return ipt_register_match(&owner_match);
85 static void __exit ipt_owner_fini(void)
87 ipt_unregister_match(&owner_match);
90 module_init(ipt_owner_init);
91 module_exit(ipt_owner_fini);