summaryrefslogtreecommitdiffstats
path: root/sys/net/if_tun.c
diff options
context:
space:
mode:
authorbrian <brian@FreeBSD.org>2001-02-03 00:31:39 +0000
committerbrian <brian@FreeBSD.org>2001-02-03 00:31:39 +0000
commitf165bef79cb06d5f16e2696260d801e6b4186754 (patch)
treef696987080f33b40f38eeb1fdcc080289e8646af /sys/net/if_tun.c
parent99d7a44ee708f2b68daee896b373bbe48bee3be2 (diff)
downloadFreeBSD-src-f165bef79cb06d5f16e2696260d801e6b4186754.zip
FreeBSD-src-f165bef79cb06d5f16e2696260d801e6b4186754.tar.gz
o Allow non-root users to open /dev/tun* (remove suser()
in tunopen()) o Change the default device permissions to 0600 root:wheel (were uucp:dialer) o Only let root (suser()) change the MTU This makes it possible for an administrator to open up the permissions on /dev/tun*, letting non-root programs service a tun interface. Co-operation is still required with a priviledged program that will configure the interface side of things.
Diffstat (limited to 'sys/net/if_tun.c')
-rw-r--r--sys/net/if_tun.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/sys/net/if_tun.c b/sys/net/if_tun.c
index c804ad3..a6e1561 100644
--- a/sys/net/if_tun.c
+++ b/sys/net/if_tun.c
@@ -106,7 +106,7 @@ tun_clone(arg, name, namelen, dev)
if (dev_stdclone(name, NULL, "tun", &u) != 1)
return;
*dev = make_dev(&tun_cdevsw, unit2minor(u),
- UID_UUCP, GID_DIALER, 0600, "tun%d", u);
+ UID_ROOT, GID_WHEEL, 0600, "tun%d", u);
}
@@ -189,11 +189,6 @@ tunopen(dev, flag, mode, p)
{
struct ifnet *ifp;
struct tun_softc *tp;
- register int error;
-
- error = suser(p);
- if (error)
- return (error);
tp = dev->si_drv1;
if (!tp) {
@@ -333,8 +328,7 @@ tunifioctl(ifp, cmd, data)
break;
case SIOCSIFMTU:
ifp->if_mtu = ifr->ifr_mtu;
- TUNDEBUG("%s%d: mtu set\n",
- ifp->if_name, ifp->if_unit);
+ TUNDEBUG("%s%d: mtu set\n", ifp->if_name, ifp->if_unit);
break;
case SIOCADDMULTI:
case SIOCDELMULTI:
@@ -449,6 +443,7 @@ tunioctl(dev, cmd, data, flag, p)
struct proc *p;
{
int s;
+ int error;
struct tun_softc *tp = dev->si_drv1;
struct tuninfo *tunp;
@@ -457,6 +452,8 @@ tunioctl(dev, cmd, data, flag, p)
tunp = (struct tuninfo *)data;
if (tunp->mtu < IF_MINMTU)
return (EINVAL);
+ if (tp->tun_if.if_mtu != tunp->mtu && (error = suser(p)) != 0)
+ return (error);
tp->tun_if.if_mtu = tunp->mtu;
tp->tun_if.if_type = tunp->type;
tp->tun_if.if_baudrate = tunp->baudrate;
OpenPOWER on IntegriCloud