tcpwrap.c 928 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*
  2. * Part of Very Secure FTPd
  3. * Licence: GPL v2
  4. * Author: Chris Evans
  5. * tcpwrap.c
  6. *
  7. * Routines to encapsulate the usage of tcp_wrappers.
  8. */
  9. #include "tcpwrap.h"
  10. #include "builddefs.h"
  11. #include "utility.h"
  12. #include "sysutil.h"
  13. #ifdef VSF_BUILD_TCPWRAPPERS
  14. #include <tcpd.h>
  15. #endif
  16. #ifdef VSF_BUILD_TCPWRAPPERS
  17. #include <sys/syslog.h>
  18. int deny_severity = LOG_WARNING;
  19. int allow_severity = LOG_INFO;
  20. int
  21. vsf_tcp_wrapper_ok(int remote_fd)
  22. {
  23. struct request_info req;
  24. vsf_sysutil_openlog(0);
  25. request_init(&req, RQ_DAEMON, "ftpz", RQ_FILE, remote_fd, 0);
  26. fromhost(&req);
  27. if (!hosts_access(&req))
  28. {
  29. vsf_sysutil_closelog();
  30. return 0;
  31. }
  32. vsf_sysutil_closelog();
  33. return 1;
  34. }
  35. #else /* VSF_BUILD_TCPWRAPPERS */
  36. int
  37. vsf_tcp_wrapper_ok(int remote_fd)
  38. {
  39. (void) remote_fd;
  40. die("tcp_wrappers is set to YES but no tcp wrapper support compiled in");
  41. return 0;
  42. }
  43. #endif /* VSF_BUILD_TCPWRAPPERS */