Репозиторий Sisyphus
Последнее обновление: 1 октября 2023 | Пакетов: 18631 | Посещений: 37561005
en ru br
Репозитории ALT
S:1.5-alt1.qa2
5.1: 20060323-alt4
4.1: 20060323-alt3
4.0: 20060323-alt3
www.altlinux.org/Changes

Группа :: Сети/Прочее
Пакет: tunctl

 Главная   Изменения   Спек   Патчи   Исходники   Загрузить   Gear   Bugs and FR  Repocop 

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 <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <fcntl.h>
#include <unistd.h>
#include <pwd.h>
#include <grp.h>
#include <net/if.h>
#include <sys/ioctl.h>
#include <linux/if_tun.h>

/* 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<!doctype refentry PUBLIC "-//OASIS//DTD DocBook V4.1//EN" [

<!-- Process this file with docbook-to-man to generate an nroff manual
page: `docbook-to-man manpage.sgml > 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 $< > $@
-->

<!-- Fill in your name for FIRSTNAME and SURNAME. -->
<!ENTITY dhfirstname "<firstname>Matt</firstname>">
<!ENTITY dhsurname "<surname>Zimmerman</surname>">
<!-- Please adjust the date whenever revising the manpage. -->
<!ENTITY dhdate "<date>July 9, 2008</date>">
<!-- SECTION should be 1-8, maybe w/ subsection other parameters are
allowed: see man(7), man(1). -->
<!ENTITY dhsection "<manvolnum>8</manvolnum>">
<!ENTITY dhemail "<email>mdz@debian.org</email>">
<!ENTITY dhusername "Matt Zimmerman">
<!ENTITY hnusername "Henrik Nordstrom">
<!ENTITY hnemail "<email>henrik@henriknordstrom.net</email>">
<!ENTITY dhucpackage "<refentrytitle>tunctl</refentrytitle>">
<!ENTITY dhpackage "tunctl">

<!ENTITY debian "<productname>Debian GNU/Linux</productname>">
<!ENTITY gnu "<acronym>GNU</acronym>">
]>

<refentry>
<refentryinfo>
<address>
&dhemail;
</address>
<author>
&dhfirstname;
&dhsurname;
</author>
<copyright>
<year>2001</year>
<holder>&dhusername;</holder>
</copyright>
&dhdate;
</refentryinfo>
<refmeta>
&dhucpackage;

&dhsection;
</refmeta>
<refnamediv>
<refname>&dhpackage;</refname>

<refpurpose>create and manage persistent TUN/TAP interfaces</refpurpose>
</refnamediv>
<refsynopsisdiv>
<cmdsynopsis>

<command>&dhpackage;</command>

<arg choice=opt>OPTIONS</arg>
<arg><option>-u</option> <replaceable>owner</replaceable></arg>
<arg><option>-t</option> <replaceable>device-name</replaceable></arg>

</cmdsynopsis>

<cmdsynopsis>
<command>&dhpackage;</command>

<arg choice=req><option>-d</option> <replaceable>device-name</replaceable></arg>
</cmdsynopsis>

</refsynopsisdiv>
<refsect1>
<title>DESCRIPTION</title>

<para><command>&dhpackage;</command> 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.</para>

</refsect1>

<refsect1>
<title>OPTIONS</title>
<variablelist>
<varlistentry>
<term>-b</term>
<listitem><para>Brief output, prints just the interface name</para></listitem>
</varlistentry>

<varlistentry>
<term>-n</term>
<listitem><para>
Create a point-to-point TUN interface without Ethernet header.
Automatically enabled if the desired interface name starts with "tun".
</para></listitem>
</varlistentry>

<varlistentry>
<term>-p</term>
<listitem><para>
Create a TAP type interface with Ethernet header. Automatically selected
if the desired interface starts with "tap" or if no interface name is given.
</para></listitem>
</varlistentry>

<varlistentry>
<term>-f <replaceable class="parameter">tun-clone-device</replaceable></term>
<listitem><para>
Specifies the tun clone device name. The default is /dev/net/tun, but some systems use /dev/misc/net/tun instead.
</para></listitem>
</varlistentry>

<varlistentry>
<term>-d <replaceable class="parameter">interfacename</replaceable></term>
<listitem><para>
Delete the specified interfacename (set it to non-persistent)
</para></listitem>
</varlistentry>

<varlistentry>
<term>-u <replaceable class="parameter">user</replaceable></term>
<listitem><para>
Specifies the owner of the interface. This user is allowed to attach
to the "network/wire" side.
</para></listitem>
</varlistentry>

<varlistentry>
<term>-g <replaceable class="parameter">group</replaceable></term>
<listitem><para>
Specifies the group of the interface. This group is allowed to attach
to the "network/wire" side of the interface.
</para></listitem>
</varlistentry>

<varlistentry>
<term>-t <replaceable class="parameter">interface</replaceable></term>
<listitem><para>
Specifies the desired interface name.
</para></listitem>
</varlistentry>
</variablelist>
</refsect1>

<refsect1>
<title>USAGE</title>

<para>To create an interface for use by a particular user, invoke
tunctl without the -d option:</para>

<informalexample>
<screen>
<prompt>#</prompt> <userinput>tunctl -u someuser</userinput>

Set 'tap0' persistent and owned by 'someuser'
</screen>
</informalexample>

<para>Then, configure the interface as normal:</para>

<informalexample>
<screen>
<prompt>#</prompt> <userinput>ifconfig tap0 192.168.0.254 up</userinput>

<prompt>#</prompt> <userinput>route add -host 192.168.0.253 dev tap0</userinput>

<prompt>#</prompt> <userinput>bash -c 'echo 1 > /proc/sys/net/ipv4/conf/tap0/proxy_arp'</userinput>

<prompt>#</prompt> <userinput>arp -Ds 192.168.0.253 eth0 pub</userinput>
</screen>
</informalexample>

<para>To delete the interface, use the -d option:</para>

<informalexample>
<screen>
<prompt>#</prompt> <userinput>tunctl -d tap0</userinput>

Set 'tap0' nonpersistent
</screen>
</informalexample>
</refsect1>

<refsect1>
<title>SEE ALSO</title>

<para>The <ulink
url="http://user-mode-linux.sourceforge.net/old/UserModeLinux-HOWTO.html"
type=alternate>UserModeLinux-HOWTO</ulink></para>
</refsect1>
<refsect1>
<title>AUTHOR</title>

<para>&dhpackage; was originally written by Jeff Dike
<email>jdike@karaya.com</email> as part of the User Mode Linux tools.
Current version is maintained as a separate package
by &hnusername; &hnemail;.</para>

<para>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.</para>


</refsect1>
</refentry>

<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:2
sgml-indent-data:t
sgml-parent-document:nil
sgml-default-dtd-file:nil
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
-->
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) <qa_ldv@altlinux.org> 1:1.5-alt1.qa1
- NMU: rebuilt for debuginfo.

* Fri Mar 19 2010 Sergey Bolshakov <sbolshakov@altlinux.ru> 1:1.5-alt1
- 1.5 released

* Sun Oct 12 2008 Sergey Bolshakov <sbolshakov@altlinux.ru> 20060323-alt4
- dropped unneeded source tree parts and rebuilt

* Sun Jun 03 2007 Fr. Br. George <george@altlinux.ru> 20060323-alt3
- Fixed #11003 (mithraen@)

* Sun Apr 29 2007 Denis Smirnov <mithraen@altlinux.ru> 20060323-alt2
- Not remove group when uninstall
- Force groupadd when install (not crash at upgrade)

* Wed Apr 18 2007 Denis Smirnov <mithraen@altlinux.ru> 20060323-alt1
- Add requires(pre) to shadow-utils (need for %%pre section)

* Tue Jan 09 2007 Fr. Br. George <george@altlinux.ru> 20060323-alt0
- Initial build from MDV+Debian

* Sat Jan 06 2007 Olivier Blin <oblin@mandriva.com> 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 <nanardon@mandriva.org> 20060323-2mdv2007.0
+ Revision: 54861
- patch0: fix build
- Import uml-utilities


* Tue Apr 4 2006 Tibor Pittich <Tibor.Pittich@mandriva.org> 20060323-1mdk
- 20060323
- remove suid bit on uml_net

* Thu Mar 16 2006 Tibor Pittich <Tibor.Pittich@mandriva.org> 20060216-1mdk
- new version

* Mon Apr 04 2005 Nicolas LИcureuil <neoclust@mandrake.org> 20040406-3mdk
- %%mkrel
- Fix summary

* Mon Apr 04 2005 Nicolas LИcureuil <neoclust@mandrake.org> 20040406-2mdk
- Rebuild for Readline

* Tue Apr 13 2004 Stew Benedict <sbenedict@mandrakesoft.com> 20040406-1mdk
- 20040406

* Thu Jan 8 2004 Olivier Thauvin <thauvin@aerov.jussieu.fr> 20030903-3mdk
- DIRM fix

* Sat Nov 08 2003 Michael Scherer <scherer.michael@free.fr> 20030903-2mdk
- BuildRequires ( libncurses-devel )

* Tue Oct 07 2003 Olivier Thauvin <thauvin@aerov.jussieu.fr> 20030903-1mdk
- 20030903

* Tue Aug 13 2002 Olivier Thauvin <thauvin@aerov.jussieu.fr> 20020729-0.1mdk
- 1st pre release

 
дизайн и разработка: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
текущий майнтейнер: Michael Shigorin