Changeset 481 for trunk/src/samhain.c
- Timestamp:
- Jul 18, 2015, 5:06:52 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/samhain.c
r473 r481 71 71 #include "sh_readconf.h" 72 72 #include "sh_hash.h" 73 #include "sh_dbIO.h" 73 74 #include "sh_restrict.h" 74 75 … … 78 79 #include "sh_gpg.h" 79 80 #include "sh_mem.h" 80 #include "sh_ forward.h"81 #include "sh_xfer.h" 81 82 #include "sh_tools.h" 82 83 #include "sh_hash.h" … … 88 89 #include "sh_ignore.h" 89 90 #include "sh_prelink.h" 91 #include "sh_sem.h" 90 92 #endif 91 93 … … 120 122 volatile int sig_termfast; /* SIGTERM */ 121 123 volatile int sig_force_check; /* SIGTTOU */ 124 volatile int sh_load_delta_flag; 122 125 long int eintr__result; 123 126 char sh_sig_msg[SH_MINIBUF]; … … 313 316 ErrFlag[0] |= (1 << 11); 314 317 #endif 318 319 sh.delayload = 0; 320 315 321 #ifdef MKA_13 316 322 ErrFlag[0] |= (1 << 12); … … 337 343 sig_termfast = 0; /* SIGTERM */ 338 344 sig_force_check = 0; /* SIGTTOU */ 345 sh_load_delta_flag = 0; 339 346 strcpy ( sh_sig_msg, _("None")); 340 347 … … 373 380 374 381 sh.pid = (UINT64) getpid(); 382 383 sh.outpath = NULL; 375 384 376 385 /* The flags. … … 647 656 { 648 657 649 skey->mlock_failed = S L_FALSE;658 skey->mlock_failed = S_FALSE; 650 659 skey->rngI = BAD; 651 660 /* properly initialized later … … 718 727 #endif 719 728 720 SL_ENTER(_("exit_handler"));721 722 729 #if defined(SH_WITH_SERVER) 723 730 sh_socket_remove (); … … 751 758 */ 752 759 sh_html_zero(); 753 /* sh_forward_html_write(); */754 760 #endif 755 761 … … 775 781 #endif 776 782 #if defined(SH_WITH_SERVER) 777 sh_ forward_free_all ();783 sh_xfer_free_all (); 778 784 #endif 779 785 #if defined(SH_WITH_MAIL) … … 796 802 /* --- Exit Message. --- 797 803 */ 804 if (sh.flag.exit == EXIT_FAILURE && !strcmp(sh_sig_msg, _("None"))) 805 sl_strlcpy(sh_sig_msg, _("exit_failure"), SH_MINIBUF); 806 if (sh.flag.exit == EXIT_SUCCESS && !strcmp(sh_sig_msg, _("None"))) 807 sl_strlcpy(sh_sig_msg, _("exit_success"), SH_MINIBUF); 798 808 sh_error_handle ((-1), FIL__, __LINE__, sh.flag.exit, MSG_EXIT_NORMAL, 799 809 sh.prg_name, sh_sig_msg); … … 805 815 /* --- Restrict error logging to stderr. --- 806 816 */ 807 #ifdef WITH_MESSAGE_QUEUE808 817 close_ipc (); 809 #endif810 818 sh_error_only_stderr (S_TRUE); 811 812 819 813 820 /* --- Remove lock, delete critical information. --- … … 1215 1222 } 1216 1223 1224 1225 void do_reconf() 1226 { 1227 int status, modnum; 1228 1229 sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_RECONF); 1230 1231 sh_thread_pause_flag = S_TRUE; 1232 1233 #if defined(WITH_EXTERNAL) 1234 /* delete list of external tasks 1235 */ 1236 (void) sh_ext_cleanup(); 1237 #endif 1238 #if defined(SH_WITH_MAIL) 1239 sh_nmail_free(); 1240 #endif 1241 1242 /* delete the file list, make all database 1243 * entries visible (allignore = FALSE) 1244 */ 1245 (void) sh_files_deldirstack (); 1246 (void) sh_files_delfilestack (); 1247 (void) sh_files_delglobstack (); 1248 (void) sh_ignore_clean (); 1249 (void) hash_full_tree (); 1250 sh_audit_delete_all (); 1251 1252 1253 #if defined(SH_WITH_CLIENT) 1254 reset_count_dev_server(); 1255 #endif 1256 #if defined(SH_WITH_CLIENT) || defined(SH_STANDALONE) 1257 sh_restrict_purge (); 1258 1259 1260 FileSchedOne = free_sched(FileSchedOne); 1261 FileSchedTwo = free_sched(FileSchedTwo); 1262 1263 for (modnum = 0; modList[modnum].name != NULL; ++modnum) 1264 { 1265 /* sh_thread_pause_flag is true, and we block in lock 1266 * until check has returned, so we are sure check will 1267 * not run until sh_thread_pause_flag is set to false 1268 */ 1269 /* if (modList[modnum].initval >= SH_MOD_ACTIVE) */ 1270 (void) modList[modnum].mod_reconf(); 1271 } 1272 #endif 1273 1274 reset_count_dev_console(); 1275 reset_count_dev_time(); 1276 1277 (void) sh_unix_maskreset(); 1278 1279 #ifdef RELOAD_DATABASE 1280 sh_hash_hashdelete(); 1281 1282 if (0 != sl_strcmp(file_path('D', 'R'), _("REQ_FROM_SERVER"))) 1283 { 1284 char hashbuf[KEYBUF_SIZE]; 1285 (void) sl_strlcpy(sh.data.hash, 1286 sh_tiger_hash (file_path('D', 'R'), 1287 TIGER_FILE, TIGER_NOLIM, 1288 hashbuf, sizeof(hashbuf)), 1289 KEY_LEN+1); 1290 } 1291 #endif 1292 (void) sl_trust_purge_user(); 1293 (void) sh_files_hle_reg (NULL); 1294 (void) sh_prelink_run (NULL, NULL, 0, 0); 1295 1296 /* -------------------------- 1297 * --- READ CONFIGURATION --- 1298 * -------------------------- 1299 */ 1300 (void) sh_readconf_read (); 1301 sig_config_read_again = 0; 1302 (void) sh_files_setrec(); 1303 (void) sh_files_test_setup(); 1304 sh_audit_commit (); 1305 1306 if (0 != sh.flag.nice) 1307 { 1308 #ifdef HAVE_SETPRIORITY 1309 setpriority(PRIO_PROCESS, 0, sh.flag.nice); 1310 #else 1311 nice(sh.flag.nice); 1312 #endif 1313 } 1314 1315 if (sh.flag.checkSum == SH_CHECK_INIT) 1316 { 1317 sh.flag.isdaemon = S_FALSE; 1318 sh.flag.loop = S_FALSE; 1319 } 1320 1321 1322 /* --- Initialize modules. --- 1323 */ 1324 TPT((0, FIL__, __LINE__, _("msg=<Initialize modules.>\n"))); 1325 for (modnum = 0; modList[modnum].name != NULL; ++modnum) 1326 { 1327 status = modList[modnum].mod_init(&(modList[modnum])); 1328 1329 if (status < 0) 1330 { 1331 if (status == (-1)) { 1332 sh_error_handle (SH_ERR_NOTICE, FIL__, __LINE__, 1333 status, MSG_MOD_FAIL, 1334 _(modList[modnum].name), 1335 status+SH_MOD_OFFSET); 1336 } else { 1337 sh_error_handle ((-1), FIL__, __LINE__, 1338 status, MSG_MOD_FAIL, 1339 _(modList[modnum].name), 1340 status+SH_MOD_OFFSET); 1341 } 1342 modList[modnum].initval = SH_MOD_FAILED; 1343 } 1344 else 1345 { 1346 sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_MOD_OK, 1347 _(modList[modnum].name)); 1348 modList[modnum].initval = status; 1349 } 1350 } 1351 1352 /* module is properly set up now 1353 */ 1354 sh_thread_pause_flag = S_FALSE; 1355 1356 return; 1357 } 1358 1359 static void check_signals (volatile int *flag_check_1, 1360 volatile int * flag_check_2) 1361 { 1362 if (sig_raised > 0) 1363 { 1364 1365 TPT((0, FIL__, __LINE__, _("msg=<Process a signal.>\n"))) 1366 1367 if (sig_termfast == 1) /* SIGTERM */ 1368 { 1369 TPT((0, FIL__, __LINE__, _("msg=<Terminate.>\n"))); 1370 --sig_raised; --sig_urgent; 1371 aud_exit (FIL__, __LINE__, EXIT_SUCCESS); 1372 } 1373 1374 if (sig_force_check == 1) /* SIGTTOU */ 1375 { 1376 TPT((0, FIL__, __LINE__, _("msg=<Check run triggered.>\n"))); 1377 *flag_check_1 = 1; *flag_check_2 = 1; 1378 sig_force_check = 0; --sig_raised; 1379 sh_sem_trylock(); 1380 } 1381 1382 if (sig_config_read_again == 1 && /* SIGHUP */ 1383 sh_global_suspend_flag == 0) 1384 { 1385 TPT((0, FIL__, __LINE__, _("msg=<Re-read configuration.>\n"))); 1386 do_reconf(); 1387 --sig_raised; 1388 } 1389 1390 if (sig_fresh_trail == 1) /* SIGIOT */ 1391 { 1392 if (sh_global_suspend_flag == 0) 1393 { 1394 SH_MUTEX_LOCK(mutex_thread_nolog); 1395 1396 /* Logfile access 1397 */ 1398 #ifdef SH_USE_XML 1399 (void) sh_log_file (NULL, NULL); 1400 #endif 1401 TPT((0, FIL__, __LINE__, _("msg=<Logfile stop/restart.>\n"))); 1402 sh_error_only_stderr (S_TRUE); 1403 (void) sh_unix_rm_lock_file(sh.srvlog.name); 1404 (void) retry_msleep(3, 0); 1405 sh.flag.log_start = S_TRUE; 1406 sh_error_only_stderr (S_FALSE); 1407 sh_thread_pause_flag = S_FALSE; 1408 sig_fresh_trail = 0; 1409 --sig_raised; 1410 SH_MUTEX_UNLOCK(mutex_thread_nolog); 1411 } 1412 } 1413 1414 if (sig_terminate == 1) /* SIGQUIT */ 1415 { 1416 TPT((0, FIL__, __LINE__, _("msg=<Terminate.>\n"))); 1417 strncpy (sh_sig_msg, _("Quit"), 20); 1418 --sig_raised; 1419 aud_exit (FIL__, __LINE__, EXIT_SUCCESS); 1420 } 1421 1422 if (sig_debug_switch == 1) /* SIGUSR1 */ 1423 { 1424 TPT((0, FIL__, __LINE__, _("msg=<Debug switch.>\n"))); 1425 sh_error_dbg_switch(); 1426 sig_debug_switch = 0; 1427 --sig_raised; 1428 } 1429 1430 if (sig_suspend_switch > 0) /* SIGUSR2 */ 1431 { 1432 TPT((0, FIL__, __LINE__, _("msg=<Suspend switch.>\n"))); 1433 if (sh_global_suspend_flag != 1) { 1434 SH_MUTEX_LOCK_UNSAFE(mutex_thread_nolog); 1435 sh_global_suspend_flag = 1; 1436 sh_error_handle((-1), FIL__, __LINE__, 0, MSG_SUSPEND, 1437 sh.prg_name); 1438 } else { 1439 sh_global_suspend_flag = 0; 1440 SH_MUTEX_UNLOCK_UNSAFE(mutex_thread_nolog); 1441 } 1442 --sig_suspend_switch; 1443 --sig_raised; --sig_urgent; 1444 } 1445 1446 if (sh_load_delta_flag > 0 && 1447 sh_global_suspend_flag == 0) /* DELTA Command */ 1448 { 1449 if (0 == sh_dbIO_load_delta()) 1450 { 1451 --sh_load_delta_flag; --sig_raised; 1452 } 1453 } 1454 1455 sig_raised = (sig_raised < 0) ? 0 : sig_raised; 1456 sig_urgent = (sig_urgent < 0) ? 0 : sig_urgent; 1457 TPT((0, FIL__, __LINE__, _("msg=<End signal processing.>\n"))); 1458 } 1459 return; 1460 } 1461 1462 void check_for_delta_db() 1463 { 1464 /* Need to contact the server. 1465 */ 1466 sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_CHECK_2); 1467 1468 if (sig_raised > 0 && sh_load_delta_flag > 0) /* DELTA Command */ 1469 { 1470 /* There was a DELTA Command 1471 */ 1472 if (0 == sh_dbIO_load_delta()) 1473 { 1474 --sh_load_delta_flag; --sig_raised; 1475 } 1476 } 1477 return; 1478 } 1479 1217 1480 #endif 1218 1481 … … 1229 1492 { 1230 1493 #if defined(INET_SYSLOG) 1231 extern int create_syslog_socket (int flag);1494 extern int sh_xfer_create_syslog_socket (int flag); 1232 1495 #endif 1233 1496 #if defined(SH_WITH_SERVER) … … 1272 1535 /* --- Close all but first three file descriptors. --- 1273 1536 */ 1274 sh_unix_closeall(3, -1, S L_FALSE); /* at program start */1537 sh_unix_closeall(3, -1, S_FALSE); /* at program start */ 1275 1538 1276 1539 … … 1535 1798 /* --- load database; checksum of database 1536 1799 */ 1537 #if defined (SH_WITH_CLIENT) || defined (SH_STANDALONE) 1538 TPT((0, FIL__, __LINE__, _("msg=<Get checksum of the database.>\n"))) 1539 if (sh.flag.checkSum == SH_CHECK_CHECK) 1540 { 1541 if (0 != sl_strcmp(file_path('D', 'R'), _("REQ_FROM_SERVER"))) 1542 { 1543 char hashbuf[KEYBUF_SIZE]; 1544 (void) sl_strlcpy(sh.data.hash, 1545 sh_tiger_hash (file_path('D', 'R'), 1546 TIGER_FILE, TIGER_NOLIM, 1547 hashbuf, sizeof(hashbuf)), 1548 KEY_LEN+1); 1549 } 1550 1551 /* this eventually fetches the file from server to get checksum 1552 */ 1553 sh_hash_init (); 1554 } 1800 #if defined (SH_WITH_CLIENT) || defined (SH_STANDALONE) 1801 if (0 == sh.delayload) 1802 sh_hash_init_and_checksum(); 1555 1803 #endif 1556 1804 … … 1564 1812 } 1565 1813 1814 #if defined (SH_WITH_CLIENT) || defined (SH_STANDALONE) 1815 if (sh.delayload) 1816 { 1817 sleep(sh.delayload); 1818 sh_hash_init_and_checksum(); 1819 } 1820 #endif 1821 1566 1822 /* --- drop privileges eventually --- 1567 1823 */ … … 1569 1825 sh_create_tcp_socket (); 1570 1826 #if defined(INET_SYSLOG) 1571 create_syslog_socket (S_TRUE);1827 sh_xfer_create_syslog_socket (S_TRUE); 1572 1828 #endif 1573 1829 SL_REQUIRE(sl_policy_get_real(DEFAULT_IDENT) == SL_ENONE, … … 1591 1847 */ 1592 1848 #if defined(INET_SYSLOG) && defined(SH_WITH_SERVER) 1593 create_syslog_socket (S_FALSE);1849 sh_xfer_create_syslog_socket (S_FALSE); 1594 1850 #endif 1595 1851 … … 1656 1912 1657 1913 1658 if ((skey == NULL) || (skey->mlock_failed == S L_TRUE))1914 if ((skey == NULL) || (skey->mlock_failed == S_TRUE)) 1659 1915 sh_error_handle ((-1), FIL__, __LINE__, EPERM, MSG_MLOCK); 1660 1916 … … 1678 1934 if (sh.flag.isserver == S_TRUE) 1679 1935 { 1680 sh_ receive();1936 sh_xfer_start_server(); 1681 1937 TPT((0, FIL__, __LINE__, _("msg=<End server.>\n"))) 1682 1938 aud_exit (FIL__, __LINE__, EXIT_SUCCESS); 1683 1939 } 1684 1940 #else 1685 sh_ receive();1941 sh_xfer_start_server(); 1686 1942 TPT((0, FIL__, __LINE__, _("msg=<End server.>\n"))) 1687 1943 aud_exit (FIL__, __LINE__, EXIT_SUCCESS); … … 1745 2001 } 1746 2002 2003 /* -------- CREATE SEMAPHORE --------- 2004 */ 2005 sh_sem_open(); 2006 1747 2007 /* -------- MAIN LOOP --------- 1748 2008 */ … … 1763 2023 tcurrent = time (NULL); 1764 2024 1765 if (sig_raised > 0) 1766 { 1767 1768 TPT((0, FIL__, __LINE__, _("msg=<Process a signal.>\n"))) 1769 1770 if (sig_termfast == 1) /* SIGTERM */ 1771 { 1772 TPT((0, FIL__, __LINE__, _("msg=<Terminate.>\n"))); 1773 /* strncpy (sh_sig_msg, _("SIGTERM"), 20); */ 1774 --sig_raised; --sig_urgent; 1775 aud_exit (FIL__, __LINE__, EXIT_SUCCESS); 1776 } 1777 1778 if (sig_force_check == 1) /* SIGTTOU */ 1779 { 1780 TPT((0, FIL__, __LINE__, _("msg=<Check run triggered.>\n"))); 1781 flag_check_1 = 1; 1782 flag_check_2 = 1; 1783 sig_force_check = 0; 1784 --sig_raised; 1785 } 1786 1787 if (sig_config_read_again == 1 && /* SIGHUP */ 1788 sh_global_suspend_flag == 0) 1789 { 1790 TPT((0, FIL__, __LINE__, _("msg=<Re-read configuration.>\n"))) 1791 sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_RECONF); 1792 1793 sh_thread_pause_flag = S_TRUE; 1794 1795 #if defined(WITH_EXTERNAL) 1796 /* delete list of external tasks 1797 */ 1798 (void) sh_ext_cleanup(); 1799 #endif 1800 #if defined(SH_WITH_MAIL) 1801 sh_nmail_free(); 1802 #endif 1803 1804 /* delete the file list, make all database 1805 * entries visible (allignore = FALSE) 1806 */ 1807 (void) sh_files_deldirstack (); 1808 (void) sh_files_delfilestack (); 1809 (void) sh_files_delglobstack (); 1810 (void) sh_ignore_clean (); 1811 (void) hash_full_tree (); 1812 sh_audit_delete_all (); 1813 1814 1815 #if defined(SH_WITH_CLIENT) 1816 reset_count_dev_server(); 1817 #endif 1818 #if defined(SH_WITH_CLIENT) || defined(SH_STANDALONE) 1819 sh_restrict_purge (); 1820 1821 1822 FileSchedOne = free_sched(FileSchedOne); 1823 FileSchedTwo = free_sched(FileSchedTwo); 1824 1825 for (modnum = 0; modList[modnum].name != NULL; ++modnum) 1826 { 1827 /* sh_thread_pause_flag is true, and we block in lock 1828 * until check has returned, so we are sure check will 1829 * not run until sh_thread_pause_flag is set to false 1830 */ 1831 /* if (modList[modnum].initval >= SH_MOD_ACTIVE) */ 1832 (void) modList[modnum].mod_reconf(); 1833 } 1834 #endif 1835 1836 reset_count_dev_console(); 1837 reset_count_dev_time(); 1838 1839 (void) sh_unix_maskreset(); 1840 1841 /* Should this be included ??? 1842 * (i.e. should we reload the database ?) 1843 */ 1844 #ifdef RELOAD_DATABASE 1845 sh_hash_hashdelete(); 1846 1847 if (0 != sl_strcmp(file_path('D', 'R'), _("REQ_FROM_SERVER"))) 1848 { 1849 char hashbuf[KEYBUF_SIZE]; 1850 (void) sl_strlcpy(sh.data.hash, 1851 sh_tiger_hash (file_path('D', 'R'), 1852 TIGER_FILE, TIGER_NOLIM, 1853 hashbuf, sizeof(hashbuf)), 1854 KEY_LEN+1); 1855 } 1856 #endif 1857 (void) sl_trust_purge_user(); 1858 (void) sh_files_hle_reg (NULL); 1859 (void) sh_prelink_run (NULL, NULL, 0); 1860 1861 /* -------------------------- 1862 * --- READ CONFIGURATION --- 1863 * -------------------------- 1864 */ 1865 (void) sh_readconf_read (); 1866 sig_config_read_again = 0; 1867 (void) sh_files_setrec(); 1868 (void) sh_files_test_setup(); 1869 sh_audit_commit (); 1870 1871 if (0 != sh.flag.nice) 1872 { 1873 #ifdef HAVE_SETPRIORITY 1874 setpriority(PRIO_PROCESS, 0, sh.flag.nice); 1875 #else 1876 nice(sh.flag.nice); 1877 #endif 1878 } 1879 1880 if (sh.flag.checkSum == SH_CHECK_INIT) 1881 { 1882 sh.flag.isdaemon = S_FALSE; 1883 sh.flag.loop = S_FALSE; 1884 } 1885 1886 1887 /* --- Initialize modules. --- 1888 */ 1889 TPT((0, FIL__, __LINE__, _("msg=<Initialize modules.>\n"))); 1890 for (modnum = 0; modList[modnum].name != NULL; ++modnum) 1891 { 1892 status = modList[modnum].mod_init(&(modList[modnum])); 1893 1894 if (status < 0) 1895 { 1896 if (status == (-1)) { 1897 sh_error_handle (SH_ERR_NOTICE, FIL__, __LINE__, 1898 status, MSG_MOD_FAIL, 1899 _(modList[modnum].name), 1900 status+SH_MOD_OFFSET); 1901 } else { 1902 sh_error_handle ((-1), FIL__, __LINE__, 1903 status, MSG_MOD_FAIL, 1904 _(modList[modnum].name), 1905 status+SH_MOD_OFFSET); 1906 } 1907 modList[modnum].initval = SH_MOD_FAILED; 1908 } 1909 else 1910 { 1911 sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_MOD_OK, 1912 _(modList[modnum].name)); 1913 modList[modnum].initval = status; 1914 } 1915 } 1916 1917 /* module is properly set up now 1918 */ 1919 sh_thread_pause_flag = S_FALSE; 1920 1921 --sig_raised; 1922 } 1923 1924 if (sig_fresh_trail == 1) /* SIGIOT */ 1925 { 1926 if (sh_global_suspend_flag == 0) 1927 { 1928 SH_MUTEX_LOCK(mutex_thread_nolog); 1929 1930 /* Logfile access 1931 */ 1932 #ifdef SH_USE_XML 1933 (void) sh_log_file (NULL, NULL); 1934 #endif 1935 TPT((0, FIL__, __LINE__, _("msg=<Logfile stop/restart.>\n"))); 1936 sh_error_only_stderr (S_TRUE); 1937 (void) sh_unix_rm_lock_file(sh.srvlog.name); 1938 (void) retry_msleep(3, 0); 1939 sh.flag.log_start = S_TRUE; 1940 sh_error_only_stderr (S_FALSE); 1941 sh_thread_pause_flag = S_FALSE; 1942 sig_fresh_trail = 0; 1943 --sig_raised; 1944 SH_MUTEX_UNLOCK(mutex_thread_nolog); 1945 } 1946 } 1947 1948 if (sig_terminate == 1) /* SIGQUIT */ 1949 { 1950 TPT((0, FIL__, __LINE__, _("msg=<Terminate.>\n"))); 1951 strncpy (sh_sig_msg, _("Quit"), 20); 1952 --sig_raised; --sig_urgent; 1953 aud_exit (FIL__, __LINE__, EXIT_SUCCESS); 1954 } 1955 1956 if (sig_debug_switch == 1) /* SIGUSR1 */ 1957 { 1958 TPT((0, FIL__, __LINE__, _("msg=<Debug switch.>\n"))); 1959 sh_error_dbg_switch(); 1960 sig_debug_switch = 0; 1961 --sig_raised; 1962 } 1963 1964 if (sig_suspend_switch > 0) /* SIGUSR2 */ 1965 { 1966 TPT((0, FIL__, __LINE__, _("msg=<Suspend switch.>\n"))); 1967 if (sh_global_suspend_flag != 1) { 1968 SH_MUTEX_LOCK_UNSAFE(mutex_thread_nolog); 1969 sh_global_suspend_flag = 1; 1970 sh_error_handle((-1), FIL__, __LINE__, 0, MSG_SUSPEND, 1971 sh.prg_name); 1972 } else { 1973 sh_global_suspend_flag = 0; 1974 SH_MUTEX_UNLOCK_UNSAFE(mutex_thread_nolog); 1975 } 1976 --sig_suspend_switch; 1977 --sig_raised; --sig_urgent; 1978 } 1979 sig_raised = (sig_raised < 0) ? 0 : sig_raised; 1980 sig_urgent = (sig_urgent < 0) ? 0 : sig_urgent; 1981 TPT((0, FIL__, __LINE__, _("msg=<End signal processing.>\n"))); 1982 } 1983 1984 if (sh_global_suspend_flag == 1) 1985 { 2025 do { 2026 check_signals(&flag_check_1, &flag_check_2); 2027 if (sh_global_suspend_flag == 1) 1986 2028 (void) retry_msleep (1, 0); 1987 continue; 1988 } 2029 } while (sh_global_suspend_flag == 1); 1989 2030 1990 2031 /* see whether its time to check files … … 2026 2067 (flag_check_1 == 1 || flag_check_2 == 1)) 2027 2068 { 2069 sh_sem_trylock(); 2070 2071 /* Starting a check now, so make sure to fetch delta DB 2072 * if there is one to download. 2073 */ 2074 check_for_delta_db(); 2075 2028 2076 SH_INOTIFY_IFUSED( sh.flag.inotify |= SH_INOTIFY_INSCAN; ); 2029 2077 /* Refresh list files matching glob patterns. … … 2065 2113 (void) sh_files_chk (); 2066 2114 2067 if (sig_urgent > 0) 2068 continue; 2069 2115 if (sig_urgent > 0) { sh_sem_unlock(sh.statistics.files_report); continue; } 2070 2116 /* 2071 2117 * check for files not visited … … 2077 2123 } 2078 2124 2079 if (sig_urgent > 0) 2080 continue; 2125 if (sig_urgent > 0) { sh_sem_unlock(sh.statistics.files_report); continue; } 2081 2126 2082 2127 /* reset … … 2084 2129 TPT((0, FIL__, __LINE__, _("msg=<Reset status.>\n"))) 2085 2130 sh_dirs_reset (); 2086 if (sig_urgent > 0) 2087 continue;2131 2132 if (sig_urgent > 0) { sh_sem_unlock(sh.statistics.files_report); continue; } 2088 2133 2089 2134 sh_files_reset (); 2135 check_done = 1; 2136 2090 2137 flag_check_1 = 0; 2091 2138 flag_check_2 = 0; 2092 check_done = 1; 2139 sh_sem_unlock(sh.statistics.files_report); 2140 2093 2141 SH_INOTIFY_IFUSED( sh.flag.inotify &= ~SH_INOTIFY_INSCAN; ); 2094 2142 SH_INOTIFY_IFUSED( sh.flag.inotify &= ~SH_INOTIFY_DOSCAN; ); 2095 2143 2096 (void) sh_prelink_run (NULL, NULL, 0); 2097 2098 if (sig_urgent > 0) 2099 continue; 2144 (void) sh_prelink_run (NULL, NULL, 0, 0); 2145 2146 if (sig_urgent > 0) continue; 2100 2147 2101 2148 runtim = time(NULL) - sh.statistics.time_start; … … 2130 2177 sh.fileCheck.alarm_last = time (NULL); 2131 2178 2132 if (sig_urgent > 0) 2133 continue; 2179 if (sig_urgent > 0) continue; 2134 2180 2135 2181 /* … … 2142 2188 } 2143 2189 2144 if (sig_urgent > 0) 2145 continue; 2190 if (sig_urgent > 0) continue; 2146 2191 2147 2192 /* execute modules … … 2161 2206 */ 2162 2207 if (sh.flag.checkSum == SH_CHECK_INIT) 2163 sh_ hash_pushdata(NULL, NULL);2208 sh_dbIO_data_write (NULL, NULL); 2164 2209 2165 2210 /* write out database … … 2168 2213 sh.flag.update == S_TRUE && 2169 2214 check_done == 1) 2170 sh_ hash_writeout();2215 sh_dbIO_writeout_update (); 2171 2216 2172 2217 /* no-op unless MEM_LOG is defined in sh_mem.c … … 2196 2241 /* no loop if not daemon 2197 2242 */ 2198 if (sh.flag.isdaemon != S_TRUE && sh.flag.loop == S_FALSE) 2199 break; 2200 if (sig_urgent > 0) 2201 continue; 2243 if (sh.flag.isdaemon != S_TRUE && sh.flag.loop == S_FALSE) break; 2244 if (sig_urgent > 0) continue; 2202 2245 2203 2246 /* see whether its time to send mail … … 2211 2254 } 2212 2255 #endif 2213 if (sig_urgent > 0) 2214 continue; 2256 if (sig_urgent > 0) continue; 2215 2257 2216 2258 /* log the timestamp … … 2232 2274 (void) taus_seed(); 2233 2275 2234 if (sig_urgent > 0) 2235 continue; 2276 if (sig_urgent > 0) continue; 2236 2277 2237 2278 /* reset cache … … 2266 2307 #endif 2267 2308 2268 #if 02269 {2270 char command[128];2271 sprintf(command, "/bin/cat /proc/%d/status", (int) getpid());2272 system(command); /* flawfinder: ignore *//* debug code */2273 malloc_stats();2274 }2275 #endif2276 2277 2309 aud_exit (FIL__, __LINE__, EXIT_SUCCESS); 2278 2310 SL_RETURN(0, _("main"));
Note:
See TracChangeset
for help on using the changeset viewer.