home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume23 / log_tcp / part01 / try.c < prev   
Encoding:
C/C++ Source or Header  |  1991-10-19  |  818 b   |  40 lines

  1.  /*
  2.   * try - program to try out host access-control tables, including the
  3.   * optional shell commands.
  4.   * 
  5.   * usage: try process_name host_name
  6.   * 
  7.   * where process_name is a daemon process name (argv[0] value), and host_name
  8.   * is a host name or address.
  9.   * 
  10.   * Prints YES if access is granted, NO if denied.
  11.   */
  12.  
  13. #include <stdio.h>
  14. #include <syslog.h>
  15.  
  16. main(argc, argv)
  17. int     argc;
  18. char  **argv;
  19. {
  20. #ifdef HOSTS_ACCESS
  21.  
  22. #ifdef LOG_MAIL
  23.     openlog(argv[0], LOG_PID, FACILITY);
  24. #else
  25.     openlog(argv[0], LOG_PID);
  26. #endif
  27.  
  28.     if (argc != 3) {
  29.     fprintf(stderr, "usage: %s process_name host_name\n", argv[0]);
  30.     return (1);
  31.     } else {
  32.     printf(hosts_access(argv[1], argv[2]) ? "YES\n" : "NO\n");
  33.     return (0);
  34.     }
  35. #else
  36.     fprintf(stderr, "host access control is not enabled.\n");
  37.     return (1);
  38. #endif
  39. }
  40.