pax_global_header00006660000000000000000000000064121335635710014520gustar00rootroot0000000000000052 comment=7ba9958a026f9fb3b370b72bd1560a68b36b8904 tunctl-1.5/000075500000000000000000000000001213356357100126745ustar00rootroot00000000000000tunctl-1.5/.gear-rules000064400000000000000000000000751213356357100147450ustar00rootroot00000000000000tar: . name=@name@-@version@-@release@ base=@name@-@version@ tunctl-1.5/.rpmwrap000064400000000000000000000001351213356357100143640ustar00rootroot00000000000000%_topdir %_macropath/... %_sourcedir %_topdir/sources %_specdir %_macropath tunctl-1.5/ChangeLog000064400000000000000000000010351213356357100144450ustar00rootroot00000000000000Version 1.5 - Imported updated version from uml_utilities_20070815.tar.bz2 - Imported fixes from OpenSUSE o -n option for point-to-point TUN devices o -p option for TAP device default is autodetection, using TUN if the device starts with tun*, TAP otherwise Version 1.4 - Packaged as a package. Identical to tunctl.c revision 1.4 from the User Mode Linux CVS repository. - Imported tunctl.sgml revision 238 from Debian SVN repository - Makefile & spec file updated/added loosely based on the UML and Fedora versions tunctl-1.5/Makefile000064400000000000000000000023471213356357100143420ustar00rootroot00000000000000PACKAGE = tunctl VERSION = 1.5 BIN = $(PACKAGE) MANS = 8 MAN = $(PACKAGE).$(MANS) DIST = Makefile $(PACKAGE).spec $(PACKAGE).c $(PACKAGE).sgml ChangeLog CFLAGS = -g -Wall BIN_DIR ?= /usr/sbin MAN_DIR ?= /usr/share/man/man$(MANS) all : $(BIN) $(MAN) $(BIN) : $(BIN).c $(CC) $(CFLAGS) -o $(BIN) $(BIN).c $(MAN) : $(PACKAGE).sgml docbook2man $(PACKAGE).sgml clean : rm -f $(BIN) $(OBJS) $(MAN) *~ manpage.* install : $(BIN) $(MAN) install -d $(DESTDIR)$(BIN_DIR) install $(BIN) $(DESTDIR)$(BIN_DIR) install -d $(DESTDIR)$(MAN_DIR) install $(MAN) $(DESTDIR)$(MAN_DIR) .PHONY: dist dist: distcheck rm -rf dist/$(PACKAGE)-$(VERSION) mkdir -p dist/$(PACKAGE)-$(VERSION) cp -p $(DIST) dist/$(PACKAGE)-$(VERSION) tar -C dist -zcf $(PACKAGE)-$(VERSION).tar.gz $(PACKAGE)-$(VERSION) distcheck: @if test "`awk '/^Version $(VERSION)($$|:)/ {print}' ChangeLog`" = ""; then \ echo "ERROR: Spec file ChangeLog not updated"; \ false; \ fi @if test `awk '/^Version:/ {print $$2}' $(PACKAGE).spec` != $(VERSION); then \ echo "ERROR: Spec file version not updated"; \ false; \ fi @if test "`awk '/^\*.* $(VERSION)-/ {print}' $(PACKAGE).spec`" = ""; then \ echo "ERROR: Spec file ChangeLog not updated"; \ false; \ fi tunctl-1.5/tun.rules000064400000000000000000000000471213356357100145570ustar00rootroot00000000000000KERNEL=="tun", GROUP="tun" MODE="0660" tunctl-1.5/tunctl.c000064400000000000000000000074371213356357100143640ustar00rootroot00000000000000/* Copyright 2002 Jeff Dike * Licensed under the GPL */ #include #include #include #include #include #include #include #include #include #include #include /* TUNSETGROUP appeared in 2.6.23 */ #ifndef TUNSETGROUP #define TUNSETGROUP _IOW('T', 206, int) #endif static void Usage(char *name) { fprintf(stderr, "Create: %s [-b] [-u owner] [-g group] [-t device-name] " "[-p|-n] [-f tun-clone-device]\n", name); fprintf(stderr, "Delete: %s -d device-name [-f tun-clone-device]\n\n", name); fprintf(stderr, "The default tun clone device is /dev/net/tun - some systems" " use\n/dev/misc/net/tun instead\n\n"); fprintf(stderr, "-b will result in brief output (just the device name)\n"); fprintf(stderr, "-n will result in a point-to-point tun device,\n"); fprintf(stderr, "-p in an ethernet tap device. Default is a tap,\n"); fprintf(stderr, " except the device contains \"tun\" in the name.\n"); exit(1); } int main(int argc, char **argv) { struct ifreq ifr; struct passwd *pw; struct group *gr; uid_t owner = -1; gid_t group = -1; int tap_fd, opt, delete = 0, brief = 0, type = 0; char *tun = "", *file = "/dev/net/tun", *name = argv[0], *end; while((opt = getopt(argc, argv, "bd:f:npt:u:g:h")) > 0){ switch(opt) { case 'b': brief = 1; break; case 'd': delete = 1; tun = optarg; break; case 'f': file = optarg; break; case 'p': if(type != 0) Usage(name); type = IFF_TAP; break; case 'n': if(type != 0) Usage(name); type = IFF_TUN; break; case 'u': pw = getpwnam(optarg); if(pw != NULL){ owner = pw->pw_uid; break; } owner = strtol(optarg, &end, 0); if(*end != '\0'){ fprintf(stderr, "'%s' is neither a username nor a numeric uid.\n", optarg); Usage(name); } break; case 'g': gr = getgrnam(optarg); if(gr != NULL){ group = gr->gr_gid; break; } group = strtol(optarg, &end, 0); if(*end != '\0'){ fprintf(stderr, "'%s' is neither a groupname nor a numeric group.\n", optarg); Usage(name); } break; case 't': tun = optarg; break; case '?': case 'h': default: Usage(name); } } argv += optind; argc -= optind; if(argc > 0) Usage(name); if((tap_fd = open(file, O_RDWR)) < 0){ fprintf(stderr, "Failed to open '%s' : ", file); perror(""); exit(1); } if(type == 0) { type = strstr(tun, "tun") ? IFF_TUN : IFF_TAP; } memset(&ifr, 0, sizeof(ifr)); ifr.ifr_flags = type | IFF_NO_PI; strncpy(ifr.ifr_name, tun, sizeof(ifr.ifr_name) - 1); if(ioctl(tap_fd, TUNSETIFF, (void *) &ifr) < 0){ perror("TUNSETIFF"); exit(1); } if(delete){ if(ioctl(tap_fd, TUNSETPERSIST, 0) < 0){ perror("disabling TUNSETPERSIST"); exit(1); } printf("Set '%s' nonpersistent\n", ifr.ifr_name); } else { /* emulate behaviour prior to TUNSETGROUP */ if(owner == -1 && group == -1) { owner = geteuid(); } if(owner != -1) { if(ioctl(tap_fd, TUNSETOWNER, owner) < 0){ perror("TUNSETOWNER"); exit(1); } } if(group != -1) { if(ioctl(tap_fd, TUNSETGROUP, group) < 0){ perror("TUNSETGROUP"); exit(1); } } if(ioctl(tap_fd, TUNSETPERSIST, 1) < 0){ perror("enabling TUNSETPERSIST"); exit(1); } if(brief) printf("%s\n", ifr.ifr_name); else { printf("Set '%s' persistent and owned by", ifr.ifr_name); if(owner != -1) printf(" uid %d", owner); if(group != -1) printf(" gid %d", group); printf("\n"); } } return(0); } tunctl-1.5/tunctl.sgml000064400000000000000000000150061213356357100150730ustar00rootroot00000000000000 manpage.1'. You may view the manual page with: `docbook-to-man manpage.sgml | nroff -man | less'. A typical entry in a Makefile or Makefile.am is: manpage.1: manpage.sgml docbook-to-man $< > $@ --> Matt"> Zimmerman"> July 9, 2008"> 8"> mdz@debian.org"> henrik@henriknordstrom.net"> tunctl"> Debian GNU/Linux"> GNU"> ]>
&dhemail;
&dhfirstname; &dhsurname; 2001 &dhusername; &dhdate;
&dhucpackage; &dhsection; &dhpackage; create and manage persistent TUN/TAP interfaces &dhpackage; OPTIONS owner device-name &dhpackage; device-name DESCRIPTION &dhpackage; allows the host sysadmin to preconfigure a TUN/TAP network interface for use by a particular user. That user may open and use the network/write side of the interface, but may not change any aspects of the host side of the interface. OPTIONS -b Brief output, prints just the interface name -n Create a point-to-point TUN interface without Ethernet header. Automatically enabled if the desired interface name starts with "tun". -p Create a TAP type interface with Ethernet header. Automatically selected if the desired interface starts with "tap" or if no interface name is given. -f tun-clone-device Specifies the tun clone device name. The default is /dev/net/tun, but some systems use /dev/misc/net/tun instead. -d interfacename Delete the specified interfacename (set it to non-persistent) -u user Specifies the owner of the interface. This user is allowed to attach to the "network/wire" side. -g group Specifies the group of the interface. This group is allowed to attach to the "network/wire" side of the interface. -t interface Specifies the desired interface name. USAGE To create an interface for use by a particular user, invoke tunctl without the -d option: # tunctl -u someuser Set 'tap0' persistent and owned by 'someuser' Then, configure the interface as normal: # ifconfig tap0 192.168.0.254 up # route add -host 192.168.0.253 dev tap0 # bash -c 'echo 1 > /proc/sys/net/ipv4/conf/tap0/proxy_arp' # arp -Ds 192.168.0.253 eth0 pub To delete the interface, use the -d option: # tunctl -d tap0 Set 'tap0' nonpersistent SEE ALSO The UserModeLinux-HOWTO AUTHOR &dhpackage; was originally written by Jeff Dike jdike@karaya.com as part of the User Mode Linux tools. Current version is maintained as a separate package by &hnusername; &hnemail;. This manual page was originally written by &dhusername; &dhemail; for the &debian; system, based on examples from Jeff Dike. Extended by &hnusername; &hnemail; to cover all options supported.
tunctl-1.5/tunctl.spec000064400000000000000000000057011213356357100150640ustar00rootroot00000000000000Name: tunctl Version: 1.5 Release: alt1.qa1 Epoch: 1 Summary: Tool to create and manage persistent TUN/TAP interfaces License: GPL Group: Networking/Other Url: http://tunctl.sourceforge.net/ Source: %name-%version-%release.tar Requires(pre): shadow-utils BuildRequires: docbook-utils %description tunctl allows the host sysadmin to preconfigure a TUN/TAP device for use by a particular user. That user may open and use the device, but may not change any aspects of the host side of the interface. %prep %setup %build make CFLAGS="%optflags" %install install -pm0644 -D tun.rules %buildroot%_sysconfdir/udev/rules.d/90-tun.rules install -pm0755 -D %name %buildroot%_sbindir/%name install -pm0644 -D %name.8 %buildroot%_man8dir/%name.8 %pre /usr/sbin/groupadd -r -f tun &>/dev/null %files %_sysconfdir/udev/rules.d/90-tun.rules %_sbindir/%name %_man8dir/%name.8* %changelog * Wed Apr 17 2013 Dmitry V. Levin (QA) 1:1.5-alt1.qa1 - NMU: rebuilt for debuginfo. * Fri Mar 19 2010 Sergey Bolshakov 1:1.5-alt1 - 1.5 released * Sun Oct 12 2008 Sergey Bolshakov 20060323-alt4 - dropped unneeded source tree parts and rebuilt * Sun Jun 03 2007 Fr. Br. George 20060323-alt3 - Fixed #11003 (mithraen@) * Sun Apr 29 2007 Denis Smirnov 20060323-alt2 - Not remove group when uninstall - Force groupadd when install (not crash at upgrade) * Wed Apr 18 2007 Denis Smirnov 20060323-alt1 - Add requires(pre) to shadow-utils (need for %%pre section) * Tue Jan 09 2007 Fr. Br. George 20060323-alt0 - Initial build from MDV+Debian * Sat Jan 06 2007 Olivier Blin 20060323-3mdv2007.0 + Revision: 104685 - make /dev/net/tun owned by the tun group (#21113) - make the tunctl package add a tun system group (part of #21113) - move tunctl in a subpackage since it is often used without UML (description from Debian manpage) * Wed Aug 09 2006 Olivier Thauvin 20060323-2mdv2007.0 + Revision: 54861 - patch0: fix build - Import uml-utilities * Tue Apr 4 2006 Tibor Pittich 20060323-1mdk - 20060323 - remove suid bit on uml_net * Thu Mar 16 2006 Tibor Pittich 20060216-1mdk - new version * Mon Apr 04 2005 Nicolas Lécureuil 20040406-3mdk - %%mkrel - Fix summary * Mon Apr 04 2005 Nicolas Lécureuil 20040406-2mdk - Rebuild for Readline * Tue Apr 13 2004 Stew Benedict 20040406-1mdk - 20040406 * Thu Jan 8 2004 Olivier Thauvin 20030903-3mdk - DIRM fix * Sat Nov 08 2003 Michael Scherer 20030903-2mdk - BuildRequires ( libncurses-devel ) * Tue Oct 07 2003 Olivier Thauvin 20030903-1mdk - 20030903 * Tue Aug 13 2002 Olivier Thauvin 20020729-0.1mdk - 1st pre release