home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / unix / volume26 / xinetd21 / part00 < prev    next >
Encoding:
Text File  |  1993-06-26  |  12.5 KB  |  546 lines

  1. Newsgroups: comp.sources.unix
  2. From: panos@cs.colorado.edu (Panos Tsirigotis)
  3. Subject: v26i244: xinetd-2.1.1 - inetd replacement with access control and logging, Part00/31
  4. Sender: unix-sources-moderator@gw.home.vix.com
  5. Approved: vixie@gw.home.vix.com
  6.  
  7. Submitted-By: panos@cs.colorado.edu (Panos Tsirigotis)
  8. Posting-Number: Volume 26, Issue 244
  9. Archive-Name: xinetd-2.1.1/part00
  10.  
  11. [ This Q&A was provided by the author in his README file.  However, to me as
  12.   the moderator of comp.sources.unix, the most important part of this package
  13.   is its beautiful selection of general C Library functions.  Due to my bias
  14.   (I prefer to see small applications with rich libraries), I have excerpted
  15.   all of the SYNOPSIS sections of the library "man" pages included with this
  16.   distribution.  They follow the author's Q&A, and due to their size I have
  17.   taken the unusual step of putting this introductory information into a
  18.   "Part 00" rather than prepending it to "Part 01".
  19.  
  20.   Even if you don't want the "xinetd" application (and I think you probably
  21.   do, though you may not know it yet :-)), you should take a hard look at the
  22.   included libraries.  I have been planning a "libcsu.a" project for a while,
  23.   being a recurring publication of generalized C Library functions, and if I
  24.   do one it will begin with the routines included in this package.
  25.  
  26.   --vix ]
  27.  
  28. Q. What is xinetd ?
  29. A. xinetd is a replacement for inetd, the internet services daemon.
  30.  
  31. Q: I am not a system administrator; what do I care about an inetd replacement ?
  32. A: xinetd is not just an inetd replacement. Anybody can use it to start servers
  33.    that don't require privileged ports because xinetd does not require that the 
  34.    services in its configuration file be listed in /etc/services.
  35.  
  36. Q. Is it compatible with inetd ?
  37. A. No, its configuration file has a different format than inetd's one
  38.    and it understands different signals. However the signal-to-action 
  39.    assignment can be changed and a program has been included to convert 
  40.    inetd.conf to xinetd.conf.
  41.  
  42. Q. Why should I use it ?
  43. A. Because it is a lot better (IMHO) than inetd. Here are the reasons:
  44.  
  45.       1) It can do access control on all services based on:
  46.             a. address of remote host
  47.             b. time of access
  48.  
  49.       2) Access control works on all services, whether multi-threaded or
  50.          single-threaded and for both the TCP and UDP protocols.
  51.          All UDP packets can be checked as well as all TCP connections.
  52.  
  53.       3) It provides hard reconfiguration:
  54.             a. kills servers for services that are no longer in the
  55.                configuration file
  56.             b. kills servers that no longer meet the access control criteria
  57.  
  58.       4) It can prevent denial-of-access attacks by
  59.             a. placing limits on the number of servers for each service
  60.                (avoids process table overflows)
  61.             b. placing an upper bound on the number of processes it will fork
  62.             c. placing limits on the size of log files it creates
  63.  
  64.       5) Extensive logging abilities:
  65.             a. for every server started it can log:
  66.                     i) the time when the server was started
  67.                    ii) the remote host address
  68.                   iii) who was the remote user (if the other end runs a
  69.                        RFC-931/RFC-1413 server)
  70.                    iv) how long the server was running
  71.                (i, ii and iii can be logged for failed attempts too).
  72.             b. for some services, if the access control fails, it can
  73.                log information about the attempted access (for example,
  74.                it can log the user name and command for the rsh service)
  75.  
  76.       6) No limit on number of server arguments
  77.  
  78. [ Here come the "SYNOPSIS" sections of all of the included library functions.
  79.   --vix ]
  80.  
  81. SYNOPSIS
  82.        #include "env.h"
  83.  
  84.        env_h env_create( env )
  85.        env_h env ;
  86.  
  87.        void env_destroy( env )
  88.        env_h env ;
  89.  
  90.        env_h env_make( env_strings )
  91.        char **env_strings ;
  92.  
  93.        int env_addvar( env, from_env, var )
  94.        env_h env ;
  95.        env_h from_env ;
  96.        char *var ;
  97.  
  98.        int env_addstr( env, str )
  99.        env_h env ;
  100.        char *str ;
  101.  
  102.        int env_remvar( env, var )
  103.        env_h env ;
  104.        char *var ;
  105.  
  106.        char **env_getvars( env )
  107.        env_h env ;
  108.  
  109. SYNOPSIS
  110.        #include "ftwx.h"
  111.  
  112.        int ftwx( path, func, depth, flags )
  113.        char *path ;
  114.        int (*func)() ;
  115.        int depth ;
  116.        int flags ;
  117.  
  118. SYNOPSIS
  119.        #include "misc.h"
  120.  
  121.        char *make_string( count, ... )
  122.        unsigned count ;
  123.  
  124.        char *make_pathname( count, ... )
  125.        unsigned count ;
  126.  
  127.        char **argv_copy_and_clear( argv, start, count )
  128.        char **argv ;
  129.        int start, count ;
  130.  
  131.        char *dirname( path )
  132.        char *path ;
  133.  
  134.        char *basename( path )
  135.        char *path ;
  136.  
  137. SYNOPSIS
  138.        #include "pq.h"
  139.  
  140.        pq_h pq_create( func, flags, errnop )
  141.        int (*func)() ;
  142.        int flags ;
  143.        int *errnop ;
  144.  
  145.        void pq_destroy( pq )
  146.        pq_h pq ;
  147.  
  148.        pq_obj pq_head( pq )
  149.        pq_h pq ;
  150.  
  151.        pq_obj pq_extract_head( pq )
  152.        pq_h pq ;
  153.  
  154.        int pq_insert( pq, object )
  155.        pq_h pq ;
  156.        pq_obj object ;
  157.  
  158.        int pq_delete( pq, object )
  159.        pq_h pq ;
  160.        pq_obj object ;
  161.  
  162. SYNOPSIS
  163.        #include "pset.h"
  164.  
  165.        pset_h pset_create( alloc_start, alloc_step )
  166.        unsigned alloc_start, alloc_step ;
  167.  
  168.        void pset_destroy( pset )
  169.        pset_h pset ;
  170.  
  171.        ANY_TYPE *pset_add( pset, ptr )
  172.        pset_h pset ;
  173.        ANY_TYPE *ptr ;
  174.  
  175.        void *pset_insert( pset, ptr )
  176.        pset_h pset ;
  177.        void *ptr ;
  178.  
  179.        void pset_remove( pset, ptr )
  180.        pset_h pset ;
  181.        ANY_TYPE *ptr ;
  182.  
  183.        void pset_delete( pset, ptr )
  184.        pset_h pset ;
  185.        void *ptr ;
  186.  
  187.        void pset_remove_index( pset, index )
  188.        pset_h pset ;
  189.        unsigned index ;
  190.  
  191.        void pset_clear( pset )
  192.        pset_h pset ;
  193.  
  194.        unsigned pset_count( pset )
  195.        pset_h pset ;
  196.  
  197.        void *pset_pointer( pset, index )
  198.        pset_h pset ;
  199.        unsigned index ;
  200.  
  201.        void pset_compact( pset )
  202.        pset_h pset ;
  203.  
  204.        void pset_sort( pset, compfunc )
  205.        pset_h pset ;
  206.        int (*compfunc)() ;
  207.  
  208.        void pset_apply( pset, func, arg )
  209.        pset_h pset ;
  210.  
  211.        void (*func)() ;
  212.        void *arg ;
  213.  
  214. SYNOPSIS
  215.        #include "pset.h"
  216.  
  217.        psi_h psi_create( pset )
  218.        pset_h pset ;
  219.  
  220.        void psi_destroy( iter )
  221.        psi_h iter ;
  222.  
  223.        void psi_reset( iter, pset )
  224.        psi_h iter ;
  225.        pset_h pset ;
  226.  
  227.        void *psi_start( iter )
  228.        psi_h iter ;
  229.  
  230.        void *psi_next( iter )
  231.        psi_h iter ;
  232.  
  233.        void psi_remove( iter )
  234.        psi_h iter ;
  235.  
  236. SYNOPSIS
  237.        int Sprint( fd, format [ , ... ] )
  238.        int fd ;
  239.        char *format ;
  240.  
  241. SYNOPSIS
  242.        #include "sio.h"
  243.        #include <varargs.h>
  244.  
  245.        int Sread( fd, buf, nbytes )
  246.        int fd ;
  247.        char *buf ;
  248.        int nbytes ;
  249.  
  250.        int Sgetc( fd )
  251.        int fd ;
  252.  
  253.        char *Srdline( fd )
  254.        int fd ;
  255.  
  256.        char *Sfetch( fd, length )
  257.        int fd ;
  258.        long *length ;
  259.  
  260.        int Swrite( fd, buf, nbytes )
  261.        int fd ;
  262.        char *buf ;
  263.        int nbytes ;
  264.  
  265.        int Sputc( fd, c )
  266.        int fd ;
  267.        char c ;
  268.  
  269.        int Sprint( fd, format [ , ... ] )
  270.        int fd ;
  271.        char *format ;
  272.  
  273.        int Sprintv( fd, format, ap )
  274.        int fd ;
  275.        char *format ;
  276.        va_list ap ;
  277.  
  278.        int Sdone( fd )
  279.        int fd ;
  280.  
  281.        int Sundo( fd, type )
  282.        int fd ;
  283.        int type ;
  284.  
  285.        int Stie( ifd, ofd )
  286.        int ifd, ofd ;
  287.  
  288.        int Suntie( fd )
  289.        int fd ;
  290.  
  291.        int Sbuftype( fd, type )
  292.        int fd, type ;
  293.  
  294.        int Smorefds()
  295.  
  296.        int Sflush( fd )
  297.        int fd ;
  298.  
  299.        int Sclose( fd )
  300.        int fd ;
  301.  
  302.        int Sgetchar( fd )
  303.        int fd ;
  304.  
  305.        int Sputchar( fd, c )
  306.        int fd;
  307.        char c ;
  308.  
  309.        int SIOLINELEN( fd )
  310.        int fd ;
  311.  
  312.        int SIOMAXLINELEN( fd )
  313.        int fd ;
  314.  
  315. SYNOPSIS
  316.        #include "str.h"
  317.  
  318.        str_h str_parse( str, separ, flags, errnop )
  319.        char *str ;
  320.        char *separ ;
  321.        int flags ;
  322.        int *errnop ;
  323.  
  324.        void str_endparse( handle )
  325.        str_h handle ;
  326.  
  327.        char *str_component( handle )
  328.        str_h handle ;
  329.  
  330.        int str_setstr( handle, newstr )
  331.        str_h handle ;
  332.        char *newstr ;
  333.  
  334.        int str_separator( handle, separ )
  335.        str_h handle ;
  336.        char *separ ;
  337.  
  338.        char *str_nextpos( handle )
  339.        str_h handle ;
  340.  
  341.        extern int str_errno ;
  342.  
  343. SYNOPSIS
  344.        #include "str.h"
  345.  
  346.        char *str_sprint( buf, format, ... )
  347.        char *buf ;
  348.        char *format ;
  349.  
  350.        char *str_sprintv( buf, format, ap )
  351.        char *buf ;
  352.        char *format ;
  353.        va_list ap ;
  354.  
  355.        int str_nprint( buf, format, ... )
  356.        char *buf ;
  357.        char *format ;
  358.  
  359.        int str_nprintv( buf, format, ap )
  360.        char *buf ;
  361.        char *format ;
  362.        va_list ap ;
  363.  
  364.        void str_print( countp, buf, format, ... )
  365.        int *countp ;
  366.        char *buf ;
  367.        char *format ;
  368.  
  369.        void str_printv( countp, buf, format, ap )
  370.        int *countp ;
  371.        char *buf ;
  372.        char *format ;
  373.        va_list ap ;
  374.  
  375.        char *strx_sprint( buf, len, format, ... )
  376.        char *buf ;
  377.        int len ;
  378.        char *format ;
  379.  
  380.        char *strx_sprintv( buf, len, format, ap )
  381.        char *buf ;
  382.        int len ;
  383.        char *format ;
  384.        va_list ap ;
  385.  
  386.        int strx_nprint( buf, len, format, ... )
  387.        char *buf ;
  388.        int len ;
  389.        char *format ;
  390.  
  391.        int strx_nprintv( buf, len, format, ap )
  392.        char *buf ;
  393.        int len ;
  394.        char *format ;
  395.        va_list ap ;
  396.  
  397.        void strx_print( countp, buf, len, format, ... )
  398.        int *countp ;
  399.        char *buf ;
  400.        int len ;
  401.        char *format ;
  402.  
  403.        void strx_printv( countp, buf, len, format, ap )
  404.        int *countp ;
  405.        char *buf ;
  406.        int len ;
  407.        char *format ;
  408.        va_list ap ;
  409.  
  410. SYNOPSIS
  411.        #include "str.h"
  412.  
  413.        strs_h strs_setup( flags, pattern [, patlen] )
  414.        int flags ;
  415.        char *pattern ;
  416.  
  417.        char *strs_match( handle, str, len )
  418.        strs_h handle ;
  419.        char *str ;
  420.        int len ;
  421.  
  422.        void strs_done( handle )
  423.        strs_h handle ;
  424.  
  425.        char *strs_search( flags, str, len, pattern [, patlen] )
  426.        int flags ;
  427.        char *str ;
  428.        int len ;
  429.        char *pattern ;
  430.  
  431. SYNOPSIS
  432.        #include "str.h"
  433.  
  434.        char *str_find( s1, s2 )
  435.        char *s1, *s2 ;
  436.  
  437.        char *str_casefind( s1, s2 )
  438.        char *s1, *s2 ;
  439.  
  440.        void str_fill( s, c )
  441.        char *s ;
  442.        char c ;
  443.  
  444.        char *str_lower( s )
  445.        char *s ;
  446.  
  447.        char *str_upper( s )
  448.        char *s ;
  449.  
  450. SYNOPSIS
  451.        #include "timemacros.h"
  452.  
  453.        void TV_ADD( tv_res, tv1, tv2 )
  454.        struct timeval tv_res, tv1, tv2 ;
  455.  
  456.        void TV_SUB( tv_res, tv1, tv2 )
  457.        struct timeval tv_res, tv1, tv2 ;
  458.  
  459.        void TV_ZERO( tv )
  460.        struct timeval tv ;
  461.  
  462.        int TV_LT( tv1, tv2 )
  463.        struct timeval tv1, tv2 ;
  464.  
  465.        int TV_LE( tv1, tv2 )
  466.        struct timeval tv1, tv2 ;
  467.  
  468.        int TV_GT( tv1, tv2 )
  469.        struct timeval tv1, tv2 ;
  470.  
  471.        int TV_GE( tv1, tv2 )
  472.        struct timeval tv1, tv2 ;
  473.  
  474.        int TV_EQ( tv1, tv2 )
  475.        struct timeval tv1, tv2 ;
  476.  
  477.        int TV_NE( tv1, tv2 )
  478.        struct timeval tv1, tv2 ;
  479.  
  480.        int TV_ISZERO( tv )
  481.        struct timeval tv ;
  482.  
  483. SYNOPSIS
  484.        #include "timer.h"
  485.  
  486.        enum timer_types { TIMER_REAL, TIMER_VIRTUAL, TIMER_PROF } ;
  487.        enum timer_timetypes { TIMER_ABSOLUTE, TIMER_RELATIVE } ;
  488.  
  489.        extern int timer_errno ;
  490.  
  491.        timer_h timer_create( type, flags, errnop )
  492.        enum timer_types type ;
  493.        int flags ;
  494.        int *errnop ;
  495.  
  496.        void timer_destroy( handle )
  497.        timer_h handle ;
  498.  
  499.        int timer_start( handle, itvp, time_type, action )
  500.        timer_h handle ;
  501.        struct itimerval *itvp ;
  502.        enum timer_timetypes time_type ;
  503.        struct timer_action *action ;
  504.  
  505.        void timer_stop( handle )
  506.        timer_h handle ;
  507.  
  508.        void timer_block( handle )
  509.        timer_h handle ;
  510.  
  511.        void timer_unblock( handle )
  512.        timer_h handle ;
  513.  
  514.        unsigned timer_expirations( handle )
  515.        timer_h handle ;
  516.  
  517.        void timer_block_type( type )
  518.        enum timer_types type ;
  519.  
  520.        void timer_unblock_type( type )
  521.        enum timer_types type ;
  522.  
  523. SYNOPSIS
  524.        #include "xlog.h"
  525.  
  526.        xlog_h xlog_create( type, id, flags, ... )
  527.        xlog_e type ;
  528.        char *id ;
  529.        int flags ;
  530.  
  531.        int xlog_parms( type, ... )
  532.        xlog_e type ;
  533.  
  534.        void xlog_destroy( xlog )
  535.        xlog_h xlog ;
  536.  
  537.        void xlog_write( xlog, buf, len, flags, ... )
  538.        xlog_h xlog ;
  539.        char buf[] ;
  540.        int len ;
  541.        int flags ;
  542.  
  543.        int xlog_control( xlog, cmd, ... )
  544.        xlog_h xlog ;
  545.        xlog_cmd_e cmd ;
  546.