commit 2cb54b16c3944e5919e2112d339b73678fd0106d from: Omar Polo date: Sat Feb 26 14:44:58 2022 UTC rething the build system for -main, keep autotools for -portable use the native bsd.prog.mk infrastructure to build the -main branch: now it targets OpenBSD only. The -portable branch remains and keeps using autotools to facilitate the porting for other systems. commit - 355ad914158c9e719ce27a9d2cce0f13d58d4db3 commit + 2cb54b16c3944e5919e2112d339b73678fd0106d blob - a7ab7b2f325e93ffdb3f0edd1a2425f828486c27 (mode 644) blob + /dev/null --- Makefile.am +++ /dev/null @@ -1,6 +0,0 @@ -bin_PROGRAMS = lstun -lstun_SOURCES = lstun.c compat.h log.c log.h - -LDADD = $(LIBOBJS) - -dist_man1_MANS = lstun.1 blob - d110508b5190c401e6924802a40785128ca47f40 blob + 8fd29229af019e74c3f373d299d5155de463e4b3 --- README.md +++ README.md @@ -3,12 +3,12 @@ lstun is a simple utility to lazily (on demand) spawn a ssh tunnel to a remote machine and kill it after some time of inactivity. +Note that the the -main branch targets OpenBSD only; on other systems +please use the -portable branch. + To compile it just run - $ ./autogen.sh # if building from a git checkout - $ ./configure $ make - # make install # eventually The only dependency is libevent. It expects ssh to be `/usr/bin/ssh`, compile with `-DSSH_PATH=...` to alter the path eventually. blob - 70027cbf3cf809c67ca8b5cff38df304aa29bcf6 (mode 755) blob + /dev/null --- autogen.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -exec autoreconf -vfi blob - ef6e22826235080b0c3b5fb54048ca316355a6fe (mode 644) blob + /dev/null --- compat/getprogname.c +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2021 Omar Polo - * - * 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. - */ - -/* - * XXX: eventualyl there are some ways, at least on linux, to get the - * program name, probably like glibc program_invocation_short_name or - * reading stuff from /proc/self. - */ - -const char * -getprogname(void) -{ - return "lstun"; -} blob - e1807693138c2fc6b662ac9d8859fa0f2431c360 (mode 644) blob + /dev/null --- compat/strtonum.c +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2004 Ted Unangst and Todd Miller - * All rights reserved. - * - * 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. - */ - -#include -#include -#include - -#define INVALID 1 -#define TOOSMALL 2 -#define TOOLARGE 3 - -long long -strtonum(const char *numstr, long long minval, long long maxval, - const char **errstrp) -{ - long long ll = 0; - int error = 0; - char *ep; - struct errval { - const char *errstr; - int err; - } ev[4] = { - { NULL, 0 }, - { "invalid", EINVAL }, - { "too small", ERANGE }, - { "too large", ERANGE }, - }; - - ev[0].err = errno; - errno = 0; - if (minval > maxval) { - error = INVALID; - } else { - ll = strtoll(numstr, &ep, 10); - if (numstr == ep || *ep != '\0') - error = INVALID; - else if ((ll == LLONG_MIN && errno == ERANGE) || ll < minval) - error = TOOSMALL; - else if ((ll == LLONG_MAX && errno == ERANGE) || ll > maxval) - error = TOOLARGE; - } - if (errstrp != NULL) - *errstrp = ev[error].errstr; - errno = ev[error].err; - if (error) - ll = 0; - - return (ll); -} blob - /dev/null blob + cb2b01653178a71648611ef5ebd948b243cbf6b7 (mode 644) --- /dev/null +++ lstun-dist.txt @@ -0,0 +1,9 @@ + +/LICENSE +/Makefile +/README.md +/log.c +/log.h +/lstun-version.mk +/lstun.1 +/lstun.c blob - b0ac36571fd683d0f780a8bd04566a16a4fedab3 (mode 644) blob + /dev/null --- compat.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2021 Omar Polo - * - * 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. - */ - -#ifndef COMPAT_H -#define COMPAT_H - -#include "config.h" - -#ifndef HAVE_GETPROGNAME -const char *getprogname(void); -#endif - -#ifndef HAVE_STRTONUM -long long strtonum(const char*, long long, long long, const char**); -#endif - -#endif /* COMPAT_H */ blob - /dev/null blob + ed13bf81e9e1ab3e46d42c9131e8e79ad529c741 (mode 644) --- /dev/null +++ lstun-version.mk @@ -0,0 +1,8 @@ +LSTUN_RELEASE=No +LSTUN_VERSION_NUMBER=0.2 + +.if ${LSTUN_RELEASE} == Yes +LSTUN_VERSION=${LSTUN_VERSION_NUMBER} +.else +LSTUN_VERSION=${LSTUN_VERSION_NUMBER}-current +.endif blob - a25d9a213ef3a95754aa8452672446b34452062e (mode 644) blob + /dev/null --- configure.ac +++ /dev/null @@ -1,24 +0,0 @@ -AC_INIT([lstun], [0.1.0], [op@omarpolo.com]) -AC_CONFIG_LIBOBJ_DIR([compat]) -AM_INIT_AUTOMAKE([-Wall foreign subdir-objects]) -AC_PROG_CC_C99 -AC_USE_SYSTEM_EXTENSIONS - -AC_REPLACE_FUNCS([ - getprogname \ - strtonum \ -]) - -AC_CHECK_LIB([event2], [event_init], [], [ - AC_CHECK_LIB([event], [event_init], [], [ - AC_MSG_ERROR([requires libevent]) - ]) -]) - -AM_CFLAGS="${AM_CFLAGS} -Wall -Wextra -Wmissing-prototypes" -AM_CFLAGS="${AM_CFLAGS} -Wstrict-prototypes -Wwrite-strings" -AM_CFLAGS="${AM_CFLAGS} -Wno-unused-parameter" - -AC_CONFIG_HEADERS([config.h]) -AC_CONFIG_FILES([Makefile]) -AC_OUTPUT blob - 859eb2b7dc29fb815517252d515596e8a2c801f3 blob + 362b9c4cbfe5998442528d99f3faaa2315f44972 --- log.c +++ log.c @@ -14,8 +14,6 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include "compat.h" - #include #include #include blob - aa11bffda1152efd9c1f6ebe7d78bbc46e4a56b3 blob + a1f799769c83791ddf04e799be4969b44d44ca85 --- lstun.c +++ lstun.c @@ -13,8 +13,6 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ - -#include "compat.h" #include #include