Changeset 170 for trunk/src/sh_portcheck.c
- Timestamp:
- Apr 30, 2008, 11:56:45 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/sh_portcheck.c
r169 r170 179 179 } 180 180 181 val = (val <= 0 ? 60 : val);182 183 181 sh_portchk_interval = (time_t) val; 184 182 SL_RETURN(0, _("sh_portchk_set_interval")); … … 251 249 /* Interface to initialize port check 252 250 */ 253 int sh_portchk_init ( );251 int sh_portchk_init (struct mod_type * arg); 254 252 255 253 /* Interface to reset port check 256 254 */ 257 int sh_portchk_reset ( );255 int sh_portchk_reset (void); 258 256 259 257 /* Interface to run port check 260 258 */ 261 int sh_portchk_check ( );259 int sh_portchk_check (void); 262 260 263 261 … … 317 315 * Thereafter, we check for entries that are still UNKN. 318 316 */ 319 static void sh_portchk_reset_lists ( )317 static void sh_portchk_reset_lists (void) 320 318 { 321 319 struct sh_portentry * portlist; … … 364 362 } 365 363 364 /* These variables are not used anywhere. They only exist 365 * to assign &pre, &ptr to them, which keeps gcc from 366 * putting it into a register, and avoids the 'clobbered 367 * by longjmp' warning. And no, 'volatile' proved insufficient. 368 */ 369 static void * sh_dummy_pre = NULL; 370 static void * sh_dummy_ptr = NULL; 371 366 372 /* check the list of open ports for any that are marked as UNKN 367 373 */ … … 372 378 char errbuf[256]; 373 379 380 /* Take the address to keep gcc from putting them into registers. 381 * Avoids the 'clobbered by longjmp' warning. 382 */ 383 sh_dummy_pre = (void*) ⪯ 384 sh_dummy_ptr = (void*) &ptr; 385 374 386 while (ptr) 375 387 { … … 817 829 flags = retry_fcntl(FIL__, __LINE__, fd, F_GETFL, 0); 818 830 retry_fcntl(FIL__, __LINE__, fd, F_SETFL, flags | O_NONBLOCK); 819 write (fd, _("SSH-2.0-Foobar"), 14);820 write (fd, "\r\n", 2);831 retval = write (fd, _("SSH-2.0-Foobar"), 14); 832 if (retval > 0) retval = write (fd, "\r\n", 2); 821 833 } 822 834 else if (port == 25) /* smtp */ … … 824 836 flags = retry_fcntl(FIL__, __LINE__, fd, F_GETFL, 0); 825 837 retry_fcntl(FIL__, __LINE__, fd, F_SETFL, flags | O_NONBLOCK); 826 write (fd, _("QUIT"), 4);827 write (fd, "\r\n", 2);838 retval = write (fd, _("QUIT"), 4); 839 if (retval > 0) retval = write (fd, "\r\n", 2); 828 840 } 829 841 else if (port == 79) /* finger */ … … 831 843 flags = retry_fcntl(FIL__, __LINE__, fd, F_GETFL, 0); 832 844 retry_fcntl(FIL__, __LINE__, fd, F_SETFL, flags | O_NONBLOCK); 833 write (fd, "\r\n", 2);845 retval = write (fd, "\r\n", 2); 834 846 } 835 847 else if (port == 110) /* pop3 */ … … 837 849 flags = retry_fcntl(FIL__, __LINE__, fd, F_GETFL, 0); 838 850 retry_fcntl(FIL__, __LINE__, fd, F_SETFL, flags | O_NONBLOCK); 839 write (fd, _("QUIT"), 4);840 write (fd, "\r\n", 2);851 retval = write (fd, _("QUIT"), 4); 852 if (retval > 0) retval = write (fd, "\r\n", 2); 841 853 } 842 854 else if (port == 143) /* imap */ … … 844 856 flags = retry_fcntl(FIL__, __LINE__, fd, F_GETFL, 0); 845 857 retry_fcntl(FIL__, __LINE__, fd, F_SETFL, flags | O_NONBLOCK); 846 write (fd, _("A01 LOGOUT"), 10); 847 write (fd, "\r\n", 2); 848 } 858 retval = write (fd, _("A01 LOGOUT"), 10); 859 if (retval > 0) retval = write (fd, "\r\n", 2); 860 } 861 862 if (portchk_debug && retval < 0) 863 fprintf(stderr, _("check port: error writing to port %5d\n"), 864 port); 849 865 } 850 866 close (fd); … … 878 894 { 879 895 struct hostent * hent; 880 int i = 0;896 volatile int i; /* might be clobbered by âlongjmpâ or âvforkâ*/ 881 897 char errbuf[256]; 882 898 … … 899 915 SH_MUTEX_LOCK(mutex_resolv); 900 916 hent = sh_gethostbyname(portchk_hostname); 901 917 i = 0; 902 918 while (hent && hent->h_addr_list[i] && (iface_list.used < SH_IFACE_MAX)) 903 919 { … … 945 961 946 962 #if !defined(TEST_ONLY) 947 int sh_portchk_reconf ( )963 int sh_portchk_reconf (void) 948 964 { 949 965 SH_MUTEX_LOCK(mutex_port_check); … … 962 978 } 963 979 964 int sh_portchk_cleanup ( )980 int sh_portchk_cleanup (void) 965 981 { 966 982 return sh_portchk_reconf (); … … 983 999 static int check_port_generic (int port, int type, int protocol) 984 1000 { 985 inti = 0;1001 volatile int i = 0; 986 1002 int sock = -1; 987 1003 int flag = 1; /* non-zero to enable an option */ … … 1002 1018 if ((sock = socket(AF_INET, type, protocol)) < 0 ) 1003 1019 { 1020 ++i; 1004 1021 #ifdef TEST_ONLY 1005 1022 if (portchk_debug) … … 1010 1027 sh_error_message(errno, errbuf, sizeof(errbuf)), _("socket")); 1011 1028 SH_MUTEX_UNLOCK(mutex_thread_nolog); 1012 ++i; 1029 #endif 1013 1030 continue; 1014 #endif1015 1031 } 1016 1032 if ( setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, 1017 1033 (void *) &flag, sizeof(flag)) < 0 ) 1018 1034 { 1035 ++i; 1019 1036 #ifdef TEST_ONLY 1020 1037 if (portchk_debug) … … 1026 1043 SH_MUTEX_UNLOCK(mutex_thread_nolog); 1027 1044 #endif 1028 ++i;1029 1045 continue; 1030 1046 } … … 1056 1072 1057 1073 1058 static int sh_portchk_scan_ports_generic (int min_port, int max_port , int type, int protocol)1074 static int sh_portchk_scan_ports_generic (int min_port, int max_port_arg, int type, int protocol) 1059 1075 { 1060 1076 /* … … 1063 1079 */ 1064 1080 1065 int port; 1081 volatile int port; /* might be clobbered by âlongjmpâ or âvforkâ*/ 1082 volatile int max_port = max_port_arg; 1066 1083 int retval; 1067 1084 int sock = -1; … … 1444 1461 int sh_portchk_check () 1445 1462 { 1446 int min_port = 0;1463 volatile int min_port; 1447 1464 1448 1465 SH_MUTEX_LOCK(mutex_port_check); 1466 1467 min_port = 0; 1468 1449 1469 if (sh_portchk_active != S_FALSE) 1450 1470 {
Note:
See TracChangeset
for help on using the changeset viewer.