From 1fe7cae368036ad16f3ec7b72ccd21349edea4f1 Mon Sep 17 00:00:00 2001 From: RISCi_ATOM Date: Fri, 29 Sep 2023 13:24:49 -0400 Subject: [PATCH] usbip : Add usbip support with appropriate dependencies. This commit adds `libevdev`,`libudev-fbsd`, `tcp_wrappers`, and `usbip`; it addresses the request made in issue #160 --- package/libs/libevdev/Makefile | 54 + ...010-no-clock-monotonic-raw-in-uclibc.patch | 14 + package/libs/libudev-fbsd/Makefile | 51 + .../003-add-pkg-config-description.patch | 20 + .../libudev-fbsd/patches/005-extern-c.patch | 25 + .../100-add-stub-udev_device_get_driver.patch | 25 + ...ev_device_new_from_subsystem_sysname.patch | 72 ++ ...b-udev_enumerate_add_nomatch_sysattr.patch | 41 + package/libs/tcp_wrappers/Makefile | 69 ++ .../patches/001-debian_subset.patch | 936 ++++++++++++++++++ .../tcp_wrappers/patches/002-opt_cflags.patch | 12 + .../patches/003-scaffold_malloc.patch | 17 + .../patches/004-ipv4_prefix.patch | 72 ++ .../patches/005-no--lnsl-on-musl.patch | 22 + .../patches/006-compilation-warnings.patch | 765 ++++++++++++++ package/network/services/usbip/Makefile | 114 +++ 16 files changed, 2309 insertions(+) create mode 100644 package/libs/libevdev/Makefile create mode 100644 package/libs/libevdev/patches/010-no-clock-monotonic-raw-in-uclibc.patch create mode 100644 package/libs/libudev-fbsd/Makefile create mode 100644 package/libs/libudev-fbsd/patches/003-add-pkg-config-description.patch create mode 100644 package/libs/libudev-fbsd/patches/005-extern-c.patch create mode 100644 package/libs/libudev-fbsd/patches/100-add-stub-udev_device_get_driver.patch create mode 100644 package/libs/libudev-fbsd/patches/101-add-stub-udev_device_new_from_subsystem_sysname.patch create mode 100644 package/libs/libudev-fbsd/patches/102-add-stub-udev_enumerate_add_nomatch_sysattr.patch create mode 100644 package/libs/tcp_wrappers/Makefile create mode 100644 package/libs/tcp_wrappers/patches/001-debian_subset.patch create mode 100644 package/libs/tcp_wrappers/patches/002-opt_cflags.patch create mode 100644 package/libs/tcp_wrappers/patches/003-scaffold_malloc.patch create mode 100644 package/libs/tcp_wrappers/patches/004-ipv4_prefix.patch create mode 100644 package/libs/tcp_wrappers/patches/005-no--lnsl-on-musl.patch create mode 100644 package/libs/tcp_wrappers/patches/006-compilation-warnings.patch create mode 100644 package/network/services/usbip/Makefile diff --git a/package/libs/libevdev/Makefile b/package/libs/libevdev/Makefile new file mode 100644 index 0000000000..0ee832c924 --- /dev/null +++ b/package/libs/libevdev/Makefile @@ -0,0 +1,54 @@ +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +include $(TOPDIR)/rules.mk + +PKG_NAME:=libevdev +PKG_VERSION:=1.6.0 +PKG_RELEASE:=1 + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz +PKG_SOURCE_URL:=https://www.freedesktop.org/software/libevdev/ +PKG_HASH:=f5005c865987d980cc1279b9ec6131b06a89fd9892f649f2a68262b8786ef814 + +PKG_LICENSE:=MIT +PKG_LICENSE_FILES:=COPYING +PKG_MAINTAINER:=Daniel Golle + +PKG_FIXUP:=autoreconf +PKG_INSTALL:=1 + +include $(INCLUDE_DIR)/package.mk + +define Package/libevdev + SECTION:=libs + CATEGORY:=Libraries + TITLE:=a wrapper library for evdev devices + URL:=https://www.freedesktop.org/wiki/Software/libevdev/ +endef + +define Package/libevdev/description + libevdev is a wrapper library for evdev devices. it moves the common + tasks when dealing with evdev devices into a library and provides a + library interface to the callers, thus avoiding erroneous ioctls, etc. + + The eventual goal is that libevdev wraps all ioctls available to + evdev devices, thus making direct access unnecessary. +endef + +define Build/InstallDev + $(INSTALL_DIR) $(1)/usr/include + $(CP) $(PKG_INSTALL_DIR)/usr/include/* $(1)/usr/include/ + $(INSTALL_DIR) $(1)/usr/lib + $(CP) $(PKG_INSTALL_DIR)/usr/lib/*.{a,so*} $(1)/usr/lib/ + $(INSTALL_DIR) $(1)/usr/lib/pkgconfig + $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/* $(1)/usr/lib/pkgconfig/ +endef + +define Package/libevdev/install + $(INSTALL_DIR) $(1)/usr/lib + $(CP) $(PKG_INSTALL_DIR)/usr/lib/*.so* $(1)/usr/lib/ +endef + +$(eval $(call BuildPackage,libevdev)) diff --git a/package/libs/libevdev/patches/010-no-clock-monotonic-raw-in-uclibc.patch b/package/libs/libevdev/patches/010-no-clock-monotonic-raw-in-uclibc.patch new file mode 100644 index 0000000000..a11ac1e465 --- /dev/null +++ b/package/libs/libevdev/patches/010-no-clock-monotonic-raw-in-uclibc.patch @@ -0,0 +1,14 @@ +--- a/test/test-libevdev-init.c ++++ b/test/test-libevdev-init.c +@@ -32,6 +32,11 @@ + #include + #include "test-common.h" + ++/* work-around CLOCK_MONOTONIC_RAW definition missing in uClibc */ ++#ifndef CLOCK_MONOTONIC_RAW ++#define CLOCK_MONOTONIC_RAW 4 ++#endif ++ + START_TEST(test_new_device) + { + struct libevdev *dev; diff --git a/package/libs/libudev-fbsd/Makefile b/package/libs/libudev-fbsd/Makefile new file mode 100644 index 0000000000..af9f278b21 --- /dev/null +++ b/package/libs/libudev-fbsd/Makefile @@ -0,0 +1,51 @@ +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +include $(TOPDIR)/rules.mk + +PKG_NAME:=libudev-fbsd + +PKG_RELEASE:=1 +PKG_VERSION:=20171216 +PKG_SOURCE_VERSION:=fa190fdf0b22a41b5f42e3a722f754c08ad7b337 + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.xz +PKG_MIRROR_HASH:=d4638099fd288a293a165304541eb9c01e828bb358a0091caa02c1327c20964b +PKG_SOURCE_PROTO:=git +PKG_SOURCE_URL:=https://github.com/jiixyj/libudev-fbsd.git + +PKG_LICENSE:=MIT +PKG_LICENSE_FILES:=COPYING +PKG_MAINTAINER:=Daniel Golle + +PKG_INSTALL:=1 + +include $(INCLUDE_DIR)/package.mk +include $(INCLUDE_DIR)/cmake.mk + +define Package/libudev-fbsd + SECTION:=libs + CATEGORY:=Libraries + TITLE:=small udev shim for FreeBSD/devd (and other non-systemd) + URL:=https://github.com/jiixyj/libudev-fbsd + DEPENDS:=+libevdev + PROVIDES:=libudev + CONFLICTS:=libudev eudev udev +endef + +define Build/InstallDev + $(INSTALL_DIR) $(1)/usr/include + $(CP) $(PKG_INSTALL_DIR)/usr/include/* $(1)/usr/include/ + $(INSTALL_DIR) $(1)/usr/lib + $(CP) $(PKG_INSTALL_DIR)/usr/lib/*.so* $(1)/usr/lib/ + $(INSTALL_DIR) $(1)/usr/lib/pkgconfig + $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/* $(1)/usr/lib/pkgconfig/ +endef + +define Package/libudev-fbsd/install + $(INSTALL_DIR) $(1)/usr/lib + $(CP) $(PKG_INSTALL_DIR)/usr/lib/*.so* $(1)/usr/lib/ +endef + +$(eval $(call BuildPackage,libudev-fbsd)) diff --git a/package/libs/libudev-fbsd/patches/003-add-pkg-config-description.patch b/package/libs/libudev-fbsd/patches/003-add-pkg-config-description.patch new file mode 100644 index 0000000000..19efcb3c92 --- /dev/null +++ b/package/libs/libudev-fbsd/patches/003-add-pkg-config-description.patch @@ -0,0 +1,20 @@ +--- a/src/CMakeLists.txt ++++ b/src/CMakeLists.txt +@@ -26,6 +26,7 @@ install(TARGETS udev LIBRARY DESTINATION + install(FILES libudev.h DESTINATION include) + + set(PKG_CONFIG_NAME libudev) ++set(PKG_CONFIG_DESCRIPTION small udev shim for FreeBSD/devd) + set(PKG_CONFIG_REQUIRES libevdev) + set(PKG_CONFIG_LIBDIR "\${prefix}/lib") + set(PKG_CONFIG_INCLUDEDIR "\${prefix}/include") +--- a/src/pkg-config.pc.cmake ++++ b/src/pkg-config.pc.cmake +@@ -3,6 +3,7 @@ libdir=${PKG_CONFIG_LIBDIR} + includedir=${PKG_CONFIG_INCLUDEDIR} + + Name: ${PKG_CONFIG_NAME} ++Description: ${PKG_CONFIG_DESCRIPTION} + Version: 143 + Requires: ${PKG_CONFIG_REQUIRES} + Libs: ${PKG_CONFIG_LIBS} diff --git a/package/libs/libudev-fbsd/patches/005-extern-c.patch b/package/libs/libudev-fbsd/patches/005-extern-c.patch new file mode 100644 index 0000000000..1e77bf4c71 --- /dev/null +++ b/package/libs/libudev-fbsd/patches/005-extern-c.patch @@ -0,0 +1,25 @@ +--- a/src/libudev.h ++++ b/src/libudev.h +@@ -7,6 +7,11 @@ + extern "C" { + #endif + ++ ++#ifdef __cplusplus ++extern "C" { ++#endif ++ + struct udev; + struct udev_device; + struct udev_list_entry; +@@ -76,6 +81,10 @@ void udev_monitor_unref(struct udev_moni + + #ifdef __cplusplus + } /* extern "C" */ ++#endif ++ ++#ifdef __cplusplus ++} /* extern "C" */ + #endif + + #endif diff --git a/package/libs/libudev-fbsd/patches/100-add-stub-udev_device_get_driver.patch b/package/libs/libudev-fbsd/patches/100-add-stub-udev_device_get_driver.patch new file mode 100644 index 0000000000..7592c8b691 --- /dev/null +++ b/package/libs/libudev-fbsd/patches/100-add-stub-udev_device_get_driver.patch @@ -0,0 +1,25 @@ +--- a/src/libudev.c ++++ b/src/libudev.c +@@ -139,6 +139,12 @@ udev_device_get_devnum(struct udev_devic + } + + char const * ++udev_device_get_driver(struct udev_device *udev_device) ++{ ++ return NULL; ++} ++ ++char const * + udev_device_get_property_value(struct udev_device *dev, char const *property) + { + LOG("udev_device_get_property_value %s\n", property); +--- a/src/libudev.h ++++ b/src/libudev.h +@@ -31,6 +31,7 @@ struct udev_device *udev_device_new_from + struct udev *udev, char const *syspath); + struct udev_device *udev_device_new_from_devnum( + struct udev *udev, char type, dev_t devnum); ++char const *udev_device_get_driver(struct udev_device *udev_device); + char const *udev_device_get_syspath(struct udev_device *udev_device); + char const *udev_device_get_sysname(struct udev_device *udev_device); + char const *udev_device_get_subsystem(struct udev_device *udev_device); diff --git a/package/libs/libudev-fbsd/patches/101-add-stub-udev_device_new_from_subsystem_sysname.patch b/package/libs/libudev-fbsd/patches/101-add-stub-udev_device_new_from_subsystem_sysname.patch new file mode 100644 index 0000000000..47ed81ac29 --- /dev/null +++ b/package/libs/libudev-fbsd/patches/101-add-stub-udev_device_new_from_subsystem_sysname.patch @@ -0,0 +1,72 @@ +--- a/src/libudev.c ++++ b/src/libudev.c +@@ -35,6 +35,7 @@ struct udev_device { + struct udev *udev; + int refcount; + char syspath[32]; ++ char sysfspath[64]; + dev_t devnum; + char const *sysname; + char const *action; +@@ -124,6 +125,29 @@ udev_device_new_from_devnum(struct udev + return NULL; + } + ++struct udev_device * ++udev_device_new_from_subsystem_sysname( ++ struct udev *udev, const char *subsystem, const char *sysname) ++{ ++ struct udev_device *u; ++ char sysfsname[64]; ++ struct stat st; ++ ++ snprintf(sysfsname, sizeof(sysfsname), "/sys/bus/%s/devices/%s/", subsystem, sysname); ++ if (stat(sysfsname, &st) == 0) ++ { ++ char sysfsdev[64]; ++ u = calloc(1, sizeof(struct udev_device)); ++ strncpy(u->sysfspath, sysfsname, sizeof(u->sysfspath)); ++ ++ return u; ++ } ++ else ++ { ++ return NULL; ++ } ++} ++ + char const * + udev_device_get_devnode(struct udev_device *udev_device) + { +@@ -141,6 +165,20 @@ udev_device_get_devnum(struct udev_devic + char const * + udev_device_get_driver(struct udev_device *udev_device) + { ++ if (udev_device->sysfspath) ++ { ++ char driverlnp[64]; ++ char driverlnk[32]; ++ snprintf(driverlnp, sizeof(driverlnp), "%s/driver", ++ udev_device->sysfspath); ++ if (readlink(driverlnp, driverlnk, sizeof(driver))) ++ { ++ char *drivernm; ++ drivernm = strrchr(driverlnk, '/'); ++ if (drivernm) ++ return ++drivernm; ++ } ++ } + return NULL; + } + +--- a/src/libudev.h ++++ b/src/libudev.h +@@ -31,6 +31,8 @@ struct udev_device *udev_device_new_from + struct udev *udev, char const *syspath); + struct udev_device *udev_device_new_from_devnum( + struct udev *udev, char type, dev_t devnum); ++struct udev_device *udev_device_new_from_subsystem_sysname( ++ struct udev *udev, const char *subsystem, const char *sysname); + char const *udev_device_get_driver(struct udev_device *udev_device); + char const *udev_device_get_syspath(struct udev_device *udev_device); + char const *udev_device_get_sysname(struct udev_device *udev_device); diff --git a/package/libs/libudev-fbsd/patches/102-add-stub-udev_enumerate_add_nomatch_sysattr.patch b/package/libs/libudev-fbsd/patches/102-add-stub-udev_enumerate_add_nomatch_sysattr.patch new file mode 100644 index 0000000000..f65a2e9781 --- /dev/null +++ b/package/libs/libudev-fbsd/patches/102-add-stub-udev_enumerate_add_nomatch_sysattr.patch @@ -0,0 +1,41 @@ +--- a/src/libudev.c ++++ b/src/libudev.c +@@ -171,7 +171,7 @@ udev_device_get_driver(struct udev_devic + char driverlnk[32]; + snprintf(driverlnp, sizeof(driverlnp), "%s/driver", + udev_device->sysfspath); +- if (readlink(driverlnp, driverlnk, sizeof(driver))) ++ if (readlink(driverlnp, driverlnk, sizeof(driverlnk))) + { + char *drivernm; + drivernm = strrchr(driverlnk, '/'); +@@ -612,6 +612,18 @@ udev_enumerate_add_match_property(struct + value); + return -1; + } ++ ++int ++udev_enumerate_add_nomatch_sysattr(struct udev_enumerate *udev_enumerate, ++ const char *sysattr, const char *value) ++{ ++ (void)udev_enumerate; ++ (void)sysattr; ++ (void)value; ++ LOG("stub: udev_enumerate_add_nomatch_sysattr %s %s\n", sysattr, ++ value); ++ return -1; ++} + + void + udev_enumerate_unref(struct udev_enumerate *udev_enumerate) +--- a/src/libudev.h ++++ b/src/libudev.h +@@ -60,6 +60,8 @@ int udev_enumerate_add_match_sysname( + struct udev_enumerate *udev_enumerate, char const *sysname); + int udev_enumerate_add_match_property(struct udev_enumerate *udev_enumerate, + char const *property, char const *value); ++int udev_enumerate_add_nomatch_sysattr(struct udev_enumerate *udev_enumerate, ++ const char *sysattr, const char *value); + void udev_enumerate_unref(struct udev_enumerate *udev_enumerate); + + #define udev_list_entry_foreach(list_entry, first_entry) \ diff --git a/package/libs/tcp_wrappers/Makefile b/package/libs/tcp_wrappers/Makefile new file mode 100644 index 0000000000..3bfa9d4e50 --- /dev/null +++ b/package/libs/tcp_wrappers/Makefile @@ -0,0 +1,69 @@ +# +# Copyright (C) 2006 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +include $(TOPDIR)/rules.mk + +PKG_NAME:=tcp_wrappers +PKG_VERSION:=7.6 +PKG_RELEASE:=2 + +PKG_SOURCE:=$(PKG_NAME)_$(PKG_VERSION).tar.gz +PKG_SOURCE_URL:=ftp://ftp.porcupine.org/pub/security +PKG_HASH:=9543d7adedf78a6de0b221ccbbd1952e08b5138717f4ade814039bb489a4315d + +PKG_LICENSE:=BSD +PKG_LICENE_FILES:=DISCLAIMER + +PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)_$(PKG_VERSION) + +include $(INCLUDE_DIR)/package.mk + +define Package/libwrap + SECTION:=libs + CATEGORY:=Libraries + TITLE:=Security wrapper library for TCP services + URL:=ftp://ftp.porcupine.org/pub/security/index.html + MAINTAINER:=Peter Wagner +endef + +TARGET_CFLAGS += $(FPIC) -Wall + +ifeq ($(CONFIG_USE_MUSL),) +TARGET_EXTRA_LIBS:=LIBS=-lnsl +endif + +define Build/Compile + $(MAKE) -C $(PKG_BUILD_DIR) \ + $(TARGET_CONFIGURE_OPTS) \ + OPT_CFLAGS="$(TARGET_CFLAGS)" \ + $(TARGET_EXTRA_LIBS) \ + NETGROUP= \ + VSYSLOG= \ + BUGS= \ + EXTRA_CFLAGS="-DSYS_ERRLIST_DEFINED -DHAVE_STRERROR -DHAVE_WEAKSYMS -D_REENTRANT -DINET6=1 \ + -Dss_family=__ss_family -Dss_len=__ss_len" \ + FACILITY=LOG_DAEMON \ + SEVERITY=LOG_INFO \ + REAL_DAEMON_DIR=/usr/sbin \ + STYLE="-DPROCESS_OPTIONS" \ + tidy all +endef + +define Build/InstallDev + $(INSTALL_DIR) $(1)/usr/include + $(CP) $(PKG_BUILD_DIR)/tcpd.h $(1)/usr/include/ + $(INSTALL_DIR) $(1)/usr/lib + $(CP) $(PKG_BUILD_DIR)/libwrap.a $(1)/usr/lib/ + $(CP) $(PKG_BUILD_DIR)/shared/libwrap.so* $(1)/usr/lib/ +endef + +define Package/libwrap/install + $(INSTALL_DIR) $(1)/usr/lib + $(CP) $(PKG_BUILD_DIR)/shared/libwrap.so.* $(1)/usr/lib/ +endef + +$(eval $(call BuildPackage,libwrap)) diff --git a/package/libs/tcp_wrappers/patches/001-debian_subset.patch b/package/libs/tcp_wrappers/patches/001-debian_subset.patch new file mode 100644 index 0000000000..0b3ad2cea1 --- /dev/null +++ b/package/libs/tcp_wrappers/patches/001-debian_subset.patch @@ -0,0 +1,936 @@ +--- a/hosts_access.c ++++ b/hosts_access.c +@@ -240,6 +240,26 @@ struct request_info *request; + } + } + ++/* hostfile_match - look up host patterns from file */ ++ ++static int hostfile_match(path, host) ++char *path; ++struct hosts_info *host; ++{ ++ char tok[BUFSIZ]; ++ int match = NO; ++ FILE *fp; ++ ++ if ((fp = fopen(path, "r")) != 0) { ++ while (fscanf(fp, "%s", tok) == 1 && !(match = host_match(tok, host))) ++ /* void */ ; ++ fclose(fp); ++ } else if (errno != ENOENT) { ++ tcpd_warn("open %s: %m", path); ++ } ++ return (match); ++} ++ + /* host_match - match host name and/or address against pattern */ + + static int host_match(tok, host) +@@ -267,6 +287,8 @@ struct host_info *host; + tcpd_warn("netgroup support is disabled"); /* not tcpd_jump() */ + return (NO); + #endif ++ } else if (tok[0] == '/') { /* /file hack */ ++ return (hostfile_match(tok, host)); + } else if (STR_EQ(tok, "KNOWN")) { /* check address and name */ + char *name = eval_hostname(host); + return (STR_NE(eval_hostaddr(host), unknown) && HOSTNAME_KNOWN(name)); +--- a/tcpd.h ++++ b/tcpd.h +@@ -4,6 +4,25 @@ + * Author: Wietse Venema, Eindhoven University of Technology, The Netherlands. + */ + ++#ifndef _TCPWRAPPERS_TCPD_H ++#define _TCPWRAPPERS_TCPD_H ++ ++/* someone else may have defined this */ ++#undef __P ++ ++/* use prototypes if we have an ANSI C compiler or are using C++ */ ++#if defined(__STDC__) || defined(__cplusplus) ++#define __P(args) args ++#else ++#define __P(args) () ++#endif ++ ++/* Need definitions of struct sockaddr_in and FILE. */ ++#include ++#include ++ ++__BEGIN_DECLS ++ + /* Structure to describe one communications endpoint. */ + + #define STRING_LENGTH 128 /* hosts, users, processes */ +@@ -25,10 +44,10 @@ struct request_info { + char pid[10]; /* access via eval_pid(request) */ + struct host_info client[1]; /* client endpoint info */ + struct host_info server[1]; /* server endpoint info */ +- void (*sink) (); /* datagram sink function or 0 */ +- void (*hostname) (); /* address to printable hostname */ +- void (*hostaddr) (); /* address to printable address */ +- void (*cleanup) (); /* cleanup function or 0 */ ++ void (*sink) __P((int)); /* datagram sink function or 0 */ ++ void (*hostname) __P((struct host_info *)); /* address to printable hostname */ ++ void (*hostaddr) __P((struct host_info *)); /* address to printable address */ ++ void (*cleanup) __P((struct request_info *)); /* cleanup function or 0 */ + struct netconfig *config; /* netdir handle */ + }; + +@@ -61,25 +80,30 @@ extern char paranoid[]; + /* Global functions. */ + + #if defined(TLI) || defined(PTX) || defined(TLI_SEQUENT) +-extern void fromhost(); /* get/validate client host info */ ++extern void fromhost __P((struct request_info *)); /* get/validate client host info */ + #else + #define fromhost sock_host /* no TLI support needed */ + #endif + +-extern int hosts_access(); /* access control */ +-extern void shell_cmd(); /* execute shell command */ +-extern char *percent_x(); /* do % expansion */ +-extern void rfc931(); /* client name from RFC 931 daemon */ +-extern void clean_exit(); /* clean up and exit */ +-extern void refuse(); /* clean up and exit */ +-extern char *xgets(); /* fgets() on steroids */ +-extern char *split_at(); /* strchr() and split */ +-extern unsigned long dot_quad_addr(); /* restricted inet_addr() */ ++extern void shell_cmd __P((char *)); /* execute shell command */ ++extern char *percent_x __P((char *, int, char *, struct request_info *)); /* do % expansion */ ++extern void rfc931 __P((struct sockaddr_in *, struct sockaddr_in *, char *)); /* client name from RFC 931 daemon */ ++extern void clean_exit __P((struct request_info *)); /* clean up and exit */ ++extern void refuse __P((struct request_info *)); /* clean up and exit */ ++extern char *xgets __P((char *, int, FILE *)); /* fgets() on steroids */ ++extern char *split_at __P((char *, int)); /* strchr() and split */ ++extern unsigned long dot_quad_addr __P((char *)); /* restricted inet_addr() */ + + /* Global variables. */ + ++#ifdef HAVE_WEAKSYMS ++extern int allow_severity __attribute__ ((weak)); /* for connection logging */ ++extern int deny_severity __attribute__ ((weak)); /* for connection logging */ ++#else + extern int allow_severity; /* for connection logging */ + extern int deny_severity; /* for connection logging */ ++#endif ++ + extern char *hosts_allow_table; /* for verification mode redirection */ + extern char *hosts_deny_table; /* for verification mode redirection */ + extern int hosts_access_verbose; /* for verbose matching mode */ +@@ -92,9 +116,14 @@ extern int resident; /* > 0 if residen + */ + + #ifdef __STDC__ ++extern int hosts_access(struct request_info *request); ++extern int hosts_ctl(char *daemon, char *client_name, char *client_addr, ++ char *client_user); + extern struct request_info *request_init(struct request_info *,...); + extern struct request_info *request_set(struct request_info *,...); + #else ++extern int hosts_access(); ++extern int hosts_ctl(); + extern struct request_info *request_init(); /* initialize request */ + extern struct request_info *request_set(); /* update request structure */ + #endif +@@ -117,27 +146,31 @@ extern struct request_info *request_set( + * host_info structures serve as caches for the lookup results. + */ + +-extern char *eval_user(); /* client user */ +-extern char *eval_hostname(); /* printable hostname */ +-extern char *eval_hostaddr(); /* printable host address */ +-extern char *eval_hostinfo(); /* host name or address */ +-extern char *eval_client(); /* whatever is available */ +-extern char *eval_server(); /* whatever is available */ ++extern char *eval_user __P((struct request_info *)); /* client user */ ++extern char *eval_hostname __P((struct host_info *)); /* printable hostname */ ++extern char *eval_hostaddr __P((struct host_info *)); /* printable host address */ ++extern char *eval_hostinfo __P((struct host_info *)); /* host name or address */ ++extern char *eval_client __P((struct request_info *)); /* whatever is available */ ++extern char *eval_server __P((struct request_info *)); /* whatever is available */ + #define eval_daemon(r) ((r)->daemon) /* daemon process name */ + #define eval_pid(r) ((r)->pid) /* process id */ + + /* Socket-specific methods, including DNS hostname lookups. */ + +-extern void sock_host(); /* look up endpoint addresses */ +-extern void sock_hostname(); /* translate address to hostname */ +-extern void sock_hostaddr(); /* address to printable address */ ++/* look up endpoint addresses */ ++extern void sock_host __P((struct request_info *)); ++/* translate address to hostname */ ++extern void sock_hostname __P((struct host_info *)); ++/* address to printable address */ ++extern void sock_hostaddr __P((struct host_info *)); ++ + #define sock_methods(r) \ + { (r)->hostname = sock_hostname; (r)->hostaddr = sock_hostaddr; } + + /* The System V Transport-Level Interface (TLI) interface. */ + + #if defined(TLI) || defined(PTX) || defined(TLI_SEQUENT) +-extern void tli_host(); /* look up endpoint addresses etc. */ ++extern void tli_host __P((struct request_info *)); /* look up endpoint addresses etc. */ + #endif + + /* +@@ -178,7 +211,7 @@ extern struct tcpd_context tcpd_context; + * behavior. + */ + +-extern void process_options(); /* execute options */ ++extern void process_options __P((char *, struct request_info *)); /* execute options */ + extern int dry_run; /* verification flag */ + + /* Bug workarounds. */ +@@ -217,3 +250,7 @@ extern char *fix_strtok(); + #define strtok my_strtok + extern char *my_strtok(); + #endif ++ ++__END_DECLS ++ ++#endif /* tcpd.h */ +--- a/Makefile ++++ b/Makefile +@@ -1,5 +1,10 @@ ++GLIBC=$(shell grep -s -c __GLIBC__ /usr/include/features.h) ++ + # @(#) Makefile 1.23 97/03/21 19:27:20 + ++# unset the HOSTNAME environment variable ++HOSTNAME = ++ + what: + @echo + @echo "Usage: edit the REAL_DAEMON_DIR definition in the Makefile then:" +@@ -19,7 +24,7 @@ what: + @echo " generic (most bsd-ish systems with sys5 compatibility)" + @echo " 386bsd aix alpha apollo bsdos convex-ultranet dell-gcc dgux dgux543" + @echo " dynix epix esix freebsd hpux irix4 irix5 irix6 isc iunix" +- @echo " linux machten mips(untested) ncrsvr4 netbsd next osf power_unix_211" ++ @echo " linux gnu machten mips(untested) ncrsvr4 netbsd next osf power_unix_211" + @echo " ptx-2.x ptx-generic pyramid sco sco-nis sco-od2 sco-os5 sinix sunos4" + @echo " sunos40 sunos5 sysv4 tandem ultrix unicos7 unicos8 unixware1 unixware2" + @echo " uts215 uxp" +@@ -43,8 +48,8 @@ what: + # Ultrix 4.x SunOS 4.x ConvexOS 10.x Dynix/ptx + #REAL_DAEMON_DIR=/usr/etc + # +-# SysV.4 Solaris 2.x OSF AIX +-#REAL_DAEMON_DIR=/usr/sbin ++# SysV.4 Solaris 2.x OSF AIX Linux ++REAL_DAEMON_DIR=/usr/sbin + # + # BSD 4.4 + #REAL_DAEMON_DIR=/usr/libexec +@@ -141,10 +146,21 @@ freebsd: + LIBS= RANLIB=ranlib ARFLAGS=rv AUX_OBJ= NETGROUP= TLI= \ + EXTRA_CFLAGS=-DSYS_ERRLIST_DEFINED VSYSLOG= all + ++ifneq ($(GLIBC),0) ++MYLIB=-lnsl ++endif ++ + linux: + @make REAL_DAEMON_DIR=$(REAL_DAEMON_DIR) STYLE=$(STYLE) \ +- LIBS= RANLIB=ranlib ARFLAGS=rv AUX_OBJ=setenv.o \ +- NETGROUP= TLI= EXTRA_CFLAGS="-DBROKEN_SO_LINGER" all ++ LIBS=$(MYLIB) RANLIB=ranlib ARFLAGS=rv AUX_OBJ=weak_symbols.o \ ++ NETGROUP=-DNETGROUP TLI= VSYSLOG= BUGS= all \ ++ EXTRA_CFLAGS="-DSYS_ERRLIST_DEFINED -DHAVE_WEAKSYMS -D_REENTRANT" ++ ++gnu: ++ @make REAL_DAEMON_DIR=$(REAL_DAEMON_DIR) STYLE=$(STYLE) \ ++ LIBS=$(MYLIB) RANLIB=ranlib ARFLAGS=rv AUX_OBJ=weak_symbols.o \ ++ NETGROUP=-DNETGROUP TLI= VSYSLOG= BUGS= all \ ++ EXTRA_CFLAGS="-DHAVE_STRERROR -DHAVE_WEAKSYMS -D_REENTRANT" + + # This is good for many SYSV+BSD hybrids with NIS, probably also for HP-UX 7.x. + hpux hpux8 hpux9 hpux10: +@@ -391,7 +407,7 @@ AR = ar + # the ones provided with this source distribution. The environ.c module + # implements setenv(), getenv(), and putenv(). + +-AUX_OBJ= setenv.o ++#AUX_OBJ= setenv.o + #AUX_OBJ= environ.o + #AUX_OBJ= environ.o strcasecmp.o + +@@ -454,7 +470,8 @@ AUX_OBJ= setenv.o + # host name aliases. Compile with -DSOLARIS_24_GETHOSTBYNAME_BUG to work + # around this. The workaround does no harm on other Solaris versions. + +-BUGS = -DGETPEERNAME_BUG -DBROKEN_FGETS -DLIBC_CALLS_STRTOK ++BUGS = ++#BUGS = -DGETPEERNAME_BUG -DBROKEN_FGETS -DLIBC_CALLS_STRTOK + #BUGS = -DGETPEERNAME_BUG -DBROKEN_FGETS -DINET_ADDR_BUG + #BUGS = -DGETPEERNAME_BUG -DBROKEN_FGETS -DSOLARIS_24_GETHOSTBYNAME_BUG + +@@ -464,7 +481,7 @@ BUGS = -DGETPEERNAME_BUG -DBROKEN_FGETS + # If your system supports NIS or YP-style netgroups, enable the following + # macro definition. Netgroups are used only for host access control. + # +-#NETGROUP= -DNETGROUP ++NETGROUP= -DNETGROUP + + ############################################################### + # System dependencies: whether or not your system has vsyslog() +@@ -491,7 +508,7 @@ VSYSLOG = -Dvsyslog=myvsyslog + # Uncomment the next definition to turn on the language extensions + # (examples: allow, deny, banners, twist and spawn). + # +-#STYLE = -DPROCESS_OPTIONS # Enable language extensions. ++STYLE = -DPROCESS_OPTIONS # Enable language extensions. + + ################################################################ + # Optional: Changing the default disposition of logfile records +@@ -514,7 +531,7 @@ VSYSLOG = -Dvsyslog=myvsyslog + # + # The LOG_XXX names below are taken from the /usr/include/syslog.h file. + +-FACILITY= LOG_MAIL # LOG_MAIL is what most sendmail daemons use ++FACILITY= LOG_DAEMON # LOG_MAIL is what most sendmail daemons use + + # The syslog priority at which successful connections are logged. + +@@ -610,7 +627,7 @@ TABLES = -DHOSTS_DENY=\"/etc/hosts.deny\ + # Paranoid mode implies hostname lookup. In order to disable hostname + # lookups altogether, see the next section. + +-PARANOID= -DPARANOID ++#PARANOID= -DPARANOID + + ######################################## + # Optional: turning off hostname lookups +@@ -623,7 +640,7 @@ PARANOID= -DPARANOID + # In order to perform selective hostname lookups, disable paranoid + # mode (see previous section) and comment out the following definition. + +-HOSTNAME= -DALWAYS_HOSTNAME ++#HOSTNAME= -DALWAYS_HOSTNAME + + ############################################# + # Optional: Turning on host ADDRESS checking +@@ -649,28 +666,46 @@ HOSTNAME= -DALWAYS_HOSTNAME + # source-routed traffic in the kernel. Examples: 4.4BSD derivatives, + # Solaris 2.x, and Linux. See your system documentation for details. + # +-# KILL_OPT= -DKILL_IP_OPTIONS ++KILL_OPT= -DKILL_IP_OPTIONS + + ## End configuration options + ############################ + + # Protection against weird shells or weird make programs. + ++CC = gcc + SHELL = /bin/sh +-.c.o:; $(CC) $(CFLAGS) -c $*.c ++.c.o:; $(CC) $(CFLAGS) -o $*.o -c $*.c ++ ++SOMAJOR = 0 ++SOMINOR = 7.6 ++ ++LIB = libwrap.a ++SHLIB = shared/libwrap.so.$(SOMAJOR).$(SOMINOR) ++SHLIBSOMAJ= shared/libwrap.so.$(SOMAJOR) ++SHLIBSO = shared/libwrap.so ++SHLIBFLAGS = -Lshared -lwrap + +-CFLAGS = -O -DFACILITY=$(FACILITY) $(ACCESS) $(PARANOID) $(NETGROUP) \ ++shared/%.o: %.c ++ $(CC) $(CFLAGS) $(SHCFLAGS) -c $< -o $@ ++ ++CFLAGS = -O2 -g -DFACILITY=$(FACILITY) $(ACCESS) $(PARANOID) $(NETGROUP) \ + $(BUGS) $(SYSTYPE) $(AUTH) $(UMASK) \ + -DREAL_DAEMON_DIR=\"$(REAL_DAEMON_DIR)\" $(STYLE) $(KILL_OPT) \ + -DSEVERITY=$(SEVERITY) -DRFC931_TIMEOUT=$(RFC931_TIMEOUT) \ + $(UCHAR) $(TABLES) $(STRINGS) $(TLI) $(EXTRA_CFLAGS) $(DOT) \ + $(VSYSLOG) $(HOSTNAME) + ++SHLINKFLAGS = -shared -Xlinker -soname -Xlinker libwrap.so.$(SOMAJOR) -lc $(LIBS) ++SHCFLAGS = -fPIC -shared -D_REENTRANT ++ + LIB_OBJ= hosts_access.o options.o shell_cmd.o rfc931.o eval.o \ + hosts_ctl.o refuse.o percent_x.o clean_exit.o $(AUX_OBJ) \ + $(FROM_OBJ) fix_options.o socket.o tli.o workarounds.o \ + update.o misc.o diag.o percent_m.o myvsyslog.o + ++SHLIB_OBJ= $(addprefix shared/, $(LIB_OBJ)); ++ + FROM_OBJ= fromhost.o + + KIT = README miscd.c tcpd.c fromhost.c hosts_access.c shell_cmd.c \ +@@ -684,46 +719,78 @@ KIT = README miscd.c tcpd.c fromhost.c h + refuse.c tcpdchk.8 setenv.c inetcf.c inetcf.h scaffold.c \ + scaffold.h tcpdmatch.8 README.NIS + +-LIB = libwrap.a +- +-all other: config-check tcpd tcpdmatch try-from safe_finger tcpdchk ++all other: config-check tcpd tcpdmatch try-from safe_finger tcpdchk $(LIB) + + # Invalidate all object files when the compiler options (CFLAGS) have changed. + + config-check: + @set +e; test -n "$(REAL_DAEMON_DIR)" || { make; exit 1; } +- @set +e; echo $(CFLAGS) >/tmp/cflags.$$$$ ; \ +- if cmp cflags /tmp/cflags.$$$$ ; \ +- then rm /tmp/cflags.$$$$ ; \ +- else mv /tmp/cflags.$$$$ cflags ; \ ++ @set +e; echo $(CFLAGS) >cflags.new ; \ ++ if cmp cflags cflags.new ; \ ++ then rm cflags.new ; \ ++ else mv cflags.new cflags ; \ + fi >/dev/null 2>/dev/null ++ @if [ ! -d shared ]; then mkdir shared; fi + + $(LIB): $(LIB_OBJ) + rm -f $(LIB) + $(AR) $(ARFLAGS) $(LIB) $(LIB_OBJ) + -$(RANLIB) $(LIB) + +-tcpd: tcpd.o $(LIB) +- $(CC) $(CFLAGS) -o $@ tcpd.o $(LIB) $(LIBS) ++$(SHLIB): $(SHLIB_OBJ) ++ rm -f $(SHLIB) ++ $(CC) -o $(SHLIB) $(SHLINKFLAGS) $(SHLIB_OBJ) ++ ln -s $(notdir $(SHLIB)) $(SHLIBSOMAJ) ++ ln -s $(notdir $(SHLIBSOMAJ)) $(SHLIBSO) ++ ++tcpd: tcpd.o $(SHLIB) ++ $(CC) $(CFLAGS) -o $@ tcpd.o $(SHLIBFLAGS) + +-miscd: miscd.o $(LIB) +- $(CC) $(CFLAGS) -o $@ miscd.o $(LIB) $(LIBS) ++miscd: miscd.o $(SHLIB) ++ $(CC) $(CFLAGS) -o $@ miscd.o $(SHLIBFLAGS) + +-safe_finger: safe_finger.o $(LIB) +- $(CC) $(CFLAGS) -o $@ safe_finger.o $(LIB) $(LIBS) ++safe_finger: safe_finger.o $(SHLIB) ++ $(CC) $(CFLAGS) -o $@ safe_finger.o $(SHLIBFLAGS) + + TCPDMATCH_OBJ = tcpdmatch.o fakelog.o inetcf.o scaffold.o + +-tcpdmatch: $(TCPDMATCH_OBJ) $(LIB) +- $(CC) $(CFLAGS) -o $@ $(TCPDMATCH_OBJ) $(LIB) $(LIBS) ++tcpdmatch: $(TCPDMATCH_OBJ) $(SHLIB) ++ $(CC) $(CFLAGS) -o $@ $(TCPDMATCH_OBJ) $(SHLIBFLAGS) + +-try-from: try-from.o fakelog.o $(LIB) +- $(CC) $(CFLAGS) -o $@ try-from.o fakelog.o $(LIB) $(LIBS) ++try-from: try-from.o fakelog.o $(SHLIB) ++ $(CC) $(CFLAGS) -o $@ try-from.o fakelog.o $(SHLIBFLAGS) + + TCPDCHK_OBJ = tcpdchk.o fakelog.o inetcf.o scaffold.o + +-tcpdchk: $(TCPDCHK_OBJ) $(LIB) +- $(CC) $(CFLAGS) -o $@ $(TCPDCHK_OBJ) $(LIB) $(LIBS) ++tcpdchk: $(TCPDCHK_OBJ) $(SHLIB) ++ $(CC) $(CFLAGS) -o $@ $(TCPDCHK_OBJ) $(SHLIBFLAGS) ++ ++install: install-lib install-bin install-dev ++ ++install-lib: ++ install -o root -g root -m 0644 $(SHLIB) ${DESTDIR}/lib/ ++ ln -s $(notdir $(SHLIB)) ${DESTDIR}/lib/$(notdir $(SHLIBSOMAJ)) ++ ++install-bin: ++ install -o root -g root -m 0755 tcpd ${DESTDIR}/usr/sbin/ ++ install -o root -g root -m 0755 tcpdchk ${DESTDIR}/usr/sbin/ ++ install -o root -g root -m 0755 tcpdmatch ${DESTDIR}/usr/sbin/ ++ install -o root -g root -m 0755 try-from ${DESTDIR}/usr/sbin/ ++ install -o root -g root -m 0755 safe_finger ${DESTDIR}/usr/sbin/ ++ install -o root -g root -m 0644 tcpd.8 ${DESTDIR}/usr/share/man/man8/ ++ install -o root -g root -m 0644 tcpdchk.8 ${DESTDIR}/usr/share/man/man8/ ++ install -o root -g root -m 0644 tcpdmatch.8 ${DESTDIR}/usr/share/man/man8/ ++ install -o root -g root -m 0644 hosts_access.5 ${DESTDIR}/usr/share/man/man5/ ++ install -o root -g root -m 0644 hosts_options.5 ${DESTDIR}/usr/share/man/man5/ ++ ++install-dev: ++ ln -s /lib/$(notdir $(SHLIBSOMAJ)) ${DESTDIR}/usr/lib/$(notdir $(SHLIBSO)) ++ install -o root -g root -m 0644 hosts_access.3 ${DESTDIR}/usr/share/man/man3/ ++ install -o root -g root -m 0644 tcpd.h ${DESTDIR}/usr/include/ ++ install -o root -g root -m 0644 $(LIB) ${DESTDIR}/usr/lib/ ++ ln -s hosts_access.3 ${DESTDIR}/usr/share/man/man3/hosts_ctl.3 ++ ln -s hosts_access.3 ${DESTDIR}/usr/share/man/man3/request_init.3 ++ ln -s hosts_access.3 ${DESTDIR}/usr/share/man/man3/request_set.3 + + shar: $(KIT) + @shar $(KIT) +@@ -739,7 +806,8 @@ archive: + + clean: + rm -f tcpd miscd safe_finger tcpdmatch tcpdchk try-from *.[oa] core \ +- cflags ++ cflags libwrap*.so* ++ rm -rf shared + + tidy: clean + chmod -R a+r . +@@ -885,5 +953,6 @@ update.o: cflags + update.o: mystdarg.h + update.o: tcpd.h + vfprintf.o: cflags ++weak_symbols.o: tcpd.h + workarounds.o: cflags + workarounds.o: tcpd.h +--- a/hosts_access.5 ++++ b/hosts_access.5 +@@ -8,9 +8,9 @@ name, host name/address) patterns. Exam + impatient reader is encouraged to skip to the EXAMPLES section for a + quick introduction. + .PP +-An extended version of the access control language is described in the +-\fIhosts_options\fR(5) document. The extensions are turned on at +-program build time by building with -DPROCESS_OPTIONS. ++The extended version of the access control language is described in the ++\fIhosts_options\fR(5) document. \fBNote that this language supersedes ++the meaning of \fIshell_command\fB as documented below.\fR + .PP + In the following text, \fIdaemon\fR is the the process name of a + network daemon process, and \fIclient\fR is the name and/or address of +@@ -40,7 +40,7 @@ A newline character is ignored when it i + character. This permits you to break up long lines so that they are + easier to edit. + .IP \(bu +-Blank lines or lines that begin with a `#\' character are ignored. ++Blank lines or lines that begin with a `#' character are ignored. + This permits you to insert comments and whitespace so that the tables + are easier to read. + .IP \(bu +@@ -69,26 +69,33 @@ checks are case insensitive. + .SH PATTERNS + The access control language implements the following patterns: + .IP \(bu +-A string that begins with a `.\' character. A host name is matched if ++A string that begins with a `.' character. A host name is matched if + the last components of its name match the specified pattern. For +-example, the pattern `.tue.nl\' matches the host name +-`wzv.win.tue.nl\'. ++example, the pattern `.tue.nl' matches the host name ++`wzv.win.tue.nl'. + .IP \(bu +-A string that ends with a `.\' character. A host address is matched if ++A string that ends with a `.' character. A host address is matched if + its first numeric fields match the given string. For example, the +-pattern `131.155.\' matches the address of (almost) every host on the ++pattern `131.155.' matches the address of (almost) every host on the + Eind\%hoven University network (131.155.x.x). + .IP \(bu +-A string that begins with an `@\' character is treated as an NIS ++A string that begins with an `@' character is treated as an NIS + (formerly YP) netgroup name. A host name is matched if it is a host + member of the specified netgroup. Netgroup matches are not supported + for daemon process names or for client user names. + .IP \(bu +-An expression of the form `n.n.n.n/m.m.m.m\' is interpreted as a +-`net/mask\' pair. A host address is matched if `net\' is equal to the +-bitwise AND of the address and the `mask\'. For example, the net/mask +-pattern `131.155.72.0/255.255.254.0\' matches every address in the +-range `131.155.72.0\' through `131.155.73.255\'. ++An expression of the form `n.n.n.n/m.m.m.m' is interpreted as a ++`net/mask' pair. A host address is matched if `net' is equal to the ++bitwise AND of the address and the `mask'. For example, the net/mask ++pattern `131.155.72.0/255.255.254.0' matches every address in the ++range `131.155.72.0' through `131.155.73.255'. ++.IP \(bu ++A string that begins with a `/' character is treated as a file ++name. A host name or address is matched if it matches any host name ++or address pattern listed in the named file. The file format is ++zero or more lines with zero or more host name or address patterns ++separated by whitespace. A file name pattern can be used anywhere ++a host name or address pattern can be used. + .SH WILDCARDS + The access control language supports explicit wildcards: + .IP ALL +@@ -115,19 +122,19 @@ without -DPARANOID when you want more co + .ne 6 + .SH OPERATORS + .IP EXCEPT +-Intended use is of the form: `list_1 EXCEPT list_2\'; this construct ++Intended use is of the form: `list_1 EXCEPT list_2'; this construct + matches anything that matches \fIlist_1\fR unless it matches + \fIlist_2\fR. The EXCEPT operator can be used in daemon_lists and in + client_lists. The EXCEPT operator can be nested: if the control +-language would permit the use of parentheses, `a EXCEPT b EXCEPT c\' +-would parse as `(a EXCEPT (b EXCEPT c))\'. ++language would permit the use of parentheses, `a EXCEPT b EXCEPT c' ++would parse as `(a EXCEPT (b EXCEPT c))'. + .br + .ne 6 + .SH SHELL COMMANDS + If the first-matched access control rule contains a shell command, that + command is subjected to % substitutions (see next section). + The result is executed by a \fI/bin/sh\fR child process with standard +-input, output and error connected to \fI/dev/null\fR. Specify an `&\' ++input, output and error connected to \fI/dev/null\fR. Specify an `&' + at the end of the command if you do not want to wait until it has + completed. + .PP +@@ -159,7 +166,7 @@ depending on how much information is ava + .IP %u + The client user name (or "unknown"). + .IP %% +-Expands to a single `%\' character. ++Expands to a single `%' character. + .PP + Characters in % expansions that may confuse the shell are replaced by + underscores. +@@ -243,9 +250,9 @@ A positive IDENT lookup result (the clie + less trustworthy. It is possible for an intruder to spoof both the + client connection and the IDENT lookup, although doing so is much + harder than spoofing just a client connection. It may also be that +-the client\'s IDENT server is lying. ++the client's IDENT server is lying. + .PP +-Note: IDENT lookups don\'t work with UDP services. ++Note: IDENT lookups don't work with UDP services. + .SH EXAMPLES + The language is flexible enough that different types of access control + policy can be expressed with a minimum of fuss. Although the language +@@ -285,7 +292,7 @@ ALL: LOCAL @some_netgroup + .br + ALL: .foobar.edu EXCEPT terminalserver.foobar.edu + .PP +-The first rule permits access from hosts in the local domain (no `.\' ++The first rule permits access from hosts in the local domain (no `.' + in the host name) and from members of the \fIsome_netgroup\fP + netgroup. The second rule permits access from all hosts in the + \fIfoobar.edu\fP domain (notice the leading dot), with the exception of +@@ -322,8 +329,8 @@ in.tftpd: LOCAL, .my.domain + /etc/hosts.deny: + .in +3 + .nf +-in.tftpd: ALL: (/some/where/safe_finger -l @%h | \\ +- /usr/ucb/mail -s %d-%h root) & ++in.tftpd: ALL: (/usr/sbin/safe_finger -l @%h | \\ ++ /usr/bin/mail -s %d-%h root) & + .fi + .PP + The safe_finger command comes with the tcpd wrapper and should be +@@ -349,7 +356,7 @@ control rule; when the length of an acce + capacity of an internal buffer; when an access control rule is not + terminated by a newline character; when the result of % + expansion would overflow an internal buffer; when a system call fails +-that shouldn\'t. All problems are reported via the syslog daemon. ++that shouldn't. All problems are reported via the syslog daemon. + .SH FILES + .na + .nf +--- a/rfc931.c ++++ b/rfc931.c +@@ -33,7 +33,7 @@ static char sccsid[] = "@(#) rfc931.c 1. + + int rfc931_timeout = RFC931_TIMEOUT;/* Global so it can be changed */ + +-static jmp_buf timebuf; ++static sigjmp_buf timebuf; + + /* fsocket - open stdio stream on top of socket */ + +@@ -62,7 +62,7 @@ int protocol; + static void timeout(sig) + int sig; + { +- longjmp(timebuf, sig); ++ siglongjmp(timebuf, sig); + } + + /* rfc931 - return remote user name, given socket structures */ +@@ -99,7 +99,7 @@ char *dest; + * Set up a timer so we won't get stuck while waiting for the server. + */ + +- if (setjmp(timebuf) == 0) { ++ if (sigsetjmp(timebuf,1) == 0) { + signal(SIGALRM, timeout); + alarm(rfc931_timeout); + +--- a/tcpd.8 ++++ b/tcpd.8 +@@ -94,7 +94,7 @@ configuration files. + .PP + The example assumes that the network daemons live in /usr/etc. On some + systems, network daemons live in /usr/sbin or in /usr/libexec, or have +-no `in.\' prefix to their name. ++no `in.' prefix to their name. + .SH EXAMPLE 2 + This example applies when \fItcpd\fR expects that the network daemons + are left in their original place. +@@ -110,26 +110,26 @@ finger stream tcp nowait nobody /us + becomes: + .sp + .ti +5 +-finger stream tcp nowait nobody /some/where/tcpd in.fingerd ++finger stream tcp nowait nobody /usr/sbin/tcpd in.fingerd + .sp + .fi + .PP + The example assumes that the network daemons live in /usr/etc. On some + systems, network daemons live in /usr/sbin or in /usr/libexec, the +-daemons have no `in.\' prefix to their name, or there is no userid ++daemons have no `in.' prefix to their name, or there is no userid + field in the inetd configuration file. + .PP + Similar changes will be needed for the other services that are to be +-covered by \fItcpd\fR. Send a `kill -HUP\' to the \fIinetd\fR(8) ++covered by \fItcpd\fR. Send a `kill -HUP' to the \fIinetd\fR(8) + process to make the changes effective. AIX users may also have to +-execute the `inetimp\' command. ++execute the `inetimp' command. + .SH EXAMPLE 3 + In the case of daemons that do not live in a common directory ("secret" + or otherwise), edit the \fIinetd\fR configuration file so that it + specifies an absolute path name for the process name field. For example: + .nf + .sp +- ntalk dgram udp wait root /some/where/tcpd /usr/local/lib/ntalkd ++ ntalk dgram udp wait root /usr/sbin/tcpd /usr/sbin/in.ntalkd + .sp + .fi + .PP +--- a/hosts_access.3 ++++ b/hosts_access.3 +@@ -3,7 +3,7 @@ + hosts_access, hosts_ctl, request_init, request_set \- access control library + .SH SYNOPSIS + .nf +-#include "tcpd.h" ++#include + + extern int allow_severity; + extern int deny_severity; +--- a/options.c ++++ b/options.c +@@ -473,6 +473,9 @@ static struct syslog_names log_fac[] = { + #ifdef LOG_CRON + "cron", LOG_CRON, + #endif ++#ifdef LOG_FTP ++ "ftp", LOG_FTP, ++#endif + #ifdef LOG_LOCAL0 + "local0", LOG_LOCAL0, + #endif +--- a/fix_options.c ++++ b/fix_options.c +@@ -35,7 +35,12 @@ struct request_info *request; + #ifdef IP_OPTIONS + unsigned char optbuf[BUFFER_SIZE / 3], *cp; + char lbuf[BUFFER_SIZE], *lp; ++#if !defined(__GLIBC__) + int optsize = sizeof(optbuf), ipproto; ++#else /* __GLIBC__ */ ++ size_t optsize = sizeof(optbuf); ++ int ipproto; ++#endif /* __GLIBC__ */ + struct protoent *ip; + int fd = request->fd; + unsigned int opt; +--- a/workarounds.c ++++ b/workarounds.c +@@ -163,7 +163,11 @@ int *fromlen; + int fix_getpeername(sock, sa, len) + int sock; + struct sockaddr *sa; ++#if !defined(__GLIBC__) + int *len; ++#else /* __GLIBC__ */ ++size_t *len; ++#endif /* __GLIBC__ */ + { + int ret; + struct sockaddr_in *sin = (struct sockaddr_in *) sa; +--- a/socket.c ++++ b/socket.c +@@ -76,7 +76,11 @@ struct request_info *request; + { + static struct sockaddr_in client; + static struct sockaddr_in server; ++#if !defined (__GLIBC__) + int len; ++#else /* __GLIBC__ */ ++ size_t len; ++#endif /* __GLIBC__ */ + char buf[BUFSIZ]; + int fd = request->fd; + +@@ -224,7 +228,11 @@ int fd; + { + char buf[BUFSIZ]; + struct sockaddr_in sin; ++#if !defined(__GLIBC__) + int size = sizeof(sin); ++#else /* __GLIBC__ */ ++ size_t size = sizeof(sin); ++#endif /* __GLIBC__ */ + + /* + * Eat up the not-yet received datagram. Some systems insist on a +--- a/safe_finger.c ++++ b/safe_finger.c +@@ -26,21 +26,24 @@ static char sccsid[] = "@(#) safe_finger + #include + #include + #include ++#include + + extern void exit(); + + /* Local stuff */ + +-char path[] = "PATH=/bin:/usr/bin:/usr/ucb:/usr/bsd:/etc:/usr/etc:/usr/sbin"; ++char path[] = "PATH=/bin:/usr/bin:/sbin:/usr/sbin"; + + #define TIME_LIMIT 60 /* Do not keep listinging forever */ + #define INPUT_LENGTH 100000 /* Do not keep listinging forever */ + #define LINE_LENGTH 128 /* Editors can choke on long lines */ + #define FINGER_PROGRAM "finger" /* Most, if not all, UNIX systems */ + #define UNPRIV_NAME "nobody" /* Preferred privilege level */ +-#define UNPRIV_UGID 32767 /* Default uid and gid */ ++#define UNPRIV_UGID 65534 /* Default uid and gid */ + + int finger_pid; ++int allow_severity = SEVERITY; ++int deny_severity = LOG_WARNING; + + void cleanup(sig) + int sig; +--- a/hosts_options.5 ++++ b/hosts_options.5 +@@ -58,12 +58,12 @@ Notice the leading dot on the domain nam + Execute, in a child process, the specified shell command, after + performing the % expansions described in the hosts_access(5) + manual page. The command is executed with stdin, stdout and stderr +-connected to the null device, so that it won\'t mess up the ++connected to the null device, so that it won't mess up the + conversation with the client host. Example: + .sp + .nf + .ti +3 +-spawn (/some/where/safe_finger -l @%h | /usr/ucb/mail root) & ++spawn (/usr/sbin/safe_finger -l @%h | /usr/bin/mail root) & + .fi + .sp + executes, in a background child process, the shell command "safe_finger +--- a/tcpdchk.c ++++ b/tcpdchk.c +@@ -350,6 +350,8 @@ char *pat; + { + if (pat[0] == '@') { + tcpd_warn("%s: daemon name begins with \"@\"", pat); ++ } else if (pat[0] == '/') { ++ tcpd_warn("%s: daemon name begins with \"/\"", pat); + } else if (pat[0] == '.') { + tcpd_warn("%s: daemon name begins with dot", pat); + } else if (pat[strlen(pat) - 1] == '.') { +@@ -382,6 +384,8 @@ char *pat; + { + if (pat[0] == '@') { /* @netgroup */ + tcpd_warn("%s: user name begins with \"@\"", pat); ++ } else if (pat[0] == '/') { ++ tcpd_warn("%s: user name begins with \"/\"", pat); + } else if (pat[0] == '.') { + tcpd_warn("%s: user name begins with dot", pat); + } else if (pat[strlen(pat) - 1] == '.') { +@@ -402,8 +406,13 @@ char *pat; + static int check_host(pat) + char *pat; + { ++ char buf[BUFSIZ]; + char *mask; + int addr_count = 1; ++ FILE *fp; ++ struct tcpd_context saved_context; ++ char *cp; ++ char *wsp = " \t\r\n"; + + if (pat[0] == '@') { /* @netgroup */ + #ifdef NO_NETGRENT +@@ -422,6 +431,21 @@ char *pat; + tcpd_warn("netgroup support disabled"); + #endif + #endif ++ } else if (pat[0] == '/') { /* /path/name */ ++ if ((fp = fopen(pat, "r")) != 0) { ++ saved_context = tcpd_context; ++ tcpd_context.file = pat; ++ tcpd_context.line = 0; ++ while (fgets(buf, sizeof(buf), fp)) { ++ tcpd_context.line++; ++ for (cp = strtok(buf, wsp); cp; cp = strtok((char *) 0, wsp)) ++ check_host(cp); ++ } ++ tcpd_context = saved_context; ++ fclose(fp); ++ } else if (errno != ENOENT) { ++ tcpd_warn("open %s: %m", pat); ++ } + } else if (mask = split_at(pat, '/')) { /* network/netmask */ + if (dot_quad_addr(pat) == INADDR_NONE + || dot_quad_addr(mask) == INADDR_NONE) +--- a/percent_m.c ++++ b/percent_m.c +@@ -13,7 +13,7 @@ static char sccsid[] = "@(#) percent_m.c + #include + + extern int errno; +-#ifndef SYS_ERRLIST_DEFINED ++#if !defined(SYS_ERRLIST_DEFINED) && !defined(HAVE_STRERROR) + extern char *sys_errlist[]; + extern int sys_nerr; + #endif +@@ -29,11 +29,15 @@ char *ibuf; + + while (*bp = *cp) + if (*cp == '%' && cp[1] == 'm') { ++#ifdef HAVE_STRERROR ++ strcpy(bp, strerror(errno)); ++#else + if (errno < sys_nerr && errno > 0) { + strcpy(bp, sys_errlist[errno]); + } else { + sprintf(bp, "Unknown error %d", errno); + } ++#endif + bp += strlen(bp); + cp += 2; + } else { +--- a/scaffold.c ++++ b/scaffold.c +@@ -180,10 +180,12 @@ struct request_info *request; + + /* ARGSUSED */ + +-void rfc931(request) +-struct request_info *request; ++void rfc931(rmt_sin, our_sin, dest) ++struct sockaddr_in *rmt_sin; ++struct sockaddr_in *our_sin; ++char *dest; + { +- strcpy(request->user, unknown); ++ strcpy(dest, unknown); + } + + /* check_path - examine accessibility */ +--- /dev/null ++++ b/weak_symbols.c +@@ -0,0 +1,11 @@ ++ /* ++ * @(#) weak_symbols.h 1.5 99/12/29 23:50 ++ * ++ * Author: Anthony Towns ++ */ ++ ++#ifdef HAVE_WEAKSYMS ++#include ++int deny_severity = LOG_WARNING; ++int allow_severity = SEVERITY; ++#endif diff --git a/package/libs/tcp_wrappers/patches/002-opt_cflags.patch b/package/libs/tcp_wrappers/patches/002-opt_cflags.patch new file mode 100644 index 0000000000..1f38eb3fef --- /dev/null +++ b/package/libs/tcp_wrappers/patches/002-opt_cflags.patch @@ -0,0 +1,12 @@ +--- a/Makefile ++++ b/Makefile +@@ -689,7 +689,8 @@ SHLIBFLAGS = -Lshared -lwrap + shared/%.o: %.c + $(CC) $(CFLAGS) $(SHCFLAGS) -c $< -o $@ + +-CFLAGS = -O2 -g -DFACILITY=$(FACILITY) $(ACCESS) $(PARANOID) $(NETGROUP) \ ++OPT_CFLAGS = -O2 -g ++CFLAGS = $(OPT_CFLAGS) -DFACILITY=$(FACILITY) $(ACCESS) $(PARANOID) $(NETGROUP) \ + $(BUGS) $(SYSTYPE) $(AUTH) $(UMASK) \ + -DREAL_DAEMON_DIR=\"$(REAL_DAEMON_DIR)\" $(STYLE) $(KILL_OPT) \ + -DSEVERITY=$(SEVERITY) -DRFC931_TIMEOUT=$(RFC931_TIMEOUT) \ diff --git a/package/libs/tcp_wrappers/patches/003-scaffold_malloc.patch b/package/libs/tcp_wrappers/patches/003-scaffold_malloc.patch new file mode 100644 index 0000000000..ecda5ae96d --- /dev/null +++ b/package/libs/tcp_wrappers/patches/003-scaffold_malloc.patch @@ -0,0 +1,17 @@ +--- a/scaffold.c ++++ b/scaffold.c +@@ -20,13 +20,12 @@ static char sccs_id[] = "@(#) scaffold.c + #include + #include + #include ++#include + + #ifndef INADDR_NONE + #define INADDR_NONE (-1) /* XXX should be 0xffffffff */ + #endif + +-extern char *malloc(); +- + /* Application-specific. */ + + #include "tcpd.h" diff --git a/package/libs/tcp_wrappers/patches/004-ipv4_prefix.patch b/package/libs/tcp_wrappers/patches/004-ipv4_prefix.patch new file mode 100644 index 0000000000..29c9cefcad --- /dev/null +++ b/package/libs/tcp_wrappers/patches/004-ipv4_prefix.patch @@ -0,0 +1,72 @@ +--- a/hosts_access.5 ++++ b/hosts_access.5 +@@ -90,6 +90,9 @@ bitwise AND of the address and the `mask + pattern `131.155.72.0/255.255.254.0' matches every address in the + range `131.155.72.0' through `131.155.73.255'. + .IP \(bu ++An expression of the form `n.n.n.n/m\' is interpreted as a ++`net/prefixlen\' pair, as below, for IPv4 addresses. ++.IP \(bu + A string that begins with a `/' character is treated as a file + name. A host name or address is matched if it matches any host name + or address pattern listed in the named file. The file format is +--- a/tcpd.h ++++ b/tcpd.h +@@ -93,6 +93,7 @@ extern void refuse __P((struct request_i + extern char *xgets __P((char *, int, FILE *)); /* fgets() on steroids */ + extern char *split_at __P((char *, int)); /* strchr() and split */ + extern unsigned long dot_quad_addr __P((char *)); /* restricted inet_addr() */ ++extern unsigned long prefix_to_netmask __P((char *)); /* 0-32 prefix length */ + + /* Global variables. */ + +--- a/misc.c ++++ b/misc.c +@@ -14,6 +14,8 @@ static char sccsic[] = "@(#) misc.c 1.2 + #include + #include + #include ++#include ++#include + + #include "tcpd.h" + +@@ -85,3 +87,22 @@ char *str; + } + return (runs == 4 ? inet_addr(str) : INADDR_NONE); + } ++ ++/* prefix_to_netmask - convert prefix (0-32) to netmask */ ++ ++unsigned long prefix_to_netmask(str) ++char *str; ++{ ++ unsigned long prefix; ++ char *endptr; ++ ++ if (!isdigit(str[0])) ++ return INADDR_NONE; ++ ++ prefix = strtoul(str, &endptr, 10); ++ if ((endptr == str) || (*endptr != '\0') || (prefix > 32)) ++ return INADDR_NONE; ++ ++ return htonl(~0UL << (32 - prefix)); ++} ++ +--- a/hosts_access.c ++++ b/hosts_access.c +@@ -345,7 +345,12 @@ char *string; + if ((addr = dot_quad_addr(string)) == INADDR_NONE) + return (NO); + if ((net = dot_quad_addr(net_tok)) == INADDR_NONE +- || (mask = dot_quad_addr(mask_tok)) == INADDR_NONE) { ++ || ((mask = dot_quad_addr(mask_tok)) == INADDR_NONE ++ && strcmp(mask_tok, "255.255.255.255") ++ && (mask = prefix_to_netmask(mask_tok)) == INADDR_NONE ++ && strcmp(mask_tok, "32"))) { ++ /* 255.255.255.255 == INADDR_NONE, separate check needed. TJ. */ ++ /* 32 == INADDR_NONE, separate check needed. philipp */ + tcpd_warn("bad net/mask expression: %s/%s", net_tok, mask_tok); + return (NO); /* not tcpd_jump() */ + } diff --git a/package/libs/tcp_wrappers/patches/005-no--lnsl-on-musl.patch b/package/libs/tcp_wrappers/patches/005-no--lnsl-on-musl.patch new file mode 100644 index 0000000000..5e7b968dde --- /dev/null +++ b/package/libs/tcp_wrappers/patches/005-no--lnsl-on-musl.patch @@ -0,0 +1,22 @@ +Index: tcp_wrappers_7.6/Makefile +=================================================================== +--- tcp_wrappers_7.6.orig/Makefile ++++ tcp_wrappers_7.6/Makefile +@@ -1,4 +1,4 @@ +-GLIBC=$(shell grep -s -c __GLIBC__ /usr/include/features.h) ++GLIBC=$(shell grep -s -c __GLIBC__ ${STAGING_DIR}/usr/include/features.h) + + # @(#) Makefile 1.23 97/03/21 19:27:20 + +@@ -146,9 +146,11 @@ freebsd: + LIBS= RANLIB=ranlib ARFLAGS=rv AUX_OBJ= NETGROUP= TLI= \ + EXTRA_CFLAGS=-DSYS_ERRLIST_DEFINED VSYSLOG= all + ++ifneq ($(GLIBC),) + ifneq ($(GLIBC),0) + MYLIB=-lnsl + endif ++endif + + linux: + @make REAL_DAEMON_DIR=$(REAL_DAEMON_DIR) STYLE=$(STYLE) \ diff --git a/package/libs/tcp_wrappers/patches/006-compilation-warnings.patch b/package/libs/tcp_wrappers/patches/006-compilation-warnings.patch new file mode 100644 index 0000000000..5cbd358aa7 --- /dev/null +++ b/package/libs/tcp_wrappers/patches/006-compilation-warnings.patch @@ -0,0 +1,765 @@ +diff -u tcp_wrappers_7.6.orig/clean_exit.c tcp_wrappers_7.6/clean_exit.c +--- tcp_wrappers_7.6.orig/clean_exit.c 1994-12-29 03:42:20.000000000 +1100 ++++ tcp_wrappers_7.6/clean_exit.c 2017-11-14 22:50:48.000000000 +1100 +@@ -9,10 +9,11 @@ + */ + + #ifndef lint +-static char sccsid[] = "@(#) clean_exit.c 1.4 94/12/28 17:42:19"; ++static char sccsid[] __attribute__((__unused__)) = "@(#) clean_exit.c 1.4 94/12/28 17:42:19"; + #endif + + #include ++#include + + extern void exit(); + +diff -u tcp_wrappers_7.6.orig/diag.c tcp_wrappers_7.6/diag.c +--- tcp_wrappers_7.6.orig/diag.c 1994-12-29 03:42:20.000000000 +1100 ++++ tcp_wrappers_7.6/diag.c 2017-11-14 22:51:09.000000000 +1100 +@@ -10,7 +10,7 @@ + */ + + #ifndef lint +-static char sccsid[] = "@(#) diag.c 1.1 94/12/28 17:42:20"; ++static char sccsid[] __attribute__((__unused__)) = "@(#) diag.c 1.1 94/12/28 17:42:20"; + #endif + + /* System libraries */ +diff -u tcp_wrappers_7.6.orig/eval.c tcp_wrappers_7.6/eval.c +--- tcp_wrappers_7.6.orig/eval.c 1995-01-31 05:51:46.000000000 +1100 ++++ tcp_wrappers_7.6/eval.c 2017-11-14 22:51:50.000000000 +1100 +@@ -19,7 +19,7 @@ + */ + + #ifndef lint +-static char sccsid[] = "@(#) eval.c 1.3 95/01/30 19:51:45"; ++static char sccsid[] __attribute__((__unused__)) = "@(#) eval.c 1.3 95/01/30 19:51:45"; + #endif + + /* System libraries. */ +diff -u tcp_wrappers_7.6.orig/fakelog.c tcp_wrappers_7.6/fakelog.c +--- tcp_wrappers_7.6.orig/fakelog.c 1994-12-29 03:42:22.000000000 +1100 ++++ tcp_wrappers_7.6/fakelog.c 2017-11-14 22:52:07.000000000 +1100 +@@ -6,7 +6,7 @@ + */ + + #ifndef lint +-static char sccsid[] = "@(#) fakelog.c 1.3 94/12/28 17:42:21"; ++static char sccsid[] __attribute__((__unused__)) = "@(#) fakelog.c 1.3 94/12/28 17:42:21"; + #endif + + #include +@@ -17,7 +17,7 @@ + + /* ARGSUSED */ + +-openlog(name, logopt, facility) ++void openlog(name, logopt, facility) + char *name; + int logopt; + int facility; +@@ -27,7 +27,7 @@ + + /* vsyslog - format one record */ + +-vsyslog(severity, fmt, ap) ++void vsyslog(severity, fmt, ap) + int severity; + char *fmt; + va_list ap; +@@ -43,7 +43,7 @@ + + /* VARARGS */ + +-VARARGS(syslog, int, severity) ++void VARARGS(syslog, int, severity) + { + va_list ap; + char *fmt; +@@ -56,7 +56,7 @@ + + /* closelog - dummy */ + +-closelog() ++void closelog() + { + /* void */ + } +diff -u tcp_wrappers_7.6.orig/fix_options.c tcp_wrappers_7.6/fix_options.c +--- tcp_wrappers_7.6.orig/fix_options.c 2017-11-13 09:29:08.000000000 +1100 ++++ tcp_wrappers_7.6/fix_options.c 2017-11-14 22:52:22.000000000 +1100 +@@ -6,7 +6,7 @@ + */ + + #ifndef lint +-static char sccsid[] = "@(#) fix_options.c 1.6 97/04/08 02:29:19"; ++static char sccsid[] __attribute__((__unused__)) = "@(#) fix_options.c 1.6 97/04/08 02:29:19"; + #endif + + #include +@@ -29,14 +29,14 @@ + + /* fix_options - get rid of IP-level socket options */ + +-fix_options(request) +-struct request_info *request; ++void fix_options(request) ++struct request_info *request; + { + #ifdef IP_OPTIONS + unsigned char optbuf[BUFFER_SIZE / 3], *cp; + char lbuf[BUFFER_SIZE], *lp; + #if !defined(__GLIBC__) +- int optsize = sizeof(optbuf), ipproto; ++ unsigned int optsize = sizeof(optbuf), ipproto; + #else /* __GLIBC__ */ + size_t optsize = sizeof(optbuf); + int ipproto; +diff -u tcp_wrappers_7.6.orig/fromhost.c tcp_wrappers_7.6/fromhost.c +--- tcp_wrappers_7.6.orig/fromhost.c 1994-12-29 03:42:24.000000000 +1100 ++++ tcp_wrappers_7.6/fromhost.c 2017-11-14 22:52:33.000000000 +1100 +@@ -11,7 +11,7 @@ + */ + + #ifndef lint +-static char sccsid[] = "@(#) fromhost.c 1.17 94/12/28 17:42:23"; ++static char sccsid[] __attribute__((__unused__)) = "@(#) fromhost.c 1.17 94/12/28 17:42:23"; + #endif + + #if defined(TLI) || defined(PTX) || defined(TLI_SEQUENT) +diff -u tcp_wrappers_7.6.orig/hosts_access.c tcp_wrappers_7.6/hosts_access.c +--- tcp_wrappers_7.6.orig/hosts_access.c 2017-11-13 09:29:25.000000000 +1100 ++++ tcp_wrappers_7.6/hosts_access.c 2017-11-14 22:52:48.000000000 +1100 +@@ -18,7 +18,7 @@ + */ + + #ifndef lint +-static char sccsid[] = "@(#) hosts_access.c 1.21 97/02/12 02:13:22"; ++static char sccsid[] __attribute__((__unused__)) = "@(#) hosts_access.c 1.21 97/02/12 02:13:22"; + #endif + + /* System libraries. */ +diff -u tcp_wrappers_7.6.orig/hosts_ctl.c tcp_wrappers_7.6/hosts_ctl.c +--- tcp_wrappers_7.6.orig/hosts_ctl.c 1994-12-29 03:42:28.000000000 +1100 ++++ tcp_wrappers_7.6/hosts_ctl.c 2017-11-14 22:53:01.000000000 +1100 +@@ -12,7 +12,7 @@ + */ + + #ifndef lint +-static char sccsid[] = "@(#) hosts_ctl.c 1.4 94/12/28 17:42:27"; ++static char sccsid[] __attribute__((__unused__)) = "@(#) hosts_ctl.c 1.4 94/12/28 17:42:27"; + #endif + + #include +diff -u tcp_wrappers_7.6.orig/inetcf.c tcp_wrappers_7.6/inetcf.c +--- tcp_wrappers_7.6.orig/inetcf.c 1997-02-12 12:13:24.000000000 +1100 ++++ tcp_wrappers_7.6/inetcf.c 2017-11-14 22:53:11.000000000 +1100 +@@ -6,7 +6,7 @@ + */ + + #ifndef lint +-static char sccsid[] = "@(#) inetcf.c 1.7 97/02/12 02:13:23"; ++static char sccsid[] __attribute__((__unused__)) = "@(#) inetcf.c 1.7 97/02/12 02:13:23"; + #endif + + #include +@@ -14,6 +14,7 @@ + #include + #include + #include ++#include + + extern int errno; + extern void exit(); +@@ -21,6 +22,8 @@ + #include "tcpd.h" + #include "inetcf.h" + ++extern int check_path(char *, struct stat *); ++ + /* + * Network configuration files may live in unusual places. Here are some + * guesses. Shorter names follow longer ones. +diff -u tcp_wrappers_7.6.orig/misc.c tcp_wrappers_7.6/misc.c +--- tcp_wrappers_7.6.orig/misc.c 2017-11-13 09:29:25.000000000 +1100 ++++ tcp_wrappers_7.6/misc.c 2017-11-14 22:53:23.000000000 +1100 +@@ -5,7 +5,7 @@ + */ + + #ifndef lint +-static char sccsic[] = "@(#) misc.c 1.2 96/02/11 17:01:29"; ++static char sccsid[] __attribute__((__unused__)) = "@(#) misc.c 1.2 96/02/11 17:01:29"; + #endif + + #include +diff -u tcp_wrappers_7.6.orig/myvsyslog.c tcp_wrappers_7.6/myvsyslog.c +--- tcp_wrappers_7.6.orig/myvsyslog.c 1994-12-29 03:42:34.000000000 +1100 ++++ tcp_wrappers_7.6/myvsyslog.c 2017-11-14 22:53:35.000000000 +1100 +@@ -8,7 +8,7 @@ + */ + + #ifndef lint +-static char sccsid[] = "@(#) myvsyslog.c 1.1 94/12/28 17:42:33"; ++static char sccsid[] __attribute__((__unused__)) = "@(#) myvsyslog.c 1.1 94/12/28 17:42:33"; + #endif + + #ifdef vsyslog +diff -u tcp_wrappers_7.6.orig/options.c tcp_wrappers_7.6/options.c +--- tcp_wrappers_7.6.orig/options.c 2017-11-13 09:29:08.000000000 +1100 ++++ tcp_wrappers_7.6/options.c 2017-11-14 22:53:50.000000000 +1100 +@@ -29,7 +29,7 @@ + */ + + #ifndef lint +-static char sccsid[] = "@(#) options.c 1.17 96/02/11 17:01:31"; ++static char sccsid[] __attribute__((__unused__)) = "@(#) options.c 1.17 96/02/11 17:01:31"; + #endif + + /* System libraries. */ +@@ -47,6 +47,8 @@ + #include + #include + #include ++#include ++#include + + #ifndef MAXPATHNAMELEN + #define MAXPATHNAMELEN BUFSIZ +@@ -108,21 +110,21 @@ + /* List of known keywords. Add yours here. */ + + static struct option option_table[] = { +- "user", user_option, NEED_ARG, +- "group", group_option, NEED_ARG, +- "umask", umask_option, NEED_ARG, +- "linger", linger_option, NEED_ARG, +- "keepalive", keepalive_option, 0, +- "spawn", spawn_option, NEED_ARG | EXPAND_ARG, +- "twist", twist_option, NEED_ARG | EXPAND_ARG | USE_LAST, +- "rfc931", rfc931_option, OPT_ARG, +- "setenv", setenv_option, NEED_ARG | EXPAND_ARG, +- "nice", nice_option, OPT_ARG, +- "severity", severity_option, NEED_ARG, +- "allow", allow_option, USE_LAST, +- "deny", deny_option, USE_LAST, +- "banners", banners_option, NEED_ARG, +- 0, ++ { "user", user_option, NEED_ARG }, ++ { "group", group_option, NEED_ARG }, ++ { "umask", umask_option, NEED_ARG }, ++ { "linger", linger_option, NEED_ARG }, ++ { "keepalive", keepalive_option, 0 }, ++ { "spawn", spawn_option, NEED_ARG | EXPAND_ARG }, ++ { "twist", twist_option, NEED_ARG | EXPAND_ARG | USE_LAST }, ++ { "rfc931", rfc931_option, OPT_ARG }, ++ { "setenv", setenv_option, NEED_ARG | EXPAND_ARG }, ++ { "nice", nice_option, OPT_ARG }, ++ { "severity", severity_option, NEED_ARG }, ++ { "allow", allow_option, USE_LAST }, ++ { "deny", deny_option, USE_LAST }, ++ { "banners", banners_option, NEED_ARG }, ++ { 0 }, + }; + + /* process_options - process access control options */ +@@ -447,88 +449,88 @@ + + static struct syslog_names log_fac[] = { + #ifdef LOG_KERN +- "kern", LOG_KERN, ++ { "kern", LOG_KERN }, + #endif + #ifdef LOG_USER +- "user", LOG_USER, ++ { "user", LOG_USER }, + #endif + #ifdef LOG_MAIL +- "mail", LOG_MAIL, ++ { "mail", LOG_MAIL }, + #endif + #ifdef LOG_DAEMON +- "daemon", LOG_DAEMON, ++ { "daemon", LOG_DAEMON }, + #endif + #ifdef LOG_AUTH +- "auth", LOG_AUTH, ++ { "auth", LOG_AUTH }, + #endif + #ifdef LOG_LPR +- "lpr", LOG_LPR, ++ { "lpr", LOG_LPR }, + #endif + #ifdef LOG_NEWS +- "news", LOG_NEWS, ++ { "news", LOG_NEWS }, + #endif + #ifdef LOG_UUCP +- "uucp", LOG_UUCP, ++ { "uucp", LOG_UUCP }, + #endif + #ifdef LOG_CRON +- "cron", LOG_CRON, ++ { "cron", LOG_CRON }, + #endif + #ifdef LOG_FTP +- "ftp", LOG_FTP, ++ { "ftp", LOG_FTP }, + #endif + #ifdef LOG_LOCAL0 +- "local0", LOG_LOCAL0, ++ { "local0", LOG_LOCAL0 }, + #endif + #ifdef LOG_LOCAL1 +- "local1", LOG_LOCAL1, ++ { "local1", LOG_LOCAL1 }, + #endif + #ifdef LOG_LOCAL2 +- "local2", LOG_LOCAL2, ++ { "local2", LOG_LOCAL2 }, + #endif + #ifdef LOG_LOCAL3 +- "local3", LOG_LOCAL3, ++ { "local3", LOG_LOCAL3 }, + #endif + #ifdef LOG_LOCAL4 +- "local4", LOG_LOCAL4, ++ { "local4", LOG_LOCAL4 }, + #endif + #ifdef LOG_LOCAL5 +- "local5", LOG_LOCAL5, ++ { "local5", LOG_LOCAL5 }, + #endif + #ifdef LOG_LOCAL6 +- "local6", LOG_LOCAL6, ++ { "local6", LOG_LOCAL6 }, + #endif + #ifdef LOG_LOCAL7 +- "local7", LOG_LOCAL7, ++ { "local7", LOG_LOCAL7 }, + #endif +- 0, ++ { 0 }, + }; + + static struct syslog_names log_sev[] = { + #ifdef LOG_EMERG +- "emerg", LOG_EMERG, ++ { "emerg", LOG_EMERG }, + #endif + #ifdef LOG_ALERT +- "alert", LOG_ALERT, ++ { "alert", LOG_ALERT }, + #endif + #ifdef LOG_CRIT +- "crit", LOG_CRIT, ++ { "crit", LOG_CRIT }, + #endif + #ifdef LOG_ERR +- "err", LOG_ERR, ++ { "err", LOG_ERR }, + #endif + #ifdef LOG_WARNING +- "warning", LOG_WARNING, ++ { "warning", LOG_WARNING }, + #endif + #ifdef LOG_NOTICE +- "notice", LOG_NOTICE, ++ { "notice", LOG_NOTICE }, + #endif + #ifdef LOG_INFO +- "info", LOG_INFO, ++ { "info", LOG_INFO }, + #endif + #ifdef LOG_DEBUG +- "debug", LOG_DEBUG, ++ { "debug", LOG_DEBUG }, + #endif +- 0, ++ { 0 }, + }; + + /* severity_map - lookup facility or severity value */ +@@ -589,7 +591,7 @@ + if (src[0] == 0) + return (0); + +- while (ch = *src) { ++ while ((ch = *src)) { + if (ch == ':') { + if (*++src == 0) + tcpd_warn("rule ends in \":\""); +diff -u tcp_wrappers_7.6.orig/patchlevel.h tcp_wrappers_7.6/patchlevel.h +--- tcp_wrappers_7.6.orig/patchlevel.h 1997-03-22 05:27:24.000000000 +1100 ++++ tcp_wrappers_7.6/patchlevel.h 2017-11-14 22:54:15.000000000 +1100 +@@ -1,3 +1,3 @@ + #ifndef lint +-static char patchlevel[] = "@(#) patchlevel 7.6 97/03/21 19:27:23"; ++static char patchlevel[] __attribute__((__unused__)) = "@(#) patchlevel 7.6 97/03/21 19:27:23"; + #endif +diff -u tcp_wrappers_7.6.orig/percent_m.c tcp_wrappers_7.6/percent_m.c +--- tcp_wrappers_7.6.orig/percent_m.c 2017-11-13 09:29:08.000000000 +1100 ++++ tcp_wrappers_7.6/percent_m.c 2017-11-14 22:54:31.000000000 +1100 +@@ -5,7 +5,7 @@ + */ + + #ifndef lint +-static char sccsid[] = "@(#) percent_m.c 1.1 94/12/28 17:42:37"; ++static char sccsid[] __attribute__((__unused__)) = "@(#) percent_m.c 1.1 94/12/28 17:42:37"; + #endif + + #include +@@ -27,7 +27,7 @@ + char *bp = obuf; + char *cp = ibuf; + +- while (*bp = *cp) ++ while ((*bp = *cp)) + if (*cp == '%' && cp[1] == 'm') { + #ifdef HAVE_STRERROR + strcpy(bp, strerror(errno)); +diff -u tcp_wrappers_7.6.orig/percent_x.c tcp_wrappers_7.6/percent_x.c +--- tcp_wrappers_7.6.orig/percent_x.c 1994-12-29 03:42:38.000000000 +1100 ++++ tcp_wrappers_7.6/percent_x.c 2017-11-14 22:54:40.000000000 +1100 +@@ -11,7 +11,7 @@ + */ + + #ifndef lint +-static char sccsid[] = "@(#) percent_x.c 1.4 94/12/28 17:42:37"; ++static char sccsid[] __attribute__((__unused__)) = "@(#) percent_x.c 1.4 94/12/28 17:42:37"; + #endif + + /* System libraries. */ +@@ -19,6 +19,7 @@ + #include + #include + #include ++#include + + extern void exit(); + +diff -u tcp_wrappers_7.6.orig/refuse.c tcp_wrappers_7.6/refuse.c +--- tcp_wrappers_7.6.orig/refuse.c 1994-12-29 03:42:40.000000000 +1100 ++++ tcp_wrappers_7.6/refuse.c 2017-11-14 22:54:50.000000000 +1100 +@@ -8,7 +8,7 @@ + */ + + #ifndef lint +-static char sccsid[] = "@(#) refuse.c 1.5 94/12/28 17:42:39"; ++static char sccsid[] __attribute__((__unused__)) = "@(#) refuse.c 1.5 94/12/28 17:42:39"; + #endif + + /* System libraries. */ +diff -u tcp_wrappers_7.6.orig/rfc931.c tcp_wrappers_7.6/rfc931.c +--- tcp_wrappers_7.6.orig/rfc931.c 2017-11-13 09:29:08.000000000 +1100 ++++ tcp_wrappers_7.6/rfc931.c 2017-11-14 22:54:58.000000000 +1100 +@@ -10,7 +10,7 @@ + */ + + #ifndef lint +-static char sccsid[] = "@(#) rfc931.c 1.10 95/01/02 16:11:34"; ++static char sccsid[] __attribute__((__unused__)) = "@(#) rfc931.c 1.10 95/01/02 16:11:34"; + #endif + + /* System libraries. */ +@@ -23,6 +23,7 @@ + #include + #include + #include ++#include + + /* Local stuff. */ + +@@ -152,7 +153,7 @@ + * protocol, not part of the data. + */ + +- if (cp = strchr(user, '\r')) ++ if ((cp = strchr(user, '\r'))) + *cp = 0; + result = user; + } +diff -u tcp_wrappers_7.6.orig/safe_finger.c tcp_wrappers_7.6/safe_finger.c +--- tcp_wrappers_7.6.orig/safe_finger.c 2017-11-13 09:29:08.000000000 +1100 ++++ tcp_wrappers_7.6/safe_finger.c 2017-11-14 22:55:08.000000000 +1100 +@@ -15,7 +15,7 @@ + */ + + #ifndef lint +-static char sccsid[] = "@(#) safe_finger.c 1.4 94/12/28 17:42:41"; ++static char sccsid[] __attribute__((__unused__)) = "@(#) safe_finger.c 1.4 94/12/28 17:42:41"; + #endif + + /* System libraries */ +@@ -27,6 +27,10 @@ + #include + #include + #include ++#include ++#include ++#include ++#include + + extern void exit(); + +@@ -45,6 +49,8 @@ + int allow_severity = SEVERITY; + int deny_severity = LOG_WARNING; + ++int pipe_stdin(); ++ + void cleanup(sig) + int sig; + { +@@ -52,7 +58,7 @@ + exit(0); + } + +-main(argc, argv) ++int main(argc, argv) + int argc; + char **argv; + { +diff -u tcp_wrappers_7.6.orig/scaffold.c tcp_wrappers_7.6/scaffold.c +--- tcp_wrappers_7.6.orig/scaffold.c 2017-11-13 09:29:21.000000000 +1100 ++++ tcp_wrappers_7.6/scaffold.c 2017-11-14 22:55:32.000000000 +1100 +@@ -5,7 +5,7 @@ + */ + + #ifndef lint +-static char sccs_id[] = "@(#) scaffold.c 1.6 97/03/21 19:27:24"; ++static char sccsid[] __attribute__((__unused__)) = "@(#) scaffold.c 1.6 97/03/21 19:27:24"; + #endif + + /* System libraries. */ +diff -u tcp_wrappers_7.6.orig/shell_cmd.c tcp_wrappers_7.6/shell_cmd.c +--- tcp_wrappers_7.6.orig/shell_cmd.c 1994-12-29 03:42:44.000000000 +1100 ++++ tcp_wrappers_7.6/shell_cmd.c 2017-11-14 22:55:45.000000000 +1100 +@@ -9,7 +9,7 @@ + */ + + #ifndef lint +-static char sccsid[] = "@(#) shell_cmd.c 1.5 94/12/28 17:42:44"; ++static char sccsid[] __attribute__((__unused__)) = "@(#) shell_cmd.c 1.5 94/12/28 17:42:44"; + #endif + + /* System libraries. */ +@@ -20,6 +20,9 @@ + #include + #include + #include ++#include ++#include ++#include + + extern void exit(); + +diff -u tcp_wrappers_7.6.orig/socket.c tcp_wrappers_7.6/socket.c +--- tcp_wrappers_7.6.orig/socket.c 2017-11-13 09:29:08.000000000 +1100 ++++ tcp_wrappers_7.6/socket.c 2017-11-14 22:55:57.000000000 +1100 +@@ -16,7 +16,7 @@ + */ + + #ifndef lint +-static char sccsid[] = "@(#) socket.c 1.15 97/03/21 19:27:24"; ++static char sccsid[] __attribute__((__unused__)) = "@(#) socket.c 1.15 97/03/21 19:27:24"; + #endif + + /* System libraries. */ +@@ -77,7 +77,7 @@ + static struct sockaddr_in client; + static struct sockaddr_in server; + #if !defined (__GLIBC__) +- int len; ++ unsigned int len; + #else /* __GLIBC__ */ + size_t len; + #endif /* __GLIBC__ */ +@@ -229,7 +229,7 @@ + char buf[BUFSIZ]; + struct sockaddr_in sin; + #if !defined(__GLIBC__) +- int size = sizeof(sin); ++ unsigned int size = sizeof(sin); + #else /* __GLIBC__ */ + size_t size = sizeof(sin); + #endif /* __GLIBC__ */ +diff -u tcp_wrappers_7.6.orig/tcpd.c tcp_wrappers_7.6/tcpd.c +--- tcp_wrappers_7.6.orig/tcpd.c 1996-02-12 03:01:33.000000000 +1100 ++++ tcp_wrappers_7.6/tcpd.c 2017-11-14 22:56:09.000000000 +1100 +@@ -11,7 +11,7 @@ + */ + + #ifndef lint +-static char sccsid[] = "@(#) tcpd.c 1.10 96/02/11 17:01:32"; ++static char sccsid[] __attribute__((__unused__)) = "@(#) tcpd.c 1.10 96/02/11 17:01:32"; + #endif + + /* System libraries. */ +@@ -24,6 +24,7 @@ + #include + #include + #include ++#include + + #ifndef MAXPATHNAMELEN + #define MAXPATHNAMELEN BUFSIZ +@@ -38,10 +39,12 @@ + #include "patchlevel.h" + #include "tcpd.h" + ++extern void fix_options(struct request_info *); ++ + int allow_severity = SEVERITY; /* run-time adjustable */ + int deny_severity = LOG_WARNING; /* ditto */ + +-main(argc, argv) ++int main(argc, argv) + int argc; + char **argv; + { +diff -u tcp_wrappers_7.6.orig/tcpd.h tcp_wrappers_7.6/tcpd.h +--- tcp_wrappers_7.6.orig/tcpd.h 2017-11-13 09:29:25.000000000 +1100 ++++ tcp_wrappers_7.6/tcpd.h 2017-11-14 22:36:40.000000000 +1100 +@@ -182,10 +182,10 @@ + + #ifdef __STDC__ + extern void tcpd_warn(char *, ...); /* report problem and proceed */ +-extern void tcpd_jump(char *, ...); /* report problem and jump */ ++extern void tcpd_jump(char *, ...) __attribute__((__noreturn__)); /* report problem and jump */ + #else + extern void tcpd_warn(); +-extern void tcpd_jump(); ++extern void tcpd_jump() __attribute__((__noreturn__)); + #endif + + struct tcpd_context { +diff -u tcp_wrappers_7.6.orig/tcpdchk.c tcp_wrappers_7.6/tcpdchk.c +--- tcp_wrappers_7.6.orig/tcpdchk.c 2017-11-13 09:29:08.000000000 +1100 ++++ tcp_wrappers_7.6/tcpdchk.c 2017-11-14 22:56:21.000000000 +1100 +@@ -15,7 +15,7 @@ + */ + + #ifndef lint +-static char sccsid[] = "@(#) tcpdchk.c 1.8 97/02/12 02:13:25"; ++static char sccsid[] __attribute__((__unused__)) = "@(#) tcpdchk.c 1.8 97/02/12 02:13:25"; + #endif + + /* System libraries. */ +@@ -30,6 +30,7 @@ + #include + #include + #include ++#include + + extern int errno; + extern void exit(); +@@ -199,13 +200,15 @@ + char sv_list[BUFLEN]; /* becomes list of daemons */ + char *cl_list; /* becomes list of requests */ + char *sh_cmd; /* becomes optional shell command */ ++#ifndef PROCESS_OPTIONS + char buf[BUFSIZ]; ++#endif + int verdict; + struct tcpd_context saved_context; + + saved_context = tcpd_context; /* stupid compilers */ + +- if (fp = fopen(table, "r")) { ++ if ((fp = fopen(table, "r"))) { + tcpd_context.file = table; + tcpd_context.line = 0; + while (xgets(sv_list, sizeof(sv_list), fp)) { +@@ -331,7 +334,7 @@ + clients = 0; + } else { + clients++; +- if (host = split_at(cp + 1, '@')) { /* user@host */ ++ if ((host = split_at(cp + 1, '@'))) { /* user@host */ + check_user(cp); + check_host(host); + } else { +@@ -446,7 +449,7 @@ + } else if (errno != ENOENT) { + tcpd_warn("open %s: %m", pat); + } +- } else if (mask = split_at(pat, '/')) { /* network/netmask */ ++ } else if ((mask = split_at(pat, '/'))) { /* network/netmask */ + if (dot_quad_addr(pat) == INADDR_NONE + || dot_quad_addr(mask) == INADDR_NONE) + tcpd_warn("%s/%s: bad net/mask pattern", pat, mask); +diff -u tcp_wrappers_7.6.orig/tcpdmatch.c tcp_wrappers_7.6/tcpdmatch.c +--- tcp_wrappers_7.6.orig/tcpdmatch.c 1996-02-12 03:01:36.000000000 +1100 ++++ tcp_wrappers_7.6/tcpdmatch.c 2017-11-14 22:56:40.000000000 +1100 +@@ -14,7 +14,7 @@ + */ + + #ifndef lint +-static char sccsid[] = "@(#) tcpdmatch.c 1.5 96/02/11 17:01:36"; ++static char sccsid[] __attribute__((__unused__)) = "@(#) tcpdmatch.c 1.5 96/02/11 17:01:36"; + #endif + + /* System libraries. */ +@@ -29,6 +29,8 @@ + #include + #include + #include ++#include ++#include + + extern void exit(); + extern int optind; +diff -u tcp_wrappers_7.6.orig/tli.c tcp_wrappers_7.6/tli.c +--- tcp_wrappers_7.6.orig/tli.c 1997-03-22 05:27:26.000000000 +1100 ++++ tcp_wrappers_7.6/tli.c 2017-11-14 22:56:50.000000000 +1100 +@@ -15,7 +15,7 @@ + */ + + #ifndef lint +-static char sccsid[] = "@(#) tli.c 1.15 97/03/21 19:27:25"; ++static char sccsid[] __attribute__((__unused__)) = "@(#) tli.c 1.15 97/03/21 19:27:25"; + #endif + + #ifdef TLI +diff -u tcp_wrappers_7.6.orig/try-from.c tcp_wrappers_7.6/try-from.c +--- tcp_wrappers_7.6.orig/try-from.c 1994-12-29 03:42:55.000000000 +1100 ++++ tcp_wrappers_7.6/try-from.c 2017-11-14 22:56:59.000000000 +1100 +@@ -11,7 +11,7 @@ + */ + + #ifndef lint +-static char sccsid[] = "@(#) try-from.c 1.2 94/12/28 17:42:55"; ++static char sccsid[] __attribute__((__unused__)) = "@(#) try-from.c 1.2 94/12/28 17:42:55"; + #endif + + /* System libraries. */ +@@ -37,7 +37,7 @@ + int allow_severity = SEVERITY; /* run-time adjustable */ + int deny_severity = LOG_WARNING; /* ditto */ + +-main(argc, argv) ++int main(argc, argv) + int argc; + char **argv; + { +diff -u tcp_wrappers_7.6.orig/update.c tcp_wrappers_7.6/update.c +--- tcp_wrappers_7.6.orig/update.c 1994-12-29 03:42:56.000000000 +1100 ++++ tcp_wrappers_7.6/update.c 2017-11-14 22:57:09.000000000 +1100 +@@ -14,7 +14,7 @@ + */ + + #ifndef lint +-static char sccsid[] = "@(#) update.c 1.1 94/12/28 17:42:56"; ++static char sccsid[] __attribute__((__unused__)) = "@(#) update.c 1.1 94/12/28 17:42:56"; + #endif + + /* System libraries */ +@@ -22,6 +22,7 @@ + #include + #include + #include ++#include + + /* Local stuff. */ + diff --git a/package/network/services/usbip/Makefile b/package/network/services/usbip/Makefile new file mode 100644 index 0000000000..6050076908 --- /dev/null +++ b/package/network/services/usbip/Makefile @@ -0,0 +1,114 @@ +# +# Copyright (C) 2010-2017 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +include $(TOPDIR)/rules.mk +include $(INCLUDE_DIR)/kernel.mk + +PKG_NAME:=usbip +PKG_RELEASE:=11 +PKG_LICENSE:=GPL-2.0 + +# Since kernel 2.6.39.1 userspace tools are inside the kernel tree +# Package Automatic match version in kernel +# HASH is not useful kernel package already check it +PKG_VERSION:=$(shell sed -n -e '/^AC_INIT/s/.*\[\([[:digit:]\.]*\)\].*/\1/gp' $(LINUX_DIR)/tools/usb/usbip/configure.ac) +PKG_SOURCE:= +PKG_SOURCE_URL:= +PKG_HASH:=unknown + +PKG_MAINTAINER:=Nuno Goncalves + +PATCH_DIR:=./patches-$(PKG_VERSION) + +define prepare_source_directory + rm -rf $(PKG_BUILD_DIR) + $(CP) $(LINUX_DIR)/tools/usb/usbip $(PKG_BUILD_DIR) +endef +Hooks/Prepare/Pre += prepare_source_directory + +PKG_FIXUP:=autoreconf +PKG_INSTALL:=1 +PKG_ASLR_PIE:=0 + +include $(INCLUDE_DIR)/package.mk +include $(INCLUDE_DIR)/nls.mk + +define Package/usbip/Common + TITLE:=USB-over-IP + URL:=http://usbip.sourceforge.net/ + DEPENDS:=@USB_SUPPORT +endef + +define Package/usbip/Default + $(call Package/usbip/Common) + SECTION:=net + CATEGORY:=Network +endef + +define Package/usbip + $(call Package/usbip/Default) + TITLE+= (common) + DEPENDS+= +libwrap +kmod-usbip +libudev-fbsd +USE_GLIBC:libbsd +endef + +define Package/usbip-client + $(call Package/usbip/Default) + TITLE+= (client) + DEPENDS+= usbip +kmod-usbip-client +endef + +define Package/usbip-server + $(call Package/usbip/Default) + TITLE+= (server) + DEPENDS+= usbip +kmod-usbip-server +endef + +CONFIGURE_PATH:=. +MAKE_PATH:=. +LIBTOOL_PATHS:=. +MAKE_FLAGS+=CFLAGS='-Dudev_device_get_devpath\(x\)=udev_device_get_syspath\(x\)+strlen\(\"/sys\"\) \ + -DSIGCLD=SIGCHLD' +CONFIGURE_ARGS+= --disable-silent-rules + +define Build/Configure + (cd $(PKG_BUILD_DIR); ./autogen.sh ); + $(call Build/Configure/Default) +endef + +CONFIGURE_VARS+= $(if $(CONFIG_USE_GLIBC),LIBS='-lbsd -lpthread') +CFLAGS+="$(TARGET_CFLAGS) -I$(STAGING_DIR)/usr/include" + +USB_IDS_VER:=0.318 +USB_IDS_FILE:=usb.ids.$(USB_IDS_VER) +define Download/usb.ids + FILE:=$(USB_IDS_FILE) + URL_FILE:=usb.ids + URL:=@GITHUB/vcrhonek/hwdata/v$(USB_IDS_VER) + HASH:=84bc5452e4e45c2250e01bc74e03528b2a53c4724b2c4a5feaea76a922f83915 +endef + +define Package/usbip/install + $(INSTALL_DIR) $(1)/usr/lib + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libusbip.so.* $(1)/usr/lib/ + $(INSTALL_DIR) $(1)/usr/share/hwdata + $(CP) $(DL_DIR)/usb.ids.$(USB_IDS_VER) $(1)/usr/share/hwdata/usb.ids +endef + +define Package/usbip-client/install + $(INSTALL_DIR) $(1)/usr/sbin + $(CP) $(PKG_INSTALL_DIR)/usr/sbin/usbip $(1)/usr/sbin/ +endef + +define Package/usbip-server/install + $(INSTALL_DIR) $(1)/usr/sbin + $(CP) $(PKG_INSTALL_DIR)/usr/sbin/usbipd $(1)/usr/sbin/ +endef + +$(eval $(call Download,usb.ids)) +$(eval $(call BuildPackage,usbip)) +$(eval $(call BuildPackage,usbip-client)) +$(eval $(call BuildPackage,usbip-server)) -- 2.25.1