xinetd

repository·master·Indexed 41 days ago

https://github.com/xinetd-org/xinetd

An extended internet services daemon (xinetd) and its supporting libraries. Includes SIO, a high-performance stream I/O library alternative to stdio; STR, a string handling library with matching and parsing functions; and ftwx, a file tree walk replacement for ftw(3). Features include TCP wrappers support via libwrap, load average monitoring, and a migration tool xconv.pl for converting inetd.conf to xinetd.conf.

Tokens
3.3K
Snippets
9
Records
19
Agent score
52%

What's inside xinetd

  1. Overview of the STR library

    master

    The STR library provides a collection of string handling functions categorized into four functional groups:

    • String matching functions: Implements various algorithms including brute force, Rabin-Karp, Knuth-Morris-Pratt, Boyer-Moore, and Shift-or.
    • String printing functions: Similar to sprintf, but with two key advantages:
      1. Functions that prevent buffer overruns.
      2. Options to return either a char * or an int depending on the use case.
    • String parsing functions: Tools for breaking strings into smaller components.
    • String utility functions: General utilities such as case conversion (upper/lower case).
  2. Overview of the xinetd library components

    master

    The library is composed of three distinct functional parts:

    • env: A collection of functions for processing environment variables.
    • misc: A collection of miscellaneous utility functions.
    • ftwx: A replacement for the standard ftw(3) function (file tree walk).
  3. What is SIO?

    master
    SIO is a stream I/O library designed as a competitor to stdio. It provides a faster interface and can utilize memory mapping for file reading if supported by the operating system. It is designed for easy migration from standard Unix read(2)/write(2) calls by replacing them with Sread and Swrite respectively.
  4. Configure xinetd access control (only_from and no_access)

    master

    xinetd uses reverse DNS lookups to implement access control for the only_from and no_access directives.

    When a client connects, xinetd performs a reverse lookup on the client's IP address. The resulting canonical name is compared against the names specified in your configuration.

    Domain Matching: If a name in the config file starts with a dot (.), it matches all hosts within that domain. For example, .synack.net matches any host whose reverse mapping is within the .synack.net domain.

  5. Compile the SIO library

    master

    To compile SIO, use the make command. The compilation behavior depends on your operating system. If your system is not listed in the specific commands below, you must modify sioconf.h by uncommenting the inclusion of customconf.h and defining your constants/macros there.

    System-specific compilation commands:

    • SunOS 4.x: make "DEFS=-DHAVE_MMAP -DHAVE_ONEXIT -DHAVE_MEMCPY -DHAVE_ISATTY"
    • SunOS 5.x (Solaris 2.y): make "DEFS=-DHAVE_MMAP -DHAVE_ATEXIT -DHAVE_MEMCPY -DHAVE_ISATTY"
    • Ultrix 4.x: make "DEFS=-DHAVE_MEMCPY -DHAVE_ATEXIT -DHAVE_ISATTY"

    Build Options:

    • Optimization: By default, SIO compiles with debugging enabled (-g). To optimize instead, append DEBUG=-O to your make command.
    • Assertions: You can enable assertions by defining the -DDEBUG flag. If an assertion fails, the program terminates with an error message indicating the SIO file and line number.
    # Example for SunOS 4.x
    make "DEFS=-DHAVE_MMAP -DHAVE_ONEXIT -DHAVE_MEMCPY -DHAVE_ISATTY"
    
    # Example for optimizing instead of debugging
    make DEBUG=-O
  6. Configure xinetd compile-time options

    master

    When building xinetd from source using the configure script, you can enable several optional features:

    • --with-libwrap: Enables support for TCP wrappers. This allows xinetd to respect /etc/hosts.{allow|deny} files. If enabled, xinetd checks these files first, then applies its internal access control. Note that xinetd passes the server name (or the service ID if no server is defined) to libwrap.
    • --with-loadavg: Enables the max_load configuration option, allowing services to be disabled when system load exceeds a threshold. Tested on Linux and Solaris 2.6+.
    • --with-howl=PATH: Adds howl mDNS advertising support. You must provide the installation prefix (e.g., /usr/local or /usr). configure will not auto-detect this path.
    • --with-inet6: Historically used to default services to IPv6. In current versions, IPv6 support is integrated; you can use the IPv6 service flag regardless of this option.
    ./configure --with-libwrap --with-loadavg --with-howl=/usr/local
  7. Configure library installation via Makefile flags

    master

    When installing the library, you may need to define specific flags in the Makefile depending on your system's headers and standard library capabilities:

    • Define OLD_DIR if your system lacks the /usr/include/dirent.h file.
    • Define __FTWX_NO_FTW if your system does not provide the standard ftw(3) function.
  8. Build and install the STR library

    master

    To build the library locally, run make. This generates the library files in the current directory.

    To perform a full installation of the library, include files, and man pages, run make install. The installation paths are controlled by the following Makefile variables, which can be edited in the Makefile or overridden via command line:

    • LIBDIR: Destination for the library files.
    • INCLUDEDIR: Destination for the header files.
    • MANDIR: Destination for the man pages.
    make
    make install
  9. Install the SIO library and manpages

    master

    The make command produces libsio.a in the current directory. To install the library, headers, and manpages to system directories, use the make install target. You can override the installation paths using the following Makefile variables:

    • LIBDIR: Destination for libsio.a
    • INCLUDEDIR: Destination for SIO header files
    • MANDIR: Destination for SIO man pages

    Example installation command:

    make install LIBDIR=/usr/local/lib INCLUDEDIR=/usr/local/include MANDIR=/usr/local/man/man3
  10. Test the SIO library

    master

    After compilation, use the testlib script located in the suite directory to verify the library functions. It is recommended to test before installation.

    • Run all tests: testlib all
    • Skip specific tests: If a test (like Sprint) fails due to environment issues (e.g., non-ANSI compatible printf), you can skip it by passing the function name as an argument after all. For example, to skip Sprint: testlib all Sprint.
    testlib all
    
    # To skip the Sprint test specifically:
    testlib all Sprint
  11. Convert inetd.conf to xinetd.conf using xconv.pl

    master

    To migrate from inetd to xinetd, use the Perl script xconv.pl. This script performs a direct translation of inetd.conf syntax to xinetd.conf format. It automatically handles:

    • tcpd configuration.
    • Warnings for rpc services.
    • Setting the REUSE flag.
    • Proper group handling (if supported by your source inetd.conf).
  12. Configure libwrap (TCP Wrappers) for xinetd services

    master

    If xinetd is compiled with --with-libwrap, access control in /etc/hosts.{allow|deny} is determined by the service's server attribute or its service name:

    1. Services with a server attribute: Use the path of the server executable in your hosts.{allow|deny} file.

      • Example Config: server = /usr/sbin/in.telnetd
      • Example hosts entry: in.telnetd: ALL
    2. Internal or Redirection services (no server attribute): Use the service name defined in the xinetd configuration.

      • Example Config: service telnet { redirect = 10.0.0.1 23 }
      • Example hosts entry: telnet: ALL
    # Example for a service with a server attribute
    service telnet
    {
         server = /usr/sbin/in.telnetd
         ...
    }
    
    # Corresponding /etc/hosts.allow entry
    in.telnetd: ALL
    
    # Example for a redirection service
    server telnet
    {
        redirect = 10.0.0.1 23
        ...
    }
    
    # Corresponding /etc/hosts.allow entry
    telnet: ALL