Changeset 109 for trunk/src/sh_portcheck.c
- Timestamp:
- Jun 18, 2007, 9:29:51 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/sh_portcheck.c
r80 r109 39 39 #include <errno.h> 40 40 #include <unistd.h> 41 #include <fcntl.h> 41 42 42 43 #define PORTCHK_VERSION "1.0" … … 110 111 #include "sh_error.h" 111 112 #include "sh_mem.h" 113 #include "sh_calls.h" 112 114 #include "sh_utils.h" 113 115 #include "sh_modules.h" … … 676 678 /* struct in_addr haddr; */ 677 679 int retval; 680 int flags; 678 681 char * p; 679 682 #ifndef TEST_ONLY … … 728 731 fprintf(stderr, _("check port: %5d on %15s open %s\n"), 729 732 port, inet_ntoa(haddr), p); 733 734 #if !defined(O_NONBLOCK) 735 #if defined(O_NDELAY) 736 #define O_NONBLOCK O_NDELAY 737 #else 738 #define O_NONBLOCK 0 739 #endif 740 #endif 741 742 /* prepare to close connection gracefully 743 */ 744 if (port == 22) /* ssh */ 745 { 746 flags = retry_fcntl(FIL__, __LINE__, fd, F_GETFL, 0); 747 retry_fcntl(FIL__, __LINE__, fd, F_SETFL, flags | O_NONBLOCK); 748 write (fd, _("SSH-2.0-Foobar"), 14); 749 write (fd, "\r\n", 2); 750 } 751 else if (port == 25) /* smtp */ 752 { 753 flags = retry_fcntl(FIL__, __LINE__, fd, F_GETFL, 0); 754 retry_fcntl(FIL__, __LINE__, fd, F_SETFL, flags | O_NONBLOCK); 755 write (fd, _("QUIT"), 4); 756 write (fd, "\r\n", 2); 757 } 758 else if (port == 79) /* finger */ 759 { 760 flags = retry_fcntl(FIL__, __LINE__, fd, F_GETFL, 0); 761 retry_fcntl(FIL__, __LINE__, fd, F_SETFL, flags | O_NONBLOCK); 762 write (fd, "\r\n", 2); 763 } 764 else if (port == 110) /* pop3 */ 765 { 766 flags = retry_fcntl(FIL__, __LINE__, fd, F_GETFL, 0); 767 retry_fcntl(FIL__, __LINE__, fd, F_SETFL, flags | O_NONBLOCK); 768 write (fd, _("QUIT"), 4); 769 write (fd, "\r\n", 2); 770 } 771 else if (port == 143) /* imap */ 772 { 773 flags = retry_fcntl(FIL__, __LINE__, fd, F_GETFL, 0); 774 retry_fcntl(FIL__, __LINE__, fd, F_SETFL, flags | O_NONBLOCK); 775 write (fd, _("A01 LOGOUT"), 10); 776 write (fd, "\r\n", 2); 777 } 730 778 } 731 779 close (fd);
Note:
See TracChangeset
for help on using the changeset viewer.