Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:bluca:openconnect:ci:openconnect:vpnc-scripts:PR-54
vpnc-scripts
_service:obs_scm:vpnc-scripts-0.1~git20230103.o...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File _service:obs_scm:vpnc-scripts-0.1~git20230103.obscpio of Package vpnc-scripts
07070100000000000081A400000000000000000000000163B478CF0000035C000000000000000000000000000000000000002C00000000vpnc-scripts-0.1~git20230103/.gitlab-ci.ymlvariables: BUILD_IMAGES_PROJECT: openconnect/build-images CENTOS7_BUILD: openconnect-cli-centos7 JOBS: 2 resolv.conf-iproute/Centos7: image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$CENTOS7_BUILD before_script: - yum install -y openconnect script: # Test with iproute2 - make -C tests check RESOLVCONF=1 tags: - shared - linux except: - tags artifacts: expire_in: 1 week untracked: true when: on_failure resolv.conf-bsdish/Centos7: image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$CENTOS7_BUILD before_script: - yum install -y openconnect net-tools script: # Test with route/ifconfig/netstat (approximation of *BSD/macOS) - make -C tests check RESOLVCONF=1 NO_IPROUTE2=1 TRACE_VPNC_SCRIPT=1 tags: - shared - linux except: - tags artifacts: expire_in: 1 week untracked: true when: on_failure 07070100000001000041ED00000000000000000000000363B478CF00000000000000000000000000000000000000000000002200000000vpnc-scripts-0.1~git20230103/.obs07070100000002000081A400000000000000000000000163B478CF00000707000000000000000000000000000000000000002B00000000vpnc-scripts-0.1~git20230103/.obs/_service<services> <service name="obs_scm"> <param name="scm">git</param> <param name="url">https://gitlab.com/openconnect/vpnc-scripts.git</param> <param name="revision">master</param> <param name="version">_auto_</param> <param name="versionformat">0.1~git%cd</param> <param name="exclude">.git</param> <param name="changesgenerate">enable</param> <param name="filename">vpnc-scripts</param> <param name="extract">.obs/vpnc-scripts.dsc</param> <param name="extract">.obs/vpnc-scripts.spec</param> </service> <!-- recreate the tarball, as it's expected by debian build tools --> <service name="tar" mode="buildtime"/> <!-- extract debian packaging --> <service name="extract_file" mode="buildtime"> <param name="archive">*.tar</param> <param name="files">*/.obs/debian/changelog</param> <param name="outfilename">debian.changelog</param> </service> <service name="extract_file" mode="buildtime"> <param name="archive">*.tar</param> <param name="files">*/.obs/debian/control</param> <param name="outfilename">debian.control</param> </service> <service name="extract_file" mode="buildtime"> <param name="archive">*.tar</param> <param name="files">*/.obs/debian/copyright</param> <param name="outfilename">debian.copyright</param> </service> <service name="extract_file" mode="buildtime"> <param name="archive">*.tar</param> <param name="files">*/.obs/debian/rules</param> <param name="outfilename">debian.rules</param> </service> <service name="set_version" mode="buildtime"> <param name="basename">vpnc-scripts</param> </service> <service name="recompress" mode="buildtime"> <param name="file">*.tar</param> <param name="compression">gz</param> </service> </services> 07070100000003000041ED00000000000000000000000263B478CF00000000000000000000000000000000000000000000002900000000vpnc-scripts-0.1~git20230103/.obs/debian07070100000004000081A400000000000000000000000163B478CF000000AF000000000000000000000000000000000000003300000000vpnc-scripts-0.1~git20230103/.obs/debian/changelogvpnc-scripts (0.1~git20220305) unstable; urgency=medium * Initial packaging. -- OpenConnect Team <openconnect-devel@lists.infradead.org> Sat, 16 Apr 2022 10:13:56 +0000 07070100000005000081A400000000000000000000000163B478CF00000467000000000000000000000000000000000000003100000000vpnc-scripts-0.1~git20230103/.obs/debian/controlSource: vpnc-scripts Maintainer: OpenConnect Team <openconnect-devel@lists.infradead.org> Section: net Priority: optional Build-Depends: debhelper-compat (= 12) Standards-Version: 4.6.0 Rules-Requires-Root: no Vcs-Browser: https://gitlab.com/openconnect/vpnc-scripts Vcs-Git: https://gitlab.com/openconnect/vpnc-scripts.git Homepage: https://www.infradead.org/openconnect/vpnc-script.html Package: vpnc-scripts Architecture: all Multi-Arch: foreign Depends: iproute2 | net-tools, ${misc:Depends} Suggests: dnsmasq, openssh-server, resolvconf Description: Network configuration scripts for VPNC and OpenConnect This package contains scripts required to configure routing and name services when invoked by the VPNC or OpenConnect VPN clients. The primary script automatically configures network routes and name servers for the active VPN connection. It also provides hooks for executing custom actions at various stages of the connection and disconnection process. . An alternate replacement script is also provided that contains the VPN in a network namespace which is accessible via SSH. 07070100000006000081A400000000000000000000000163B478CF00000550000000000000000000000000000000000000003300000000vpnc-scripts-0.1~git20230103/.obs/debian/copyrightFormat: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Upstream-Name: vpnc-scripts Upstream-Contact: David Woodhouse <dwmw2@infradead.org> Source: https://gitlab.com/openconnect/vpnc-scripts Files: * Copyright: 2005-2012 Maurice Massar, Jörg Mayer, Antonio Borneo et al. 2009-2020 David Woodhouse <dwmw2@infradead.org> License: GPL-2+ Files: debian/* Copyright: 2012-2019 Mike Miller <mtmiller@debian.org> 2020-2022 Luca Boccassi <bluca@debian.org> License: GPL-2+ License: GPL-2+ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. . This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. . You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. . On Debian systems, the complete text of the GNU General Public License version 2 can be found in `/usr/share/common-licenses/GPL-2'. 07070100000007000081ED00000000000000000000000163B478CF00000123000000000000000000000000000000000000002F00000000vpnc-scripts-0.1~git20230103/.obs/debian/rules#!/usr/bin/make -f SCRIPTS = vpnc-script vpnc-script-sshd %: dh $@ override_dh_auto_install: dh_auto_install mkdir -p debian/vpnc-scripts/usr/share/vpnc-scripts cp $(SCRIPTS) debian/vpnc-scripts/usr/share/vpnc-scripts chmod +x debian/vpnc-scripts/usr/share/vpnc-scripts/vpnc-script* 07070100000008000081A400000000000000000000000163B478CF00000313000000000000000000000000000000000000003300000000vpnc-scripts-0.1~git20230103/.obs/vpnc-scripts.dscFormat: 1.0 Source: vpnc-scripts Binary: vpnc-scripts Architecture: all Version: 0.1~git20220305 Maintainer: OpenConnect Team <openconnect-devel@lists.infradead.org> Homepage: https://www.infradead.org/openconnect/vpnc-script.html Standards-Version: 4.6.0 Vcs-Browser: https://gitlab.com/openconnect/vpnc-scripts Vcs-Git: https://gitlab.com/openconnect/vpnc-scripts.git Build-Depends: debhelper-compat (= 12) Package-List: vpnc-scripts deb net optional arch=all Checksums-Sha1: 4ec0a3855a12e87879ee93ee18622f8d3ffe7dc8 39925 vpnc-scripts_0.1~git20210402.orig.tar.gz Checksums-Sha256: cd00e831904554c7acbc9cd20e6457c6e787fe52dc2f75d39263a65faccc19f0 39925 vpnc-scripts_0.1~git20210402.orig.tar.gz Files: 0de3882a4daed875229e3f25c7789d40 39925 vpnc-scripts_0.1~git20210402.orig.tar.gz 07070100000009000081A400000000000000000000000163B478CF00000407000000000000000000000000000000000000003400000000vpnc-scripts-0.1~git20230103/.obs/vpnc-scripts.specName: vpnc-scripts Version: 0.1~git20220305 Release: 1 Summary: Routing setup script for vpnc and openconnect Group: Productivity/Networking/Other BuildArch: noarch Requires: iproute Requires: which # Compatibility with Fedora package Provides: vpnc-script = %{version} License: GPL-2.0-or-later URL: https://gitlab.com/openconnect/vpnc-scripts/ Source: https://gitlab.com/openconnect/vpnc-scripts/-/archive/master/vpnc-scripts-%{version}.tar.gz %description This script sets up routing for VPN connectivity, when invoked by vpnc or openconnect. %prep %setup -q %build %install mkdir -p -m 755 %{buildroot}%{_sysconfdir}/vpnc install -m 0755 vpnc-script \ %{buildroot}%{_sysconfdir}/vpnc/vpnc-script install -m 0755 vpnc-script-sshd \ %{buildroot}%{_sysconfdir}/vpnc/vpnc-script-sshd %files %dir %{_sysconfdir}/vpnc %{_sysconfdir}/vpnc/vpnc-script %{_sysconfdir}/vpnc/vpnc-script-sshd %changelog * Sat Apr 16 2022 OpenConnect Team <openconnect-devel@lists.infradead.org> - 0.1~git20220305 - Import from Fedora 0707010000000A000081A400000000000000000000000163B478CF0000018C000000000000000000000000000000000000003000000000vpnc-scripts-0.1~git20230103/.obs/workflows.ymlpull_request: steps: - branch_package: source_project: home:bluca:openconnect source_package: vpnc-scripts target_project: home:bluca:openconnect:ci filters: event: pull_request rebuild: steps: - trigger_services: project: home:bluca:openconnect package: vpnc-scripts filters: event: push branches: only: - master 0707010000000B000081A400000000000000000000000163B478CF000046AC000000000000000000000000000000000000002500000000vpnc-scripts-0.1~git20230103/COPYING GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Lesser General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. <one line to give the program's name and a brief idea of what it does.> Copyright (C) <year> <name of author> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. <signature of Ty Coon>, 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. 0707010000000C000081A400000000000000000000000163B478CF000001CF000000000000000000000000000000000000002A00000000vpnc-scripts-0.1~git20230103/netunshare.c#define _GNU_SOURCE #include <sched.h> #include <unistd.h> #include <stdio.h> #include <errno.h> #ifndef CLONE_NEWNET #error CLONE_NEWNET not defined #endif int main(int argc, char *argv[]) { if (argc < 1) { fprintf(stderr, "usage: %s <command> [<args...>]\n", basename(argv[0])); return 1; } argv++; if (unshare(CLONE_NEWNET) == -1) { perror("unshare"); return 1; } execv(argv[0], argv); /* Failed... */ perror("execve"); return 1; } 0707010000000D000041ED00000000000000000000000463B478CF00000000000000000000000000000000000000000000002300000000vpnc-scripts-0.1~git20230103/tests0707010000000E000081A400000000000000000000000163B478CF0000005E000000000000000000000000000000000000002C00000000vpnc-scripts-0.1~git20230103/tests/Makefileall: check check: ./vpn-routes > test-output.log 2>&1 ./vpn-noroute > test-output.log 2>&1 0707010000000F000041ED00000000000000000000000263B478CF00000000000000000000000000000000000000000000002900000000vpnc-scripts-0.1~git20230103/tests/certs07070100000010000081A400000000000000000000000163B478CF00000CF7000000000000000000000000000000000000003400000000vpnc-scripts-0.1~git20230103/tests/certs/ca-key.pem -----BEGIN RSA PRIVATE KEY----- MIIFfgIBAAKCATEAtGsnmCWvwf8eyrB+9Ni87UOGZ1Rd2rQewpBfgzwCEfwTcoWy iKRlQQt2XyO+ip/+eUtzOy7HSzy/FsmXVTUX86FySzDC4CeUEvNWAObOgksRXaQe m/r6uRsqTRi1uqXmDMeoqKFtqoiE3JYOsmwcNarnx5Q9+dXHwqINS7NuevcIX8UJ zRWTGveY3ypMZokk7R/QFmOBZaVYO6HNJWKbmYFUCBcY7HwvCKI7KFcynRdHCob7 YrFBmeb73qjqIH7zG+666pohZCmS8q1z5RkFnTdT4hGfGF8iuuKLDQCMni+nhz1A vkqipZIIDC5hwFh8mpnh1qyDOSXPPhvt66NtncvFON7Bx26bNBS+MD6CkB65Spp2 5O8zDEaiMXL2w2EL+KpnifSl5XY3oSmfgHmqdQIDAQABAoIBMQCAiid3esIx0PW7 KuwIvbI8yHMlgzIq81FHBV1HPqWq8pFYcnC0cYvCP8xiFDFYyoyfFmZOsBFFRU5P iejLyDv8U/X+JAtzcD9LERshIU/X/Guu75LvRm0DHJuSuhwfkrrIOCetnPVpHkKq di6aZ/PhOJZR1wggy3K69IHMgVYhPYc11EgbWVepSuYbeSNdmjA40QWMLfCu3V65 SwpX0+LnFVc1eJmFrE5wYNe0pomce4J3FWsn8Yu3G5EumWV50KOGKSLklSd+pTdu VSxwQMRQn9oKBx3zgyr16PlhJkR4+Q+PA4WIN/IYIUV9SxfsMaij7wgLpxXLxJdM 3gvxi36pv/Pkax6IdNKRXss4dzd8LBUy3uUKu23TxTCkDrW04MPrN7rRqlh1jvBw 6KihBoEBAoGZAO02FxxbPPTRVFxjFHgV6EFSSvhPeEkRagoV9o6fn1N3kWTS08fl xKO1NDtFYCoZSnbRdgomrMinsYIukrLUQu1TKMrhJ1RDyZfRtfZT429k9iptXq87 5hVtirC+QoePF+SYwenwvKO7qapODb8COagg6ds1lySj5IuzqVYFV68yyZUP+Flp MHn0YFWJF42UV6sSvuGqfuYlAoGZAMK1e+7cRZFnp/zIbgeYG8Ss+vQKgpeuyDJv qclkD7HztouQgCw791vMgaXW9y+Rgdkced7eheqI8RGenHbKGifNVQD3Mbl8mkEN pu8eVqbOX758fHZz0Iaum3ZWrkSihNpuUcl4dZRz5NfOdxPmltrJCI+7uHOMztzH oMu6gQhh+F3lSDUpHdvhWvIshZQu9EbyxFfNyDoRAoGZAILZPoBW19YYDlf0E5t2 QiqeMVqtw6VSpNKxcNMVu/Z300zxev8egIzpbMlxKG2wi8HlIx7QXKlGz4UHGcbp jY2KPMtEzcQOrIpBlQUvGxscbynSMNOqz+1sAoAiQ2KxjTV9CiJ4uCX9Y8bczXpa yOE0Xqub8Sa1/WEOls8rnUW4VzgRmiX//0yWf/lO6R4hAQcODRtASEW9AoGZAJ6/ ixkXfJztr3gZDiSg7tru0fjQ7OKwvUbp5btuGqHS+51UpjvqdGXjGj1VQ9oDv6N9 ZRvBv9uV5T6hXB457xNOhSSxZlg98CJj+BvzV2DO2B8drfiBup1klRnp2FHbU4gn 9ATYcr0jtIwDKPEPyyT8TT+rJNsJDcvR8xbHq9Zi0jXz72hwaojQdu8GP66ujbme y1hvTfWRAoGZALNT3AbF9EDnJmZlS30MWtBggw83UhszC8XN2tY30AsvsDOS6a0F /aQ45EKyCvnqtsCOmB6giDsKRaVncp6lIHSH4kHKT7UvlKadWDW5CNWGR3puoHLk UVhyNvBTKo6lPqXqUsVxp16TKeeQKF+DuYuuNZN3pXXsHTiHkRMDCRVEqz7UnZEc /Bq/Kh2aOkelkX2S27QzTZGL -----END RSA PRIVATE KEY----- -----BEGIN CERTIFICATE----- MIIDtDCCAmygAwIBAgIETeC0yjANBgkqhkiG9w0BAQsFADAZMRcwFQYDVQQDEw5H bnVUTFMgVGVzdCBDQTAeFw0xMTA1MjgwODM5MzlaFw0zODEwMTIwODM5NDBaMC8x LTArBgNVBAMTJEdudVRMUyBUZXN0IFNlcnZlciAoUlNBIGNlcnRpZmljYXRlKTCC AVIwDQYJKoZIhvcNAQEBBQADggE/ADCCAToCggExALRrJ5glr8H/HsqwfvTYvO1D hmdUXdq0HsKQX4M8AhH8E3KFsoikZUELdl8jvoqf/nlLczsux0s8vxbJl1U1F/Oh ckswwuAnlBLzVgDmzoJLEV2kHpv6+rkbKk0Ytbql5gzHqKihbaqIhNyWDrJsHDWq 58eUPfnVx8KiDUuzbnr3CF/FCc0Vkxr3mN8qTGaJJO0f0BZjgWWlWDuhzSVim5mB VAgXGOx8LwiiOyhXMp0XRwqG+2KxQZnm+96o6iB+8xvuuuqaIWQpkvKtc+UZBZ03 U+IRnxhfIrriiw0AjJ4vp4c9QL5KoqWSCAwuYcBYfJqZ4dasgzklzz4b7eujbZ3L xTjewcdumzQUvjA+gpAeuUqaduTvMwxGojFy9sNhC/iqZ4n0peV2N6Epn4B5qnUC AwEAAaOBjTCBijAMBgNVHRMBAf8EAjAAMBQGA1UdEQQNMAuCCWxvY2FsaG9zdDAT BgNVHSUEDDAKBggrBgEFBQcDATAPBgNVHQ8BAf8EBQMDB6AAMB0GA1UdDgQWBBR2 B1hM6rUp9S2ABoyDSoINCeyT3jAfBgNVHSMEGDAWgBRNVrdqAFjxZ5L0pnVVG45T AQPvzzANBgkqhkiG9w0BAQsFAAOCATEAdNWmTsh5uIfngyhOWwm7pK2+vgUMY8nH gMoMFHt0yuxuImcUMXu3LRS1dZSoCJACBpTFGi/Dg2U0qvOHQcEmc3OwNqHB90R3 LG5jUSCtq/bYW7h/6Gd9KeWCgZczaHbQ9IPTjLH1dLswVPt+fXKB6Eh0ggSrGATE /wRZT/XgDCW8t4C+2+TmJ8ZEzvU87KAPQ9rUBS1+p3EUAR/FfMApApsEig1IZ+ZD 5joaGBW7zh1H0B9mEKidRvD7yuRJyzAcvD25nT15NLW0QR3dEeXosLc720xxJl1h h8NJ7YOvn323mOjR9er4i4D6iJlXmJ8tvN9vakCankWvBzb7plFn2sfMQqICFpRc w075D8hdQxfpGffL2tEeKSgjyNHXS7x3dFhUpN3IQjUi2x4f2e/ZXg== -----END CERTIFICATE----- 07070100000011000081A400000000000000000000000163B478CF000004A4000000000000000000000000000000000000003000000000vpnc-scripts-0.1~git20230103/tests/certs/ca.pem-----BEGIN CERTIFICATE----- MIIDPzCCAfegAwIBAgIEUdguzDANBgkqhkiG9w0BAQsFADANMQswCQYDVQQDEwJD QTAiGA8yMDEzMDcwNjE0NTA1MloYDzIwMjMwNTE1MTQ1MDUyWjANMQswCQYDVQQD EwJDQTCCAVIwDQYJKoZIhvcNAQEBBQADggE/ADCCAToCggExALRrJ5glr8H/Hsqw fvTYvO1DhmdUXdq0HsKQX4M8AhH8E3KFsoikZUELdl8jvoqf/nlLczsux0s8vxbJ l1U1F/OhckswwuAnlBLzVgDmzoJLEV2kHpv6+rkbKk0Ytbql5gzHqKihbaqIhNyW DrJsHDWq58eUPfnVx8KiDUuzbnr3CF/FCc0Vkxr3mN8qTGaJJO0f0BZjgWWlWDuh zSVim5mBVAgXGOx8LwiiOyhXMp0XRwqG+2KxQZnm+96o6iB+8xvuuuqaIWQpkvKt c+UZBZ03U+IRnxhfIrriiw0AjJ4vp4c9QL5KoqWSCAwuYcBYfJqZ4dasgzklzz4b 7eujbZ3LxTjewcdumzQUvjA+gpAeuUqaduTvMwxGojFy9sNhC/iqZ4n0peV2N6Ep n4B5qnUCAwEAAaNDMEEwDwYDVR0TAQH/BAUwAwEB/zAPBgNVHQ8BAf8EBQMDBwQA MB0GA1UdDgQWBBRIIzRTCokxOEpa6sq20qbezh0rGDANBgkqhkiG9w0BAQsFAAOC ATEAa1kdd8E1PkM06Isw0S/thEll0rAYsNHwSX17IDUWocTTQlmVXBXcvLqM04QT z7WNG4eushLhRpSn8LJQkf4RgvAxOMIjHM9troDbPVoec6k8fZrJ8jfXurOgoOVP g+hScT3VDvxgiOVwgXSe2XBryGDaviRuSOHlfy5GPVirLJLZwpcX6RpsHMX9rrZX ghvf8dwm4To9H5wT0Le2FnZRoLOTMmpr49bfKJqy/U7AUHaf4saSdkdEIaGOxkPk x+SFlr9TjavnJvL0TApkvfNZ1aOVHRHINgaFYHQJ4U0jQ/g7lPmD+UtZWnvSMNXH yct5cKOyP4j7Kla1sKPs+oamOQ7pR1Z/GwBxe48FvO7VDi7EkugLwlzoXC2G+4Jg fJbi9Ui2FmXEeKkX34f1ONNj9Q== -----END CERTIFICATE----- 07070100000012000081A400000000000000000000000163B478CF00000512000000000000000000000000000000000000003900000000vpnc-scripts-0.1~git20230103/tests/certs/server-cert.pem-----BEGIN CERTIFICATE----- MIIDkTCCAkmgAwIBAgIEUdgu8DANBgkqhkiG9w0BAQsFADANMQswCQYDVQQDEwJD QTAiGA8yMDEzMDcwNjE0NTEyOVoYDzIwMjMwNTE1MTQ1MTI5WjAUMRIwEAYDVQQD Ewlsb2NhbGhvc3QwggFSMA0GCSqGSIb3DQEBAQUAA4IBPwAwggE6AoIBMQCnOivs PxSwLBn28W6QHb+OqfbpcIQJh/NQ81/DlFD6LGTWV4BY4Zb87tC9BBV+X3+lM/j8 u5HvN3nDWtv4Ge0DryLW6Tcs6FPCt4srEfCkh5l54LrMmWbhFgkVlN5fTqoY0lnd YJx2X8WWldRjeL+8E7nFUcFStWrgi9AzgMFrjsL4pql97YAZRXcMoQXVjbRmzVLZ IVumQy7c+tl7Eqz8lx/xS/5Fx9tIRunqNS5jEUs8Nn5E6FvraAcy+eI0gXTGk759 KNPYisSqAuFAmmt/XDTTvvOo6dpAseXqtR2/LjZJWOlXdiZ/yjHg5+RKQ5dt3dk5 7lAIWER9egIOo/+GAkyek0ZJ5GWU6VxTsFcIl6oy3S7EtB0NCIM7hvhy32QrJ5ZU yNncTSf6qMVoedgdAgMBAAGjgY0wgYowDAYDVR0TAQH/BAIwADAUBgNVHREEDTAL gglsb2NhbGhvc3QwEwYDVR0lBAwwCgYIKwYBBQUHAwEwDwYDVR0PAQH/BAUDAweg ADAdBgNVHQ4EFgQUqCVH9o9E1jUb72ys0de5boT536MwHwYDVR0jBBgwFoAUSCM0 UwqJMThKWurKttKm3s4dKxgwDQYJKoZIhvcNAQELBQADggExAK7dBCSwM/OJw+6s 9MJAb7Ygi9xhHSq30Hg3M7DaPC7J9rZB6+IAVb3poOZAtDDtyTqvXH7qY5UMjJC9 GsFmHPI/OSk2xuJJpG+ZJaP54b7kzTtUD6UCHETsgBk2aNuqNhjXR2fYnR9QME0C zZWIDV+5DFEBI97ln30N6PcXvIxp7Rsac3qwzvwt3zL+23kTwgM+DoRPoPO0PHr/ eQ9hvRU5wA2Vc47zhUXIFy1Jmx7Sf//pw0/wq46VUAjDZ5B09EoCpzBNvOD7P+cF FQQ7SId8h8OQ2uOWxT2baeJX0pVbVv+qwOOB1F0q3sjx0dZa/2rxOUZ3wnHG9j8j LZSUkZxGpPQffCSpSPma5RhYff8/BncdA8soT0dyEfXIX5V91IXnrlI8XZrADvJM zzJKdNg= -----END CERTIFICATE----- 07070100000013000081A400000000000000000000000163B478CF00001A82000000000000000000000000000000000000003800000000vpnc-scripts-0.1~git20230103/tests/certs/server-key.pemPublic Key Info: Public Key Algorithm: RSA Key Security Level: Normal (2432 bits) modulus: 00:a7:3a:2b:ec:3f:14:b0:2c:19:f6:f1:6e:90:1d: bf:8e:a9:f6:e9:70:84:09:87:f3:50:f3:5f:c3:94: 50:fa:2c:64:d6:57:80:58:e1:96:fc:ee:d0:bd:04: 15:7e:5f:7f:a5:33:f8:fc:bb:91:ef:37:79:c3:5a: db:f8:19:ed:03:af:22:d6:e9:37:2c:e8:53:c2:b7: 8b:2b:11:f0:a4:87:99:79:e0:ba:cc:99:66:e1:16: 09:15:94:de:5f:4e:aa:18:d2:59:dd:60:9c:76:5f: c5:96:95:d4:63:78:bf:bc:13:b9:c5:51:c1:52:b5: 6a:e0:8b:d0:33:80:c1:6b:8e:c2:f8:a6:a9:7d:ed: 80:19:45:77:0c:a1:05:d5:8d:b4:66:cd:52:d9:21: 5b:a6:43:2e:dc:fa:d9:7b:12:ac:fc:97:1f:f1:4b: fe:45:c7:db:48:46:e9:ea:35:2e:63:11:4b:3c:36: 7e:44:e8:5b:eb:68:07:32:f9:e2:34:81:74:c6:93: be:7d:28:d3:d8:8a:c4:aa:02:e1:40:9a:6b:7f:5c: 34:d3:be:f3:a8:e9:da:40:b1:e5:ea:b5:1d:bf:2e: 36:49:58:e9:57:76:26:7f:ca:31:e0:e7:e4:4a:43: 97:6d:dd:d9:39:ee:50:08:58:44:7d:7a:02:0e:a3: ff:86:02:4c:9e:93:46:49:e4:65:94:e9:5c:53:b0: 57:08:97:aa:32:dd:2e:c4:b4:1d:0d:08:83:3b:86: f8:72:df:64:2b:27:96:54:c8:d9:dc:4d:27:fa:a8: c5:68:79:d8:1d: public exponent: 01:00:01: private exponent: 79:2b:86:6d:fd:5b:41:38:03:6c:52:8e:59:70:a4: bf:7b:da:44:55:d9:e6:8a:12:bd:22:4b:ce:8c:66: 8c:8f:a4:55:47:3b:e1:ab:3c:5b:73:b3:de:71:da: 1d:22:97:7c:1e:07:99:21:54:61:f0:61:93:32:ff: d6:6a:fa:b9:43:aa:cb:ec:5a:a5:78:86:50:bd:eb: e2:3e:72:8e:d5:0e:59:28:84:52:02:09:70:a9:25: d5:f4:73:98:bd:88:34:ca:1e:81:71:22:8e:07:61: 45:76:b5:59:8a:41:eb:c6:a3:42:1d:b6:25:f6:fc: 45:4e:29:83:58:15:4e:99:38:1f:31:ab:f8:6a:21: fa:ad:c1:d0:6d:d0:ab:67:ad:43:1c:1d:9e:e5:33: e2:68:f9:e2:fa:d8:9a:e7:36:e0:20:8c:25:4d:e9: 17:95:4b:71:38:df:18:71:cd:e0:a0:7f:b2:58:fe: 8b:c0:1c:d2:96:4a:17:14:bf:1c:3b:e8:b5:54:2b: 8d:47:50:a7:77:56:61:a8:e3:79:dd:70:88:5f:89: a1:f8:78:0d:47:ef:32:98:c1:47:88:d8:33:ed:95: 10:90:7f:f1:57:cb:2b:18:c9:58:a1:de:ef:1c:70: 5a:58:3c:86:3d:96:17:ad:9c:fd:0b:eb:d8:33:a4: 5f:7f:db:97:c0:78:b4:94:56:56:0a:83:b3:d3:02: c6:6f:08:dc:0d:22:8f:2a:4b:25:7a:34:97:8e:63: 49:8a:39:d1:c1:1e:9b:93:41:c5:9c:b6:50:9e:ff: 7a:37:e4:c1: prime1: 00:cb:13:4a:a3:8f:ad:5c:63:89:30:f3:3b:eb:25: 85:d9:6c:ad:6d:50:f8:03:00:d3:1e:e3:ae:ad:54: 7a:9b:21:1a:72:18:a6:54:e4:32:58:8d:66:37:65: 8c:f7:8f:37:65:ec:f8:ef:2e:a9:c1:78:bb:04:90: aa:fe:0a:f2:7c:80:82:32:c7:db:ef:bc:10:c6:ff: e0:d4:2e:b9:3a:0e:cc:29:28:81:b8:41:78:37:80: 69:39:5e:97:44:36:d6:cd:39:af:14:c2:df:f3:67: b7:d4:a7:49:da:f4:d3:ee:14:10:e4:5c:3f:4a:62: 52:81:34:d0:8e:f3:7e:d4:42:0a:34:e2:f9:a7:bc: 03:f9:c0:48:e8:9b:7f:da:08:ec:db:82:fd:a2:aa: 0f:5d:71: prime2: 00:d2:cf:2d:81:00:28:43:76:b3:76:10:3f:04:57: 63:94:fa:bb:08:6a:a2:7d:99:4b:0f:ad:76:11:da: 5c:2a:2b:33:0a:05:0d:f8:51:9a:4d:b3:40:4b:53: 63:c8:c1:96:45:c7:42:35:cf:05:cf:8a:e2:aa:bd: dc:96:c0:fd:c8:c4:dc:4c:0b:1f:43:74:04:cf:13: f5:fa:ea:b6:0d:82:92:8c:03:bd:e9:7b:b1:f2:d0: df:fd:c5:1b:6e:66:b7:ce:f6:12:65:34:c8:15:01: da:36:5e:f9:d8:ad:37:86:52:2b:ea:9f:f5:75:6b: 91:b3:01:6f:52:e9:e9:07:16:db:ba:65:e2:49:cc: 4f:70:11:39:5c:fa:d2:da:d4:0c:24:17:c4:68:6f: d4:7f:6d: coefficient: 3b:96:f2:06:96:22:14:a2:fe:27:09:2f:43:b0:22: a6:f4:ae:33:c2:f8:be:d5:03:96:7d:4a:d1:eb:7b: 9d:51:bd:77:1d:3f:79:ef:62:1d:c3:e9:c2:9a:53: df:ec:33:9b:32:36:f6:e7:40:e8:6c:1b:16:3d:4e: 94:97:94:02:5d:cc:23:45:6b:53:8d:b8:7c:0e:24: f9:5c:30:e4:e3:76:5b:f6:1f:74:3d:ca:e7:ef:a0: 1e:d3:c8:a2:54:d2:db:06:4b:0d:b0:b9:64:ca:dd: 68:44:51:d6:07:c5:ac:5b:e7:11:4b:76:b0:78:ba: aa:b1:af:06:64:0d:27:1a:85:2d:a8:5a:c1:d7:c1: 2e:f6:ef:fe:f6:0d:d6:f1:18:fc:0b:14:b1:d7:76: 51:1b: exp1: 76:ce:d4:8e:18:92:ee:48:75:8d:23:e0:dc:53:d9: 99:38:d1:c5:f0:e7:08:aa:c4:d9:7f:8f:44:6c:f6: 46:27:f9:d6:e2:c0:fd:4d:7c:7e:fe:4a:dd:02:16: 95:07:3e:fb:ec:c6:3e:f8:e7:eb:fe:fc:3b:51:80: 18:9c:c2:fd:40:19:ec:27:ad:6e:f6:72:42:5a:95: 68:cd:e5:24:28:60:1d:7c:4b:58:47:45:54:03:56: 8c:6f:e0:c3:d1:e9:9d:ab:af:d8:cf:a2:42:3f:5d: f7:95:df:c9:b0:0f:05:6c:cb:ed:2e:63:00:db:c1: 35:42:76:fa:0b:4f:1a:53:80:b1:2c:51:af:66:7a: 54:f5:c0:32:06:37:a8:92:2c:30:c8:d4:27:04:a3: 74:a1: exp2: 18:07:41:5a:88:d8:0e:08:83:a0:1b:6d:f3:62:ba: 99:0a:93:32:fc:64:95:08:5a:03:e9:73:a1:c9:4f: e4:06:94:84:b9:da:c3:c9:19:5b:6d:e9:10:2c:eb: 1c:c0:e4:0e:04:0e:49:ef:d4:eb:b9:1a:e8:f7:47: 23:6f:cf:fd:88:62:cb:d0:20:ba:21:89:42:c9:35: aa:6a:02:62:3b:d5:d4:5b:c0:d3:d2:23:90:57:ba: 90:44:5d:42:12:37:35:41:db:0a:ea:1f:3c:35:bf: d7:9e:af:bf:c0:ce:a9:62:c8:5a:af:ec:dc:7b:6c: 5a:08:f9:d5:6b:90:02:1c:da:e2:be:26:32:df:34: d6:c3:3f:d4:97:4a:5d:62:fa:17:4b:16:3a:09:35: 21:69: Public Key ID: A8:25:47:F6:8F:44:D6:35:1B:EF:6C:AC:D1:D7:B9:6E:84:F9:DF:A3 Public key's random art: +--[ RSA 2432]----+ | + | | . . = | | o o . . . | | o = = o| | . + S . O.o| | = . o * o.| | . . . . o. | | .+.| | Eo.=| +-----------------+ -----BEGIN RSA PRIVATE KEY----- MIIFegIBAAKCATEApzor7D8UsCwZ9vFukB2/jqn26XCECYfzUPNfw5RQ+ixk1leA WOGW/O7QvQQVfl9/pTP4/LuR7zd5w1rb+BntA68i1uk3LOhTwreLKxHwpIeZeeC6 zJlm4RYJFZTeX06qGNJZ3WCcdl/FlpXUY3i/vBO5xVHBUrVq4IvQM4DBa47C+Kap fe2AGUV3DKEF1Y20Zs1S2SFbpkMu3PrZexKs/Jcf8Uv+RcfbSEbp6jUuYxFLPDZ+ ROhb62gHMvniNIF0xpO+fSjT2IrEqgLhQJprf1w0077zqOnaQLHl6rUdvy42SVjp V3Ymf8ox4OfkSkOXbd3ZOe5QCFhEfXoCDqP/hgJMnpNGSeRllOlcU7BXCJeqMt0u xLQdDQiDO4b4ct9kKyeWVMjZ3E0n+qjFaHnYHQIDAQABAoIBMHkrhm39W0E4A2xS jllwpL972kRV2eaKEr0iS86MZoyPpFVHO+GrPFtzs95x2h0il3weB5khVGHwYZMy /9Zq+rlDqsvsWqV4hlC96+I+co7VDlkohFICCXCpJdX0c5i9iDTKHoFxIo4HYUV2 tVmKQevGo0IdtiX2/EVOKYNYFU6ZOB8xq/hqIfqtwdBt0KtnrUMcHZ7lM+Jo+eL6 2JrnNuAgjCVN6ReVS3E43xhxzeCgf7JY/ovAHNKWShcUvxw76LVUK41HUKd3VmGo 43ndcIhfiaH4eA1H7zKYwUeI2DPtlRCQf/FXyysYyVih3u8ccFpYPIY9lhetnP0L 69gzpF9/25fAeLSUVlYKg7PTAsZvCNwNIo8qSyV6NJeOY0mKOdHBHpuTQcWctlCe /3o35MECgZkAyxNKo4+tXGOJMPM76yWF2WytbVD4AwDTHuOurVR6myEachimVOQy WI1mN2WM9483Zez47y6pwXi7BJCq/gryfICCMsfb77wQxv/g1C65Og7MKSiBuEF4 N4BpOV6XRDbWzTmvFMLf82e31KdJ2vTT7hQQ5Fw/SmJSgTTQjvN+1EIKNOL5p7wD +cBI6Jt/2gjs24L9oqoPXXECgZkA0s8tgQAoQ3azdhA/BFdjlPq7CGqifZlLD612 EdpcKiszCgUN+FGaTbNAS1NjyMGWRcdCNc8Fz4riqr3clsD9yMTcTAsfQ3QEzxP1 +uq2DYKSjAO96Xux8tDf/cUbbma3zvYSZTTIFQHaNl752K03hlIr6p/1dWuRswFv UunpBxbbumXiScxPcBE5XPrS2tQMJBfEaG/Uf20CgZh2ztSOGJLuSHWNI+DcU9mZ ONHF8OcIqsTZf49EbPZGJ/nW4sD9TXx+/krdAhaVBz777MY++Ofr/vw7UYAYnML9 QBnsJ61u9nJCWpVozeUkKGAdfEtYR0VUA1aMb+DD0emdq6/Yz6JCP133ld/JsA8F bMvtLmMA28E1Qnb6C08aU4CxLFGvZnpU9cAyBjeokiwwyNQnBKN0oQKBmBgHQVqI 2A4Ig6AbbfNiupkKkzL8ZJUIWgPpc6HJT+QGlIS52sPJGVtt6RAs6xzA5A4EDknv 1Ou5Guj3RyNvz/2IYsvQILohiULJNapqAmI71dRbwNPSI5BXupBEXUISNzVB2wrq Hzw1v9eer7/AzqliyFqv7Nx7bFoI+dVrkAIc2uK+JjLfNNbDP9SXSl1i+hdLFjoJ NSFpAoGYO5byBpYiFKL+JwkvQ7AipvSuM8L4vtUDln1K0et7nVG9dx0/ee9iHcPp wppT3+wzmzI29udA6GwbFj1OlJeUAl3MI0VrU424fA4k+Vww5ON2W/YfdD3K5++g HtPIolTS2wZLDbC5ZMrdaERR1gfFrFvnEUt2sHi6qrGvBmQNJxqFLahawdfBLvbv /vYN1vEY/AsUsdd2URs= -----END RSA PRIVATE KEY----- 07070100000014000081A400000000000000000000000163B478CF00000F07000000000000000000000000000000000000002D00000000vpnc-scripts-0.1~git20230103/tests/common.sh#!/bin/bash # # Copyright 2020 Nikos Mavrogiannopoulos # # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This file is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this file; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. builddir=${builddir:-.} srcdir=${srcdir:-.} OPENCONNECT=${OPENCONNECT:-$(type -P openconnect)} OCCTL=${OCCTL:-$(type -P occtl)} OCSERV=${OCSERV:-$(type -P ocserv)} IP=${IP:-$(type -P ip)} if test -z "${OPENCONNECT}" || ! test -x ${OPENCONNECT};then echo "You need openconnect to run this test" exit 1 fi if test -z "${OCSERV}" || ! test -x ${OCSERV};then echo "You need ocserv to run this test" exit 1 fi if test -z "$NO_NEED_ROOT";then if test "$(id -u)" != "0";then echo "You need to run this script as root" exit 77 fi fi update_config() { file=$1 username=$(whoami) group=$(groups|cut -f 1 -d ' ') if test -z "${ISOLATE_WORKERS}";then if test "${COVERAGE}" = "1";then ISOLATE_WORKERS=false else ISOLATE_WORKERS=true fi fi cp "${srcdir}/data/${file}" "$file.$$.tmp" sed -i -e 's|@USERNAME@|'${username}'|g' "$file.$$.tmp" \ -e 's|@GROUP@|'${group}'|g' "$file.$$.tmp" \ -e 's|@SRCDIR@|'${srcdir}'|g' "$file.$$.tmp" \ -e 's|@ISOLATE_WORKERS@|'${ISOLATE_WORKERS}'|g' "$file.$$.tmp" \ -e 's|@OTP_FILE@|'${OTP_FILE}'|g' "$file.$$.tmp" \ -e 's|@CRLNAME@|'${CRLNAME}'|g' "$file.$$.tmp" \ -e 's|@PORT@|'${PORT}'|g' "$file.$$.tmp" \ -e 's|@DNS@|'${DNS}'|g' "$file.$$.tmp" \ -e 's|@ADDRESS@|'${ADDRESS}'|g' "$file.$$.tmp" \ -e 's|@VPNNET@|'${VPNNET}'|g' "$file.$$.tmp" \ -e 's|@VPNNET6@|'${VPNNET6}'|g' "$file.$$.tmp" \ -e 's|@ROUTE1@|'${ROUTE1}'|g' "$file.$$.tmp" \ -e 's|@ROUTE2@|'${ROUTE2}'|g' "$file.$$.tmp" \ -e 's|@NOROUTE1@|'${NOROUTE1}'|g' "$file.$$.tmp" \ -e 's|@NOROUTE2@|'${NOROUTE2}'|g' "$file.$$.tmp" \ -e 's|@MATCH_CIPHERS@|'${MATCH_CIPHERS}'|g' "$file.$$.tmp" \ -e 's|@OCCTL_SOCKET@|'${OCCTL_SOCKET}'|g' "$file.$$.tmp" \ -e 's|@LISTEN_NS@|'${LISTEN_NS}'|g' "$file.$$.tmp" CONFIG="$file.$$.tmp" } # Check for a utility to list ports. Both ss and netstat will list # ports for normal users, and have similar semantics, so put the # command in the caller's PFCMD, or exit, indicating an unsupported # test. Prefer ss from iproute2 over the older netstat. have_port_finder() { for file in $(type -P ss) /*bin/ss /usr/*bin/ss /usr/local/*bin/ss;do if test -x "$file";then PFCMD="$file";return 0 fi done if test -z "$PFCMD";then for file in $(type -P netstat) /bin/netstat /usr/bin/netstat /usr/local/bin/netstat;do if test -x "$file";then PFCMD="$file";return 0 fi done fi if test -z "$PFCMD";then echo "neither ss nor netstat found" exit 1 fi } check_if_port_in_use() { local PORT="$1" local PFCMD; have_port_finder $PFCMD -an|grep "[\:\.]$PORT" >/dev/null 2>&1 } # Find a port number not currently in use. GETPORT=' rc=0 unset myrandom while test $rc = 0; do if test -n "$RANDOM"; then myrandom=$(($RANDOM + $RANDOM)); fi if test -z "$myrandom"; then myrandom=$(date +%N | sed s/^0*//); fi if test -z "$myrandom"; then myrandom=0; fi PORT="$(((($$<<15)|$myrandom) % 63001 + 2000))" check_if_port_in_use $PORT;rc=$? done ' 07070100000015000041ED00000000000000000000000263B478CF00000000000000000000000000000000000000000000002800000000vpnc-scripts-0.1~git20230103/tests/data07070100000016000081A400000000000000000000000163B478CF00000279000000000000000000000000000000000000003600000000vpnc-scripts-0.1~git20230103/tests/data/ocserv.passwdtest:tost,group1, group2 , group3:$5$i6SNmLDCgBNjyJ7q$SZ4bVJb7I/DLgXo3txHBVohRFBjOtdbxGQZp.DOnrA. sp@c/al:*:$5$kDNrlGibUoktiQ0n$mE/ys1XehvvoWQiSqAfB.Aw1WbAYayMV/ZYTX/6IlkC test2:*:$5$QB3iB31ID49rW6kr$wSvbsDTzUPw51hqWTgvac9LyJ6HLv2HYyxh2Ud4v.x1 test3:*:$5$d24yO9edrMd5ISka$/77d6DRK4fhdbTAecc4V8mmnQXSOU4Qn4zZQhOVaEqC test4:*:$5$5Hzjz2RPxM70vXiH$lCAFmGx77MNcauzf30.HJlKWm8dwVNiut.nyZyQRndC test5:*:$5$nvA.6.RBPqZg16K2$WAEXw7MJaSUj/Nwosu54JfqxMDlkZnrG.0/rsxl276C empty:*:$5$tScKhdO1ZcJ0GmmQ$rw095k.ThqbeQ60N06efHnAOibV/GoW5cRZKyHr8jd2 locked:tost,group1, group2 , group3:!$5$i6SNmLDCgBNjyJ7q$SZ4bVJb7I/DLgXo3txHBVohRFBjOtdbxGQZp.DOnrA. 07070100000017000081A400000000000000000000000163B478CF00001727000000000000000000000000000000000000003B00000000vpnc-scripts-0.1~git20230103/tests/data/vpn-noroute.config# User authentication method. Could be set multiple times and in that case # all should succeed. # Options: certificate, pam. #auth = "certificate" auth = "plain[@SRCDIR@/data/ocserv.passwd]" #auth = "pam" isolate-workers = @ISOLATE_WORKERS@ # Only supported in ocserv v1.1.1+; use iproute2's ip netns to run # in network namespaces with earlier versions. #listen-netns = @LISTEN_NS@ max-ban-score = 0 # A banner to be displayed on clients #banner = "Welcome" # Use listen-host to limit to specific IPs or to the IPs of a provided hostname. #listen-host = @ADDRESS@ use-dbus = no # Limit the number of clients. Unset or set to zero for unlimited. #max-clients = 1024 max-clients = 16 listen-proxy-proto = false # Limit the number of client connections to one every X milliseconds # (X is the provided value). Set to zero for no limit. rate-limit-ms = 100 # Limit the number of identical clients (i.e., users connecting multiple times) # Unset or set to zero for unlimited. max-same-clients = 2 # TCP and UDP port number tcp-port = @PORT@ udp-port = @PORT@ # Keepalive in seconds keepalive = 32400 # Dead peer detection in seconds dpd = 440 # MTU discovery (DPD must be enabled) try-mtu-discovery = false # The key and the certificates of the server # The key may be a file, or any URL supported by GnuTLS (e.g., # tpmkey:uuid=xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx;storage=user # or pkcs11:object=my-vpn-key;object-type=private) # # There may be multiple certificate and key pairs and each key # should correspond to the preceding certificate. server-cert = @SRCDIR@/certs/server-cert.pem server-key = @SRCDIR@/certs/server-key.pem # Diffie-Hellman parameters. Only needed if you require support # for the DHE ciphersuites (by default this server supports ECDHE). # Can be generated using: # certtool --generate-dh-params --outfile /path/to/dh.pem #dh-params = /path/to/dh.pem # If you have a certificate from a CA that provides an OCSP # service you may provide a fresh OCSP status response within # the TLS handshake. That will prevent the client from connecting # independently on the OCSP server. # You can update this response periodically using: # ocsptool --ask --load-cert=your_cert --load-issuer=your_ca --outfile response # Make sure that you replace the following file in an atomic way. #ocsp-response = /path/to/ocsp.der # In case PKCS #11 or TPM keys are used the PINs should be available # in files. The srk-pin-file is applicable to TPM keys only (It's the storage # root key). #pin-file = /path/to/pin.txt #srk-pin-file = /path/to/srkpin.txt # The Certificate Authority that will be used # to verify clients if certificate authentication # is set. #ca-cert = /path/to/ca.pem # The object identifier that will be used to read the user ID in the client certificate. # The object identifier should be part of the certificate's DN # Useful OIDs are: # CN = 2.5.4.3, UID = 0.9.2342.19200300.100.1.1 #cert-user-oid = 0.9.2342.19200300.100.1.1 # The object identifier that will be used to read the user group in the client # certificate. The object identifier should be part of the certificate's DN # Useful OIDs are: # OU (organizational unit) = 2.5.4.11 #cert-group-oid = 2.5.4.11 # A revocation list of ca-cert is set #crl = /path/to/crl.pem # GnuTLS priority string tls-priorities = "PERFORMANCE:%SERVER_PRECEDENCE:%COMPAT" # To enforce perfect forward secrecy (PFS) on the main channel. #tls-priorities = "NORMAL:%SERVER_PRECEDENCE:%COMPAT:-RSA" # The time (in seconds) that a client is allowed to stay connected prior # to authentication auth-timeout = 40 # The time (in seconds) that a client is not allowed to reconnect after # a failed authentication attempt. #min-reauth-time = 2 # Script to call when a client connects and obtains an IP # Parameters are passed on the environment. # REASON, USERNAME, GROUPNAME, HOSTNAME (the hostname selected by client), # DEVICE, IP_REAL (the real IP of the client), IP_LOCAL (the local IP # in the P-t-P connection), IP_REMOTE (the VPN IP of the client). REASON # may be "connect" or "disconnect". #connect-script = /usr/bin/myscript #disconnect-script = /usr/bin/myscript # UTMP #use-utmp = true # PID file #pid-file = ./ocserv.pid # The default server directory. Does not require any devices present. #chroot-dir = /path/to/chroot # socket file used for IPC, will be appended with .PID # It must be accessible within the chroot environment (if any) socket-file = ./ocserv-socket occtl-socket-file = @OCCTL_SOCKET@ use-occtl = true # The user the worker processes will be run as. It should be # unique (no other services run as this user). run-as-user = @USERNAME@ run-as-group = @GROUP@ # Network settings device = vpns # The default domain to be advertised default-domain = example.com ipv4-network = @VPNNET@ # Use the keyword local to advertise the local P-t-P address as DNS server ipv4-dns = @DNS@ # The NBNS server (if any) #ipv4-nbns = 192.168.2.3 ipv6-network = @VPNNET6@ #address = #ipv6-mask = #ipv6-dns = # Prior to leasing any IP from the pool ping it to verify that # it is not in use by another (unrelated to this server) host. ping-leases = false # Leave empty to assign the default MTU of the device # mtu = route = default no-route = @NOROUTE1@ no-route = @NOROUTE2@ # # The following options are for (experimental) AnyConnect client # compatibility. They are only available if the server is built # with --enable-anyconnect # # Client profile xml. A sample file exists in doc/profile.xml. # This file must be accessible from inside the worker's chroot. # The profile is ignored by the openconnect client. #user-profile = profile.xml # Unless set to false it is required for clients to present their # certificate even if they are authenticating via a previously granted # cookie. Legacy CISCO clients do not do that, and thus this option # should be set for them. #always-require-cert = false 07070100000018000081A400000000000000000000000163B478CF0000170D000000000000000000000000000000000000003A00000000vpnc-scripts-0.1~git20230103/tests/data/vpn-routes.config# User authentication method. Could be set multiple times and in that case # all should succeed. # Options: certificate, pam. #auth = "certificate" auth = "plain[@SRCDIR@/data/ocserv.passwd]" #auth = "pam" isolate-workers = @ISOLATE_WORKERS@ # Only supported in ocserv v1.1.1+; use iproute2's ip netns to run # in network namespaces with earlier versions. #listen-netns = @LISTEN_NS@ max-ban-score = 0 # A banner to be displayed on clients #banner = "Welcome" # Use listen-host to limit to specific IPs or to the IPs of a provided hostname. #listen-host = @ADDRESS@ use-dbus = no # Limit the number of clients. Unset or set to zero for unlimited. #max-clients = 1024 max-clients = 16 listen-proxy-proto = false # Limit the number of client connections to one every X milliseconds # (X is the provided value). Set to zero for no limit. rate-limit-ms = 100 # Limit the number of identical clients (i.e., users connecting multiple times) # Unset or set to zero for unlimited. max-same-clients = 2 # TCP and UDP port number tcp-port = @PORT@ udp-port = @PORT@ # Keepalive in seconds keepalive = 32400 # Dead peer detection in seconds dpd = 440 # MTU discovery (DPD must be enabled) try-mtu-discovery = false # The key and the certificates of the server # The key may be a file, or any URL supported by GnuTLS (e.g., # tpmkey:uuid=xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx;storage=user # or pkcs11:object=my-vpn-key;object-type=private) # # There may be multiple certificate and key pairs and each key # should correspond to the preceding certificate. server-cert = @SRCDIR@/certs/server-cert.pem server-key = @SRCDIR@/certs/server-key.pem # Diffie-Hellman parameters. Only needed if you require support # for the DHE ciphersuites (by default this server supports ECDHE). # Can be generated using: # certtool --generate-dh-params --outfile /path/to/dh.pem #dh-params = /path/to/dh.pem # If you have a certificate from a CA that provides an OCSP # service you may provide a fresh OCSP status response within # the TLS handshake. That will prevent the client from connecting # independently on the OCSP server. # You can update this response periodically using: # ocsptool --ask --load-cert=your_cert --load-issuer=your_ca --outfile response # Make sure that you replace the following file in an atomic way. #ocsp-response = /path/to/ocsp.der # In case PKCS #11 or TPM keys are used the PINs should be available # in files. The srk-pin-file is applicable to TPM keys only (It's the storage # root key). #pin-file = /path/to/pin.txt #srk-pin-file = /path/to/srkpin.txt # The Certificate Authority that will be used # to verify clients if certificate authentication # is set. #ca-cert = /path/to/ca.pem # The object identifier that will be used to read the user ID in the client certificate. # The object identifier should be part of the certificate's DN # Useful OIDs are: # CN = 2.5.4.3, UID = 0.9.2342.19200300.100.1.1 #cert-user-oid = 0.9.2342.19200300.100.1.1 # The object identifier that will be used to read the user group in the client # certificate. The object identifier should be part of the certificate's DN # Useful OIDs are: # OU (organizational unit) = 2.5.4.11 #cert-group-oid = 2.5.4.11 # A revocation list of ca-cert is set #crl = /path/to/crl.pem # GnuTLS priority string tls-priorities = "PERFORMANCE:%SERVER_PRECEDENCE:%COMPAT" # To enforce perfect forward secrecy (PFS) on the main channel. #tls-priorities = "NORMAL:%SERVER_PRECEDENCE:%COMPAT:-RSA" # The time (in seconds) that a client is allowed to stay connected prior # to authentication auth-timeout = 40 # The time (in seconds) that a client is not allowed to reconnect after # a failed authentication attempt. #min-reauth-time = 2 # Script to call when a client connects and obtains an IP # Parameters are passed on the environment. # REASON, USERNAME, GROUPNAME, HOSTNAME (the hostname selected by client), # DEVICE, IP_REAL (the real IP of the client), IP_LOCAL (the local IP # in the P-t-P connection), IP_REMOTE (the VPN IP of the client). REASON # may be "connect" or "disconnect". #connect-script = /usr/bin/myscript #disconnect-script = /usr/bin/myscript # UTMP #use-utmp = true # PID file #pid-file = ./ocserv.pid # The default server directory. Does not require any devices present. #chroot-dir = /path/to/chroot # socket file used for IPC, will be appended with .PID # It must be accessible within the chroot environment (if any) socket-file = ./ocserv-socket occtl-socket-file = @OCCTL_SOCKET@ use-occtl = true # The user the worker processes will be run as. It should be # unique (no other services run as this user). run-as-user = @USERNAME@ run-as-group = @GROUP@ # Network settings device = vpns # The default domain to be advertised default-domain = example.com ipv4-network = @VPNNET@ # Use the keyword local to advertise the local P-t-P address as DNS server ipv4-dns = @DNS@ # The NBNS server (if any) #ipv4-nbns = 192.168.2.3 ipv6-network = @VPNNET6@ #address = #ipv6-mask = #ipv6-dns = # Prior to leasing any IP from the pool ping it to verify that # it is not in use by another (unrelated to this server) host. ping-leases = false # Leave empty to assign the default MTU of the device # mtu = route = @ROUTE1@ route = @ROUTE2@ # # The following options are for (experimental) AnyConnect client # compatibility. They are only available if the server is built # with --enable-anyconnect # # Client profile xml. A sample file exists in doc/profile.xml. # This file must be accessible from inside the worker's chroot. # The profile is ignored by the openconnect client. #user-profile = profile.xml # Unless set to false it is required for clients to present their # certificate even if they are authenticating via a previously granted # cookie. Legacy CISCO clients do not do that, and thus this option # should be set for them. #always-require-cert = false 07070100000019000081A400000000000000000000000163B478CF000010B6000000000000000000000000000000000000002900000000vpnc-scripts-0.1~git20230103/tests/ns.sh#!/bin/bash # # Copyright (C) 2018 Nikos Mavrogiannopoulos # # This file is part of ocserv. # # ocserv is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the # Free Software Foundation; either version 2 of the License, or (at # your option) any later version. # # ocserv is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # # Input: # ADDRESS=10.200.2.1 # ADDRESS2=10.200.2.2 # CLI_ADDRESS=10.200.1.1 # CLI_ADDRESS2=10.200.1.2 # VPNNET=192.168.1.0/24 # VPNADDR=192.168.1.1 # # Provides: # ${NSCMD1} - to run on NS1 # ${NSCMD2} - to run on NS2 # ${NSCMD3} - to run on NS3 # # Cleanup is automatic via a trap # Requires: finish() to be defined PATH=${PATH}:/usr/sbin if test -z ${IP};then IP=$(type -P ip) fi if test "$(id -u)" != "0";then echo "This test must be run as root" exit 1 fi ${IP} netns list >/dev/null 2>&1 if test $? != 0;then echo "This test requires ip netns command" exit 1 fi if test "$(uname -s)" != Linux;then echo "This test must be run on Linux" exit 1 fi function nsfinish { set +e test -n "${ETHNAME1}" && ${IP} link delete ${ETHNAME1} >/dev/null 2>&1 test -n "${ETHNAME2}" && ${IP} link delete ${ETHNAME2} >/dev/null 2>&1 test -n "${ETHNAME3}" && ${IP} link delete ${ETHNAME3} >/dev/null 2>&1 test -n "${ETHNAME4}" && ${IP} link delete ${ETHNAME4} >/dev/null 2>&1 test -n "${NSNAME1}" && ${IP} netns delete ${NSNAME1} >/dev/null 2>&1 test -n "${NSNAME2}" && ${IP} netns delete ${NSNAME2} >/dev/null 2>&1 test -n "${NSNAME3}" && ${IP} netns delete ${NSNAME3} >/dev/null 2>&1 finish } trap nsfinish EXIT # ETHNAME1 and ETHNAME2 are a veth pair # ETHNAME3 and ETHNAME4 are a veth pair # NSNAME1 and NSNAME3 are client namespaces containing ETHNAME1 and ETHNAME3 # NSNAME2 is the server namespace containing ETHNAME2 and ETHNAME4 echo " * Setting up namespaces..." set -e NSNAME1="ocserv-c-tmp-$$" NSNAME3="ocserv-c-2-tmp-$$" NSNAME2="ocserv-s-tmp-$$" ETHNAME1="oceth-c$$" ETHNAME2="oceth-s$$" ETHNAME3="oceth-c-2$$" ETHNAME4="oceth-s-2$$" ${IP} netns add ${NSNAME1} ${IP} netns add ${NSNAME2} ${IP} netns add ${NSNAME3} ${IP} link add ${ETHNAME1} type veth peer name ${ETHNAME2} ${IP} link set ${ETHNAME1} netns ${NSNAME1} ${IP} link set ${ETHNAME2} netns ${NSNAME2} ${IP} link add ${ETHNAME3} type veth peer name ${ETHNAME4} ${IP} link set ${ETHNAME3} netns ${NSNAME3} ${IP} link set ${ETHNAME4} netns ${NSNAME2} ${IP} -n ${NSNAME1} link set ${ETHNAME1} up ${IP} -n ${NSNAME2} link set ${ETHNAME2} up ${IP} -n ${NSNAME3} link set ${ETHNAME3} up ${IP} -n ${NSNAME2} link set ${ETHNAME4} up ${IP} -n ${NSNAME2} link set lo up ${IP} -n ${NSNAME1} addr add ${CLI_ADDRESS} dev ${ETHNAME1} ${IP} -n ${NSNAME2} addr add ${ADDRESS} dev ${ETHNAME2} test -n "${CLI_ADDRESS2}" && ${IP} -n ${NSNAME3} addr add ${CLI_ADDRESS2} dev ${ETHNAME3} test -n "${ADDRESS2}" && ${IP} -n ${NSNAME2} addr add ${ADDRESS2} dev ${ETHNAME4} ${IP} -n ${NSNAME1} route add default via ${CLI_ADDRESS} dev ${ETHNAME1} ${IP} -n ${NSNAME2} route ${IP} -n ${NSNAME2} route add default via ${ADDRESS} dev ${ETHNAME2} test -n "${CLI_ADDRESS2}" && ${IP} -n ${NSNAME3} route add default via ${CLI_ADDRESS2} dev ${ETHNAME3} test -n "${ADDRESS2}" && ${IP} -n ${NSNAME2} route add ${CLI_ADDRESS2}/32 via ${ADDRESS2} dev ${ETHNAME4} ${IP} -n ${NSNAME2} addr ${IP} -n ${NSNAME2} route ${IP} -n ${NSNAME1} route test -n "${CLI_ADDRESS2}" && ${IP} -n ${NSNAME3} route ${IP} netns exec ${NSNAME1} ping -c 1 ${ADDRESS} >/dev/null ${IP} netns exec ${NSNAME2} ping -c 1 ${ADDRESS} >/dev/null ${IP} netns exec ${NSNAME2} ping -c 1 ${CLI_ADDRESS} >/dev/null test -n "${ADDRESS2}" && ${IP} netns exec ${NSNAME2} ping -c 1 ${ADDRESS2} >/dev/null test -n "${CLI_ADDRESS2}" && ${IP} netns exec ${NSNAME2} ping -c 1 ${CLI_ADDRESS2} >/dev/null set +e CMDNS1="${IP} netns exec ${NSNAME1}" CMDNS2="${IP} netns exec ${NSNAME2}" CMDNS3="${IP} netns exec ${NSNAME3}" 0707010000001A000081ED00000000000000000000000163B478CF00001BD1000000000000000000000000000000000000002F00000000vpnc-scripts-0.1~git20230103/tests/vpn-noroute#!/bin/bash # # Copyright (C) 2018 Nikos Mavrogiannopoulos # # This file is part of ocserv. # # ocserv is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the # Free Software Foundation; either version 2 of the License, or (at # your option) any later version. # # ocserv is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # PIDFILE=ocserv-pid.$$.tmp CLIPIDFILE=oc-pid.$$.tmp PATH=${PATH}:/usr/sbin RESOLVCONFBAK=resolv.conf.$$.bak OUTFILE=noroute-tun.$$.tmp ALLFILE=noroute-all.$$.tmp TUNDEV=oc-$$-tun0 . `dirname $0`/common.sh eval "${GETPORT}" if test "$TRACE_VPNC_SCRIPT" = 1;then echo "Enabling detailed tracing in vpnc-script (env; set -x)." sed -i.trace -e 's|^#TRACE#||' ${srcdir}/../vpnc-script || exit 1 fi if test "$NO_IPROUTE2" = 1;then echo "Disabling iproute2 support in vpnc-script." sed -i.iproute2 -e 's|IPROUTE=....*|IPROUTE="" # disable|g' ${srcdir}/../vpnc-script || exit 1 elif test -z "${IP}";then echo "no IP tool is present" exit 1 fi if test "$(id -u)" != "0";then echo "This test must be run as root" exit 1 fi if test "${RESOLVCONF}" = 1;then cp /etc/resolv.conf ${RESOLVCONFBAK} fi echo "Testing $0... " function finish { set +e echo " * Cleaning up..." test -e "${CLIPIDFILE}" && kill $(cat ${CLIPIDFILE}) >/dev/null 2>&1 test -e "${CLIPIDFILE}" && rm -f ${CLIPIDFILE} >/dev/null 2>&1 test -e "${PIDFILE}" && kill $(cat ${PIDFILE}) >/dev/null 2>&1 test -e "${PIDFILE}" && rm -f ${PIDFILE} >/dev/null 2>&1 test -e "${CONFIG}" && rm -f ${CONFIG} >/dev/null 2>&1 if test "${RESOLVCONF}" = 1;then cp ${RESOLVCONFBAK} /etc/resolv.conf fi rm -f ${OUTFILE} ${ALLFILE} ${RESOLVCONFBAK} 2>&1 if test "${NO_IPROUTE2}" = 1;then mv -f ${srcdir}/../vpnc-script.iproute2 ${srcdir}/../vpnc-script 2>&1 fi if test "${TRACE_VPNC_SCRIPT}" = 1;then mv -f ${srcdir}/../vpnc-script.trace ${srcdir}/../vpnc-script 2>&1 fi } trap finish EXIT # server address; we test for default route + two excluded # IPv4 routes. We don't test for IPv6 exclude routes because # it doesn't seem to work. ADDRESS=10.200.2.1 CLI_ADDRESS=10.200.1.1 DNS=192.168.1.1 VPNNET=192.168.1.0/24 NOROUTE1=192.168.32.0/24 NOROUTE2=10.157.107.128/26 VPNADDR=192.168.1.1 VPNNET6=fd91:6d87:7341:db6a::/112 VPNADDR6=fd91:6d87:7341:db6a::1 OCCTL_SOCKET=./occtl-vpn-$$.socket USERNAME=test . `dirname $0`/ns.sh LISTEN_NS=${NSNAME2} # Run server update_config vpn-noroute.config if test "$VERBOSE" = 1;then DEBUG="-d 3" fi echo " * Running server on ${ADDRESS}:${PORT}" # run on NSNAME2 ${CMDNS2} ${OCSERV} -p ${PIDFILE} -c ${CONFIG} ${DEBUG} -f & sleep 4 # Run clients echo " * Getting cookie from ${ADDRESS}:${PORT}..." ( echo "test" | ${CMDNS1} ${OPENCONNECT} ${ADDRESS}:${PORT} -u ${USERNAME} --servercert=d66b507ae074d03b02eafca40d35f87dd81049d3 --cookieonly ) if test $? != 0;then echo "Could not get cookie from server" exit 1 fi echo " * Connecting to ${ADDRESS}:${PORT}..." export INTERNAL_IP6_NETMASK="fd91:6d87:7341:db6a::1/112" INTERNAL_IP6_ADDRESS="fd91:6d87:7341:db6a::1" # FIXME see #12 and !16#note_454710802 ( echo "test" | ${CMDNS1} ${OPENCONNECT} ${ADDRESS}:${PORT} --interface ${TUNDEV} -u ${USERNAME} --servercert=d66b507ae074d03b02eafca40d35f87dd81049d3 -s ${srcdir}/../vpnc-script --pid-file=${CLIPIDFILE} --passwd-on-stdin -b ) if test $? != 0;then echo "Could not connect to server" exit 1 fi echo " * wait for ${TUNDEV}" TIMEOUT=10 while ! ${CMDNS1} ${IP} addr list dev ${TUNDEV} &>/dev/null; do TIMEOUT=$(($TIMEOUT - 1)) if [ $TIMEOUT -eq 0 ]; then echo "Timed out waiting for ${TUNDEV}" exit 1 fi sleep 1 done sleep 3 # XX: CI needs additional delay here if test "$NO_IPROUTE2" = 1;then # XX: 'route flush' doesn't work properly on Linux ${CMSNS1} ${IP} route flush cache 2>/dev/null ${CMSNS1} ${IP} -6 route flush cache 2>/dev/null fi set -e echo " * ping remote address" ${CMDNS1} ping -c 2 ${VPNADDR} #${CMDNS1} ping -6 -c 2 ${VPNADDR6} set +e echo " * showing connected user info" ${CMDNS2} ${OCCTL} -s ${OCCTL_SOCKET} show user ${USERNAME} if test $? != 0;then echo "occtl didn't find connected user!" exit 1 fi echo "* listing routes on ${TUNDEV}" ${CMDNS1} ${IP} route list dev ${TUNDEV} > ${OUTFILE} ${CMDNS1} ${IP} -6 route list dev ${TUNDEV} >> ${OUTFILE} ${CMDNS1} ${IP} route list > ${ALLFILE} ${CMDNS1} ${IP} -6 route list >> ${ALLFILE} echo " * Checking whether server routes are present in client" grep -e "${VPNNET}" ${OUTFILE} >/dev/null if test $? != 0;then cat ${OUTFILE} echo "Did not find VPN route ${VPNNET}" exit 1 fi grep -e "default" ${OUTFILE} >/dev/null if test $? != 0;then cat ${OUTFILE} echo "Did not find default route in VPN device" exit 1 fi grep -e "${NOROUTE1}" ${OUTFILE} >/dev/null if test $? = 0;then cat ${OUTFILE} echo "Found exclude route in VPN device: ${NOROUTE1}" exit 1 fi grep -e "${NOROUTE1}" ${ALLFILE} >/dev/null if test $? != 0;then cat ${ALLFILE} echo "Did not find exclude route: ${NOROUTE1}" exit 1 fi grep -e "${NOROUTE2}" ${ALLFILE} >/dev/null if test $? != 0;then cat ${ALLFILE} echo "Did not find exclude route: ${NOROUTE2}" exit 1 fi if test "${RESOLVCONF}" = 1;then echo " * checking resolv.conf" grep ${DNS} /etc/resolv.conf >/dev/null if test $? != 0;then cat /etc/resolv.conf echo "Resolv.conf doesn't contain the VPN DNS server" exit 1 fi fi echo " * Found all expected routes" echo " * Terminating client" # Kill the client and check whether resolvconf is as expected if test -e "${CLIPIDFILE}"; then kill $(cat ${CLIPIDFILE}) >/dev/null 2>&1 for ii in $(seq 10); do kill -0 $(cat ${CLIPIDFILE}) >/dev/null 2>&1 || break sleep 1 done rm -f ${CLIPIDFILE} >/dev/null 2>&1 fi sleep 4 if test "${RESOLVCONF}" = 1;then cmp ${RESOLVCONFBAK} /etc/resolv.conf if test $? != 0;then echo "Resolv.conf was not restored" cat /etc/resolv.conf exit 1 fi fi echo " * Checking whether routes are removed" ${CMDNS1} ${IP} route list dev ${TUNDEV} > ${OUTFILE} ${CMDNS1} ${IP} -6 route list dev ${TUNDEV} >> ${OUTFILE} ${CMDNS1} ${IP} route list > ${ALLFILE} ${CMDNS1} ${IP} -6 route list >> ${ALLFILE} grep -e "${VPNNET}" ${OUTFILE} >/dev/null if test $? = 0;then cat ${OUTFILE} echo "Found VPN route ${VPNNET} after disconnect" exit 1 fi grep -e "default" ${OUTFILE} >/dev/null if test $? = 0;then cat ${OUTFILE} echo "Found VPN default route after disconnect" exit 1 fi grep -e "${NOROUTE1}" ${ALLFILE} >/dev/null if test $? = 0;then cat ${ALLFILE} echo "Found exclude route: ${NOROUTE1} after disconnect" exit 1 fi grep -e "${NOROUTE2}" ${ALLFILE} >/dev/null if test $? = 0;then cat ${ALLFILE} echo "Found exclude route: ${NOROUTE2} after disconnect" exit 1 fi exit 0 0707010000001B000081ED00000000000000000000000163B478CF0000188A000000000000000000000000000000000000002E00000000vpnc-scripts-0.1~git20230103/tests/vpn-routes#!/bin/bash # # Copyright (C) 2018 Nikos Mavrogiannopoulos # # This file is part of ocserv. # # ocserv is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the # Free Software Foundation; either version 2 of the License, or (at # your option) any later version. # # ocserv is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # PIDFILE=ocserv-pid.$$.tmp CLIPIDFILE=oc-pid.$$.tmp PATH=${PATH}:/usr/sbin RESOLVCONFBAK=resolv.conf.$$.bak OUTFILE=traffic.$$.tmp TUNDEV=oc-$$-tun0 . `dirname $0`/common.sh eval "${GETPORT}" if test "$TRACE_VPNC_SCRIPT" = 1;then echo "Enabling detailed tracing in vpnc-script (env; set -x)." sed -i.trace -e 's|^#TRACE#||' ${srcdir}/../vpnc-script || exit 1 fi if test "$NO_IPROUTE2" = 1;then echo "Disabling iproute2 support in vpnc-script." sed -i.iproute2 -e 's|IPROUTE=....*|IPROUTE="" # disable|' ${srcdir}/../vpnc-script || exit 1 elif test -z "${IP}";then echo "no IP tool is present" exit 1 fi if test "$(id -u)" != "0";then echo "This test must be run as root" exit 1 fi if test "${RESOLVCONF}" = 1;then cp /etc/resolv.conf ${RESOLVCONFBAK} fi echo "Testing $0... " function finish { set +e echo " * Cleaning up..." test -e "${CLIPIDFILE}" && kill $(cat ${CLIPIDFILE}) >/dev/null 2>&1 test -e "${CLIPIDFILE}" && rm -f ${CLIPIDFILE} >/dev/null 2>&1 test -e "${PIDFILE}" && kill $(cat ${PIDFILE}) >/dev/null 2>&1 test -e "${PIDFILE}" && rm -f ${PIDFILE} >/dev/null 2>&1 test -e "${CONFIG}" && rm -f ${CONFIG} >/dev/null 2>&1 if test "${RESOLVCONF}" = 1;then cp ${RESOLVCONFBAK} /etc/resolv.conf fi rm -f ${OUTFILE} ${RESOLVCONFBAK} 2>&1 if test "${NO_IPROUTE2}" = 1;then mv -f ${srcdir}/../vpnc-script.iproute2 ${srcdir}/../vpnc-script 2>&1 fi if test "${TRACE_VPNC_SCRIPT}" = 1;then mv -f ${srcdir}/../vpnc-script.trace ${srcdir}/../vpnc-script 2>&1 fi } trap finish EXIT # server address ADDRESS=10.200.2.1 CLI_ADDRESS=10.200.1.1 DNS=192.168.1.1 VPNNET=192.168.1.0/24 ROUTE1=192.168.32.0/24 ROUTE2=fd91:6d87:7341:dcba::/96 VPNADDR=192.168.1.1 VPNNET6=fd91:6d87:7341:db6a::/112 VPNADDR6=fd91:6d87:7341:db6a::1 OCCTL_SOCKET=./occtl-vpn-$$.socket USERNAME=test . `dirname $0`/ns.sh LISTEN_NS=${NSNAME2} # Run server update_config vpn-routes.config if test "$VERBOSE" = 1;then DEBUG="-d 3" fi echo " * Running server on ${ADDRESS}:${PORT}" # run on NSNAME2 ${CMDNS2} ${OCSERV} -p ${PIDFILE} -c ${CONFIG} ${DEBUG} -f & sleep 4 # Run clients echo " * Getting cookie from ${ADDRESS}:${PORT}..." ( echo "test" | ${CMDNS1} ${OPENCONNECT} ${ADDRESS}:${PORT} -u ${USERNAME} --servercert=d66b507ae074d03b02eafca40d35f87dd81049d3 --cookieonly ) if test $? != 0;then echo "Could not get cookie from server" exit 1 fi echo " * Connecting to ${ADDRESS}:${PORT}..." export INTERNAL_IP6_NETMASK="fd91:6d87:7341:db6a::1/112" INTERNAL_IP6_ADDRESS="fd91:6d87:7341:db6a::1" # FIXME see #12 and !16#note_454710802 ( echo "test" | ${CMDNS1} ${OPENCONNECT} ${ADDRESS}:${PORT} --interface ${TUNDEV} -u ${USERNAME} --servercert=d66b507ae074d03b02eafca40d35f87dd81049d3 -s ${srcdir}/../vpnc-script --pid-file=${CLIPIDFILE} --passwd-on-stdin -b ) if test $? != 0;then echo "Could not connect to server" exit 1 fi echo " * wait for ${TUNDEV}" TIMEOUT=10 while ! ${CMDNS1} ${IP} addr list dev ${TUNDEV} &>/dev/null; do TIMEOUT=$(($TIMEOUT - 1)) if [ $TIMEOUT -eq 0 ]; then echo "Timed out waiting for ${TUNDEV}" exit 1 fi sleep 1 done sleep 3 # XX: CI needs additional delay here if test "$NO_IPROUTE2" = 1;then # XX: 'route flush' doesn't work properly on Linux ${CMDNS1} ${IP} route flush cache 2>/dev/null ${CMDNS1} ${IP} -6 route flush cache 2>/dev/null fi set -e echo " * ping remote address" ${CMDNS1} ping -c 2 ${VPNADDR} #${CMDNS1} ping -6 -c 2 ${VPNADDR6} set +e echo " * showing connected user info" ${CMDNS2} ${OCCTL} -s ${OCCTL_SOCKET} show user ${USERNAME} if test $? != 0;then echo "occtl didn't find connected user!" exit 1 fi echo "* listing routes on ${TUNDEV}" ${CMDNS1} ${IP} route list dev ${TUNDEV} > ${OUTFILE} ${CMDNS1} ${IP} -6 route list dev ${TUNDEV} >> ${OUTFILE} echo " * Checking whether server routes are present in client" grep -e "${VPNNET}" ${OUTFILE} >/dev/null if test $? != 0;then cat ${OUTFILE} echo "Did not find VPN route ${VPNNET}" exit 1 fi grep -e "${ROUTE1}" ${OUTFILE} >/dev/null if test $? != 0;then cat ${OUTFILE} echo "Did not find route: ${ROUTE1}" exit 1 fi grep -e "${ROUTE2}" ${OUTFILE} >/dev/null if test $? != 0;then cat ${OUTFILE} echo "Did not find route: ${ROUTE2}" exit 1 fi if test "${RESOLVCONF}" = 1;then echo " * checking resolv.conf" grep ${DNS} /etc/resolv.conf >/dev/null if test $? != 0;then cat /etc/resolv.conf echo "Resolv.conf doesn't contain the VPN DNS server" exit 1 fi fi echo " * Found all expected routes" echo " * Terminating client" # Kill the client and check whether resolvconf is as expected if test -e "${CLIPIDFILE}"; then kill $(cat ${CLIPIDFILE}) >/dev/null 2>&1 for ii in $(seq 10); do kill -0 $(cat ${CLIPIDFILE}) >/dev/null 2>&1 || break sleep 1 done rm -f ${CLIPIDFILE} >/dev/null 2>&1 fi sleep 4 if test "${RESOLVCONF}" = 1;then cmp ${RESOLVCONFBAK} /etc/resolv.conf if test $? != 0;then echo "Resolv.conf was not restored" cat /etc/resolv.conf exit 1 fi fi echo " * Checking whether routes are removed" ${CMDNS1} ${IP} route list > ${OUTFILE} ${CMDNS1} ${IP} -6 route list >> ${OUTFILE} grep -e "${VPNNET}" ${OUTFILE} >/dev/null if test $? = 0;then cat ${OUTFILE} echo "Found VPN route ${VPNNET} after disconnect" exit 1 fi grep -e "${ROUTE1}" ${OUTFILE} >/dev/null if test $? = 0;then cat ${OUTFILE} echo "Found route: ${ROUTE1} after disconnect" exit 1 fi grep -e "${ROUTE2}" ${OUTFILE} >/dev/null if test $? = 0;then cat ${OUTFILE} echo "Found route: ${ROUTE2} after disconnect" exit 1 fi exit 0 0707010000001C000081ED00000000000000000000000163B478CF0000968A000000000000000000000000000000000000002900000000vpnc-scripts-0.1~git20230103/vpnc-script#!/bin/sh # # Originally part of vpnc source code: # © 2005-2012 Maurice Massar, Jörg Mayer, Antonio Borneo et al. # © 2009-2022 David Woodhouse <dwmw2@infradead.org>, Daniel Lenski <dlenski@gmail.com> et al. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # ################ # # List of parameters passed through environment #* reason -- why this script was called, one of: pre-init connect disconnect reconnect attempt-reconnect #* VPNGATEWAY -- VPN gateway address (always present) #* VPNPID -- PID of the process controlling the VPN (OpenConnect v9.0+) #* TUNDEV -- tunnel device (always present) #* IDLE_TIMEOUT -- gateway's idle timeout in seconds (OpenConnect v8.06+); unused #* LOG_LEVEL -- log level; ERROR=0, INFO=1, DEBUG=2, TRACE=3 (OpenConnect v9.0+) #* INTERNAL_IP4_ADDRESS -- address (always present) #* INTERNAL_IP4_MTU -- MTU (often unset) #* INTERNAL_IP4_NETMASK -- netmask (often unset) #* INTERNAL_IP4_NETMASKLEN -- netmask length (often unset) #* INTERNAL_IP4_NETADDR -- address of network (only present if netmask is set) #* INTERNAL_IP4_DNS -- list of DNS servers #* INTERNAL_IP4_NBNS -- list of WINS servers #* INTERNAL_IP6_ADDRESS -- IPv6 address #* INTERNAL_IP6_NETMASK -- IPv6 netmask #* INTERNAL_IP6_DNS -- IPv6 list of dns servers #* CISCO_DEF_DOMAIN -- default domain name #* CISCO_BANNER -- banner from server #* CISCO_SPLIT_DNS -- DNS search domain list #* CISCO_SPLIT_INC -- number of networks in split-network-list #* CISCO_SPLIT_INC_%d_ADDR -- network address #* CISCO_SPLIT_INC_%d_MASK -- subnet mask (for example: 255.255.255.0) #* CISCO_SPLIT_INC_%d_MASKLEN -- subnet masklen (for example: 24) #* CISCO_SPLIT_INC_%d_PROTOCOL -- protocol (often just 0); unused #* CISCO_SPLIT_INC_%d_SPORT -- source port (often just 0); unused #* CISCO_SPLIT_INC_%d_DPORT -- destination port (often just 0); unused #* CISCO_IPV6_SPLIT_INC -- number of networks in IPv6 split-network-list #* CISCO_IPV6_SPLIT_INC_%d_ADDR -- IPv6 network address #* CISCO_IPV6_SPLIT_INC_$%d_MASKLEN -- IPv6 subnet masklen # # The split tunnel variables above have *_EXC* counterparts for network # addresses to be excluded from the VPN tunnel. # FIXMEs: # Section A: route handling # 1) The 3 values CISCO_SPLIT_INC_%d_PROTOCOL/SPORT/DPORT are currently being ignored # In order to use them, we'll probably need os specific solutions # * Linux: iptables -t mangle -I PREROUTING <conditions> -j ROUTE --oif $TUNDEV # This would be an *alternative* to changing the routes (and thus 2) and 3) # shouldn't be relevant at all) # 2) There are two different functions to set routes: generic routes and the # default route. Why isn't the defaultroute handled via the generic route case? # 3) In the split tunnel case, all routes but the default route might get replaced # without getting restored later. We should explicitly check and save them just # like the defaultroute # 4) Replies to a dhcp-server should never be sent into the tunnel # Section B: Split DNS handling # 1) Maybe dnsmasq can do something like that # 2) Parse DNS packets going out via tunnel and redirect them to original DNS-server # ======== For test logging (CI/CD will uncomment automatically) ========= #TRACE# echo "------------------" #TRACE# echo "vpnc-script environment:" #TRACE# env | grep -E '^(CISCO_|INTERNAL_IP|VPNGATEWAY|TUNDEV|IDLE_TIMEOUT|reason)' | sort #TRACE# echo "------------------" #TRACE# set -x # =========== script (variable) setup ==================================== PATH=/sbin:/usr/sbin:$PATH OS="`uname -s`" HOOKS_DIR=/etc/vpnc # Use the PID of the controlling process (vpnc or OpenConnect) to # uniquely identify this VPN connection. Normally, the parent process # is a shell, and the grandparent's PID is the relevant one. # OpenConnect v9.0+ provides VPNPID, so we don't need to determine it. if [ -z "$VPNPID" ]; then VPNPID=$PPID PCMD=`ps -c -o command= -p $PPID` case "$PCMD" in *sh) VPNPID=`ps -o ppid= -p $PPID` ;; esac fi DEFAULT_ROUTE_FILE=/var/run/vpnc/defaultroute.${VPNPID} DEFAULT_ROUTE_FILE_IPV6=/var/run/vpnc/defaultroute_ipv6.${VPNPID} RESOLV_CONF_BACKUP=/var/run/vpnc/resolv.conf-backup.${VPNPID} SCRIPTNAME=`basename $0` # some systems, eg. Darwin & FreeBSD, prune /var/run on boot if [ ! -d "/var/run/vpnc" ]; then mkdir -p /var/run/vpnc [ -x /sbin/restorecon ] && /sbin/restorecon /var/run/vpnc fi if ifconfig --help 2>&1 | grep BusyBox > /dev/null; then ifconfig_syntax_inet="" else ifconfig_syntax_inet="inet" fi if [ "$OS" = "Linux" ]; then IPROUTE="`command -v ip | grep '^/'`" ifconfig_syntax_ptp="pointopoint" route_syntax_gw="gw" route_syntax_del="del" route_syntax_netmask="netmask" route_syntax_inet6="-6" route_syntax_inet6_host="-6" route_syntax_inet6_net="-6" ifconfig_syntax_add_inet6="add" ifconfig_syntax_del() { case "$1" in *:*) echo del "$1" ;; *) echo 0.0.0.0 ;; esac; } netstat_syntax_ipv6="-6" else # iproute2 is Linux only; if `command -v ip` returns something on another OS, it's likely an unrelated tool # (see https://github.com/dlenski/openconnect/issues/132#issuecomment-470475009) IPROUTE="" ifconfig_syntax_ptp="" route_syntax_gw="" route_syntax_del="delete" route_syntax_netmask="-netmask" route_syntax_inet6="-inet6" route_syntax_inet6_host="-inet6 -host" route_syntax_inet6_net="-inet6 -net" ifconfig_syntax_del() { case "$1" in *:*) echo inet6 "$1" delete ;; *) echo "$1" delete ;; esac; } ifconfig_syntax_add_inet6="inet6" netstat_syntax_ipv6="-f inet6" fi if [ "$OS" = "SunOS" ]; then route_syntax_interface="-interface" ifconfig_syntax_ptpv6="$INTERNAL_IP6_ADDRESS" else route_syntax_interface="" ifconfig_syntax_ptpv6="" fi RESOLVEDENABLED=0 grep '^hosts' /etc/nsswitch.conf 2>/dev/null|grep resolve >/dev/null 2>&1 if [ $? = 0 ];then command resolvectl status >/dev/null 2>&1 || command systemd-resolve --status >/dev/null 2>&1 if [ $? = 0 ];then RESOLVEDENABLED=1 fi fi if [ -r /etc/openwrt_release ] && [ -n "$OPENWRT_INTERFACE" ]; then . /etc/functions.sh include /lib/network MODIFYRESOLVCONF=modify_resolvconf_openwrt RESTORERESOLVCONF=restore_resolvconf_openwrt elif [ -x /usr/bin/resolvectl ] && [ ${RESOLVEDENABLED} = 1 ]; then # For systemd-resolved (version 239 and above) MODIFYRESOLVCONF=modify_resolved_manager RESTORERESOLVCONF=restore_resolved_manager elif [ -x /usr/bin/busctl ] && [ ${RESOLVEDENABLED} = 1 ]; then # For systemd-resolved (version 229 and above) MODIFYRESOLVCONF=modify_resolved_manager_old RESTORERESOLVCONF=restore_resolved_manager_old elif [ -x /sbin/resolvconf ] && [ "`basename $(readlink /sbin/resolvconf) 2> /dev/null`" != resolvectl ]; then # Optional tool on Debian, Ubuntu, Gentoo, FreeBSD and DragonFly BSD # (ignored if symlink to resolvctl, created by some versions of systemd-resolved) MODIFYRESOLVCONF=modify_resolvconf_manager RESTORERESOLVCONF=restore_resolvconf_manager elif [ -x /sbin/netconfig ] && [ ! -f /etc/slackware-version ]; then # tool on Suse after 11.1 # Slackware's netconfig is an unrelated tool that should not be invoked here # (see https://www.linuxquestions.org/questions/slackware-14/vpnc-on-slackware-14-2-is-bringing-up-network-configuration-dialog-each-time-4175595447/#post5646866) MODIFYRESOLVCONF=modify_resolvconf_suse_netconfig RESTORERESOLVCONF=restore_resolvconf_suse_netconfig elif [ -x /sbin/modify_resolvconf ]; then # Mandatory tool on Suse earlier than 11.1 MODIFYRESOLVCONF=modify_resolvconf_suse RESTORERESOLVCONF=restore_resolvconf_suse elif [ -x /usr/sbin/unbound-control ] && /usr/sbin/unbound-control status > /dev/null 2>&1; then MODIFYRESOLVCONF=modify_resolvconf_unbound RESTORERESOLVCONF=restore_resolvconf_unbound elif [ -x /usr/sbin/rcctl ] && /usr/sbin/rcctl check resolvd >/dev/null; then # OpenBSD's resolvd by sending route messages MODIFYRESOLVCONF=modify_resolvconf_resolvd RESTORERESOLVCONF=restore_resolvconf_resolvd else # Generic for any OS MODIFYRESOLVCONF=modify_resolvconf_generic RESTORERESOLVCONF=restore_resolvconf_generic fi # =========== script hooks ================================================= run_hooks() { HOOK="$1" if [ -d ${HOOKS_DIR}/${HOOK}.d ]; then for script in ${HOOKS_DIR}/${HOOK}.d/* ; do [ -f $script ] && . $script done fi } # =========== tunnel interface handling ==================================== do_ifconfig() { if [ -n "$INTERNAL_IP4_MTU" ]; then MTU=$INTERNAL_IP4_MTU elif [ -n "$IPROUTE" ]; then MTUDEV=`$IPROUTE route get "$VPNGATEWAY" | sed -ne 's/^.*dev \([a-z0-9]*\).*$/\1/p'` MTU=`$IPROUTE link show "$MTUDEV" | sed -ne 's/^.*mtu \([[:digit:]]\+\).*$/\1/p'` if [ -n "$MTU" ]; then MTU=`expr $MTU - 88` fi fi if [ -z "$MTU" ]; then MTU=1412 fi # Point to point interface require a netmask of 255.255.255.255 on some systems if [ -n "$IPROUTE" ]; then $IPROUTE link set dev "$TUNDEV" up mtu "$MTU" $IPROUTE addr add "$INTERNAL_IP4_ADDRESS/32" peer "$INTERNAL_IP4_ADDRESS" dev "$TUNDEV" else ifconfig "$TUNDEV" ${ifconfig_syntax_inet} "$INTERNAL_IP4_ADDRESS" $ifconfig_syntax_ptp "$INTERNAL_IP4_ADDRESS" netmask 255.255.255.255 mtu ${MTU} up fi if [ -n "$INTERNAL_IP4_NETMASK" ]; then set_network_route "$INTERNAL_IP4_NETADDR" "$INTERNAL_IP4_NETMASK" "$INTERNAL_IP4_NETMASKLEN" "$TUNDEV" fi # If the netmask is provided, it contains the address _and_ netmask if [ -n "$INTERNAL_IP6_ADDRESS" ] && [ -z "$INTERNAL_IP6_NETMASK" ]; then INTERNAL_IP6_NETMASK="$INTERNAL_IP6_ADDRESS/128" fi if [ -n "$INTERNAL_IP6_NETMASK" ]; then if [ -n "$IPROUTE" ]; then $IPROUTE -6 addr add $INTERNAL_IP6_NETMASK dev $TUNDEV else # Unlike for Legacy IP, we don't specify the dest_address # here on *BSD. OpenBSD for one will refuse to accept # incoming packets to that address if we do. # OpenVPN does the same (gives dest_address for Legacy IP # but not for IPv6). # Only Solaris needs it; hence $ifconfig_syntax_ptpv6 ifconfig "$TUNDEV" $ifconfig_syntax_add_inet6 $INTERNAL_IP6_NETMASK $ifconfig_syntax_ptpv6 mtu $MTU up fi fi } # =========== route handling ==================================== if [ -n "$IPROUTE" ]; then fix_ip_get_output () { sed -e 's/ /\n/g' | \ sed -ne "1 s|\$|${1}|p;/via/{N;p};/dev/{N;p};/src/{N;p};/mtu/{N;p};/metric/{N;p};/onlink/{p}" } # returns all routes to a destination *except* those through $TUNDEV, # sorted by increasing metric (with absent metric as last) list_non_loopback_routes () { echo "$1" | grep -q : && FAMILY=-6 ROOT=::/0 || FAMILY=-4 ROOT=0/0 # put metric in front, sort by metric, then chop off first two fields (metric and destination) $IPROUTE $FAMILY route show to "$1" root "$ROOT" | awk '/dev '"$TUNDEV"'/ { next; } { printf "%s %s\n", (match($0, /metric ([^ ]+)/) ? substr($0, RSTART+7, RLENGTH-7) : 4294967295), $0; }' | sort -n | cut -d' ' -f3- } set_vpngateway_route() { # We'll attempt to add a host route to the gateway through every route that matches # its address (excluding those through TUNDEV because the goal is to avoid loopback). echo "$VPNGATEWAY" | grep -q : && FAMILY=-6 || FAMILY=-4 list_non_loopback_routes "$VPNGATEWAY" | while read LINE ; do # We do not want to use 'replace', since a route to the gateway that already # exists is mostly likely the correct one (e.g. the case of a reconnect attempt # after dead-peer detection, but no change in the underlying network devices). $IPROUTE $FAMILY route add `echo "$VPNGATEWAY $LINE" | fix_ip_get_output` 2>/dev/null done if [ $FAMILY != -4 ]; then $IPROUTE $FAMILY route flush cache 2>/dev/null fi } del_vpngateway_route() { echo "$VPNGATEWAY" | grep -q : && FAMILY=-6 || FAMILY=-4 $IPROUTE route $route_syntax_del "$VPNGATEWAY" if [ $FAMILY != -4 ]; then $IPROUTE $FAMILY route flush cache 2>/dev/null fi } set_default_route() { $IPROUTE route | grep '^default' | fix_ip_get_output > "$DEFAULT_ROUTE_FILE" $IPROUTE route replace default dev "$TUNDEV" $IPROUTE route flush cache 2>/dev/null } set_network_route() { NETWORK="$1" NETMASK="$2" NETMASKLEN="$3" NETDEV="$4" NETGW="$5" if [ -n "$NETGW" ]; then $IPROUTE route replace "$NETWORK/$NETMASKLEN" dev "$NETDEV" via "$NETGW" else $IPROUTE route replace "$NETWORK/$NETMASKLEN" dev "$NETDEV" fi } set_exclude_route() { # add explicit route to keep current routing for this target # (keep traffic separate from VPN tunnel) NETWORK="$1" NETMASK="$2" NETMASKLEN="$3" list_non_loopback_routes "$NETWORK/$NETMASKLEN" | while read LINE ; do $IPROUTE route add `echo "$NETWORK/$NETMASKLEN $LINE" | fix_ip_get_output` 2>/dev/null done } del_exclude_route() { # FIXME: In theory, this could delete existing routes which are # identical to split-exclude routes specified by VPNGATEWAY NETWORK="$1" NETMASK="$2" NETMASKLEN="$3" $IPROUTE route $route_syntax_del "$NETWORK/$NETMASKLEN" } reset_default_route() { if [ -s "$DEFAULT_ROUTE_FILE" ]; then $IPROUTE route replace `cat "$DEFAULT_ROUTE_FILE"` rm -f -- "$DEFAULT_ROUTE_FILE" fi } del_network_route() { NETWORK="$1" NETMASK="$2" NETMASKLEN="$3" NETDEV="$4" $IPROUTE route $route_syntax_del "$NETWORK/$NETMASKLEN" dev "$NETDEV" } set_ipv6_default_route() { # We don't save/restore IPv6 default route; just add a higher-priority one. $IPROUTE -6 route add default dev "$TUNDEV" metric 1 $IPROUTE -6 route flush cache 2>/dev/null } set_ipv6_network_route() { NETWORK="$1" NETMASKLEN="$2" NETDEV="$3" NETGW="$4" if [ -n "$NETGW" ]; then $IPROUTE -6 route replace "$NETWORK/$NETMASKLEN" dev "$NETDEV" via "$NETGW" else $IPROUTE -6 route replace "$NETWORK/$NETMASKLEN" dev "$NETDEV" fi $IPROUTE -6 route flush cache 2>/dev/null } set_ipv6_exclude_route() { NETWORK="$1" NETMASKLEN="$2" set_exclude_route "$NETWORK" nomask "$NETMASKLEN" } reset_ipv6_default_route() { $IPROUTE -6 route del default dev "$TUNDEV" $IPROUTE -6 route flush cache 2>/dev/null } del_ipv6_network_route() { NETWORK="$1" NETMASKLEN="$2" NETDEV="$3" $IPROUTE -6 route del "$NETWORK/$NETMASKLEN" dev "$NETDEV" $IPROUTE -6 route flush cache 2>/dev/null } del_ipv6_exclude_route() { # FIXME: In theory, this could delete existing routes which are # identical to split-exclude routes specified by VPNGATEWAY NETWORK="$1" NETMASKLEN="$2" $IPROUTE -6 route del "$NETWORK/$NETMASKLEN" $IPROUTE -6 route flush cache 2>/dev/null } else # use route command get_default_gw() { # Intended behavior, starting with `netstat -r -n` output: # - keep lines starting with 'default' or '0.0.0.0', but exclude bogus routes '0.0.0.0/nn' where nn != 0 # - remove lines containing IPv6 addresses (':') # - remove lines for link-local routes (https://superuser.com/a/1067742) # - remove lines containing $TUNDEV (we don't want loopback) netstat -r -n | awk '/:/ { next; } /link#/ { next; } /[[:space:]]'"$TUNDEV"'([[:space:]]|$)/ { next; } /^(default|0\.0\.0\.0([[:space:]]|\/0))/ { print $2; exit; }' } set_vpngateway_route() { # Unlike with iproute2, there is no way to determine which current # route(s) match the VPN gateway, so we simply find a default # route and use its gateway. case "$VPNGATEWAY" in *:*) route add $route_syntax_inet6_host "$VPNGATEWAY" $route_syntax_gw "`get_ipv6_default_gw`";; *) route add -host "$VPNGATEWAY" $route_syntax_gw "`get_default_gw`";; esac } del_vpngateway_route() { case "$VPNGATEWAY" in *:*) route $route_syntax_del $route_syntax_inet6_host "$VPNGATEWAY" $route_syntax_gw "`get_ipv6_default_gw`";; *) route $route_syntax_del -host "$VPNGATEWAY" $route_syntax_gw "`get_default_gw`";; esac } set_default_route() { DEFAULTGW="`get_default_gw`" echo "$DEFAULTGW" > "$DEFAULT_ROUTE_FILE" route $route_syntax_del default $route_syntax_gw "$DEFAULTGW" route add default $route_syntax_gw "$INTERNAL_IP4_ADDRESS" $route_syntax_interface } set_network_route() { NETWORK="$1" NETMASK="$2" NETMASKLEN="$3" if [ -n "$5" ]; then NETGW="$5" else NETGW="$INTERNAL_IP4_ADDRESS" fi route add -net "$NETWORK" $route_syntax_netmask "$NETMASK" $route_syntax_gw "$NETGW" $route_syntax_interface } set_exclude_route() { NETWORK="$1" NETMASK="$2" NETMASKLEN="$3" DEFAULTGW="${DEFAULTGW:-`get_default_gw`}" if [ -z "$DEFAULTGW" ]; then echo "cannot find route for exclude route $NETWORK/$NETMASKLEN, ignoring" >&2 return fi # Add explicit route to keep traffic for this target separate # from tunnel. FIXME: We use default gateway - this is our best # guess in absence of "ip" command to query effective route. route add -net "$NETWORK" $route_syntax_netmask "$NETMASK" $route_syntax_gw "$DEFAULTGW" $route_syntax_interface } del_exclude_route() { # FIXME: This can delete existing routes in case they're # identical to split-exclude routes specified by VPNGATEWAY NETWORK="$1" NETMASK="$2" NETMASKLEN="$3" route $route_syntax_del -net "$NETWORK" $route_syntax_netmask "$NETMASK" } reset_default_route() { if [ -s "$DEFAULT_ROUTE_FILE" ]; then route $route_syntax_del default $route_syntax_gw "`get_default_gw`" $route_syntax_interface route add default $route_syntax_gw `cat "$DEFAULT_ROUTE_FILE"` rm -f -- "$DEFAULT_ROUTE_FILE" fi } del_network_route() { NETWORK="$1" NETMASK="$2" NETMASKLEN="$3" if [ -n "$5" ]; then NETGW="$5" else NETGW="$INTERNAL_IP4_ADDRESS" fi route $route_syntax_del -net "$NETWORK" $route_syntax_netmask "$NETMASK" $route_syntax_gw "$NETGW" } get_ipv6_default_gw() { # Intended behavior, starting with `netstat -r -n` IPv6 output: # - keep lines starting with 'default' or '::' # - append %$interface to link-local routes (fe80::/10) # - remove lines for loopback interface (lo) # - remove lines containing $TUNDEV (we don't want loopback) # FIXME: is there a better way to exclude loopback routes than filtering interface /^lo/? netstat -r -n $netstat_syntax_ipv6 | awk '/^(default|::\/0)/ { if ($NF!~/^lo/ && $NF!~/'"$TUNDEV"'([[:space:]]|$)/) { print ($2~/^fe[89ab]/ ? $2"%"$NF : $2); } }' } set_ipv6_default_route() { DEFAULTGW="`get_ipv6_default_gw`" echo "$DEFAULTGW" > "$DEFAULT_ROUTE_FILE_IPV6" route $route_syntax_del $route_syntax_inet6 default $route_syntax_gw "$DEFAULTGW" route add $route_syntax_inet6 default $route_syntax_gw "$INTERNAL_IP6_ADDRESS" $route_syntax_interface } set_ipv6_network_route() { NETWORK="$1" NETMASK="$2" DEVICE="$3" if [ -n "$4" ]; then NETGW="$4" elif [ "$OS" = "Linux" ]; then route add $route_syntax_inet6_net "$NETWORK/$NETMASK" dev "$DEVICE" return else NETGW="$INTERNAL_IP6_ADDRESS" fi route add $route_syntax_inet6_net "$NETWORK/$NETMASK" $route_syntax_gw "$NETGW" $route_syntax_interface : } set_ipv6_exclude_route() { NETWORK="$1" NETMASK="$2" IPV6DEFAULTGW="${IPV6DEFAULTGW:-`get_ipv6_default_gw`}" if [ -z "$IPV6DEFAULTGW" ]; then echo "cannot find route for exclude route $NETWORK/$NETMASKLEN, ignoring" >&2 return fi # Add explicit route to keep traffic for this target separate # from tunnel. FIXME: We use default gateway - this is our best # guess in absence of "ip" command to query effective route. route add $route_syntax_inet6_net "$NETWORK/$NETMASK" "$IPV6DEFAULTGW" $route_syntax_interface : } reset_ipv6_default_route() { if [ -s "$DEFAULT_ROUTE_FILE_IPV6" ]; then route $route_syntax_del $route_syntax_inet6 default $route_syntax_gw "`get_ipv6_default_gw`" $route_syntax_interface route add $route_syntax_inet6 default $route_syntax_gw `cat "$DEFAULT_ROUTE_FILE_IPV6"` rm -f -- "$DEFAULT_ROUTE_FILE_IPV6" fi : } del_ipv6_network_route() { NETWORK="$1" NETMASK="$2" DEVICE="$3" if [ -n "$4" ]; then NETGW="$4" elif [ "$OS" = "Linux" ]; then route $route_syntax_del $route_syntax_inet6 "$NETWORK/$NETMASK" dev "$DEVICE" return else NETGW="$INTERNAL_IP6_ADDRESS" fi route $route_syntax_del $route_syntax_inet6 "$NETWORK/$NETMASK" $route_syntax_gw "$NETGW" : } del_ipv6_exclude_route() { NETWORK="$1" NETMASK="$2" route $route_syntax_del $route_syntax_inet6 "$NETWORK/$NETMASK" : } fi # =========== resolv.conf handling ==================================== # =========== resolv.conf handling for any OS ========================= modify_resolvconf_generic() { grep '^#@VPNC_GENERATED@' /etc/resolv.conf > /dev/null 2>&1 || cp -- /etc/resolv.conf "$RESOLV_CONF_BACKUP" NEW_RESOLVCONF="#@VPNC_GENERATED@ -- this file is generated by vpnc # and will be overwritten by vpnc # as long as the above mark is intact" DOMAINS="$CISCO_DEF_DOMAIN" exec 6< "$RESOLV_CONF_BACKUP" while read LINE <&6 ; do case "$LINE" in # omit; we will overwrite these nameserver*) ;; # extract listed domains and prepend to list domain* | search*) DOMAINS="${LINE#* } $DOMAINS" ;; # retain other lines *) NEW_RESOLVCONF="$NEW_RESOLVCONF $LINE" ;; esac done exec 6<&- for i in $INTERNAL_IP4_DNS ; do NEW_RESOLVCONF="$NEW_RESOLVCONF nameserver $i" done # note that "search" is mutually exclusive with "domain"; # "search" allows multiple domains to be listed, so use that if [ -n "$DOMAINS" ]; then NEW_RESOLVCONF="$NEW_RESOLVCONF search $DOMAINS" fi echo "$NEW_RESOLVCONF" > /etc/resolv.conf if [ "$OS" = "Darwin" ]; then case "`uname -r`" in # Skip for pre-10.4 systems 4.*|5.*|6.*|7.*) ;; # 10.4 and later require use of scutil for DNS to work properly *) OVERRIDE_PRIMARY="" if [ -n "$CISCO_SPLIT_INC" ]; then if [ $CISCO_SPLIT_INC -lt 1 ]; then # Must override for correct default route # Cannot use multiple DNS matching in this case OVERRIDE_PRIMARY='d.add OverridePrimary # 1' fi # Overriding the default gateway breaks split routing OVERRIDE_GATEWAY="" # Not overriding the default gateway breaks usage of # INTERNAL_IP4_DNS. Prepend INTERNAL_IP4_DNS to list # of used DNS servers SERVICE=`echo "show State:/Network/Global/IPv4" | scutil | grep -oE '[a-fA-F0-9]{8}-([a-fA-F0-9]{4}-){3}[a-fA-F0-9]{12}'` SERVICE_DNS=`echo "show State:/Network/Service/$SERVICE/DNS" | scutil | grep -oE '([0-9]{1,3}[\.]){3}[0-9]{1,3}' | xargs` if [ X"$SERVICE_DNS" != X"$INTERNAL_IP4_DNS" ]; then scutil >/dev/null 2>&1 <<-EOF open get State:/Network/Service/$SERVICE/DNS d.add ServerAddresses * $INTERNAL_IP4_DNS $SERVICE_DNS set State:/Network/Service/$SERVICE/DNS close EOF fi else # No split routing. Override default gateway OVERRIDE_GATEWAY="d.add Router $INTERNAL_IP4_ADDRESS" fi # Uncomment the following if/fi pair to use multiple # DNS matching when available. When multiple DNS matching # is present, anything reading the /etc/resolv.conf file # directly will probably not work as intended. #if [ -z "$CISCO_DEF_DOMAIN" ]; then # Cannot use multiple DNS matching without a domain OVERRIDE_PRIMARY='d.add OverridePrimary # 1' #fi scutil >/dev/null 2>&1 <<-EOF open d.init d.add ServerAddresses * $INTERNAL_IP4_DNS set State:/Network/Service/$TUNDEV/DNS d.init $OVERRIDE_GATEWAY d.add Addresses * $INTERNAL_IP4_ADDRESS d.add SubnetMasks * 255.255.255.255 d.add InterfaceName $TUNDEV $OVERRIDE_PRIMARY set State:/Network/Service/$TUNDEV/IPv4 close EOF if [ -n "$CISCO_DEF_DOMAIN" ]; then scutil >/dev/null 2>&1 <<-EOF open get State:/Network/Service/$TUNDEV/DNS d.add DomainName $CISCO_DEF_DOMAIN d.add SearchDomains * $CISCO_DEF_DOMAIN d.add SupplementalMatchDomains * $CISCO_DEF_DOMAIN set State:/Network/Service/$TUNDEV/DNS close EOF fi # For newer MacOS versions it is needed to set DNS ACTIVE_INTERFACE=`route -n get default | grep interface | awk '{print $2}'` ACTIVE_NETWORK_SERVICE=`networksetup -listnetworkserviceorder | grep -B 1 "$ACTIVE_INTERFACE" | head -n 1 | awk '/\([0-9]+\)/{ print }'|cut -d " " -f2-` networksetup -setdnsservers "$ACTIVE_NETWORK_SERVICE" $INTERNAL_IP4_DNS ;; esac fi } restore_resolvconf_generic() { if [ ! -f "$RESOLV_CONF_BACKUP" ]; then return fi grep '^#@VPNC_GENERATED@' /etc/resolv.conf > /dev/null 2>&1 && cat "$RESOLV_CONF_BACKUP" > /etc/resolv.conf rm -f -- "$RESOLV_CONF_BACKUP" if [ "$OS" = "Darwin" ]; then case "`uname -r`" in # Skip for pre-10.4 systems 4.*|5.*|6.*|7.*) ;; # 10.4 and later require use of scutil for DNS to work properly *) scutil >/dev/null 2>&1 <<-EOF open remove State:/Network/Service/$TUNDEV/IPv4 remove State:/Network/Service/$TUNDEV/DNS close EOF # Split routing required prepending of INTERNAL_IP4_DNS # to list of used DNS servers if [ -n "$CISCO_SPLIT_INC" ]; then SERVICE=`echo "show State:/Network/Global/IPv4" | scutil | grep -oE '[a-fA-F0-9]{8}-([a-fA-F0-9]{4}-){3}[a-fA-F0-9]{12}'` SERVICE_DNS=`echo "show State:/Network/Service/$SERVICE/DNS" | scutil | grep -oE '([0-9]{1,3}[\.]){3}[0-9]{1,3}' | xargs` if [ X"$SERVICE_DNS" != X"$INTERNAL_IP4_DNS" ]; then scutil >/dev/null 2>&1 <<-EOF open get State:/Network/Service/$SERVICE/DNS d.add ServerAddresses * ${SERVICE_DNS##$INTERNAL_IP4_DNS} set State:/Network/Service/$SERVICE/DNS close EOF fi fi # For newer MacOS versions it is needed to unset DNS ACTIVE_INTERFACE=`route -n get default | grep interface | awk '{print $2}'` ACTIVE_NETWORK_SERVICE=`networksetup -listnetworkserviceorder | grep -B 1 "$ACTIVE_INTERFACE" | head -n 1 | awk '/\([0-9]+\)/{ print }'|cut -d " " -f2-` networksetup -setdnsservers "$ACTIVE_NETWORK_SERVICE" Empty ;; esac fi } # === resolv.conf handling via /sbin/netconfig (Suse 11.1) ===================== # Suse provides a script that modifies resolv.conf. Use it because it will # restart/reload all other services that care about it (e.g. lwresd). [unclear if this is still true, but probably --mlk] modify_resolvconf_suse_netconfig() { /sbin/netconfig modify -s vpnc -i "$TUNDEV" <<-EOF INTERFACE='$TUNDEV' DNSSERVERS='$INTERNAL_IP4_DNS' DNSDOMAIN='$CISCO_DEF_DOMAIN' EOF } # Restore resolv.conf to old contents on Suse restore_resolvconf_suse_netconfig() { /sbin/netconfig remove -s vpnc -i "$TUNDEV" } # === resolv.conf handling via /sbin/modify_resolvconf (Suse) ===================== # Suse provides a script that modifies resolv.conf. Use it because it will # restart/reload all other services that care about it (e.g. lwresd). modify_resolvconf_suse() { FULL_SCRIPTNAME=`readlink -f $0` RESOLV_OPTS='' test -n "$INTERNAL_IP4_DNS" && RESOLV_OPTS="-n \"$INTERNAL_IP4_DNS\"" test -n "$CISCO_DEF_DOMAIN" && RESOLV_OPTS="$RESOLV_OPTS -d $CISCO_DEF_DOMAIN" test -n "$RESOLV_OPTS" && eval /sbin/modify_resolvconf modify -s vpnc -p $SCRIPTNAME -f $FULL_SCRIPTNAME -e $TUNDEV $RESOLV_OPTS -t \"This file was created by $SCRIPTNAME\" } # Restore resolv.conf to old contents on Suse restore_resolvconf_suse() { FULL_SCRIPTNAME=`readlink -f $0` /sbin/modify_resolvconf restore -s vpnc -p $SCRIPTNAME -f $FULL_SCRIPTNAME -e $TUNDEV } # === resolv.conf handling via UCI (OpenWRT) ========= modify_resolvconf_openwrt() { add_dns $OPENWRT_INTERFACE $INTERNAL_IP4_DNS } restore_resolvconf_openwrt() { remove_dns $OPENWRT_INTERFACE } # === resolv.conf handling via /sbin/resolvconf (Debian, Ubuntu, Gentoo)) ========= modify_resolvconf_manager() { NEW_RESOLVCONF="" for i in $INTERNAL_IP4_DNS; do NEW_RESOLVCONF="$NEW_RESOLVCONF nameserver $i" done if [ -n "$CISCO_DEF_DOMAIN" ]; then NEW_RESOLVCONF="$NEW_RESOLVCONF search $CISCO_DEF_DOMAIN" fi echo "$NEW_RESOLVCONF" | /sbin/resolvconf -a $TUNDEV } restore_resolvconf_manager() { /sbin/resolvconf -d $TUNDEV } AF_INET=2 get_if_index() { local link link="$(ip link show dev "$1")" || return $? echo ${link} | awk -F: '{print $1}' } busctl_call() { local dest node dest=org.freedesktop.resolve1 node=/org/freedesktop/resolve1 busctl call "$dest" "${node}" "${dest}.Manager" "$@" } busctl_set_nameservers() { local if_index addresses args addr if_index=$1 shift addresses="$@" args="$if_index $#" for addr in ${addresses}; do args="$args ${AF_INET} 4 $(echo $addr | sed 's/[.]/ /g')" done busctl_call SetLinkDNS 'ia(iay)' ${args} } resolvectl_set_nameservers() { local if_index addresses if_index=$1 shift addresses="$@" /usr/bin/resolvectl dns $if_index $addresses } busctl_set_search() { local if_index domains args domain if_index=$1 shift domains="$@" args="$if_index $#" for domain in ${domains}; do args="$args ${domain} false" done busctl_call SetLinkDomains 'ia(sb)' ${args} } resolvectl_set_search() { local if_index domains if_index=$1 shift domains="$@" /usr/bin/resolvectl domain $if_index $domains } modify_resolved_manager() { local if_index split_dns_list if_index=$(get_if_index $TUNDEV) split_dns_list=$(echo $CISCO_SPLIT_DNS | tr ',' ' ') resolvectl_set_nameservers $if_index $INTERNAL_IP4_DNS if [ -n "$CISCO_DEF_DOMAIN" ] || [ -n "$split_dns_list" ]; then resolvectl_set_search $if_index $CISCO_DEF_DOMAIN $split_dns_list fi } modify_resolved_manager_old() { local if_index if_index=$(get_if_index $TUNDEV) busctl_set_nameservers $if_index $INTERNAL_IP4_DNS if [ -n "$CISCO_DEF_DOMAIN" ]; then busctl_set_search $if_index $CISCO_DEF_DOMAIN fi } restore_resolved_manager() { local if_index if_index=$(get_if_index $TUNDEV) /usr/bin/resolvectl revert $if_index } restore_resolved_manager_old() { local if_index if_index=$(get_if_index $TUNDEV) busctl_call RevertLink 'i' $if_index } # === resolv.conf handling via unbound ========= modify_resolvconf_unbound() { if [ -n "$CISCO_DEF_DOMAIN" ]; then /usr/sbin/unbound-control forward_add +i ${CISCO_DEF_DOMAIN} ${INTERNAL_IP4_DNS} /usr/sbin/unbound-control flush_requestlist /usr/sbin/unbound-control flush_zone ${CISCO_DEF_DOMAIN} fi } restore_resolvconf_unbound() { if [ -n "$CISCO_DEF_DOMAIN" ]; then /usr/sbin/unbound-control forward_remove +i ${CISCO_DEF_DOMAIN} /usr/sbin/unbound-control flush_zone ${CISCO_DEF_DOMAIN} /usr/sbin/unbound-control flush_requestlist fi } # === resolv.conf handling via resolvd ========= modify_resolvconf_resolvd() { /sbin/route nameserver $TUNDEV $INTERNAL_IP4_DNS $INTERNAL_IP6_DNS } restore_resolvconf_resolvd() { /sbin/route nameserver $TUNDEV } # ========= Toplevel state handling ======================================= do_pre_init() { if [ "$OS" = "Linux" ]; then if (exec 6< /dev/net/tun) > /dev/null 2>&1 ; then : else # can't open /dev/net/tun test -e /proc/sys/kernel/modprobe && `cat /proc/sys/kernel/modprobe` tun 2>/dev/null # make sure tun device exists if [ ! -e /dev/net/tun ]; then mkdir -p /dev/net mknod -m 0640 /dev/net/tun c 10 200 [ -x /sbin/restorecon ] && /sbin/restorecon /dev/net/tun fi # workaround for a possible latency caused by udev, sleep max. 10s for x in $(seq 100) ; do (exec 6<> /dev/net/tun) > /dev/null 2>&1 && break; sleep 0.1 done fi elif [ "$OS" = "FreeBSD" -o "$OS" = "DragonFly" ]; then if ! ifconfig $TUNDEV > /dev/null; then ifconfig $TUNDEV create fi elif [ "$OS" = "GNU/kFreeBSD" ]; then if [ ! -e /dev/tun ]; then kldload if_tun fi elif [ "$OS" = "NetBSD" ]; then : elif [ "$OS" = "OpenBSD" ]; then if ! ifconfig $TUNDEV > /dev/null; then ifconfig $TUNDEV create fi : elif [ "$OS" = "SunOS" ]; then : elif [ "$OS" = "Darwin" ]; then : fi } do_connect() { if [ -n "$CISCO_BANNER" ]; then echo "Connect Banner:" echo "$CISCO_BANNER" | while read LINE ; do echo "|" "$LINE" ; done echo fi case "$VPNGATEWAY" in 127.*|::1) ;; # localhost (probably proxy) *) set_vpngateway_route ;; esac do_ifconfig if [ -n "$CISCO_SPLIT_EXC" ]; then i=0 while [ $i -lt $CISCO_SPLIT_EXC ] ; do eval NETWORK="\${CISCO_SPLIT_EXC_${i}_ADDR}" eval NETMASK="\${CISCO_SPLIT_EXC_${i}_MASK}" eval NETMASKLEN="\${CISCO_SPLIT_EXC_${i}_MASKLEN}" case "$NETWORK" in 0.*|127.*|169.254.*) echo "ignoring non-forwardable exclude route $NETWORK/$NETMASKLEN" >&2 ;; *) set_exclude_route "$NETWORK" "$NETMASK" "$NETMASKLEN" ;; esac i=`expr $i + 1` done fi if [ -n "$CISCO_IPV6_SPLIT_EXC" ]; then # untested i=0 while [ $i -lt $CISCO_IPV6_SPLIT_EXC ] ; do eval NETWORK="\${CISCO_IPV6_SPLIT_EXC_${i}_ADDR}" eval NETMASKLEN="\${CISCO_IPV6_SPLIT_EXC_${i}_MASKLEN}" set_ipv6_exclude_route "$NETWORK" "$NETMASKLEN" i=`expr $i + 1` done fi if [ -n "$CISCO_SPLIT_INC" ]; then i=0 while [ $i -lt $CISCO_SPLIT_INC ] ; do eval NETWORK="\${CISCO_SPLIT_INC_${i}_ADDR}" eval NETMASK="\${CISCO_SPLIT_INC_${i}_MASK}" eval NETMASKLEN="\${CISCO_SPLIT_INC_${i}_MASKLEN}" if [ "$NETWORK" != "0.0.0.0" ]; then set_network_route "$NETWORK" "$NETMASK" "$NETMASKLEN" "$TUNDEV" else set_default_route fi i=`expr $i + 1` done elif [ -n "$INTERNAL_IP4_ADDRESS" ]; then set_default_route fi if [ -n "$CISCO_IPV6_SPLIT_INC" ]; then i=0 while [ $i -lt $CISCO_IPV6_SPLIT_INC ] ; do eval NETWORK="\${CISCO_IPV6_SPLIT_INC_${i}_ADDR}" eval NETMASKLEN="\${CISCO_IPV6_SPLIT_INC_${i}_MASKLEN}" if [ $NETMASKLEN -eq 0 ]; then set_ipv6_default_route else set_ipv6_network_route "$NETWORK" "$NETMASKLEN" "$TUNDEV" fi i=`expr $i + 1` done elif [ -n "$INTERNAL_IP6_NETMASK" -o -n "$INTERNAL_IP6_ADDRESS" ]; then set_ipv6_default_route fi if [ -n "$INTERNAL_IP4_DNS" ]; then $MODIFYRESOLVCONF fi } do_disconnect() { if [ -n "$CISCO_SPLIT_INC" ]; then i=0 while [ $i -lt $CISCO_SPLIT_INC ] ; do eval NETWORK="\${CISCO_SPLIT_INC_${i}_ADDR}" eval NETMASK="\${CISCO_SPLIT_INC_${i}_MASK}" eval NETMASKLEN="\${CISCO_SPLIT_INC_${i}_MASKLEN}" if [ "$NETWORK" != "0.0.0.0" ]; then # FIXME: This doesn't restore previously overwritten # routes. del_network_route "$NETWORK" "$NETMASK" "$NETMASKLEN" "$TUNDEV" else reset_default_route fi i=`expr $i + 1` done else reset_default_route fi if [ -n "$CISCO_SPLIT_EXC" ]; then i=0 while [ $i -lt $CISCO_SPLIT_EXC ] ; do eval NETWORK="\${CISCO_SPLIT_EXC_${i}_ADDR}" eval NETMASK="\${CISCO_SPLIT_EXC_${i}_MASK}" eval NETMASKLEN="\${CISCO_SPLIT_EXC_${i}_MASKLEN}" case "$NETWORK" in 0.*|127.*|169.254.*) ;; # ignoring non-forwardable exclude route *) del_exclude_route "$NETWORK" "$NETMASK" "$NETMASKLEN" ;; esac i=`expr $i + 1` done fi if [ -n "$CISCO_IPV6_SPLIT_EXC" ]; then # untested i=0 while [ $i -lt $CISCO_IPV6_SPLIT_EXC ] ; do eval NETWORK="\${CISCO_IPV6_SPLIT_EXC_${i}_ADDR}" eval NETMASKLEN="\${CISCO_IPV6_SPLIT_EXC_${i}_MASKLEN}" del_ipv6_exclude_route "$NETWORK" "$NETMASKLEN" i=`expr $i + 1` done fi if [ -n "$CISCO_IPV6_SPLIT_INC" ]; then i=0 while [ $i -lt $CISCO_IPV6_SPLIT_INC ] ; do eval NETWORK="\${CISCO_IPV6_SPLIT_INC_${i}_ADDR}" eval NETMASKLEN="\${CISCO_IPV6_SPLIT_INC_${i}_MASKLEN}" if [ $NETMASKLEN -eq 0 ]; then reset_ipv6_default_route else del_ipv6_network_route "$NETWORK" "$NETMASKLEN" "$TUNDEV" fi i=`expr $i + 1` done elif [ -n "$INTERNAL_IP6_NETMASK" -o -n "$INTERNAL_IP6_ADDRESS" ]; then reset_ipv6_default_route fi del_vpngateway_route if [ -n "$INTERNAL_IP4_DNS" ]; then $RESTORERESOLVCONF fi if [ -n "$IPROUTE" ]; then if [ -n "$INTERNAL_IP4_ADDRESS" ]; then $IPROUTE addr del "$INTERNAL_IP4_ADDRESS/255.255.255.255" peer "$INTERNAL_IP4_ADDRESS" dev "$TUNDEV" fi # If the netmask is provided, it contains the address _and_ netmask if [ -n "$INTERNAL_IP6_ADDRESS" ] && [ -z "$INTERNAL_IP6_NETMASK" ]; then INTERNAL_IP6_NETMASK="$INTERNAL_IP6_ADDRESS/128" fi if [ -n "$INTERNAL_IP6_NETMASK" ]; then $IPROUTE -6 addr del $INTERNAL_IP6_NETMASK dev $TUNDEV fi $IPROUTE link set dev "$TUNDEV" down else if [ -n "$INTERNAL_IP4_ADDRESS" ]; then ifconfig "$TUNDEV" `ifconfig_syntax_del "$INTERNAL_IP4_ADDRESS"` fi if [ -n "$INTERNAL_IP6_ADDRESS" ] && [ -z "$INTERNAL_IP6_NETMASK" ]; then INTERNAL_IP6_NETMASK="$INTERNAL_IP6_ADDRESS/128" fi if [ -n "$INTERNAL_IP6_NETMASK" ]; then ifconfig "$TUNDEV" `ifconfig_syntax_del "$INTERNAL_IP6_NETMASK"` fi ifconfig "$TUNDEV" down fi case "$OS" in NetBSD|OpenBSD) # and probably others... ifconfig "$TUNDEV" destroy ;; FreeBSD|DragonFly) ifconfig "$TUNDEV" destroy > /dev/null 2>&1 & ;; esac } do_attempt_reconnect() { set_vpngateway_route } #### Main if [ -z "$reason" ]; then echo "this script must be called from vpnc" 1>&2 exit 1 fi case "$reason" in pre-init) run_hooks pre-init do_pre_init ;; connect) run_hooks connect do_connect run_hooks post-connect ;; disconnect) run_hooks disconnect do_disconnect run_hooks post-disconnect ;; attempt-reconnect) # Invoked before each attempt to re-establish the session. # If the underlying physical connection changed, we might # be left with a route to the VPN server through the VPN # itself, which would need to be fixed. run_hooks attempt-reconnect do_attempt_reconnect run_hooks post-attempt-reconnect ;; reconnect) # After successfully re-establishing the session. run_hooks reconnect ;; *) echo "unknown reason '$reason'. Maybe vpnc-script is out of date" 1>&2 exit 1 ;; esac exit 0 0707010000001D000081ED00000000000000000000000163B478CF000013C8000000000000000000000000000000000000002F00000000vpnc-scripts-0.1~git20230103/vpnc-script-ptrtd#!/bin/sh # # © 2009 David Woodhouse <dwmw2@infradead.org> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # ################ # # This is a replacement for the standard vpnc-script for use with vpnc # and openconnect. It sets up VPN routing which doesn't screw over the # _normal_ routing of the box. # It sets up a new network namespace for the VPN to use, and it runs # pTRTd (http://www.litech.org/ptrtd/) in that namespace. Connections # to the VPN are actually made as IPv6 connections, and pTRTd handles # converting them to Legacy IP and forwarding them. # The full range of Legacy IP addresses on the VPN is available to the # host through a tiny corner of the IPv6 address space; for this purpose # we use fec0:0:0:ffff:0:0:xxyy:zzww to represent the address xx.yy.zz.ww # on the VPN. # TODO: Either use totd (ftp://ftp.pasta.cs.uit.no/pub/Vermicelli/) or # preferably extend dnsmasq to handle DNS for us. We want the following: # - A queries for non-existent VPN hosts return NXDOMAIN (no munging) # - A queries for _extant_ VPN hosts return NOERROR instead of the result. # - AAAA queries return the A result, converted to the above IPv6 space. # - PTR queries within the IPv6 space converted appropriately. IP="`command -v ip | grep '^/'`" connect_parent() { # XXX: How do we work out what it _really_ is? export PARENT_NETNS=$$ # XXX: Make sure it doesn't exist in this namespace already export RETURNDEV=x$TUNDEV ./netunshare $0 $@ & CHILDPID=$! # XXX: If we do this too soon (before the unshare), we're just # giving it to our _own_ netns. which achieves nothing. # So give it away until we _can't_ give it away any more. while $IP link set $TUNDEV netns $CHILDPID 2>/dev/null; do sleep 0.1 done # Wait for the ptrtd tundev to appear in this namespace while ! $IP link show $RETURNDEV >/dev/null 2>&1 ; do sleep 1 done $IP link set $RETURNDEV up $IP addr add fe80::1 dev $RETURNDEV $IP route add fec0:0:0:ffff::/64 dev $RETURNDEV # XXX: Local hack -- my company's VPN server returns # "foo.company.com" instead of just "company.com". CISCO_DEF_DOMAIN=`echo $CISCO_DEF_DOMAIN | cut -f2- -d.` # Work out the IPv6 address of the nameservers... IPV6NS= for NS in $INTERNAL_IP4_DNS; do A=`echo $NS | cut -f1 -d.` B=`echo $NS | cut -f2 -d.` C=`echo $NS | cut -f3 -d.` D=`echo $NS | cut -f4 -d.` THISNS=`printf fec0:0:0:ffff:0:0:%02x%02x:%02x%02x $A $B $C $D` IPV6NS="$THISNS $IPV6NS" DNSMASQ_CMDLINE="-S /$CISCO_DEF_DOMAIN/$IPV6NS $DNSMASQ_CMDLINE" done echo IPv6 DNS: $IPV6NS # XXX: Add totd-like capability to dnsmasq dnsmasq $DNSMASQ_CMDLINE } connect() { if [ -z "$PARENT_NETNS" ]; then connect_parent exit 0 fi # Wait for the tundev to appear in this namespace while ! $IP link show $TUNDEV >/dev/null 2>&1 ; do sleep 0.1 done # Set up Legacy IP in the new namespace $IP link set lo up $IP link set $TUNDEV up $IP -4 addr add $INTERNAL_IP4_ADDRESS dev $TUNDEV $IP -4 route add default dev $TUNDEV if [ "$INTERNAL_IP4_MTU" != "" ]; then $IP link set $TUNDEV mtu $INTERNAL_IP4_MTU fi # ifconfig # route # For debugging, really. Lets you ssh into the netns with # ssh fec0:0:0:ffff:0:0:7f00:1 /usr/sbin/sshd -D & SSHD_PID=$! # Start ptrtd ptrtd -i tun:$RETURNDEV -d >/dev/null 2>&1 & PTRTD_PID=$! # Wait for the ptrtd to make its device while ! $IP link show $TUNDEV >/dev/null 2>&1 ; do sleep 0.1 done # Now give the ptrtd device back to the parent $IP link set $RETURNDEV down $IP link set $RETURNDEV netns $PARENT_NETNS #Hm, this doesn't work because the tundev doesn't go away when it should #while ip link show $TUNDEV 2> /dev/null ; do # sleep 1 #done # Wait for ptrtd to die (which it will when disconnect() kills its tun) wait $PTRTD_PID kill -TERM $SSHD_PID # Wait a while to avoid tun BUG() if we quit and the netns goes away # before vpnc/openconnect closes its tun fd. sleep 1 } disconnect() { RETURNDEV=x$TUNDEV # This will kill ptrtd inside the netns, leaving the script to clean up $IP link del $RETURNDEV # XXX: Undo the dnsmasq stuff. killall dnsmasq # XXX: properly. } case $reason in connect) connect ;; disconnect) disconnect ;; esac 0707010000001E000081ED00000000000000000000000163B478CF0000280A000000000000000000000000000000000000002E00000000vpnc-scripts-0.1~git20230103/vpnc-script-sshd#!/bin/sh # # © 2009 David Woodhouse <dwmw2@infradead.org> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # ################ # # This is a replacement for the standard vpnc-script used with vpnc and # openconnect. It sets up VPN routing which doesn't screw over the # _normal_ routing of the box. # # It sets up a new network namespace for the VPN to use, and it runs # a Secure Shell dæmon inside that namespace, with full access to all # routes on the VPN. # # It links the 'real' network namespace of the computer to this new one # by an IPv6 site-local connection -- you can ssh into the 'VPN namespace' # by connecting to the host 'fec0::1'. # # You don't need any IPv6 configuration or connectivity for this; you # only need to have IPv6 support in your kernel. The use of IPv6 is purely # local to your machine. # # This gives you effectively the same service as if your company used a # SSH "bastion host" for access, instead of a VPN. It's just that the # bastion host is a special network namespace in your _own_ machine. # # Since your connection to it is _private_, though, you can run a few # services that a secure bastion host could not -- like a web proxy, # for example. You can also just forward certain points so that, for # example, connections to port 25 on your bastion host are automatically # forwarded inside the VPN to your internal mail server. There should # be a sample xinetd.conf with this script which shows how to do that # using 'netcat' started from xinetd. # # It probably helps if you think of the VPN namespace as if it was a # separate machine. From the network point of view, that's what it is. # It just happens to share the file system (and a lot of other stuff) # with your _real_ computer. # # You can configure various other services to use this for connections into # your VPN, as follows... # # SOCKS # # SSH has a built-in SOCKS server. If you run 'ssh -D 1080 fec0::1', SSH # will listen on port 1080 and will forward connections through the SSH # connection and give you full SOCKS access to the VPN. # # It might make sense to make this script automatically start a SSH # connection with SOCKS enabled, if you want that to be available. # # SSH # # The OpenSSH client is capable of connecting to a SSH server by running # and arbitrary command and using its stdin/stdout, instead of having to # make a direct TCP connection to the server. # # So you can configure it to SSH into the VPN 'namespace' and use the # 'netcat' command for certain connections. You can add something like # this to your ~/.ssh/config: # # Host *.example.internal # ProxyCommand ssh fec0::1 exec nc %h %p # # (This also works if your company has made the mistake of overloading the # public 'company.com' domain for internal purposes, instead of doing the # sensible thing and using a _separate_ domain.) # # MAIL # # Like SSH, most decent mail clients are able to run a command to connect # to their IMAP server instead of being limited to a direct TCP connection. # # Commands you might want to use could look like... # ssh $MAILSRV exec /usr/sbin/dovecot --exec-mail imap # ssh $MAILSRV exec /usr/sbin/wu-imapd # ssh fec0::1 openssl s_client -quiet -connect $MAILSRV:993 -crlf 2>/dev/null # # Where '$MAILSRV' is the name of your mail server, of course. # # Note that the first two assume that you've set up SSH as described above, # so that SSH connections to the mail server work transparently. For the # latter, you probably need to redirect stderr to /dev/null to avoid # spurious output from openssl configuring your mail client (openssl doesn't # seem to take the -quiet option very seriously). # # For mail clients which _cannot_ simply run an external command for their # connection, first file a bug and then see the 'PORT FORWARDING' section # below. # # WEB # # Firefox and most other browsers should understand a 'proxy autoconfig' # file and that can tell it to use SOCKS (see above) for certain domains. # A suitable PAC file might look like this: # # function FindProxyForURL(url, host) # { # if (dnsDomainIs(host, "company.com")) # return "SOCKS5 localhost:1080"; # # return "DIRECT"; # } # # PORT FORWARDING # # You can use SSH to forward certain ports, of course -- but there's another, # simpler option. # # The included example of xinetd configuration will accept connections on # port 25 and 993 of the host fec0::1, and will automatically forward them # using netcat to the appropriate hosts within your VPN. This can be extended # to forward other ports. # # OTHER SERVICES # # Most other services should also be available through SSH, through the # SOCKS proxy, or by port forwarding in some way. If all else fails, you # can just ssh into the vpn namespace (ssh fec0::1) and have a shell with # complete access. # # BREAKING OUT OF THE VPN # # If you ssh _into_ your machine from the VPN side, you'll get a shell in # the VPN namespace. To 'break out' from there, you may want to ssh to # fec0::2 which is the normal machine. # # CONTROLLING ACCESS TO THE VPN # # One serious flaw with the _traditional_ VPN setup is that it allows # _all_ processes and users on the machine to have free access to the # VPN, instead of only the user who is supposed to have access. The # approach implemented here allows you to fix that, by running the # SSHD in the VPN namespace with a separate configuration that allows # only certain users to connect to it. # # (Be aware that using port forwarding or using SSH to run a SOCKS proxy # will negate that benefit, of course) # # David Woodhouse <dwmw2@infradead.org> # 2009-06-06 IP="`command -v ip | grep '^/'`" SCRIPTNAME=`basename $0` NETNSNAME=$SCRIPTNAME # XINETDCONF=`dirname $0`/xinetd.netns.conf PS4=" \$\$+ " connect_parent() { export PARENT_NETNS=$$ $IP link set $TUNDEV down if ! $IP link set $TUNDEV netns $$; then echo "Setting network namespace for $TUNDEV failed" echo "Perhaps you don't have network namespace support in your kernel?" exit 1 fi $IP netns delete $NETNSNAME >/dev/null 2>&1 if ! $IP netns add $NETNSNAME; then echo "Creating network namespace $NETNSNAME failed" echo "Perhaps you don't have network namespace support in your kernel?" exit 1 fi LOCALDEV=$TUNDEV-vpnssh0 export REMOTEDEV=$TUNDEV-vpnssh1 $IP link add name $LOCALDEV type veth peer name $REMOTEDEV if [ $? -ne 0 ]; then # Fallback for older iproute2: assume vpnssh0 and vpnssh1; ip doesn't tell us! $IP link add dev $TUNDEV-vpnssh%d type veth fi $IP netns exec $NETNSNAME $0 $@ & CHILDPID=$! # XXX: If we do this too soon (before the unshare), we're just # giving it to our _own_ netns. which achieves nothing. # So give it away until we _can't_ give it away any more. while $IP link set $REMOTEDEV netns $CHILDPID 2>/dev/null; do sleep 0.1 done # Give away the real VPN tun device too $IP link set $TUNDEV netns $CHILDPID $IP link set $LOCALDEV up $IP addr add fec0::2/64 dev $LOCALDEV echo "VPN now accessible through 'ssh fec0::1'" if ! grep -q 127.0.0.1 /etc/resolv.conf; then echo "WARNING: Your host needs to be running a local dnsmasq or named" echo "WARNING: and /etc/resolv.conf needs to point to 127.0.0.1" # XXX: We could probably fix that for ourselves... fi } connect() { if [ -z "$PARENT_NETNS" ]; then connect_parent exit 0 fi # This is the child, which remains running in the background # Wait for the tundev to appear in this namespace while ! ip link show $TUNDEV >/dev/null 2>&1 ; do sleep 0.1 done # Set up Legacy IP in the new namespace $IP link set lo up $IP link set $TUNDEV up if [ -n "$INTERNAL_IP4_ADDRESS" ]; then $IP -4 addr add $INTERNAL_IP4_ADDRESS dev $TUNDEV $IP -4 route add default dev $TUNDEV fi if [ -n "$INTERNAL_IP6_ADDRESS" ]; then $IP -6 addr add $INTERNAL_IP6_ADDRESS dev $TUNDEV $IP -6 route add default dev $TUNDEV fi if [ "$INTERNAL_IP4_MTU" != "" ]; then $IP link set $TUNDEV mtu $INTERNAL_IP4_MTU fi # Set up the veth back to the real system $IP link set $REMOTEDEV up $IP -6 addr add fec0::1/64 dev $REMOTEDEV # Run dnsmasq to provide DNS service for this namespace. # The host needs to be running its own local nameserver/dnsmasq and # /etc/resolv.conf should be pointing to 127.0.0.1 already. DNSMASQ_ARGS="--port=53 -k -R" for NS in $INTERNAL_IP4_DNS; do DNSMASQ_ARGS="$DNSMASQ_ARGS -S $NS" done for NS in $INTERNAL_IP6_DNS; do DNSMASQ_ARGS="$DNSMASQ_ARGS -S $NS" done /usr/sbin/dnsmasq $DNSMASQ_ARGS & DNSMASQ_PID=$! # Set up sshd /usr/sbin/sshd -D & SSHD_PID=$! XINETD_PID= if [ "$XINETDCONF" != "" ] && [ -r "$XINETDCONF" ]; then /usr/sbin/xinetd -dontfork -f $XINETDCONF & XINETD_PID=$! fi # Wait for the veth link to be closed... while ip link show $REMOTEDEV >/dev/null 2>&1 ; do sleep 1 done kill -TERM $DNSMASQ_PID kill -TERM $SSHD_PID if [ "$XINETD_PID" != "" ]; then kill -TERM $XINETD_PID fi # Wait a while to avoid tun BUG() if we quit and the netns goes away # before vpnc/openconnect closes its tun fd. sleep 1 } disconnect() { # Kill our end of the veth link, leaving the child script to clean up $IP link del $TUNDEV-vpnssh0 while ! $IP netns delete $NETNSNAME >/dev/null 2>&1 ; do sleep 0.1 done } case $reason in connect) connect ;; disconnect) disconnect ;; esac 0707010000001F000081A400000000000000000000000163B478CF00002F35000000000000000000000000000000000000003000000000vpnc-scripts-0.1~git20230103/vpnc-script-win.js// vpnc-script-win.js // // Originally part of vpnc source code: // © 2007-2008 Maurice Massar, Jörg Mayer, Antonio Borneo, et al. // © 2014 David Woodhouse <dwmw2@infradead.org> // © 2020-2022 Daniel Lenski <dlenski@gmail.com> et al. // // Routing, IP, and DNS configuration script for OpenConnect. // // Microsoft's "JScript" is what we're actually using here. It's // based on a truly ancient version of JavaScript (ECMAScript 3.0 // according to a Microsoft engineer, see // https://stackoverflow.com/a/28331933) so it doesn't include any // modern features: // - no String.prototype.trim (ECMAScript 5.0) // - no Date.prototype.toISOString (ECMAScript 5.1) // - no 'const' (ECMAScript 6.0) // -------------------------------------------------------------- // Initial setup // -------------------------------------------------------------- var accumulatedExitCode = 0; var ws = WScript.CreateObject("WScript.Shell"); var env = ws.Environment("Process"); var comspec = ws.ExpandEnvironmentStrings("%comspec%"); var ERROR = 0, INFO = 1, DEBUG = 2, TRACE = 3; var logLevel = parseInt(env("LOG_LEVEL")) || INFO; var logTimestamps = false; // How to add the default internal route // 0 - As interface gateway when setting properties // 1 - As a 0.0.0.0/0 route with a lower metric than the default route // 2 - As 0.0.0.0/1 + 128.0.0.0/1 routes (override the default route cleanly) var REDIRECT_GATEWAY_METHOD = 0; // -------------------------------------------------------------- // Utilities // -------------------------------------------------------------- function ocTimestamp(d) { // Matches format of `openconnect --timestamp` ("%Y-%m-%d %H:%M:%S", local time) function pad(number) { if (number < 10) return '0' + number; return number; } return (d.getFullYear() + '-' + pad(d.getMonth() + 1) + '-' + pad(d.getDate()) + ' ' + pad(d.getHours()) + ':' + pad(d.getMinutes()) + ':' + pad(d.getSeconds())); } function echo(level, msg) { if (logLevel < level) return; if (logTimestamps) WScript.echo("[" + ocTimestamp(new Date()) + "] " + msg); else WScript.echo(msg); } function run(cmd) { var fullCmd = comspec + " /C \"" + cmd + "\" 2>&1"; echo(DEBUG, "-> " + fullCmd); var oExec = ws.Exec(fullCmd); oExec.StdIn.Close(); var s = oExec.StdOut.ReadAll(); var exitCode = oExec.ExitCode; if (exitCode != 0) echo(ERROR, "\"" + cmd + "\" returned non-zero exit status: " + exitCode); echo((exitCode != 0 ? ERROR : TRACE), " stdout+stderr dump: " + s); accumulatedExitCode += exitCode; return s; } function getDefaultGateway() { if (run("route print").match(/0\.0\.0\.0 *(0|128)\.0\.0\.0 *([0-9\.]*)/)) { return (RegExp.$2); } return (""); } if (!String.prototype.trim) { String.prototype.trim = function () { return this.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, ''); }; } // -------------------------------------------------------------- // Script starts here // -------------------------------------------------------------- switch (env("reason")) { case "pre-init": break; case "connect": if (env("CISCO_BANNER")) { echo(INFO, "--------------------------------------------------"); echo(INFO, env("CISCO_BANNER")); echo(INFO, "--------------------------------------------------"); } var gw = getDefaultGateway(); // Use INTERNAL_IP4_ADDRESS as the "gateway" address for the // VPN tunnel connection. As noted in the OpenConnect source, // "It's a tunnel; having a gateway is meaningless." Setting // the gateway to match the INTERNAL_IP4_ADDRESS seems like // the simplest way to behave correctly in all cases, // including when the INTERNAL_IP4_NETMASK is /0 or /32. var internal_ip4_netmask = env("INTERNAL_IP4_NETMASK") || "255.255.255.255"; var internal_gw = env("INTERNAL_IP4_ADDRESS"); echo(INFO, "Default/Internet gateway : " + gw); echo(INFO, "VPN Interface Identifiers : \"" + env("TUNDEV") + "\" / " + env("TUNIDX")); echo(INFO, "Public VPN Gateway Address: " + env("VPNGATEWAY")); echo(INFO, "Internal Legacy IP Address: " + env("INTERNAL_IP4_ADDRESS")); echo(INFO, "Internal Legacy IP Netmask: " + internal_ip4_netmask); if (env("INTERNAL_IP4_MTU")) { echo(INFO, "MTU: " + env("INTERNAL_IP4_MTU")); run("netsh interface ipv4 set subinterface " + env("TUNIDX") + " mtu=" + env("INTERNAL_IP4_MTU") + " store=active"); if (env("INTERNAL_IP6_ADDRESS")) { run("netsh interface ipv6 set subinterface " + env("TUNIDX") + " mtu=" + env("INTERNAL_IP4_MTU") + " store=active"); } } // Add explicit route for the VPN gateway to avoid routing loops // FIXME: handle IPv6 gateway address echo(INFO, "Configuring explicit route to VPN gateway " + env("VPNGATEWAY")); run("route add " + env("VPNGATEWAY") + " mask 255.255.255.255 " + gw); echo(INFO, "done."); echo(INFO, "Configuring \"" + env("TUNDEV") + "\" / " + env("TUNIDX") + " interface for Legacy IP..."); if (!env("CISCO_SPLIT_INC") && REDIRECT_GATEWAY_METHOD != 2) { // Interface metric must be set to 1 in order to add a route with metric 1 since Windows Vista run("netsh interface ip set interface " + env("TUNIDX") + " metric=1 store=active"); } if (env("CISCO_SPLIT_INC") || REDIRECT_GATEWAY_METHOD > 0) { run("netsh interface ip set address " + env("TUNIDX") + " static " + env("INTERNAL_IP4_ADDRESS") + " " + internal_ip4_netmask + " store=active"); } else { // The default route will be added automatically run("netsh interface ip set address " + env("TUNIDX") + " static " + env("INTERNAL_IP4_ADDRESS") + " " + internal_ip4_netmask + " " + internal_gw + " gwmetric=1 store=active"); } run("netsh interface ipv4 delete winsservers " + env("TUNIDX") + " all"); if (env("INTERNAL_IP4_NBNS")) { var wins = env("INTERNAL_IP4_NBNS").split(/ /); for (var i = 0; i < wins.length; i++) { run("netsh interface ipv4 add winsservers " + env("TUNIDX") + " " + wins[i]); } echo(INFO, "Configured " + wins.length + " WINS servers: " + wins.join(" ")); } run("netsh interface ipv4 delete dnsservers " + env("TUNIDX") + " all"); run("netsh interface ipv6 delete dnsservers " + env("TUNIDX") + " all"); if (env("INTERNAL_IP4_DNS")) { var dns = env("INTERNAL_IP4_DNS").split(/ /); for (var i = 0; i < dns.length; i++) { var protocol = dns[i].indexOf(":") !== -1 ? "ipv6" : "ipv4"; // With 'validate=yes' (the default on newer Windows versions), Windows will try to // connect to the DNS server, time out after ~10 seconds, and print a warning, but // nevertheless add the specified server. Adding 'validate=no' is thus NECESSARY. // We know that Windows 7 supports/requires the 'validate=no' flag (see #52). If // someone using an older version of Windows that errors out on the unknown flag // really wants us to support it, we'll need to figure out how to distinguish it. run("netsh interface " + protocol + " add dnsservers " + env("TUNIDX") + " " + dns[i] + " validate=no"); } echo(INFO, "Configured " + dns.length + " DNS servers: " + dns.join(" ")); } echo(INFO, "done."); // Add internal network routes echo(INFO, "Configuring Legacy IP networks:"); if (env("CISCO_SPLIT_INC")) { for (var i = 0 ; i < parseInt(env("CISCO_SPLIT_INC")); i++) { var network = env("CISCO_SPLIT_INC_" + i + "_ADDR"); var netmask = env("CISCO_SPLIT_INC_" + i + "_MASK"); var netmasklen = env("CISCO_SPLIT_INC_" + i + "_MASKLEN"); run("route add " + network + " mask " + netmask + " " + internal_gw + " if " + env("TUNIDX")); echo(INFO, "Configured Legacy IP split-include route: " + network + "/" + netmasklen); } } else if (REDIRECT_GATEWAY_METHOD == 1) { run("route add 0.0.0.0 mask 0.0.0.0 " + internal_gw + " metric 1"); echo(INFO, "Configured Legacy IP default route."); } else if (REDIRECT_GATEWAY_METHOD == 2) { run("route add 0.0.0.0 mask 128.0.0.0 " + internal_gw); run("route add 128.0.0.0 mask 128.0.0.0 " + internal_gw); echo(INFO, "Configured Legacy IP default route pair (0.0.0.0/1, 128.0.0.0/1)"); } // Add excluded routes if (env("CISCO_SPLIT_EXC")) { for (var i = 0 ; i < parseInt(env("CISCO_SPLIT_EXC")); i++) { var network = env("CISCO_SPLIT_EXC_" + i + "_ADDR"); var netmask = env("CISCO_SPLIT_EXC_" + i + "_MASK"); var netmasklen = env("CISCO_SPLIT_EXC_" + i + "_MASKLEN"); run("route add " + network + " mask " + netmask + " " + gw); echo(INFO, "Configured Legacy IP split-exclude route: " + network + "/" + netmasklen); } } echo(INFO, "Legacy IP route configuration done."); if (env("INTERNAL_IP6_ADDRESS")) { echo(INFO, "Configuring \"" + env("TUNDEV") + "\" / " + env("TUNIDX") + " interface for IPv6..."); run("netsh interface ipv6 set address " + env("TUNIDX") + " " + env("INTERNAL_IP6_ADDRESS") + " store=active"); echo(INFO, "done."); // Add internal network routes echo(INFO, "Configuring IPv6 networks:"); if (env("INTERNAL_IP6_NETMASK") && !env("INTERNAL_IP6_NETMASK").match("/128$")) { run("netsh interface ipv6 add route " + env("INTERNAL_IP6_NETMASK") + " " + env("TUNIDX") + " store=active"); } if (env("CISCO_IPV6_SPLIT_INC")) { for (var i = 0 ; i < parseInt(env("CISCO_IPV6_SPLIT_INC")); i++) { var network = env("CISCO_IPV6_SPLIT_INC_" + i + "_ADDR"); var netmasklen = env("CISCO_IPV6_SPLIT_INC_" + i + "_MASKLEN"); run("netsh interface ipv6 add route " + network + "/" + netmasklen + " " + env("TUNIDX") + " store=active") echo(INFO, "Configured IPv6 split-include route: " + network + "/" + netmasklen); } } else { echo(INFO, "Setting default IPv6 route through VPN."); run("netsh interface ipv6 add route 2000::/3 " + env("TUNIDX") + " store=active"); } // FIXME: handle IPv6 split-excludes echo(INFO, "IPv6 route configuration done."); } break; case "disconnect": echo(INFO, "Deconfiguring \"" + env("TUNDEV") + "\" / " + env("TUNIDX") + " interface..."); // Delete explicit route for the VPN gateway // FIXME: handle IPv6 gateway address echo(INFO, "Removing explicit route to VPN gateway " + env("VPNGATEWAY")); run("route delete " + env("VPNGATEWAY") + " mask 255.255.255.255"); // Delete address echo(INFO, "Removing" + (env("INTERNAL_IP6_ADDRESS") ? " IPv6 and" : "") + " Legacy IP addresses"); run("netsh interface ipv4 delete address " + env("TUNIDX") + " " + env("INTERNAL_IP4_ADDRESS") + " gateway=all"); if (env("INTERNAL_IP6_ADDRESS")) { run("netsh interface ipv6 delete address " + env("TUNIDX") + " " + env("INTERNAL_IP6_ADDRESS") + " store=active"); } // Delete Legacy IP split-exclude routes if (env("CISCO_SPLIT_EXC")) { echo(INFO, "Removing Legacy IP split-exclude routes"); for (var i = 0 ; i < parseInt(env("CISCO_SPLIT_EXC")); i++) { var network = env("CISCO_SPLIT_EXC_" + i + "_ADDR"); var netmask = env("CISCO_SPLIT_EXC_" + i + "_MASK"); var netmasklen = env("CISCO_SPLIT_EXC_" + i + "_MASKLEN"); run("route delete " + network + " mask " + netmask ); } } // FIXME: handle IPv6 split-excludes echo(INFO, "done."); } WScript.Quit(accumulatedExitCode); 07070100000020000081A400000000000000000000000163B478CF00000541000000000000000000000000000000000000002F00000000vpnc-scripts-0.1~git20230103/xinetd.netns.conf# # This is the master xinetd configuration file. Settings in the # default section will be inherited by all service configurations # unless explicitly overridden in the service configuration. See # xinetd.conf in the man pages for a more detailed explanation of # these attributes. defaults { # The next two items are intended to be a quick access place to # temporarily enable or disable services. # # enabled = # disabled = # Define general logging characteristics. log_type = SYSLOG daemon info log_on_failure = HOST log_on_success = PID HOST DURATION EXIT # Define access restriction defaults # # no_access = # only_from = # max_load = 0 cps = 50 10 instances = 50 per_source = 10 # Address and networking defaults # # bind = # mdns = yes v6only = no # setup environmental attributes # # passenv = groups = yes umask = 002 # Generally, banners are not used. This sets up their global defaults # # banner = # banner_fail = # banner_success = } service smtp { disable = no port = 25 socket_type = stream protocol = tcp wait = no user = root server = /usr/bin/nc server_args = smtp.company.internal 25 # bind = fec0::1 } service imaps { disable = no port = 993 socket_type = stream protocol = tcp wait = no user = root server = /usr/bin/nc server_args = imap.company.internal 993 # bind = fec0::1 } 07070100000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000B00000000TRAILER!!!285 blocks
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor