Changeset 321
- Timestamp:
- Mar 17, 2011, 10:07:44 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/configure.ac
r310 r321 12 12 dnl start 13 13 dnl 14 AM_INIT_AUTOMAKE(samhain, 2.8. 2)14 AM_INIT_AUTOMAKE(samhain, 2.8.3) 15 15 AC_DEFINE([SAMHAIN], 1, [Application is samhain]) 16 16 AC_CANONICAL_HOST … … 1974 1974 1975 1975 sh_insmod_cmd=": # no kernel module" 1976 sh_insmod_pre=": # no kernel module" 1976 1977 sh_lkm="" 1977 1978 lkm_inc="" … … 2151 2152 2152 2153 sh_lkm="${sh_lkm} samhain_kmem.ko" 2153 echo "${sh_insmod_cmd}" | grep 'no kernel module' >/dev/null 2154 if [ $? -eq 0 ]; then 2155 sh_insmod_cmd="modprobe ${install_name}_kmem" 2156 else 2157 sh_insmod_cmd="modprobe ${install_name}_kmem; ${sh_insmod_cmd}" 2158 fi 2154 sh_insmod_pre="modprobe ${install_name}_kmem" 2155 2159 2156 fi 2160 2157 else … … 2168 2165 AC_SUBST(sh_lkm) 2169 2166 AC_SUBST(sh_insmod_cmd) 2167 AC_SUBST(sh_insmod_pre) 2170 2168 2171 2169 AC_SUBST(systemmap) -
trunk/docs/Changelog
r315 r321 1 1 2.8.3: 2 * init scripts: load samhain_kmem.ko before samhain starts 3 * slib.c: eliminate mutex from sl_create_ticket() 4 * sh_entropy.c: move pthread usage out of child 5 * sh_hash.c, sh_pthread.c, sh_pthread.h: sh_hash_hashdelete() 6 needs deadlock detection, may be called from within sh_hash_init() 7 via atexit handler on error condition 8 * sh_suidchk.c, sh_calls.c, sh_calls.h: need a nosub version of lstat() 9 to use with relative path after chdir() 10 * samhain.c, sh_calls.c, sh_calls.h: only run (l)stat() in subprocess 11 after reading config file (to allow disabling) 12 * sh_unix.c: run sh_sub_kill() in parent after forking the daemon 2 13 * fix zeroing of result from getnameinfo() (problem reported by Richard) 3 14 * fix spurious warnings about unsupported address family (reported -
trunk/include/sh_sub.h
r316 r321 2 2 #define SH_SUB_H 3 3 4 void sh_kill_sub (); 4 5 int sh_sub_stat (const char *path, struct stat *buf); 5 6 int sh_sub_lstat (const char *path, struct stat *buf); -
trunk/init/samhain.startGentoo.in
r1 r321 9 9 start() { 10 10 ebegin "Starting @install_name@" 11 @sh_insmod_pre@ 11 12 /sbin/start-stop-daemon --start --quiet --exec @sbindir@/@install_name@ 12 13 eend $? -
trunk/init/samhain.startLSB.in
r279 r321 87 87 case "$1" in 88 88 start) 89 # 90 # Preloaded kernel module 91 # 92 @sh_insmod_pre@ 93 # 89 94 ${DAEMON} start 90 95 ERRNUM=$? -
trunk/init/samhain.startLinux.in
r59 r321 140 140 fi 141 141 # 142 # Preloaded kernel module 143 # 144 @sh_insmod_pre@ 145 # 142 146 case "$DISTRO" in 143 147 debian) -
trunk/src/sh_extern.c
r294 r321 569 569 char infomsg[256]; 570 570 571 #ifdef WCONTINUED 572 int wflags = WNOHANG|WUNTRACED|WCONTINUED; 573 #else 574 int wflags = WNOHANG|WUNTRACED; 575 #endif 576 571 577 SL_ENTER(_("sh_ext_pclose")); 572 578 … … 586 592 587 593 nochmal: 588 retval = waitpid(task->pid, &(task->exit_status), WNOHANG|WUNTRACED);594 retval = waitpid(task->pid, &(task->exit_status), wflags); 589 595 /*@-bufferoverflowhigh@*/ 590 596 if (task->pid == retval) … … 614 620 (void) aud_kill (FIL__, __LINE__, task->pid, 9); 615 621 (void) retry_msleep (0, 30); 616 (void) waitpid (task->pid, NULL, WNOHANG|WUNTRACED);622 (void) waitpid (task->pid, NULL, wflags); 617 623 } 618 624 else -
trunk/src/sh_ipvx.c
r314 r321 52 52 static int sh_ipvx_is_ipv6 (const char * addr) 53 53 { 54 int j ;54 int j, k = 0; 55 55 char c; 56 56 int len = sl_strlen(addr); … … 63 63 ( c != ':') && ( c != '.')) 64 64 return (1 == 0); 65 else if (c == ':') 66 ++k; 67 else if (c == '.' && k < 3) 68 return (1 == 0); /* ::ffff:ipv4 */ 65 69 } 66 70 return (1 == 1); … … 234 238 } 235 239 #else 236 port = ntohs(((struct sockaddr_in *)sa).sin_port); 240 (void) sa_family; 241 port = ntohs(((struct sockaddr_in *)sa)->sin_port); 237 242 #endif 238 243 return port; -
trunk/src/sh_kern.c
r303 r321 746 746 int errcode; 747 747 748 #ifdef WCONTINUED 749 int wflags = WNOHANG|WUNTRACED|WCONTINUED; 750 #else 751 int wflags = WNOHANG|WUNTRACED; 752 #endif 753 748 754 /* Close reading side of pipe, and wait some milliseconds 749 755 */ … … 820 826 821 827 if (status < 0) 822 res = waitpid(mpid, NULL, WNOHANG|WUNTRACED);828 res = waitpid(mpid, NULL, wflags); 823 829 else 824 830 { 825 res = waitpid(mpid, &status, WNOHANG|WUNTRACED);831 res = waitpid(mpid, &status, wflags); 826 832 if (res == 0 && 0 != WIFEXITED(status)) 827 833 status = WEXITSTATUS(status); -
trunk/src/sh_sub.c
r316 r321 20 20 #include "config_xor.h" 21 21 22 /* 0->1 for debug */ 23 #if 0 24 #define SH_SUB_DBG 1 25 #endif 26 22 27 #ifndef NULL 23 28 #if !defined(__cplusplus) … … 62 67 static ssize_t sh_sub_read(int fd, void *buf, size_t count); 63 68 64 staticvoid sh_kill_sub()69 void sh_kill_sub() 65 70 { 66 71 SH_MUTEX_LOCK(mutex_sub); 72 67 73 if (sh_child_pid != -1) 68 74 { 69 75 int status; 76 #ifdef WCONTINUED 77 int wflags = WNOHANG|WUNTRACED|WCONTINUED; 78 #else 79 int wflags = WNOHANG|WUNTRACED; 80 #endif 70 81 71 82 close (parent2child[1]); 72 83 close (child2parent[0]); 73 84 74 fprintf(stderr, "FIXME kill_sub %d\n", (int) sh_child_pid);85 /* fprintf(stderr, "FIXME kill_sub %d\n", (int) sh_child_pid); */ 75 86 76 87 /* Let's be rude. */ … … 80 91 81 92 if (sh_wait_ret == 0) 82 sh_wait_ret = waitpid( -1, &status, WNOHANG|WUNTRACED);93 sh_wait_ret = waitpid( -1, &status, wflags); 83 94 else 84 sh_wait_ret = waitpid(sh_child_pid, &status, WNOHANG|WUNTRACED);95 sh_wait_ret = waitpid(sh_child_pid, &status, wflags); 85 96 86 97 sh_child_pid = -1; 87 98 } 99 88 100 SH_MUTEX_UNLOCK(mutex_sub); 89 101 return; … … 93 105 { 94 106 pid_t res; 95 int retval = 0;107 volatile int retval = 0; 96 108 97 109 SH_MUTEX_LOCK(mutex_sub); … … 162 174 ++fd; 163 175 } 176 177 /* 178 for (i = 0; i < 3; ++i) 179 { 180 if ( fcntl(i, F_GETFL, 0) == (-1)) 181 (void) open(_("/dev/null"), O_RDWR, 0); 182 } 183 */ 164 184 165 185 /* reset signal handling … … 275 295 do { 276 296 277 / / fprintf(stderr, "FIXME wait_com polling..\n");297 /* fprintf(stderr, "FIXME wait_com polling..\n"); */ 278 298 279 299 do { … … 307 327 outbuf.errnum = errno; 308 328 309 / / fprintf(stderr, "FIXME wait_com writing..\n");329 /* fprintf(stderr, "FIXME wait_com writing..\n"); */ 310 330 311 331 ret = sh_sub_write(child2parent[1], &outbuf, sizeof(outbuf)); 312 332 if (ret < 0) 313 333 { 314 fprintf(stderr, "FIXME wait_com return 1\n");334 /* fprintf(stderr, "FIXME wait_com return 1\n"); */ 315 335 return; 316 336 } … … 318 338 else /* sh_sub_read() < 0 */ 319 339 { 320 fprintf(stderr, "FIXME wait_com return 2\n");340 /* fprintf(stderr, "FIXME wait_com return 2\n"); */ 321 341 return; 322 342 } 323 343 } 324 344 325 / / fprintf(stderr, "FIXME wait_com next..\n");345 /* fprintf(stderr, "FIXME wait_com next..\n"); */ 326 346 327 347 } while (1 == 1); … … 362 382 } 363 383 384 #ifdef SH_SUB_DBG 385 #include <stdarg.h> 386 static void debug_it (const char *fmt, ...) 387 { 388 char msg[256]; 389 va_list ap; 390 391 int fd = open("debug.it", O_CREAT|O_WRONLY|O_APPEND, 0666); 392 393 va_start(ap, fmt); 394 vsnprintf(msg, sizeof(msg), fmt, ap); /* flawfinder: ignore */ 395 va_end(ap); 396 397 write(fd, msg, strlen(msg)); 398 write(fd, "\n", 1); 399 close(fd); 400 return; 401 } 402 #endif 403 364 404 static int sh_sub_stat_int(const char *path, struct stat *buf, char command) 365 405 { … … 397 437 start: 398 438 439 #ifdef SH_SUB_DBG 440 debug_it("%d sh_child_pid %d\n", (int)getpid(), (int) sh_child_pid); 441 #endif 442 399 443 if (sh_child_pid == -1) 400 444 sh_create_sub(); 401 445 402 // fprintf(stderr, "FIXME stat_sub %s\n", inbuf.path); 446 #ifdef SH_SUB_DBG 447 debug_it("%d stat_sub %s (%d)\n", (int)getpid(), inbuf.path, (int) sh_child_pid); 448 #endif 403 449 404 450 SH_MUTEX_LOCK(mutex_sub_work); … … 412 458 } 413 459 414 // fprintf(stderr, "FIXME stat_sub polling..\n"); 460 #ifdef SH_SUB_DBG 461 debug_it("%d stat_sub polling..\n", (int)getpid()); 462 #endif 415 463 416 464 pfds.fd = child2parent[0]; … … 428 476 } 429 477 430 // fprintf(stderr, "FIXME stat_sub reading..\n"); 478 #ifdef SH_SUB_DBG 479 debug_it("%d stat_sub reading..\n", (int)getpid()); 480 #endif 431 481 432 482 retval = sh_sub_read (child2parent[0], &outbuf, sizeof(outbuf)); … … 444 494 if (sflag == 0) 445 495 { 446 // fprintf(stderr, "FIXME stat_sub done..\n"); 496 #ifdef SH_SUB_DBG 497 debug_it("%d stat_sub done..\n", (int)getpid()); 498 #endif 447 499 memcpy(buf, &(outbuf.sbuf), sizeof(struct stat)); 448 500 errno = outbuf.errnum; … … 451 503 else if (sflag == 1) 452 504 { 505 #ifdef SH_SUB_DBG 506 debug_it("%d stat_sub error..\n", (int)getpid()); 507 #endif 453 508 /* could not read, thus subprocess may have gone */ 509 sflag = 0; 454 510 goto start; 455 511 } -
trunk/src/sh_unix.c
r315 r321 1909 1909 char errbuf[SH_ERRBUF_SIZE]; 1910 1910 1911 extern void sh_kill_sub(); 1912 1911 1913 SL_ENTER(_("sh_unix_init")); 1912 1914 … … 1918 1920 case 0: break; /* child process continues */ 1919 1921 case -1: SL_RETURN((-1),_("sh_unix_init")); /* error */ 1920 default: aud__exit(FIL__, __LINE__, 0); /* parent process exits */ 1922 default: /* parent process exits */ 1923 sh_kill_sub(); 1924 aud__exit(FIL__, __LINE__, 0); 1921 1925 } 1922 1926 … … 1932 1936 case 0: break; /* child process continues */ 1933 1937 case -1: SL_RETURN((-1),_("sh_unix_init")); /* error */ 1934 default: aud__exit(FIL__, __LINE__, 0); /* parent process exits */ 1938 default: /* parent process exits */ 1939 sh_kill_sub(); 1940 aud__exit(FIL__, __LINE__, 0); 1935 1941 } 1936 1942 -
trunk/test/testrun_1c.sh
r115 r321 340 340 $MAKE 'DBGDEF=-DSH_SUIDTESTDIR=\"${BASE}\"' >/dev/null 2>&1 341 341 if test x$? = x0; then 342 [ -z "$verbose" ] || log_msg_ok "make ...";342 [ -z "$verbose" ] || log_msg_ok "make DBGDEF=-DSH_SUIDTESTDIR=${BASE} ..."; 343 343 else 344 344 [ -z "$quiet" ] && log_msg_fail "make...";
Note:
See TracChangeset
for help on using the changeset viewer.