mirror of
https://github.com/kaboomserver/buildpack.git
synced 2024-09-28 19:23:01 +00:00
Attempt to include autossh
This commit is contained in:
parent
c5b686d4da
commit
b0f78cf489
10
bin/compile
10
bin/compile
|
@ -2,6 +2,16 @@
|
|||
BIN_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||
BUILD_DIR=$1
|
||||
|
||||
# Build autossh for reliable SSH tunnels
|
||||
|
||||
cd vendor/autossh/
|
||||
./configure
|
||||
make
|
||||
mkdir -p $BUILD_DIR/autossh/bin/
|
||||
mv autossh $BUILD_DIR/autossh/bin/
|
||||
cd ../../
|
||||
|
||||
|
||||
# Build dtach for running scripts in the background
|
||||
|
||||
cd vendor/dtach/
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
# This is the core script that Heroku uses when booting up a dyno
|
||||
|
||||
PATH="$HOME/dtach/bin/:$HOME/java/bin/:$PATH"
|
||||
PATH="$HOME/autossh/bin/:$HOME/dtach/bin/:$HOME/java/bin/:$PATH"
|
||||
|
||||
# Set up SSH for proxy server and schematics repository
|
||||
# Load keys from environmental variables
|
||||
|
|
|
@ -7,7 +7,10 @@
|
|||
set -x
|
||||
|
||||
while true; do
|
||||
ssh -i ~/.ssh/proxy \
|
||||
autossh -M 0 \
|
||||
-o "ServerAliveInterval 30" \
|
||||
-o "ServerAliveCountMax 3" \
|
||||
-i ~/.ssh/proxy \
|
||||
-o StrictHostKeyChecking=no -o ExitOnForwardFailure=yes -o StreamLocalBindUnlink=yes \
|
||||
-c aes128-ctr \
|
||||
-C -S none -N -T -R \
|
||||
|
|
213
vendor/autossh/CHANGES
vendored
Normal file
213
vendor/autossh/CHANGES
vendored
Normal file
|
@ -0,0 +1,213 @@
|
|||
|
||||
Version 1.4g
|
||||
- Make sure to clear alarm handler when interrupted by signal
|
||||
(diagnosed by and patch from Jeff Forys). In retrospect this
|
||||
issue was reported by a number of people.
|
||||
- Note -M as optional in README, to match usage output and man page.
|
||||
(Vladimir Panteleev)
|
||||
- Add -J to SSH option string (Matt Stancliff)
|
||||
- Typo "then"->"than" and add datarootdir to Makefile.in
|
||||
(Stig-??rjan Smelror)
|
||||
- More correct checking that we have a monitor port and remote
|
||||
host. (Vladimir D. Seleznev)
|
||||
|
||||
Version 1.4f
|
||||
- Change behaviour when ssh child exits on signal. Previously
|
||||
if SIGHUP, SIGTERM, or SIGKILL were used, autossh assumed that
|
||||
it also was meant to exit. But it is possible that ssh was
|
||||
killed because it had hung up or was unresponsive for some
|
||||
reason. Restarting it is probably the better course.
|
||||
- Fix order of arguments to kill(). Bug reported by Dapeng Gao.
|
||||
- Ignore SIGPIPE. Issue noted and debugged by Rick van der Zwet.
|
||||
- Note use of ExitOnForwardFailure and ClientAliveInterval in
|
||||
README and man page (Till Maas).
|
||||
- Should accept the default -1 with AUTOSSH_MAXSTART. Reported by
|
||||
Daniel Hahler.
|
||||
- Restart ssh when ssh exits with 2, which it can do if
|
||||
setting up tunnel fails due to race with remote end
|
||||
tearing down. (Daniel Sutcliffe).
|
||||
- Daniel Hahler and Jindrich Makovich both reported that signals
|
||||
will have no effect if before ssh started (sleeping in gatetime,
|
||||
etc.) Signal handling is now set just just before monitoring the
|
||||
child, and unset just after.
|
||||
- Makefile should use LDFLAGS (Waldemar Brodkorb).
|
||||
- memset() sigaction structure before use.
|
||||
|
||||
Version 1.4e
|
||||
- By default, changing the poll time should change the first poll
|
||||
time to match. Only have different times if AUTOSSH_FIRST_POLL
|
||||
is explicitly set. Jerry Xie forwarded on change request from
|
||||
Ubuntu bug forums.
|
||||
|
||||
Version 1.4d
|
||||
|
||||
- call daemon() before opening any sockets. Problem discovered and
|
||||
diagnosed by Frank van der Aa when trying to start autossh at
|
||||
system init.
|
||||
- don't use malloc(n * size) idiom; use calloc()
|
||||
|
||||
Version 1.4c
|
||||
|
||||
- updated option string up to OpenSSH 5.6
|
||||
- when using -f, set gate_time to 0; the assumption is that
|
||||
it is being used for infrastructure (i.e. in a system startup),
|
||||
has been tested, and bombing out just because the remote end is
|
||||
not up is not the desired behaviour.
|
||||
- add patch from Thorsten Glaser for configure, fixes misplaced
|
||||
parenthesis and check for __progname.
|
||||
|
||||
Version 1.4b
|
||||
|
||||
- add AUTOSSH_MAXLIFETIME (patch from Steven Clark)
|
||||
- include configure.ac in package
|
||||
- fix poll flags so not checking for writable when write done (patch
|
||||
from John Grahor)
|
||||
- compile time TOUCH_PIDFILE option to touch pid file on connection test.
|
||||
|
||||
Version 1.4a
|
||||
|
||||
- fix up pid file generation (Xander Hudson)
|
||||
- fix up Makefile.in (Andrew Schulman)
|
||||
|
||||
Version 1.4
|
||||
|
||||
- initialise ep in main() to avoid warning (Marcelo Goes)
|
||||
- fix where cast to int happens when calculating next time to poll
|
||||
connection (Omer Erdem Demir)
|
||||
- fix '--' use so can pass -M to autossh for session multiplexing
|
||||
- fix use of strcpy for overlapping copy in strip_arg (Filippo Giunchedi).
|
||||
- add basic GNU autoconf support and drop per-platform Makefiles (Andre Lucas)
|
||||
- pid file support (Ben Vitale)
|
||||
- arbitrary messages in echo string (Ron Yorston)
|
||||
|
||||
Version 1.3
|
||||
|
||||
- fix AUTOSSH_DEBUG for Solaris and AIX
|
||||
- fix attempt to free() static storage (affected platforms without
|
||||
getaddrinfo() -- mostly cygwin) (Andrew Schulman)
|
||||
- change test and placement of typedef for socklen_t under OS X; new
|
||||
OS X defines it
|
||||
- add ability to signal autossh to kill and restart ssh child, using
|
||||
SIGUSR1
|
||||
- add hostname to monitor message (Ron Yorston)
|
||||
- check on looping on poll() where connection has been lost (spinning
|
||||
and high CPU)
|
||||
- fix bug where length argument to accept() was not initialised
|
||||
- fix arg parsing bug where stripping -f from arguments would strip
|
||||
from a parameter to the argument: e.g -L8808:foo:80 would become
|
||||
-L8808:oo:80 (pointed out by Eric Larson)
|
||||
- pull out r/w loops in conn_test() into separate functions, makes
|
||||
logic more apparent
|
||||
- add echo port support: have the remote server use the inetd
|
||||
echo service to echo our test string back to us. Or use some other
|
||||
echo service. Idea and patch from Ron Yorston. This makes it 1.3.
|
||||
- remove bad strcpy() (left over from some testing?) thanks to Ron
|
||||
Yorston, change to memset read buffer to all zeros
|
||||
- fix ssh args when AUTOSSH_PORT=0 is used to turn monitor loop off
|
||||
(Karl Berry)
|
||||
- add more descriptive usage output, by popular request
|
||||
|
||||
Version 1.2g
|
||||
|
||||
- add AUTOSSH_NTSERVICE (Andrew Schulman)
|
||||
- fix bad calculation for seconds left in poll time (again from
|
||||
Andrew Schulman)
|
||||
- from Andrew Schulman: add support for older networking and cygwin
|
||||
- add AUTOSSH_MAXSTART (from Hugo Haas)
|
||||
- loop around waitpid() in ssh_kill() in case interrupted (thanks to
|
||||
Jens Krabbenhoeft)
|
||||
- update ssh argument string
|
||||
- move openlog above port error checking
|
||||
- handle environment variables and -M arg being set to the
|
||||
empty string (reported by Dan Christensen via Filippo Giunche)
|
||||
- add some rudimetary auto-adjust to the network timeouts for
|
||||
low poll times. So by default 15secs on each of accept() and
|
||||
poll()to deal with high-latency connections, but as poll time
|
||||
falls below 30secs, then adjust timeouts down as well.
|
||||
- adjust division in grace_time() to allow for low poll time
|
||||
- don't call shutdown() and close() on invalid socket ()
|
||||
(found by Dmitry V. Levin)
|
||||
|
||||
Version 1.2f
|
||||
|
||||
- by popular request, support the -f flag by doing the fork/background
|
||||
ourselves, and not passing the flag to ssh (thanks to Dan Christensen
|
||||
for prodding me into it)
|
||||
- change timeout to from 5000 to 15000 ms to deal with reported issues
|
||||
with high-latency links; unused var removal; and man page typo (thanks
|
||||
to Michael Shields)
|
||||
|
||||
Version 1.2e
|
||||
|
||||
- check for attempt to use -f flag; exit as error
|
||||
- if AUTOSSH_GATETIME is 0, then disable any of the startup
|
||||
failure bailouts, and just retry
|
||||
- set SO_REUSEADDR on listening socket (Jedi One's suggestion)
|
||||
- show port number in some error messages
|
||||
- note in man page and README about -M 0 turning port monitoring off
|
||||
- remove duplicate include of sys/socket.h
|
||||
|
||||
Version 1.2d
|
||||
|
||||
- AIX support (thanks to Stefan Rodenstein)
|
||||
- fix argument rewrite bug when using AUTOSSH_PORT (thanks
|
||||
to Peter Williams)
|
||||
- log pid of ssh child just after fork
|
||||
|
||||
Version 1.2c
|
||||
|
||||
- use Marcus Friedl's suggestion to simply connect to "127.0.0.1"
|
||||
rather than "localhost", as not really using IPv6 anyway. And this
|
||||
gets rid of annoying ipv6 localhost message on Solaris at least.
|
||||
- support for MacOS X using Greg Parker's fakepoll.
|
||||
|
||||
Version 1.2b
|
||||
|
||||
(Thanks to Simon Easter for bug reports and trials)
|
||||
|
||||
- fix file descriptor leak
|
||||
- setsockopt()'s don't work for Solaris either. Give up on them.
|
||||
- set close-on-exec for read socket so will be closed when
|
||||
ssh executed
|
||||
- do shutdown() before close() (paranoia)
|
||||
- close read socket before exit
|
||||
- pull read socket open and close up out of ssh_run()
|
||||
- cosmetic changes to some loops, get rid of newlines in some
|
||||
errlog strings.
|
||||
|
||||
Version 1.2a
|
||||
|
||||
- setsockopt() will not set timeouts on socket read/write ops
|
||||
under Linux 2.2 kernels (and earlier, I presume). So unless
|
||||
someone tells me we really need them, I've #ifdef'd the
|
||||
setsockopt()s out for Linux.
|
||||
- check value of fd returned by accept().
|
||||
- Oh, there's a man page now. Unfortunately, it doesn't render
|
||||
for Solaris. Sorry, Solaris users are still stuck with the
|
||||
README.
|
||||
|
||||
Version 1.2
|
||||
|
||||
- Major restructuring of code, mostly to support the change to
|
||||
a loop of forwarded ports to test the network connection.
|
||||
- Incremental back off on rate of connection attempts when
|
||||
there are rapid failures to establish/maintain a connection.
|
||||
|
||||
Version 1.1b
|
||||
|
||||
- change handling of ssh exit status
|
||||
- introduce "starting gate" time: ssh process that dies too
|
||||
early is deemed not to have made it out of the starting
|
||||
gate, and autossh exits.
|
||||
|
||||
Version 1.1a
|
||||
|
||||
- fix race after failure to exec ssh where parent will
|
||||
loop attempting to restart
|
||||
- add -V version flag
|
||||
- use strtoul() for environment option parsing
|
||||
- drop useless intermediate function ssh_setwatch()
|
||||
|
||||
Version 1.1
|
||||
|
||||
Initial release
|
229
vendor/autossh/INSTALL
vendored
Normal file
229
vendor/autossh/INSTALL
vendored
Normal file
|
@ -0,0 +1,229 @@
|
|||
Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002 Free Software
|
||||
Foundation, Inc.
|
||||
|
||||
This file is free documentation; the Free Software Foundation gives
|
||||
unlimited permission to copy, distribute and modify it.
|
||||
|
||||
Basic Installation
|
||||
==================
|
||||
|
||||
These are generic installation instructions.
|
||||
|
||||
The `configure' shell script attempts to guess correct values for
|
||||
various system-dependent variables used during compilation. It uses
|
||||
those values to create a `Makefile' in each directory of the package.
|
||||
It may also create one or more `.h' files containing system-dependent
|
||||
definitions. Finally, it creates a shell script `config.status' that
|
||||
you can run in the future to recreate the current configuration, and a
|
||||
file `config.log' containing compiler output (useful mainly for
|
||||
debugging `configure').
|
||||
|
||||
It can also use an optional file (typically called `config.cache'
|
||||
and enabled with `--cache-file=config.cache' or simply `-C') that saves
|
||||
the results of its tests to speed up reconfiguring. (Caching is
|
||||
disabled by default to prevent problems with accidental use of stale
|
||||
cache files.)
|
||||
|
||||
If you need to do unusual things to compile the package, please try
|
||||
to figure out how `configure' could check whether to do them, and mail
|
||||
diffs or instructions to the address given in the `README' so they can
|
||||
be considered for the next release. If you are using the cache, and at
|
||||
some point `config.cache' contains results you don't want to keep, you
|
||||
may remove or edit it.
|
||||
|
||||
The file `configure.ac' (or `configure.in') is used to create
|
||||
`configure' by a program called `autoconf'. You only need
|
||||
`configure.ac' if you want to change it or regenerate `configure' using
|
||||
a newer version of `autoconf'.
|
||||
|
||||
The simplest way to compile this package is:
|
||||
|
||||
1. `cd' to the directory containing the package's source code and type
|
||||
`./configure' to configure the package for your system. If you're
|
||||
using `csh' on an old version of System V, you might need to type
|
||||
`sh ./configure' instead to prevent `csh' from trying to execute
|
||||
`configure' itself.
|
||||
|
||||
Running `configure' takes awhile. While running, it prints some
|
||||
messages telling which features it is checking for.
|
||||
|
||||
2. Type `make' to compile the package.
|
||||
|
||||
3. Optionally, type `make check' to run any self-tests that come with
|
||||
the package.
|
||||
|
||||
4. Type `make install' to install the programs and any data files and
|
||||
documentation.
|
||||
|
||||
5. You can remove the program binaries and object files from the
|
||||
source code directory by typing `make clean'. To also remove the
|
||||
files that `configure' created (so you can compile the package for
|
||||
a different kind of computer), type `make distclean'. There is
|
||||
also a `make maintainer-clean' target, but that is intended mainly
|
||||
for the package's developers. If you use it, you may have to get
|
||||
all sorts of other programs in order to regenerate files that came
|
||||
with the distribution.
|
||||
|
||||
Compilers and Options
|
||||
=====================
|
||||
|
||||
Some systems require unusual options for compilation or linking that
|
||||
the `configure' script does not know about. Run `./configure --help'
|
||||
for details on some of the pertinent environment variables.
|
||||
|
||||
You can give `configure' initial values for configuration parameters
|
||||
by setting variables in the command line or in the environment. Here
|
||||
is an example:
|
||||
|
||||
./configure CC=c89 CFLAGS=-O2 LIBS=-lposix
|
||||
|
||||
*Note Defining Variables::, for more details.
|
||||
|
||||
Compiling For Multiple Architectures
|
||||
====================================
|
||||
|
||||
You can compile the package for more than one kind of computer at the
|
||||
same time, by placing the object files for each architecture in their
|
||||
own directory. To do this, you must use a version of `make' that
|
||||
supports the `VPATH' variable, such as GNU `make'. `cd' to the
|
||||
directory where you want the object files and executables to go and run
|
||||
the `configure' script. `configure' automatically checks for the
|
||||
source code in the directory that `configure' is in and in `..'.
|
||||
|
||||
If you have to use a `make' that does not support the `VPATH'
|
||||
variable, you have to compile the package for one architecture at a
|
||||
time in the source code directory. After you have installed the
|
||||
package for one architecture, use `make distclean' before reconfiguring
|
||||
for another architecture.
|
||||
|
||||
Installation Names
|
||||
==================
|
||||
|
||||
By default, `make install' will install the package's files in
|
||||
`/usr/local/bin', `/usr/local/man', etc. You can specify an
|
||||
installation prefix other than `/usr/local' by giving `configure' the
|
||||
option `--prefix=PATH'.
|
||||
|
||||
You can specify separate installation prefixes for
|
||||
architecture-specific files and architecture-independent files. If you
|
||||
give `configure' the option `--exec-prefix=PATH', the package will use
|
||||
PATH as the prefix for installing programs and libraries.
|
||||
Documentation and other data files will still use the regular prefix.
|
||||
|
||||
In addition, if you use an unusual directory layout you can give
|
||||
options like `--bindir=PATH' to specify different values for particular
|
||||
kinds of files. Run `configure --help' for a list of the directories
|
||||
you can set and what kinds of files go in them.
|
||||
|
||||
If the package supports it, you can cause programs to be installed
|
||||
with an extra prefix or suffix on their names by giving `configure' the
|
||||
option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
|
||||
|
||||
Optional Features
|
||||
=================
|
||||
|
||||
Some packages pay attention to `--enable-FEATURE' options to
|
||||
`configure', where FEATURE indicates an optional part of the package.
|
||||
They may also pay attention to `--with-PACKAGE' options, where PACKAGE
|
||||
is something like `gnu-as' or `x' (for the X Window System). The
|
||||
`README' should mention any `--enable-' and `--with-' options that the
|
||||
package recognizes.
|
||||
|
||||
For packages that use the X Window System, `configure' can usually
|
||||
find the X include and library files automatically, but if it doesn't,
|
||||
you can use the `configure' options `--x-includes=DIR' and
|
||||
`--x-libraries=DIR' to specify their locations.
|
||||
|
||||
Specifying the System Type
|
||||
==========================
|
||||
|
||||
There may be some features `configure' cannot figure out
|
||||
automatically, but needs to determine by the type of machine the package
|
||||
will run on. Usually, assuming the package is built to be run on the
|
||||
_same_ architectures, `configure' can figure that out, but if it prints
|
||||
a message saying it cannot guess the machine type, give it the
|
||||
`--build=TYPE' option. TYPE can either be a short name for the system
|
||||
type, such as `sun4', or a canonical name which has the form:
|
||||
|
||||
CPU-COMPANY-SYSTEM
|
||||
|
||||
where SYSTEM can have one of these forms:
|
||||
|
||||
OS KERNEL-OS
|
||||
|
||||
See the file `config.sub' for the possible values of each field. If
|
||||
`config.sub' isn't included in this package, then this package doesn't
|
||||
need to know the machine type.
|
||||
|
||||
If you are _building_ compiler tools for cross-compiling, you should
|
||||
use the `--target=TYPE' option to select the type of system they will
|
||||
produce code for.
|
||||
|
||||
If you want to _use_ a cross compiler, that generates code for a
|
||||
platform different from the build platform, you should specify the
|
||||
"host" platform (i.e., that on which the generated programs will
|
||||
eventually be run) with `--host=TYPE'.
|
||||
|
||||
Sharing Defaults
|
||||
================
|
||||
|
||||
If you want to set default values for `configure' scripts to share,
|
||||
you can create a site shell script called `config.site' that gives
|
||||
default values for variables like `CC', `cache_file', and `prefix'.
|
||||
`configure' looks for `PREFIX/share/config.site' if it exists, then
|
||||
`PREFIX/etc/config.site' if it exists. Or, you can set the
|
||||
`CONFIG_SITE' environment variable to the location of the site script.
|
||||
A warning: not all `configure' scripts look for a site script.
|
||||
|
||||
Defining Variables
|
||||
==================
|
||||
|
||||
Variables not defined in a site shell script can be set in the
|
||||
environment passed to `configure'. However, some packages may run
|
||||
configure again during the build, and the customized values of these
|
||||
variables may be lost. In order to avoid this problem, you should set
|
||||
them in the `configure' command line, using `VAR=value'. For example:
|
||||
|
||||
./configure CC=/usr/local2/bin/gcc
|
||||
|
||||
will cause the specified gcc to be used as the C compiler (unless it is
|
||||
overridden in the site shell script).
|
||||
|
||||
`configure' Invocation
|
||||
======================
|
||||
|
||||
`configure' recognizes the following options to control how it
|
||||
operates.
|
||||
|
||||
`--help'
|
||||
`-h'
|
||||
Print a summary of the options to `configure', and exit.
|
||||
|
||||
`--version'
|
||||
`-V'
|
||||
Print the version of Autoconf used to generate the `configure'
|
||||
script, and exit.
|
||||
|
||||
`--cache-file=FILE'
|
||||
Enable the cache: use and save the results of the tests in FILE,
|
||||
traditionally `config.cache'. FILE defaults to `/dev/null' to
|
||||
disable caching.
|
||||
|
||||
`--config-cache'
|
||||
`-C'
|
||||
Alias for `--cache-file=config.cache'.
|
||||
|
||||
`--quiet'
|
||||
`--silent'
|
||||
`-q'
|
||||
Do not print messages saying which checks are being made. To
|
||||
suppress all normal output, redirect it to `/dev/null' (any error
|
||||
messages will still be shown).
|
||||
|
||||
`--srcdir=DIR'
|
||||
Look for the package's source code in directory DIR. Usually
|
||||
`configure' can determine that directory automatically.
|
||||
|
||||
`configure' also accepts some other, not widely useful, options. Run
|
||||
`configure --help' for more details.
|
||||
|
63
vendor/autossh/Makefile.in
vendored
Normal file
63
vendor/autossh/Makefile.in
vendored
Normal file
|
@ -0,0 +1,63 @@
|
|||
# $Id: Makefile.in,v 1.9 2019/01/05 01:24:52 harding Exp $
|
||||
#
|
||||
# @configure_input@
|
||||
|
||||
VER= 1.4g
|
||||
|
||||
SSH= @path_ssh@
|
||||
|
||||
prefix= @prefix@
|
||||
exec_prefix= @exec_prefix@
|
||||
bindir= @bindir@
|
||||
datadir= @datadir@
|
||||
datarootdir= @datarootdir@
|
||||
mandir= @mandir@
|
||||
|
||||
SRCDIR= @srcdir@
|
||||
VPATH= @srcdir@
|
||||
|
||||
CC= @CC@
|
||||
CFLAGS= @CFLAGS@ -DVER=\"$(VER)\" -DSSH_PATH=\"$(SSH)\"
|
||||
CPPFLAGS= @CPPFLAGS@
|
||||
|
||||
OFILES= autossh.o
|
||||
|
||||
LD= @LD@
|
||||
LDFLAGS= @LDFLAGS@
|
||||
LIBS= @LIBS@
|
||||
|
||||
TARGET= autossh
|
||||
|
||||
all: $(TARGET)
|
||||
|
||||
|
||||
$(TARGET): $(OFILES)
|
||||
$(CC) $(CPPFLAGS) $(LDFLAGS) -o $(TARGET) $(OFILES) $(LIBS)
|
||||
|
||||
clean:
|
||||
- /bin/rm -f *.o *.a *.core *~
|
||||
|
||||
allclean: clean
|
||||
- /bin/rm -f $(TARGET)
|
||||
|
||||
distclean: allclean
|
||||
- /bin/rm -f config.log config.cache config.status config.h
|
||||
- /bin/rm -rf autom4te.cache
|
||||
- /bin/rm -f Makefile
|
||||
|
||||
install: $(TARGET)
|
||||
mkdir -p -m 755 $(DESTDIR)$(bindir)
|
||||
mkdir -p -m 755 $(DESTDIR)$(prefix)/share/doc/autossh
|
||||
mkdir -p -m 755 $(DESTDIR)$(datadir)/examples/autossh
|
||||
mkdir -p -m 755 $(DESTDIR)$(mandir)/man1
|
||||
cp $(TARGET) $(DESTDIR)$(bindir)
|
||||
cp CHANGES README $(DESTDIR)$(datadir)/doc/autossh
|
||||
cp autossh.host $(DESTDIR)$(datadir)/examples/autossh
|
||||
cp rscreen $(DESTDIR)$(datadir)/examples/autossh
|
||||
cp autossh.1 $(DESTDIR)$(mandir)/man1
|
||||
chmod 755 $(DESTDIR)$(bindir)/$(TARGET)
|
||||
chmod 644 $(DESTDIR)$(datadir)/doc/autossh/CHANGES
|
||||
chmod 644 $(DESTDIR)$(datadir)/doc/autossh/README
|
||||
chmod 644 $(DESTDIR)$(datadir)/examples/autossh/autossh.host
|
||||
chmod 644 $(DESTDIR)$(datadir)/examples/autossh/rscreen
|
||||
chmod 644 $(DESTDIR)$(mandir)/man1/autossh.1
|
230
vendor/autossh/README
vendored
Normal file
230
vendor/autossh/README
vendored
Normal file
|
@ -0,0 +1,230 @@
|
|||
|
||||
autossh Version 1.4
|
||||
-------------------
|
||||
|
||||
Building and Installing Autossh
|
||||
--------------------------------
|
||||
|
||||
With version 1.4, autossh now uses autoconf. So the build procedure
|
||||
is now the well-known:
|
||||
|
||||
./configure
|
||||
make
|
||||
make install
|
||||
|
||||
Look at autossh.host for an example wrapper script.
|
||||
|
||||
|
||||
Usage
|
||||
-----
|
||||
autossh [-M <port>[:echo_port]] [-f] [SSH OPTIONS]
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
||||
autossh is a program to start a copy of ssh and monitor it, restarting
|
||||
it as necessary should it die or stop passing traffic.
|
||||
|
||||
The original idea and the mechanism were from rstunnel (Reliable SSH
|
||||
Tunnel). With version 1.2 the method changed: autossh now uses ssh to
|
||||
construct a loop of ssh forwardings (one from local to remote, one
|
||||
from remote to local), and then sends test data that it expects to get
|
||||
back. (The idea is thanks to Terrence Martin.)
|
||||
|
||||
With version 1.3, a new method is added (thanks to Ron Yorston): a
|
||||
port may be specified for a remote echo service that will echo back
|
||||
the test data. This avoids the congestion and the aggravation of
|
||||
making sure all the port numbers on the remote machine do not
|
||||
collide. The loop-of -forwardings method remains available for
|
||||
situations where using an echo service may not be possible.
|
||||
|
||||
autossh has only three arguments of its own:
|
||||
|
||||
-M <port>[:echo_port], to specify the base monitoring port to use, or
|
||||
alternatively, to specify the monitoring port and echo service
|
||||
port to use.
|
||||
|
||||
When no echo service port is specified, this port and the port
|
||||
immediately above it (port# + 1) should be something nothing
|
||||
else is using. autossh will send test data on the base monitoring
|
||||
port, and receive it back on the port above. For example, if you
|
||||
specify "-M 20000", autossh will set up forwards so that it can
|
||||
send data on port 20000 and receive it back on 20001.
|
||||
|
||||
Alternatively a port for a remote echo service may be
|
||||
specified. This should be port 7 if you wish to use the
|
||||
standard inetd echo service. When an echo port is specified,
|
||||
only the specified monitor port is used, and it carries the
|
||||
monitor message in both directions.
|
||||
|
||||
Many people disable the echo service, or even disable inetd,
|
||||
so check that this service is available on the remote
|
||||
machine. Some operating systems allow one to specify that the
|
||||
service only listen on the localhost (loopback interface),
|
||||
which would suffice for this use.
|
||||
|
||||
The echo service may also be something more complicated:
|
||||
perhaps a daemon that monitors a group of ssh tunnels.
|
||||
|
||||
-M 0 will turn the monitoring off, and autossh will only
|
||||
restart ssh on ssh exit.
|
||||
|
||||
For example, if you are using a recent version of OpenSSH, you
|
||||
may wish to explore using the ServerAliveInterval and
|
||||
ServerAliveCountMax options to have the SSH client exit if it
|
||||
finds itself no longer connected to the server. In many ways
|
||||
this may be a better solution than the monitoring port.
|
||||
|
||||
-f Causes autossh to drop to the background before running ssh. The
|
||||
-f flag is stripped from arguments passed to ssh. Note that there
|
||||
is a crucial difference between the -f with autossh, and -f
|
||||
with ssh: when used with autossh, ssh will be *unable* to ask for
|
||||
passwords or passphrases. When -f is used, the "starting gate"
|
||||
time (see AUTOSSH_GATETIME) will be set to 0.
|
||||
|
||||
-V to have autossh display its version and exit.
|
||||
|
||||
All other arguments are passed to ssh. There are a number of
|
||||
other settings, but these are all controlled through environment
|
||||
variables. ssh seems to be appropriating more and more letters for
|
||||
options, and this seems the easiest way to avoid collisions.
|
||||
|
||||
autossh tries to distinguish the manner of death of the ssh process it
|
||||
is monitoring and act appropriately. The rules are:
|
||||
|
||||
- If the ssh process exited normally (for example, someone typed
|
||||
"exit" in an interactive session), autossh exits rather than
|
||||
restarting;
|
||||
- If autossh itself receives a SIGTERM, SIGINT, or a SIGKILL
|
||||
signal, it assumes that it was deliberately signalled, and exits
|
||||
after killing the child ssh process;
|
||||
- If autossh itself receives a SIGUSR1 signal, it will kill the child
|
||||
ssh process and start a new one;
|
||||
- Periodically (by default every 10 minutes), autossh attempts to pass
|
||||
traffic on the monitor forwarded port. If this fails, autossh will
|
||||
kill the child ssh process (if it is still running) and start a new
|
||||
one;
|
||||
- If the child ssh process dies for any other reason, autossh will
|
||||
attempt to start a new one.
|
||||
|
||||
Startup behaviour:
|
||||
|
||||
- If the ssh session fails with an exit status of 1 on the very first
|
||||
try, autossh will assume that there is some problem with syntax or
|
||||
the connection setup, and will exit rather than retrying;
|
||||
- There is now a "starting gate" time. If the first ssh process fails
|
||||
within the first few seconds of being started, autossh assumes that
|
||||
it never made it "out of the starting gate", and exits. This is to handle
|
||||
initial failed authentication, connection, etc. This time is 30 seconds
|
||||
by default, and can be adjusted (see the AUTOSSH_GATETIME environment
|
||||
variable below).
|
||||
- NOTE: If AUTOSSH_GATETIME is set to 0, then BOTH of the above
|
||||
behaviours are disabled. This is useful for, for example,
|
||||
having autossh start on boot. The "starting gate" time is
|
||||
also set to 0 with the -f flag to autossh is used.
|
||||
|
||||
Continued failures:
|
||||
|
||||
- If the ssh connection fails and attempts to restart it fail in
|
||||
quick succession, autossh will start delaying its attempts to
|
||||
restart, gradually backing farther and farther off up to a
|
||||
maximum interval of the autossh poll time (usually 10 minutes).
|
||||
autossh can be "prodded" to retry by signalling it, perhaps with
|
||||
SIGHUP ("kill -HUP").
|
||||
|
||||
Connection Setup
|
||||
----------------
|
||||
|
||||
As connections must be established unattended, the use of autossh
|
||||
requires that some form of automatic authentication be set up. The use
|
||||
of RSAAuthentication with ssh-agent is the recommended method. The
|
||||
example wrapper script attempts to check if there is an agent running
|
||||
for the current environment, and to start one if there isn't.
|
||||
|
||||
It cannot be stressed enough that you must make sure ssh works on its
|
||||
own, that you can set up the session you want before you try to
|
||||
run it under autossh.
|
||||
|
||||
If you are tunnelling and using an older version of ssh that does not
|
||||
support the -N flag, you should upgrade (your version has security
|
||||
flaws). If you can't upgrade, you may wish to do as rstunnel does, and
|
||||
give ssh a command to run, such as "sleep 99999999999".
|
||||
|
||||
Disabling connection monitoring
|
||||
-------------------------------
|
||||
|
||||
A monitor port value of "0" ("autossh -M 0") will disable use of
|
||||
the monitor ports; autossh will then only react to signals and the
|
||||
death of the ssh process.
|
||||
|
||||
Environment Variables
|
||||
---------------------
|
||||
|
||||
The following environment variables can be set:
|
||||
|
||||
AUTOSSH_DEBUG - sets logging level to LOG_DEBUG, and if
|
||||
the operating system supports it, sets
|
||||
syslog to duplicate log entries to stderr.
|
||||
AUTOSSH_FIRST_POLL - time to initial poll (default is as
|
||||
AUTOSSH_POLL below).
|
||||
AUTOSSH_GATETIME - how long ssh must be up before we consider
|
||||
it a successful connection. Default is 30
|
||||
seconds. If set to 0, then this behaviour
|
||||
is disabled, and as well, autossh will retry
|
||||
even on failure of first attempt to run ssh.
|
||||
AUTOSSH_LOGFILE - sets autossh to use the named log file,
|
||||
rather than syslog.
|
||||
AUTOSSH_LOGLEVEL - log level, they correspond to the levels
|
||||
used by syslog; so 0-7 with 7 being the
|
||||
chattiest.
|
||||
AUTOSSH_MAXLIFETIME - Sets the maximum number of seconds the process
|
||||
should live for before killing off the ssh child
|
||||
and exiting.
|
||||
AUTOSSH_MAXSTART - specifies how many times ssh should be started.
|
||||
A negative number means no limit on the number
|
||||
of times ssh is started. The default value is -1.
|
||||
AUTOSSH_MESSAGE - append a custom message to the echo string (max 64
|
||||
bytes).
|
||||
AUTOSSH_NTSERVICE - when set to "yes" , setup autossh to run as an
|
||||
NT service under cygrunsrv. This adds the -N flag
|
||||
for ssh if not already set, sets the log output
|
||||
to stdout, and changes the behaviour on ssh exit
|
||||
so that it will restart even on a normal exit.
|
||||
AUTOSSH_PATH - path to the ssh executable, in case
|
||||
it is different than that compiled in.
|
||||
AUTOSSH_PIDFILE - write autossh pid to specified file.
|
||||
AUTOSSH_POLL - poll time in seconds; default is 600.
|
||||
Changing this will also change the first
|
||||
poll time, unless AUTOSSH_FIRST_POLL is
|
||||
used to set it to something different.
|
||||
If the poll time is less than twice the
|
||||
network timeouts (default 15 seconds) the
|
||||
network timeouts will be adjusted downward
|
||||
to 1/2 the poll time.
|
||||
AUTOSSH_PORT - set monitor port. Mostly in case ssh
|
||||
appropriates -M at some time. But because
|
||||
of this possible use, AUTOSSH_PORT overrides
|
||||
the -M flag.
|
||||
|
||||
SSH Options
|
||||
------------------
|
||||
|
||||
There are two particular OpenSSH options that are useful when using
|
||||
autossh:
|
||||
|
||||
1) ExitOnForwardFailure=yes on the client side to make sure forwardings
|
||||
have succeeded when autossh assumes the connection is setup properly.
|
||||
|
||||
2) ClientAliveInterval on the server side to make sure the listening
|
||||
socket is closed on the server side if the connection closes on the
|
||||
client side.
|
||||
|
||||
Logging and Syslog
|
||||
------------------
|
||||
|
||||
autossh logs to syslog using the LOG_USER facility. Your syslog may
|
||||
have to be configured to accept messages for this facility. This is
|
||||
usually done in /etc/syslog.conf.
|
||||
|
||||
--
|
||||
Kudos and raspberries to harding [at] motd.ca
|
292
vendor/autossh/autossh.1
vendored
Normal file
292
vendor/autossh/autossh.1
vendored
Normal file
|
@ -0,0 +1,292 @@
|
|||
.\" -*- nroff -*-
|
||||
.\"
|
||||
.\" Author: Carson Harding
|
||||
.\" Copyright (c) 2002-2018 Carson Harding. All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Id: autossh.1,v 1.24 2018/03/18 19:28:38 harding Exp $
|
||||
.\"
|
||||
.Dd Mar 18, 2018
|
||||
.Dt AUTOSSH 1
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm autossh
|
||||
.Nd monitor and restart ssh sessions
|
||||
.Sh SYNOPSIS
|
||||
.Nm autossh
|
||||
.Op Fl V
|
||||
.Op Fl M Ar port[:echo_port]
|
||||
.Op Fl f
|
||||
.Ar [SSH_OPTIONS]
|
||||
.Sh DESCRIPTION
|
||||
.Nm
|
||||
is a program to start a copy of ssh and monitor it, restarting it as
|
||||
necessary should it die or stop passing traffic.
|
||||
.Pp
|
||||
The original idea and the mechanism were from rstunnel (Reliable SSH
|
||||
Tunnel). With version 1.2 of
|
||||
.Nm
|
||||
the method changed:
|
||||
.Nm
|
||||
uses ssh to construct a loop of ssh forwardings (one from local to
|
||||
remote, one from remote to local), and then sends test data that it
|
||||
expects to get back. (The idea is thanks to Terrence Martin.)
|
||||
.Pp
|
||||
With version 1.3, a new method is added (thanks to Ron Yorston): a
|
||||
port may be specified for a remote echo service that will echo back
|
||||
the test data. This avoids the congestion and the aggravation of
|
||||
making sure all the port numbers on the remote machine do not
|
||||
collide. The loop-of-forwardings method remains available for
|
||||
situations where using an echo service may not be possible.
|
||||
.Pp
|
||||
.Sh CONTROLLING SSH
|
||||
.Pp
|
||||
.Ss SSH exits
|
||||
.Pp
|
||||
.Bl -tag -width Ds
|
||||
.Nm
|
||||
tries to distinguish the manner of death of the ssh process it
|
||||
is monitoring and act appropriately. The rules are:
|
||||
.Bl -tag -width Ds
|
||||
.It 1.
|
||||
If the ssh process exited normally (for example, someone typed
|
||||
"exit" in an interactive session),
|
||||
.Nm
|
||||
exits rather than restarting;
|
||||
.It 2.
|
||||
If
|
||||
.Nm
|
||||
itself receives a SIGTERM, SIGINT, or a SIGKILL signal, it assumes
|
||||
that it was deliberately signalled, and exits after killing the child
|
||||
ssh process;
|
||||
.It 3.
|
||||
If
|
||||
.Nm
|
||||
itself receives a SIGUSR1 signal, it kills the child ssh process and starts
|
||||
a new one;
|
||||
.It 4.
|
||||
Periodically (by default every 10 minutes),
|
||||
.Nm
|
||||
attempts to pass traffic on the monitor forwarded port. If this fails,
|
||||
.Nm
|
||||
will kill the child ssh process (if it is still running) and start a new one;
|
||||
.It 5.
|
||||
If the child ssh process dies for any other reason,
|
||||
.Nm
|
||||
will attempt to start a new one.
|
||||
.El
|
||||
.Pp
|
||||
.Ss Startup behaviour
|
||||
.Pp
|
||||
If the ssh session fails with an exit status of 1 on the very first
|
||||
try,
|
||||
.Nm
|
||||
.Bl -tag -width Ds
|
||||
.It 1.
|
||||
will assume that there is some problem with syntax or the connection
|
||||
setup, and will exit rather than retrying;
|
||||
.It 2.
|
||||
There is a "starting gate" time. If the first ssh process fails within
|
||||
the first few seconds of being started,
|
||||
.Nm
|
||||
assumes that
|
||||
it never made it "out of the starting gate", and exits. This is to handle
|
||||
initial failed authentication, connection, etc. This time is 30 seconds
|
||||
by default, and can be adjusted (see the AUTOSSH_GATETIME environment
|
||||
variable below). If AUTOSSH_GATETIME is set to 0, then both behaviours
|
||||
are disabled: there is no "starting gate", and autossh will restart even
|
||||
if ssh fails on the first run with an exit status of 1. The "starting gate"
|
||||
time is also set to 0 when the
|
||||
.Fl f
|
||||
flag to autossh is used.
|
||||
.El
|
||||
.Pp
|
||||
.Ss Continued failures
|
||||
.Pp
|
||||
If the ssh connection fails and attempts to restart it fail in
|
||||
quick succession,
|
||||
.Nm
|
||||
will start delaying its attempts to
|
||||
restart, gradually backing farther and farther off up to a
|
||||
maximum interval of the
|
||||
.Nm
|
||||
poll time (usually 10 minutes).
|
||||
.Nm
|
||||
can be "prodded" to retry by signalling it, perhaps with
|
||||
SIGHUP ("kill -HUP").
|
||||
.Pp
|
||||
.Ss Connection setup
|
||||
.Pp
|
||||
As connections must be established unattended, the use of
|
||||
.Nm
|
||||
requires that some form of automatic authentication be set up. The use
|
||||
of RSAAuthentication with ssh-agent is the recommended method. The
|
||||
example wrapper script attempts to check if there is an agent running
|
||||
for the current environment, and to start one if there isn't.
|
||||
.Pp
|
||||
It cannot be stressed enough that you must make sure ssh works on its
|
||||
own, that you can set up the session you want before you try to
|
||||
run it under
|
||||
.Nm
|
||||
.
|
||||
.Pp
|
||||
If you are tunnelling and using an older version of ssh that does not
|
||||
support the
|
||||
.Fl N
|
||||
flag, you should upgrade (your version has security
|
||||
flaws). If you can't upgrade, you may wish to do as rstunnel does, and
|
||||
give ssh a command to run, such as "sleep 99999999999".
|
||||
.Sh OPTIONS
|
||||
.Bl -tag -width Ds
|
||||
.It Fl M Ar port[:echo_port]
|
||||
specifies the base monitoring port to use. Without the echo port,
|
||||
this port and the port
|
||||
immediately above it (
|
||||
.Ar port
|
||||
+ 1) should be something nothing else is
|
||||
using.
|
||||
.Nm
|
||||
will send test data on the base monitoring port, and
|
||||
receive it back on the port above. For example, if you specify "-M
|
||||
20000",
|
||||
.Nm
|
||||
will set up forwards so that it can send data on port
|
||||
20000 and receive it back on 20001.
|
||||
.Pp
|
||||
Alternatively, a port for a remote echo service may be specified. This
|
||||
should be port 7 if you wish to use the standard inetd echo service.
|
||||
When an echo port is specified, only the specified monitor port is
|
||||
used, and it carries the monitor message in both directions.
|
||||
.Pp
|
||||
Many people disable the echo service, or even disable inetd, so check
|
||||
that this service is available on the remote machine. Some operating
|
||||
systems allow one to specify that the service only listen on the
|
||||
localhost (loopback interface), which would suffice for this use.
|
||||
.Pp
|
||||
The echo service may also be something more complicated: perhaps
|
||||
a daemon that monitors a group of ssh tunnels.
|
||||
.Pp
|
||||
Setting the monitor port to 0 turns the monitoring function off, and
|
||||
autossh will only restart ssh upon ssh's exit. For example, if you are
|
||||
using a recent version of OpenSSH, you may wish to explore using the
|
||||
.Cm ServerAliveInterval
|
||||
and
|
||||
.Cm ServerAliveCountMax
|
||||
options to have the SSH client exit if it finds itself no longer
|
||||
connected to the server. In many ways this may be a better solution than
|
||||
the monitoring port.
|
||||
.It Fl f
|
||||
causes autossh to drop to the background before running ssh. The
|
||||
.Fl f
|
||||
flag is stripped from arguments passed to ssh. Note that there is a crucial
|
||||
difference between
|
||||
.Fl f
|
||||
with autossh, and
|
||||
.Fl f
|
||||
with ssh: when used with
|
||||
.Nm
|
||||
ssh will be unable to ask for passwords or passphrases. When
|
||||
.Fl f
|
||||
is used, the "starting gate" time (see AUTOSSH_GATETIME)
|
||||
is set to 0.
|
||||
.It Fl V
|
||||
causes
|
||||
.Nm
|
||||
to display its version number and exit.
|
||||
.El
|
||||
.Sh ENVIRONMENT
|
||||
Other than the flag to set the connection monitoring port,
|
||||
.Nm
|
||||
uses environment variables to control features. ssh seems to be
|
||||
still collecting letters for options, and this seems the easiest
|
||||
way to avoid collisions.
|
||||
.Bl -tag -width Ds
|
||||
.It Ev AUTOSSH_DEBUG
|
||||
If this variable is set, the logging level is set to to LOG_DEBUG, and
|
||||
if the operating system supports it, syslog is set to duplicate log
|
||||
entries to stderr.
|
||||
.It Ev AUTOSSH_FIRST_POLL
|
||||
Specifies the time to wait before the first connection test. Thereafter
|
||||
the general poll time is used (see AUTOSSH_POLL below).
|
||||
.It Ev AUTOSSH_GATETIME
|
||||
Specifies how long ssh must be up before we consider it a successful
|
||||
connection. The default is 30 seconds. Note that if AUTOSSH_GATETIME
|
||||
is set to 0, then not only is the gatetime behaviour turned off, but
|
||||
autossh also ignores the first run failure of ssh. This may be useful
|
||||
when running autossh at boot.
|
||||
.It Ev AUTOSSH_LOGLEVEL
|
||||
Specifies the log level, corresponding to the levels used by syslog;
|
||||
so 0-7 with 7 being the chattiest.
|
||||
.It Ev AUTOSSH_LOGFILE
|
||||
Specifies that
|
||||
.Nm
|
||||
should use the named log file, rather than syslog.
|
||||
.It Ev AUTOSSH_MAXLIFETIME
|
||||
Sets the maximum number of seconds that the program should run. Once
|
||||
the number of seconds has been passed, the ssh child will be killed
|
||||
and the program will exit.
|
||||
.It Ev AUTOSSH_MAXSTART
|
||||
Specifies how many times ssh should be started. A negative number
|
||||
means no limit on the number of times ssh is started. The default
|
||||
value is -1.
|
||||
.It Ev AUTOSSH_MESSAGE
|
||||
Append message to echo message sent when testing connections.
|
||||
.It Ev AUTOSSH_NTSERVICE
|
||||
(Cygwin only.) When set to "yes" , autossh sets up to run as an NT
|
||||
service under cygrunsrv. This adds the -N flag for ssh if not already
|
||||
set, sets the log output to stdout, and changes the behaviour on ssh
|
||||
exit so that it will restart even on a normal exit.
|
||||
.It Ev AUTOSSH_PATH
|
||||
Specifies the path to the ssh executable, in case it is
|
||||
different than the path compiled in.
|
||||
.It Ev AUTOSSH_PIDFILE
|
||||
Write autossh pid to specified file.
|
||||
.It Ev AUTOSSH_POLL
|
||||
Specifies the connection poll time in seconds; default is 600 seconds.
|
||||
Unless AUTOSSH_FIRST_POLL is used, the first poll time will
|
||||
set to match the poll time. If the poll time is less than twice the
|
||||
network timeouts (default 15 seconds) the network timeouts will be
|
||||
adjusted downward to 1/2 the poll time.
|
||||
.It Ev AUTOSSH_PORT
|
||||
Sets the connection monitoring port. Mostly in case ssh appropriates
|
||||
-M at some time. But because of this possible use, AUTOSSH_PORT
|
||||
overrides the -M flag. A value of 0 turns the monitoring function off.
|
||||
.El
|
||||
.Sh ENVIRONMENT
|
||||
There are two particular OpenSSH options that are useful when using
|
||||
.Nm
|
||||
:
|
||||
.Fp
|
||||
.Cm ExitOnForwardFailure=yes
|
||||
on the client side to make sure forwardings
|
||||
have succeeded when autossh assumes the connection is setup properly.
|
||||
.Fp
|
||||
.Cm ClientAliveInterval
|
||||
on the server side to make sure the listening
|
||||
socket is closed on the server side if the connection closes on the
|
||||
client side.
|
||||
.El
|
||||
.Sh AUTHOR
|
||||
.Nm
|
||||
was written by Carson Harding.
|
||||
.Sh SEE ALSO
|
||||
.Xr ssh 1 ,
|
||||
.Xr ssh_config 5,
|
||||
.Xr sshd_config 5,
|
||||
.Xr ssh-add 1 ,
|
||||
.Xr ssh-agent 1 ,
|
||||
.Xr ssh-keygen 1 ,
|
||||
.Xr cygrunsrv 1 .
|
1821
vendor/autossh/autossh.c
vendored
Normal file
1821
vendor/autossh/autossh.c
vendored
Normal file
File diff suppressed because it is too large
Load diff
28
vendor/autossh/autossh.host
vendored
Executable file
28
vendor/autossh/autossh.host
vendored
Executable file
|
@ -0,0 +1,28 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Example script to start up tunnel with autossh.
|
||||
#
|
||||
# This script will tunnel 2200 from the remote host
|
||||
# to 22 on the local host. On remote host do:
|
||||
# ssh -p 2200 localhost
|
||||
#
|
||||
# $Id: autossh.host,v 1.6 2004/01/24 05:53:09 harding Exp $
|
||||
#
|
||||
|
||||
ID=username
|
||||
HOST=hostname.your.net
|
||||
|
||||
if [ "X$SSH_AUTH_SOCK" = "X" ]; then
|
||||
eval `ssh-agent -s`
|
||||
ssh-add $HOME/.ssh/id_rsa
|
||||
fi
|
||||
|
||||
#AUTOSSH_POLL=600
|
||||
#AUTOSSH_PORT=20000
|
||||
#AUTOSSH_GATETIME=30
|
||||
#AUTOSSH_LOGFILE=$HOST.log
|
||||
#AUTOSSH_DEBUG=yes
|
||||
#AUTOSSH_PATH=/usr/local/bin/ssh
|
||||
export AUTOSSH_POLL AUTOSSH_LOGFILE AUTOSSH_DEBUG AUTOSSH_PATH AUTOSSH_GATETIME AUTOSSH_PORT
|
||||
|
||||
autossh -2 -fN -M 20000 -R 2200:localhost:22 ${ID}@${HOST}
|
51
vendor/autossh/autossh.spec
vendored
Normal file
51
vendor/autossh/autossh.spec
vendored
Normal file
|
@ -0,0 +1,51 @@
|
|||
Summary: Automatically restart SSH sessions and tunnels
|
||||
Name: autossh
|
||||
Version: 1.4b
|
||||
Release: 1
|
||||
License: Distributable
|
||||
Group: Applications/Networking
|
||||
Vendor: Carson Harding <harding@motd.ca>
|
||||
URL: http://www.harding.motd.ca/autossh/
|
||||
Source0: %{name}-%{version}.tgz
|
||||
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot
|
||||
|
||||
%description
|
||||
autossh is a program to start a copy of ssh and monitor it, restarting
|
||||
it as necessary should it die or stop passing traffic.
|
||||
|
||||
%prep
|
||||
%setup -q
|
||||
|
||||
%build
|
||||
%configure
|
||||
|
||||
%{__make}
|
||||
|
||||
%install
|
||||
rm -rf $RPM_BUILD_ROOT
|
||||
install -d $RPM_BUILD_ROOT{%{_bindir},%{_mandir}/man1}
|
||||
|
||||
install autossh $RPM_BUILD_ROOT%{_bindir}
|
||||
install autossh.1 $RPM_BUILD_ROOT%{_mandir}/man1
|
||||
|
||||
%clean
|
||||
rm -rf $RPM_BUILD_ROOT
|
||||
|
||||
%files
|
||||
%defattr(644,root,root,755)
|
||||
%doc README CHANGES autossh.host rscreen
|
||||
%attr(755,root,root) %{_bindir}/*
|
||||
%{_mandir}/man1/*
|
||||
|
||||
%changelog
|
||||
* Fri Mar 28 2008 Carson Harding <harding@motd.ca>
|
||||
- update to 1.4b
|
||||
|
||||
* Sat May 20 2006 Carson Harding <harding@motd.ca>
|
||||
- update to 1.4 and use autoconf
|
||||
|
||||
* Wed Feb 02 2005 Carson Harding <harding@motd.ca>
|
||||
- very minor changes to spec file
|
||||
|
||||
* Thu Oct 21 2004 Ron Yorston <rmy@tigress.co.uk> 1.3-1
|
||||
- Original version
|
232
vendor/autossh/config.h.in
vendored
Normal file
232
vendor/autossh/config.h.in
vendored
Normal file
|
@ -0,0 +1,232 @@
|
|||
/* config.h.in. Generated from configure.ac by autoheader. */
|
||||
|
||||
/* Define to 1 if you have struct addrinfo. */
|
||||
#undef HAVE_ADDRINFO
|
||||
|
||||
/* Define to 1 if you have the `alarm' function. */
|
||||
#undef HAVE_ALARM
|
||||
|
||||
/* Define to 1 if you have the <arpa/inet.h> header file. */
|
||||
#undef HAVE_ARPA_INET_H
|
||||
|
||||
/* Define to 1 if you have the `daemon' function. */
|
||||
#undef HAVE_DAEMON
|
||||
|
||||
/* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */
|
||||
#undef HAVE_DOPRNT
|
||||
|
||||
/* Define to 1 if you have the `dup2' function. */
|
||||
#undef HAVE_DUP2
|
||||
|
||||
/* Define to 1 if you have the <fcntl.h> header file. */
|
||||
#undef HAVE_FCNTL_H
|
||||
|
||||
/* Define to 1 if you have the `fork' function. */
|
||||
#undef HAVE_FORK
|
||||
|
||||
/* Define to 1 if you have the `gethostbyname' function. */
|
||||
#undef HAVE_GETHOSTBYNAME
|
||||
|
||||
/* Define to 1 if you have the `gettimeofday' function. */
|
||||
#undef HAVE_GETTIMEOFDAY
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
#undef HAVE_INTTYPES_H
|
||||
|
||||
/* Define to 1 if you have the `nsl' library (-lnsl). */
|
||||
#undef HAVE_LIBNSL
|
||||
|
||||
/* Define to 1 if you have the `socket' library (-lsocket). */
|
||||
#undef HAVE_LIBSOCKET
|
||||
|
||||
/* Define to 1 if you have the <limits.h> header file. */
|
||||
#undef HAVE_LIMITS_H
|
||||
|
||||
/* Define to 1 if you have LOG_PERROR. */
|
||||
#undef HAVE_LOG_PERROR
|
||||
|
||||
/* Define to 1 if your system has a GNU libc compatible `malloc' function, and
|
||||
to 0 otherwise. */
|
||||
#undef HAVE_MALLOC
|
||||
|
||||
/* Define to 1 if you have the `memmove' function. */
|
||||
#undef HAVE_MEMMOVE
|
||||
|
||||
/* Define to 1 if you have the <memory.h> header file. */
|
||||
#undef HAVE_MEMORY_H
|
||||
|
||||
/* Define to 1 if you have the `memset' function. */
|
||||
#undef HAVE_MEMSET
|
||||
|
||||
/* Define to 1 if you have the <netdb.h> header file. */
|
||||
#undef HAVE_NETDB_H
|
||||
|
||||
/* Define to 1 if you have the <netinet/in.h> header file. */
|
||||
#undef HAVE_NETINET_IN_H
|
||||
|
||||
/* Define to 1 if you have the <paths.h> header file. */
|
||||
#undef HAVE_PATHS_H
|
||||
|
||||
/* Define to 1 if you have the `poll' function. */
|
||||
#undef HAVE_POLL
|
||||
|
||||
/* Define to 1 if your system has a GNU libc compatible `realloc' function,
|
||||
and to 0 otherwise. */
|
||||
#undef HAVE_REALLOC
|
||||
|
||||
/* Define to 1 if you have the `select' function. */
|
||||
#undef HAVE_SELECT
|
||||
|
||||
/* Define to 1 if you have the `setproctitle' function. */
|
||||
#undef HAVE_SETPROCTITLE
|
||||
|
||||
/* Define to 1 if you have the `socket' function. */
|
||||
#undef HAVE_SOCKET
|
||||
|
||||
/* Define to 1 if you have socklen_t. */
|
||||
#undef HAVE_SOCKLEN_T
|
||||
|
||||
/* Define to 1 if you have the <stdint.h> header file. */
|
||||
#undef HAVE_STDINT_H
|
||||
|
||||
/* Define to 1 if you have the <stdlib.h> header file. */
|
||||
#undef HAVE_STDLIB_H
|
||||
|
||||
/* Define to 1 if you have the `strchr' function. */
|
||||
#undef HAVE_STRCHR
|
||||
|
||||
/* Define to 1 if you have the `strerror' function. */
|
||||
#undef HAVE_STRERROR
|
||||
|
||||
/* Define to 1 if you have the `strftime' function. */
|
||||
#undef HAVE_STRFTIME
|
||||
|
||||
/* Define to 1 if you have the <strings.h> header file. */
|
||||
#undef HAVE_STRINGS_H
|
||||
|
||||
/* Define to 1 if you have the <string.h> header file. */
|
||||
#undef HAVE_STRING_H
|
||||
|
||||
/* Define to 1 if you have the `strncasecmp' function. */
|
||||
#undef HAVE_STRNCASECMP
|
||||
|
||||
/* Define to 1 if you have the `strtoul' function. */
|
||||
#undef HAVE_STRTOUL
|
||||
|
||||
/* Define to 1 if you have the <syslog.h> header file. */
|
||||
#undef HAVE_SYSLOG_H
|
||||
|
||||
/* Define to 1 if you have the <sys/select.h> header file. */
|
||||
#undef HAVE_SYS_SELECT_H
|
||||
|
||||
/* Define to 1 if you have the <sys/socket.h> header file. */
|
||||
#undef HAVE_SYS_SOCKET_H
|
||||
|
||||
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||
#undef HAVE_SYS_STAT_H
|
||||
|
||||
/* Define to 1 if you have the <sys/time.h> header file. */
|
||||
#undef HAVE_SYS_TIME_H
|
||||
|
||||
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||
#undef HAVE_SYS_TYPES_H
|
||||
|
||||
/* Define to 1 if you have <sys/wait.h> that is POSIX.1 compatible. */
|
||||
#undef HAVE_SYS_WAIT_H
|
||||
|
||||
/* Define to 1 if you have uint16_t. */
|
||||
#undef HAVE_UINT16_T
|
||||
|
||||
/* Define to 1 if you have the `uname' function. */
|
||||
#undef HAVE_UNAME
|
||||
|
||||
/* Define to 1 if you have the <unistd.h> header file. */
|
||||
#undef HAVE_UNISTD_H
|
||||
|
||||
/* Define to 1 if you have u_int16_t. */
|
||||
#undef HAVE_U_INT16_T
|
||||
|
||||
/* Define to 1 if you have the `vfork' function. */
|
||||
#undef HAVE_VFORK
|
||||
|
||||
/* Define to 1 if you have the <vfork.h> header file. */
|
||||
#undef HAVE_VFORK_H
|
||||
|
||||
/* Define to 1 if you have the `vprintf' function. */
|
||||
#undef HAVE_VPRINTF
|
||||
|
||||
/* Define to 1 if you have the `vsyslog' function. */
|
||||
#undef HAVE_VSYSLOG
|
||||
|
||||
/* Define to 1 if `fork' works. */
|
||||
#undef HAVE_WORKING_FORK
|
||||
|
||||
/* Define to 1 if `vfork' works. */
|
||||
#undef HAVE_WORKING_VFORK
|
||||
|
||||
/* Define to 1 if you __progname is available. */
|
||||
#undef HAVE___PROGNAME
|
||||
|
||||
/* Define to the address where bug reports for this package should be sent. */
|
||||
#undef PACKAGE_BUGREPORT
|
||||
|
||||
/* Define to the full name of this package. */
|
||||
#undef PACKAGE_NAME
|
||||
|
||||
/* Define to the full name and version of this package. */
|
||||
#undef PACKAGE_STRING
|
||||
|
||||
/* Define to the one symbol short name of this package. */
|
||||
#undef PACKAGE_TARNAME
|
||||
|
||||
/* Define to the version of this package. */
|
||||
#undef PACKAGE_VERSION
|
||||
|
||||
/* Set this to the path to your ssh program. */
|
||||
#undef PATH_SSH
|
||||
|
||||
/* Define to the type of arg 1 for `select'. */
|
||||
#undef SELECT_TYPE_ARG1
|
||||
|
||||
/* Define to the type of args 2, 3 and 4 for `select'. */
|
||||
#undef SELECT_TYPE_ARG234
|
||||
|
||||
/* Define to the type of arg 5 for `select'. */
|
||||
#undef SELECT_TYPE_ARG5
|
||||
|
||||
/* Define to 1 if you have the ANSI C header files. */
|
||||
#undef STDC_HEADERS
|
||||
|
||||
/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
|
||||
#undef TIME_WITH_SYS_TIME
|
||||
|
||||
/* Define to 1 if your <sys/time.h> declares `struct tm'. */
|
||||
#undef TM_IN_SYS_TIME
|
||||
|
||||
/* Define to empty if `const' does not conform to ANSI C. */
|
||||
#undef const
|
||||
|
||||
/* Define to `__inline__' or `__inline' if that's what the C compiler
|
||||
calls it, or to nothing if 'inline' is not supported under any name. */
|
||||
#ifndef __cplusplus
|
||||
#undef inline
|
||||
#endif
|
||||
|
||||
/* Define to rpl_malloc if the replacement function should be used. */
|
||||
#undef malloc
|
||||
|
||||
/* Define to `int' if <sys/types.h> does not define. */
|
||||
#undef pid_t
|
||||
|
||||
/* Define to rpl_realloc if the replacement function should be used. */
|
||||
#undef realloc
|
||||
|
||||
/* Define to `unsigned' if <sys/types.h> does not define. */
|
||||
#undef size_t
|
||||
|
||||
/* Define as `fork' if `vfork' does not work. */
|
||||
#undef vfork
|
||||
|
||||
/* Define to empty if the keyword `volatile' does not work. Warning: valid
|
||||
code using `volatile' can become incorrect without. Disable with care. */
|
||||
#undef volatile
|
7408
vendor/autossh/configure
vendored
Executable file
7408
vendor/autossh/configure
vendored
Executable file
File diff suppressed because it is too large
Load diff
145
vendor/autossh/configure.ac
vendored
Normal file
145
vendor/autossh/configure.ac
vendored
Normal file
|
@ -0,0 +1,145 @@
|
|||
# -*- Autoconf -*-
|
||||
# Process this file with autoconf to produce a configure script.
|
||||
|
||||
AC_PREREQ(2.59)
|
||||
AC_INIT(autossh, 1.4, [Carson Harding <harding@motd.ca>])
|
||||
AC_REVISION($Revision: 1.2 $)
|
||||
AC_CONFIG_SRCDIR([daemon.h])
|
||||
AC_CONFIG_HEADER([config.h])
|
||||
AC_CONFIG_FILES([Makefile])
|
||||
|
||||
# Checks for programs.
|
||||
AC_PROG_CC
|
||||
# Add -Wall for gcc
|
||||
if test "$ac_compiler_gnu" = "yes"; then
|
||||
CFLAGS="$CFLAGS -Wall"
|
||||
fi
|
||||
|
||||
AC_ARG_WITH(ssh,
|
||||
AC_HELP_STRING([--with-ssh=ARG], [specify path to ssh executable]),
|
||||
[ac_cv_path_ssh=$withval], []
|
||||
)
|
||||
if test -z "$ac_cv_path_ssh"; then
|
||||
AC_PATH_PROG([ssh], [ssh])
|
||||
fi
|
||||
if test -n "$ac_cv_path_ssh"; then
|
||||
AC_DEFINE_UNQUOTED(
|
||||
PATH_SSH, "$ac_cv_path_ssh",
|
||||
[Set this to the path to your ssh program.]
|
||||
)
|
||||
else
|
||||
AC_MSG_ERROR([ssh program not found! Modify PATH, or use --with-ssh.])
|
||||
fi
|
||||
path_ssh="$ac_cv_path_ssh"
|
||||
AC_SUBST(path_ssh)
|
||||
|
||||
# Checks for libraries.
|
||||
|
||||
# Checks for header files.
|
||||
AC_HEADER_STDC
|
||||
AC_HEADER_SYS_WAIT
|
||||
AC_CHECK_HEADERS([arpa/inet.h fcntl.h limits.h netdb.h])
|
||||
AC_CHECK_HEADERS([netinet/in.h paths.h stdlib.h string.h sys/socket.h])
|
||||
AC_CHECK_HEADERS([sys/time.h syslog.h unistd.h])
|
||||
|
||||
|
||||
# Checks for typedefs, structures, and compiler characteristics.
|
||||
AC_C_CONST
|
||||
AC_C_INLINE
|
||||
AC_TYPE_SIZE_T
|
||||
AC_HEADER_TIME
|
||||
AC_STRUCT_TM
|
||||
AC_C_VOLATILE
|
||||
AC_CHECK_TYPE(socklen_t,
|
||||
AC_DEFINE(HAVE_SOCKLEN_T, 1, [Define to 1 if you have socklen_t.]),
|
||||
[],
|
||||
[
|
||||
#ifdef HAVE_SYS_TYPES_H
|
||||
# include <sys/types.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_SOCKET_H
|
||||
# include <sys/socket.h>
|
||||
#endif
|
||||
#ifdef HAVE_ARPA_INET_H
|
||||
# include <arpa/inet.h>
|
||||
#endif
|
||||
]
|
||||
)
|
||||
AC_CHECK_TYPE([struct addrinfo],
|
||||
AC_DEFINE(HAVE_ADDRINFO, 1, [Define to 1 if you have struct addrinfo.]),
|
||||
[],
|
||||
[
|
||||
#ifdef HAVE_NETDB_H
|
||||
# include <netdb.h>
|
||||
#endif
|
||||
]
|
||||
)
|
||||
AC_CHECK_TYPE(u_int16_t,
|
||||
AC_DEFINE(HAVE_U_INT16_T, 1, [Define to 1 if you have u_int16_t.]),
|
||||
[], [
|
||||
#ifdef HAVE_SYS_TYPES_H
|
||||
# include <sys/types.h>
|
||||
#endif
|
||||
]
|
||||
)
|
||||
AC_CHECK_TYPE(uint16_t,
|
||||
AC_DEFINE(HAVE_UINT16_T, 1, [Define to 1 if you have uint16_t.]),
|
||||
[],
|
||||
[
|
||||
#ifdef HAVE_SYS_TYPES_H
|
||||
# include <sys/types.h>
|
||||
#endif
|
||||
]
|
||||
)
|
||||
AC_CHECK_DECL(LOG_PERROR,
|
||||
AC_DEFINE(HAVE_LOG_PERROR, 1, [Define to 1 if you have LOG_PERROR.]),
|
||||
[],
|
||||
[
|
||||
#ifdef HAVE_SYSLOG_H
|
||||
# include <syslog.h>
|
||||
#endif
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
# Checks for library functions.
|
||||
AC_FUNC_FORK
|
||||
AC_FUNC_MALLOC
|
||||
AC_FUNC_REALLOC
|
||||
AC_FUNC_SELECT_ARGTYPES
|
||||
AC_FUNC_STRFTIME
|
||||
AC_FUNC_VPRINTF
|
||||
AC_CHECK_FUNCS([alarm daemon dup2 gethostbyname gettimeofday memmove])
|
||||
AC_CHECK_FUNCS([memset poll select setproctitle socket strchr strerror])
|
||||
AC_CHECK_FUNCS([strncasecmp strtoul uname vsyslog])
|
||||
|
||||
AC_CHECK_LIB(nsl, gethostbyname)
|
||||
AC_CHECK_LIB(socket, connect)
|
||||
|
||||
# Other checks
|
||||
|
||||
# Copyright (c) 1999-2004 Damien Miller
|
||||
#
|
||||
# Permission to use, copy, modify, and distribute this software for any
|
||||
# purpose with or without fee is hereby granted, provided that the above
|
||||
# copyright notice and this permission notice appear in all copies.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
AC_CACHE_CHECK([if libc defines __progname], ac_cv_libc_defines___progname, [
|
||||
AC_TRY_LINK([],
|
||||
[ extern char *__progname; printf("%s", __progname); ],
|
||||
[ ac_cv_libc_defines___progname="yes" ],
|
||||
[ ac_cv_libc_defines___progname="no" ]
|
||||
)
|
||||
])
|
||||
if test "x$ac_cv_libc_defines___progname" = "xyes" ; then
|
||||
AC_DEFINE(HAVE___PROGNAME, 1, [Define if libc defines __progname])
|
||||
fi
|
||||
|
||||
AC_OUTPUT
|
76
vendor/autossh/daemon.h
vendored
Normal file
76
vendor/autossh/daemon.h
vendored
Normal file
|
@ -0,0 +1,76 @@
|
|||
/*
|
||||
* this is BSD's daemon() for things that don't have it; cut from OpenBSD
|
||||
* $Id: daemon.h,v 1.5 2006/05/21 03:33:01 harding Exp $
|
||||
*/
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#if !defined(HAVE_DAEMON)
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
static char rcsid[] = "$OpenBSD: daemon.c,v 1.2 1996/08/19 08:22:13 tholo Exp $";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
int daemon(int nochdir, int noclose);
|
||||
|
||||
int
|
||||
daemon(int nochdir, int noclose)
|
||||
{
|
||||
int fd;
|
||||
|
||||
switch (fork()) {
|
||||
case -1:
|
||||
return -1;
|
||||
case 0:
|
||||
break;
|
||||
default:
|
||||
_exit(0);
|
||||
}
|
||||
|
||||
if (setsid() == -1)
|
||||
return -1;
|
||||
|
||||
if (!nochdir)
|
||||
(void)chdir("/");
|
||||
|
||||
if (!noclose && (fd = open(_PATH_DEVNULL, O_RDWR, 0)) != -1) {
|
||||
(void)dup2(fd, STDIN_FILENO);
|
||||
(void)dup2(fd, STDOUT_FILENO);
|
||||
(void)dup2(fd, STDERR_FILENO);
|
||||
if (fd > 2)
|
||||
(void)close (fd);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif
|
171
vendor/autossh/fakepoll.h
vendored
Normal file
171
vendor/autossh/fakepoll.h
vendored
Normal file
|
@ -0,0 +1,171 @@
|
|||
/* fakepoll.h
|
||||
* poll using select
|
||||
*
|
||||
* Warning: a call to this poll() takes about 4K of stack space.
|
||||
* Greg Parker gparker-web@sealiesoftware.com December 2000
|
||||
* This code is in the public domain and may be copied or modified without
|
||||
* permission.
|
||||
*
|
||||
* Updated May 2002:
|
||||
* * fix crash when an fd is less than 0
|
||||
* * set errno=EINVAL if an fd is greater or equal to FD_SETSIZE
|
||||
* * don't set POLLIN or POLLOUT in revents if it wasn't requested
|
||||
* in events (only happens when an fd is in the poll set twice)
|
||||
*
|
||||
* Updated Dec 2002:
|
||||
* * change comment style (for autossh, Carson Harding)
|
||||
* * undef FD_SETSIZE first
|
||||
*/
|
||||
|
||||
#ifndef _FAKE_POLL_H
|
||||
#define _FAKE_POLL_H
|
||||
|
||||
#include <limits.h>
|
||||
#undef FD_SETSIZE
|
||||
#define FD_SETSIZE OPEN_MAX
|
||||
#include <sys/types.h>
|
||||
#include <sys/time.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
typedef struct pollfd {
|
||||
int fd; /* file desc to poll */
|
||||
short events; /* events of interest on fd */
|
||||
short revents; /* events that occurred on fd */
|
||||
} pollfd_t;
|
||||
|
||||
|
||||
/* poll flags */
|
||||
#define POLLIN 0x0001
|
||||
#define POLLOUT 0x0004
|
||||
#define POLLERR 0x0008
|
||||
|
||||
/* synonyms */
|
||||
#define POLLNORM POLLIN
|
||||
#define POLLPRI POLLIN
|
||||
#define POLLRDNORM POLLIN
|
||||
#define POLLRDBAND POLLIN
|
||||
#define POLLWRNORM POLLOUT
|
||||
#define POLLWRBAND POLLOUT
|
||||
|
||||
/* ignored */
|
||||
#define POLLHUP 0x0010
|
||||
#define POLLNVAL 0x0020
|
||||
|
||||
inline int poll(struct pollfd *pollSet, int pollCount, int pollTimeout)
|
||||
{
|
||||
struct timeval tv;
|
||||
struct timeval *tvp;
|
||||
fd_set readFDs, writeFDs, exceptFDs;
|
||||
fd_set *readp, *writep, *exceptp;
|
||||
struct pollfd *pollEnd, *p;
|
||||
int selected;
|
||||
int result;
|
||||
int maxFD;
|
||||
|
||||
if (!pollSet) {
|
||||
pollEnd = NULL;
|
||||
readp = NULL;
|
||||
writep = NULL;
|
||||
exceptp = NULL;
|
||||
maxFD = 0;
|
||||
}
|
||||
else {
|
||||
pollEnd = pollSet + pollCount;
|
||||
readp = &readFDs;
|
||||
writep = &writeFDs;
|
||||
exceptp = &exceptFDs;
|
||||
|
||||
FD_ZERO(readp);
|
||||
FD_ZERO(writep);
|
||||
FD_ZERO(exceptp);
|
||||
|
||||
/* Find the biggest fd in the poll set */
|
||||
maxFD = 0;
|
||||
for (p = pollSet; p < pollEnd; p++) {
|
||||
if (p->fd > maxFD) maxFD = p->fd;
|
||||
}
|
||||
|
||||
if (maxFD >= FD_SETSIZE) {
|
||||
/* At least one fd is too big */
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Transcribe flags from the poll set to the fd sets */
|
||||
for (p = pollSet; p < pollEnd; p++) {
|
||||
if (p->fd < 0) {
|
||||
/* Negative fd checks nothing and always reports zero */
|
||||
} else {
|
||||
if (p->events & POLLIN) FD_SET(p->fd, readp);
|
||||
if (p->events & POLLOUT) FD_SET(p->fd, writep);
|
||||
if (p->events != 0) FD_SET(p->fd, exceptp);
|
||||
/* POLLERR is never set coming in; poll() always reports errors
|
||||
* But don't report if we're not listening to anything at all.
|
||||
*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* poll timeout is in milliseconds. Convert to struct timeval.
|
||||
* poll timeout == -1 : wait forever : select timeout of NULL
|
||||
* poll timeout == 0 : return immediately : select timeout of zero
|
||||
*/
|
||||
if (pollTimeout >= 0) {
|
||||
tv.tv_sec = pollTimeout / 1000;
|
||||
tv.tv_usec = (pollTimeout % 1000) * 1000;
|
||||
tvp = &tv;
|
||||
} else {
|
||||
tvp = NULL;
|
||||
}
|
||||
|
||||
|
||||
selected = select(maxFD+1, readp, writep, exceptp, tvp);
|
||||
|
||||
|
||||
if (selected < 0) {
|
||||
/* Error during select */
|
||||
result = -1;
|
||||
}
|
||||
else if (selected > 0) {
|
||||
/* Select found something
|
||||
* Transcribe result from fd sets to poll set.
|
||||
* Also count the number of selected fds. poll returns the
|
||||
* number of ready fds; select returns the number of bits set.
|
||||
*/
|
||||
int polled = 0;
|
||||
for (p = pollSet; p < pollEnd; p++) {
|
||||
p->revents = 0;
|
||||
if (p->fd < 0) {
|
||||
/* Negative fd always reports zero */
|
||||
} else {
|
||||
if ((p->events & POLLIN) && FD_ISSET(p->fd, readp)) {
|
||||
p->revents |= POLLIN;
|
||||
}
|
||||
if ((p->events & POLLOUT) && FD_ISSET(p->fd, writep)) {
|
||||
p->revents |= POLLOUT;
|
||||
}
|
||||
if ((p->events != 0) && FD_ISSET(p->fd, exceptp)) {
|
||||
p->revents |= POLLERR;
|
||||
}
|
||||
|
||||
if (p->revents) polled++;
|
||||
}
|
||||
}
|
||||
result = polled;
|
||||
}
|
||||
else {
|
||||
/* selected == 0, select timed out before anything happened
|
||||
* Clear all result bits and return zero.
|
||||
*/
|
||||
for (p = pollSet; p < pollEnd; p++) {
|
||||
p->revents = 0;
|
||||
}
|
||||
result = 0;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
26
vendor/autossh/rscreen
vendored
Executable file
26
vendor/autossh/rscreen
vendored
Executable file
|
@ -0,0 +1,26 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# sample script to use autossh to open up a remote screen
|
||||
# session, or reconnect to an existing one.
|
||||
#
|
||||
# $Id: rscreen,v 1.4 2002/05/07 17:54:13 harding Exp $
|
||||
#
|
||||
if [ "X$1" = "X" ]; then
|
||||
echo "usage: `basename $0` <host>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "X$SSH_AUTH_SOCK" = "X" ]; then
|
||||
eval `ssh-agent -s`
|
||||
ssh-add $HOME/.ssh/id_rsa
|
||||
fi
|
||||
|
||||
#AUTOSSH_POLL=600
|
||||
#AUTOSSH_PORT=20000
|
||||
#AUTOSSH_GATETIME=30
|
||||
#AUTOSSH_LOGFILE=$HOST.log
|
||||
#AUTOSSH_DEBUG=yes
|
||||
#AUTOSSH_PATH=/usr/local/bin/ssh
|
||||
export AUTOSSH_POLL AUTOSSH_LOGFILE AUTOSSH_DEBUG AUTOSSH_PATH AUTOSSH_GATETIME AUTOSSH_PORT
|
||||
|
||||
autossh -M 20004 -t $1 "screen -e^Zz -D -R"
|
Loading…
Reference in a new issue