aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/tun.c
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2008-11-13 18:39:18 -0500
committerJames Morris <jmorris@namei.org>2008-11-13 18:39:18 -0500
commit86a264abe542cfececb4df129bc45a0338d8cdb9 (patch)
tree30152f04ba847f311028d5ca697f864c16c7ebb3 /drivers/net/tun.c
parentf1752eec6145c97163dbce62d17cf5d928e28a27 (diff)
CRED: Wrap current->cred and a few other accessors
Wrap current->cred and a few other accessors to hide their actual implementation. Signed-off-by: David Howells <dhowells@redhat.com> Acked-by: James Morris <jmorris@namei.org> Acked-by: Serge Hallyn <serue@us.ibm.com> Signed-off-by: James Morris <jmorris@namei.org>
Diffstat (limited to 'drivers/net/tun.c')
-rw-r--r--drivers/net/tun.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index b14e2025e221..55dc70c6b4db 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -702,6 +702,7 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr)
702 struct tun_net *tn; 702 struct tun_net *tn;
703 struct tun_struct *tun; 703 struct tun_struct *tun;
704 struct net_device *dev; 704 struct net_device *dev;
705 const struct cred *cred = current_cred();
705 int err; 706 int err;
706 707
707 tn = net_generic(net, tun_net_id); 708 tn = net_generic(net, tun_net_id);
@@ -712,11 +713,12 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr)
712 713
713 /* Check permissions */ 714 /* Check permissions */
714 if (((tun->owner != -1 && 715 if (((tun->owner != -1 &&
715 current_euid() != tun->owner) || 716 cred->euid != tun->owner) ||
716 (tun->group != -1 && 717 (tun->group != -1 &&
717 current_egid() != tun->group)) && 718 cred->egid != tun->group)) &&
718 !capable(CAP_NET_ADMIN)) 719 !capable(CAP_NET_ADMIN)) {
719 return -EPERM; 720 return -EPERM;
721 }
720 } 722 }
721 else if (__dev_get_by_name(net, ifr->ifr_name)) 723 else if (__dev_get_by_name(net, ifr->ifr_name))
722 return -EINVAL; 724 return -EINVAL;