Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 58958
b: refs/heads/master
c: 8c64462
h: refs/heads/master
v: v3
  • Loading branch information
Guido Guenther authored and David S. Miller committed Jul 11, 2007
1 parent ec14c91 commit f8871c4
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 0ba48053831d5b89ee2afaefaae1c06eae80cb05
refs/heads/master: 8c644623fe7e41f59fe97cdf666cba3cb7ced7d8
15 changes: 13 additions & 2 deletions trunk/drivers/net/tun.c
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,7 @@ static void tun_setup(struct net_device *dev)
init_waitqueue_head(&tun->read_wait);

tun->owner = -1;
tun->group = -1;

SET_MODULE_OWNER(dev);
dev->open = tun_net_open;
Expand Down Expand Up @@ -467,8 +468,11 @@ static int tun_set_iff(struct file *file, struct ifreq *ifr)
return -EBUSY;

/* Check permissions */
if (tun->owner != -1 &&
current->euid != tun->owner && !capable(CAP_NET_ADMIN))
if (((tun->owner != -1 &&
current->euid != tun->owner) ||
(tun->group != -1 &&
current->egid != tun->group)) &&
!capable(CAP_NET_ADMIN))
return -EPERM;
}
else if (__dev_get_by_name(ifr->ifr_name))
Expand Down Expand Up @@ -610,6 +614,13 @@ static int tun_chr_ioctl(struct inode *inode, struct file *file,
DBG(KERN_INFO "%s: owner set to %d\n", tun->dev->name, tun->owner);
break;

case TUNSETGROUP:
/* Set group of the device */
tun->group= (gid_t) arg;

DBG(KERN_INFO "%s: group set to %d\n", tun->dev->name, tun->group);
break;

case TUNSETLINK:
/* Only allow setting the type when the interface is down */
if (tun->dev->flags & IFF_UP) {
Expand Down
2 changes: 2 additions & 0 deletions trunk/include/linux/if_tun.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ struct tun_struct {
unsigned long flags;
int attached;
uid_t owner;
gid_t group;

wait_queue_head_t read_wait;
struct sk_buff_head readq;
Expand Down Expand Up @@ -78,6 +79,7 @@ struct tun_struct {
#define TUNSETPERSIST _IOW('T', 203, int)
#define TUNSETOWNER _IOW('T', 204, int)
#define TUNSETLINK _IOW('T', 205, int)
#define TUNSETGROUP _IOW('T', 206, int)

/* TUNSETIFF ifr flags */
#define IFF_TUN 0x0001
Expand Down

0 comments on commit f8871c4

Please sign in to comment.