xtables-addons: rework uid/gid compat patch to use KUIDT_INIT() and KGIDT_INIT()...
[15.05/openwrt.git] / package / network / utils / xtables-addons / patches / 400-uid-gid-linux-3.7-compat.patch
1 --- a/extensions/xt_DNETMAP.c
2 +++ b/extensions/xt_DNETMAP.c
3 @@ -21,6 +21,7 @@
4  #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
5  #include <linux/inet.h>
6  #include <linux/ip.h>
7 +#include <linux/version.h>
8  #include <linux/module.h>
9  #include <linux/netdevice.h>
10  #include <linux/netfilter.h>
11 @@ -328,8 +329,8 @@ static int dnetmap_tg_check(const struct
12                 ret = -ENOMEM;
13                 goto out;
14         }
15 -       pde_data->uid = proc_uid;
16 -       pde_data->gid = proc_gid;
17 +       pde_data->uid = XT_UID(proc_uid);
18 +       pde_data->gid = XT_GID(proc_gid);
19  
20         /* statistics */
21         pde_stat = create_proc_entry(p->proc_str_stat, proc_perms,
22 @@ -341,8 +342,8 @@ static int dnetmap_tg_check(const struct
23         }
24         pde_stat->data = p;
25         pde_stat->read_proc = dnetmap_stat_proc_read;
26 -       pde_stat->uid = proc_uid;
27 -       pde_stat->gid = proc_gid;
28 +       pde_stat->uid = XT_UID(proc_uid);
29 +       pde_stat->gid = XT_GID(proc_gid);
30  #endif
31  
32         spin_lock_bh(&dnetmap_lock);
33 --- a/extensions/xt_condition.c
34 +++ b/extensions/xt_condition.c
35 @@ -14,6 +14,7 @@
36   */
37  #include <linux/kernel.h>
38  #include <linux/list.h>
39 +#include <linux/version.h>
40  #include <linux/module.h>
41  #include <linux/proc_fs.h>
42  #include <linux/spinlock.h>
43 @@ -155,8 +156,8 @@ static int condition_mt_check(const stru
44         var->status_proc->read_proc  = condition_proc_read;
45         var->status_proc->write_proc = condition_proc_write;
46         list_add(&var->list, &conditions_list);
47 -       var->status_proc->uid = condition_uid_perms;
48 -       var->status_proc->gid = condition_gid_perms;
49 +       var->status_proc->uid = XT_UID(condition_uid_perms);
50 +       var->status_proc->gid = XT_GID(condition_gid_perms);
51         mutex_unlock(&proc_lock);
52         info->condvar = var;
53         return 0;
54 --- a/extensions/compat_xtables.h
55 +++ b/extensions/compat_xtables.h
56 @@ -12,6 +12,14 @@
57  #      warning Kernels below 3.7 not supported.
58  #endif
59  
60 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 7, 0)
61 +#  define XT_UID(x) KUIDT_INIT(x)
62 +#  define XT_GID(x) KGIDT_INIT(x)
63 +#else
64 +#  define XT_UID(x) (x)
65 +#  define XT_GID(x) (x)
66 +#endif
67 +
68  #if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
69  #      if !defined(CONFIG_NF_CONNTRACK_MARK)
70  #              warning You have CONFIG_NF_CONNTRACK enabled, but CONFIG_NF_CONNTRACK_MARK is not (please enable).
71 --- a/extensions/xt_quota2.c
72 +++ b/extensions/xt_quota2.c
73 @@ -131,8 +131,8 @@ q2_get_counter(const struct xt_quota_mti
74         p->data         = e;
75         p->read_proc    = quota_proc_read;
76         p->write_proc   = quota_proc_write;
77 -       p->uid          = quota_list_uid;
78 -       p->gid          = quota_list_gid;
79 +       p->uid          = XT_UID(quota_list_uid);
80 +       p->gid          = XT_GID(quota_list_gid);
81         list_add_tail(&e->list, &counter_list);
82         spin_unlock_bh(&counter_list_lock);
83         return e;