home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume16 / log_tcp / part01 / miscd.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-01-10  |  1.7 KB  |  64 lines

  1.  /*
  2.   * Front end to the ULTRIX miscd service. The front end logs the remote host
  3.   * name and then invokes the real miscd daemon. Install as "/usr/etc/miscd",
  4.   * after moving the real miscd daemon to the "/usr/etc/..." directory.
  5.   * Connections and diagnostics are logged through syslog(3).
  6.   * 
  7.   * The Ultrix miscd program implements the systat service, which pipes the
  8.   * output from who(1) to stdout. This information is potentially useful to
  9.   * systems crackers.
  10.   * 
  11.   * Compile with -DHOSTS_ACCESS in order to enable access control. See the
  12.   * hosts_access(5) manual page for details.
  13.   * 
  14.   * Author: Wietse Venema, Eindhoven University of Technology, The Netherlands.
  15.   */
  16.  
  17. #ifndef lint
  18. static char sccsid[] = "@(#) miscd.c 1.1 91/01/06 22:30:32";
  19. #endif
  20.  
  21. #include <stdio.h>
  22. #include <syslog.h>
  23.  
  24. /* The following specifies where the vendor-provided daemon should go. */
  25.  
  26. #define REAL_DAEMON    "/usr/etc/.../miscd"
  27.  
  28. main(argc, argv)
  29. int     argc;
  30. char  **argv;
  31. {
  32.     char   *fromhost();
  33.     char   *host_name;
  34.  
  35.     /*
  36.      * Open a channel to the syslog daemon. Older versions of openlog()
  37.      * require only two arguments.
  38.      */
  39.  
  40. #ifdef LOG_MAIL
  41.     (void) openlog(argv[0], LOG_PID, LOG_MAIL);
  42. #else
  43.     (void) openlog(argv[0], LOG_PID);
  44. #endif
  45.  
  46.     /* Find out and report the remote host name. */
  47.  
  48.     if ((host_name = fromhost()) == 0)
  49.     host_name = "unknown";
  50.     syslog(LOG_INFO, "connect from %s", host_name);
  51.  
  52.     /* Check whether this host can access the service in argv[0]. */
  53.  
  54. #ifdef HOSTS_ACCESS
  55.     hosts_access(argv[0], host_name);
  56. #endif
  57.  
  58.     /* Invoke the real daemon program. */
  59.  
  60.     (void) execv(REAL_DAEMON, argv);
  61.     syslog(LOG_ERR, "%s: %m", REAL_DAEMON);
  62.     return (1);
  63. }
  64.