- Timestamp:
- Jul 18, 2015, 5:06:52 PM (9 years ago)
- Location:
- trunk
- Files:
-
- 17 added
- 14 deleted
- 120 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Install.sh
r112 r481 279 279 fi 280 280 281 #------------------------------------------------------------282 #283 # Kernel module284 #285 #------------------------------------------------------------286 287 KCHECK="no"288 289 if [ "x$I386_LINUX" = "xyes" ]; then290 291 $dialog \292 --title "Kernel module rootkit detection" \293 --backtitle "Samhain $VERSION" \294 --inputbox "SAMHAIN can detect kernel module rootkits if compiled with support\nfor this. If you want to enable this option, please give the path\nto your System.map file, else choose CANCEL.\n\nNOTE: this option will require root privileges for at least one\ncommand during compilation (to read from /dev/kmem)." \295 16 75 "/boot/System.map" \296 2> $tmp297 298 299 mtest=$?300 301 if [ $mtest = -1 ]; then302 exit 1303 fi304 if [ $mtest = 0 ]; then305 mfile=`cat $tmp`306 for z in $mfile ; do307 cfgline="$cfgline --with-kcheck=$z"308 done309 KCHECK="yes"310 fi311 312 fi313 281 314 282 #------------------------------------------------------------ -
trunk/Makefile.in
r461 r481 74 74 SAMHAIN = @sh_main_prg@ 75 75 YULECTL = @yulectl_prg@ 76 SADMIN = @samhainadmin_prg@ 76 77 XOR_CODE = @xor_code@ 77 SH_LKM = @sh_lkm@78 78 TIGER_SRC = @tiger_src@ 79 79 … … 116 116 sh_getopt.h sh_readconf.h sh_tiger.h sh_hash.h \ 117 117 sh_mail.h sh_mail_int.h sh_nmail.h sh_filter.h \ 118 sh_mem.h sh_entropy.h sh_ forward.h sh_modules.h sh_utmp.h \119 sh_ kern.h sh_suidchk.h sh_srp.h sh_fifo.h sh_html.h sh_tools.h \118 sh_mem.h sh_entropy.h sh_xfer.h sh_modules.h sh_utmp.h \ 119 sh_suidchk.h sh_srp.h sh_fifo.h sh_html.h sh_tools.h \ 120 120 sh_gpg.h sh_cat.h sh_calls.h sh_extern.h sh_database.h sh_trace.h \ 121 121 sh_schedule.h bignum.h trustfile.h slib.h zAVLTree.h \ … … 126 126 sh_log_check.h sh_log_evalrule.h sh_log_correlate.h \ 127 127 sh_log_mark.h sh_log_repeat.h sh_inotify.h sh_registry.h sh_ipvx.h \ 128 sh_restrict.h sh_sub.h sh_fInotify.h sh_checksum.h 128 sh_restrict.h sh_sub.h sh_fInotify.h sh_checksum.h \ 129 sh_dbIO.h sh_dbIO_int.h sh_guid.h sh_dbCheck.h sh_dbCreate.h \ 130 sh_sem.h 129 131 130 132 … … 137 139 $(srcsrc)/sh_hash.c $(srcsrc)/sh_mail.c $(srcsrc)/sh_nmail.c \ 138 140 $(srcsrc)/sh_mem.c $(srcsrc)/sh_entropy.c \ 139 $(srcsrc)/sh_forward.c $(srcsrc)/sh_modules.c \ 140 $(srcsrc)/sh_utmp.c $(srcsrc)/sh_login_track.c $(srcsrc)/sh_kern.c \ 141 $(srcsrc)/sh_xfer_client.c $(srcsrc)/sh_xfer_server.c \ 142 $(srcsrc)/sh_xfer_syslog.c $(srcsrc)/sh_modules.c \ 143 $(srcsrc)/sh_utmp.c $(srcsrc)/sh_login_track.c \ 141 144 $(srcsrc)/sh_suidchk.c $(srcsrc)/sh_srp.c \ 142 145 $(srcsrc)/sh_fifo.c $(srcsrc)/sh_tools.c \ … … 169 172 $(srcsrc)/sh_audit.c $(srcsrc)/sh_registry.c \ 170 173 $(srcsrc)/sh_ipvx.c $(srcsrc)/sh_restrict.c \ 171 $(srcsrc)/sh_filetype.c $(srcsrc)/sh_sub.c $(srcsrc)/sh_fInotify.c\ 172 $(srcsrc)/sh_checksum.c \ 174 $(srcsrc)/sh_filetype.c $(srcsrc)/sh_sub.c $(srcsrc)/sh_fInotify.c \ 175 $(srcsrc)/sh_checksum.c $(srcsrc)/sh_guid.c $(srcsrc)/sh_sem.c \ 176 $(srcsrc)/sh_dbIO.c $(srcsrc)/sh_dbCheck.c $(srcsrc)/sh_dbCreate.c \ 173 177 $(srcsrc)/t-test1.c 174 178 … … 177 181 sh_getopt.o sh_readconf.o sh_filter.o \ 178 182 sh_hash.o sh_mail.o sh_nmail.o sh_mem.o sh_login_track.o \ 179 sh_entropy.o sh_forward.o sh_modules.o sh_utmp.o sh_kern.o \ 183 sh_entropy.o sh_modules.o sh_utmp.o \ 184 sh_xfer_client.o sh_xfer_server.o sh_xfer_syslog.o \ 180 185 sh_suidchk.o sh_srp.o sh_fifo.o sh_tools.o sh_html.o sh_gpg.o \ 181 186 sh_cat.o sh_calls.o sh_extern.o sh_database.o sh_err_log.o \ … … 191 196 sh_pthread.o sh_string.o sh_inotify.o dnmalloc.o \ 192 197 sh_audit.o sh_registry.o sh_ipvx.o sh_restrict.o \ 193 sh_filetype.o sh_sub.o sh_fInotify.o sh_checksum.o 194 195 KERN = kern_head.h kern_head.c 198 sh_filetype.o sh_sub.o sh_fInotify.o sh_checksum.o \ 199 sh_guid.o sh_sem.o sh_dbIO.o sh_dbCheck.o sh_dbCreate.o 200 196 201 197 202 TESTSUITE = test.sh testcompile.sh testhash.sh testtiger.txt \ … … 217 222 src include man scripts init docs sql_init test dsys 218 223 219 PROGRAMS = $(SETPWD) $(STEGIN) $(SAMHAIN) $(YULECTL) 224 PROGRAMS = $(SETPWD) $(STEGIN) $(SAMHAIN) $(YULECTL) $(SADMIN) 220 225 221 226 #---------------------------------------------------------- … … 225 230 #---------------------------------------------------------- 226 231 227 all: $(top_srcdir)/depend.sum $(SETPWD) $(STEGIN) $(SAMHAIN) $(YULECTL) @sh_lkm@sstrip232 all: $(top_srcdir)/depend.sum $(SETPWD) $(STEGIN) $(SAMHAIN) $(YULECTL) sstrip 228 233 229 234 … … 281 286 if test -f depend-gen; then \ 282 287 failfiles=""; \ 283 for ff in $(SOURCES) $(srcsrc)/kern_head.c; do \288 for ff in $(SOURCES); do \ 284 289 ./depend-gen -i '$$(srcinc)/' -o $(top_srcdir)/depend.dep $$ff || \ 285 290 failfiles="$${failfiles} $$ff"; \ … … 320 325 if test -f depend-gen; then \ 321 326 failfiles=""; \ 322 for ff in $(SOURCES) $(srcsrc)/kern_head.c; do \327 for ff in $(SOURCES); do \ 323 328 ./depend-gen -i '$$(srcinc)/' -o $(top_srcdir)/Makefile.in $$ff || \ 324 329 failfiles="$${failfiles} $$ff"; \ … … 339 344 depend: depend-gen 340 345 @echo "update Makefile.in ..."; \ 341 for ff in $(SOURCES) $(srcsrc)/kern_head.c; do \346 for ff in $(SOURCES); do \ 342 347 ./depend-gen -i '$$(srcinc)/' -o $(top_srcdir)/Makefile.in $$ff; \ 343 348 echo $(srcsrc) > $(top_srcdir)/stamp-dep; \ … … 355 360 # 356 361 357 CLEANFILES = encode config_xor.h depend-gen sh_ks.h sh_ks_xor.h kern_head\362 CLEANFILES = encode config_xor.h depend-gen \ 358 363 internal.h sh_MK.h trustfile sstrip samhain mkhdr encode cutest \ 359 yule samhain_setpwd samhain_stealth samhainrc yulectl \ 360 samhain_hide.ko samhain_kmem.ko 364 yule samhain_setpwd samhain_stealth samhainrc yulectl 361 365 362 366 clean: … … 374 378 init/samhain.startIRIX init/samhain.startMACOSX \ 375 379 deploy.sh sh_MK.h samhain-install.sh sh_gpg_chksum.h sh_gpg_fp.h \ 376 rules.deb rules.deb-light \380 rules.deb rules.deb-light src/CuTestMain.c \ 377 381 scripts/samhainadmin.pl scripts/check_samhain.pl \ 378 scripts/samhain.ebuild scripts/samhain.ebuild-light 382 scripts/samhain.ebuild scripts/samhain.ebuild-light \ 383 scripts/yuleadmin.pl scripts/logrotate \ 384 scripts/redhat_i386.client.spec scripts/samhain.spec hp_ux.psf 379 385 380 386 TESTCLEANFILES = samhain.build samhain.new yule.html \ … … 464 470 #---------------------------------------------------------- 465 471 466 install: install- lkm install-program install-man install-data472 install: install-program install-man install-data 467 473 @echo; \ 468 474 echo " You can use 'samhain-install.sh uninstall' for uninstalling"; \ … … 472 478 echo 473 479 474 install-light: install- lkm install-program install-data480 install-light: install-program install-data 475 481 @echo; \ 476 482 echo " You can use 'samhain-install.sh uninstall' for uninstalling"; \ … … 480 486 echo 481 487 482 purge: uninstall- lkm uninstall-program uninstall-man488 purge: uninstall-program uninstall-man 483 489 @echo "./samhain-install.sh --destdir=$(DESTDIR) --force --verbose uninstall-data"; \ 484 490 ./samhain-install.sh --destdir=$(DESTDIR) --force --verbose uninstall-data … … 486 492 remove: uninstall 487 493 488 uninstall: uninstall- lkm uninstall-program uninstall-man uninstall-data494 uninstall: uninstall-program uninstall-man uninstall-data 489 495 @echo; \ 490 496 echo " Use 'make purge' if you also want to uninstall the configuration file"; \ … … 505 511 # --- program --- 506 512 # 507 508 # -- NEW --509 install-lkm: @sh_lkm@510 @RVER=`uname -r`; \511 if test "x@sh_lkm@" != "x"; then \512 if test -d /lib/modules/$$RVER; then \513 MODDIR="/lib/modules/$$RVER"; \514 elif test -d /lib/modules/misc; then \515 MODDIR="/lib/modules/misc"; \516 elif test -d /lib/modules; then \517 MODDIR="/lib/modules/misc"; \518 fi; \519 $(mkinstalldirs) $(DESTDIR)$${MODDIR}; \520 list='@sh_lkm@'; for p in $$list; do \521 echo " cp $$p $(DESTDIR)$${MODDIR}/`echo $$p|sed 's%samhain%@install_name@%'`"; \522 cp $$p $(DESTDIR)$${MODDIR}/`echo $$p|sed 's%samhain%@install_name@%'` ; \523 chown root $(DESTDIR)$${MODDIR}/`echo $$p|sed 's%samhain%@install_name@%'`; \524 done; \525 if test "x$(DESTDIR)" = x; then \526 echo " depmod -a || /sbin/depmod -a"; \527 depmod -a || /sbin/depmod -a; \528 fi; \529 fi530 531 uninstall-lkm:532 @echo "./samhain-install.sh --destdir=$(DESTDIR) --express --verbose uninstall-lkm";\533 ./samhain-install.sh --destdir=$(DESTDIR) --express --verbose uninstall-lkm534 513 535 514 … … 541 520 @list='$(PROGRAMS)'; for p in $$list; do \ 542 521 if test -f $$p; then \ 543 echo " $(INSTALL_PROGRAM) $$p $(DESTDIR)$(sbindir)/`echo $$p|sed 's%samhain%@install_name@%'|sed 's%yule%@install_name@%'`"; \ 544 $(INSTALL_PROGRAM) $$p $(DESTDIR)$(sbindir)/`echo $$p|sed 's%samhain%@install_name@%'|sed 's%yule%@install_name@%'`; \ 545 chmod 0700 $(DESTDIR)$(sbindir)/`echo $$p|sed 's%samhain%@install_name@%'|sed 's%yule%@install_name@%'`; \ 546 echo " ./sstrip $(DESTDIR)$(sbindir)/`echo $$p|sed 's%samhain%@install_name@%'|sed 's%yule%@install_name@%'`"; \ 547 ./sstrip $(DESTDIR)$(sbindir)/`echo $$p|sed 's%samhain%@install_name@%'|sed 's%yule%@install_name@%'`; \ 522 target=$(DESTDIR)$(sbindir)/`echo $$p|sed 's%samhain%@install_name@%'|sed 's%yule%@install_name@%'|sed 's%.*/%%'`; \ 523 extension=`echo $$target|sed 's%.*\.%%'`; \ 524 if test x$$extension = x; then \ 525 echo " $(INSTALL_PROGRAM) $$p $$target"; \ 526 $(INSTALL_PROGRAM) $$p $$target; \ 527 chmod 0700 $$target; \ 528 echo " ./sstrip $$target"; \ 529 ./sstrip $$target; \ 530 else \ 531 echo " $(INSTALL_SHELL) $$p $$target"; \ 532 $(INSTALL_SHELL) $$p $$target; \ 533 chmod 0700 $$target; \ 534 fi; \ 548 535 else :; fi; \ 549 536 done … … 709 696 echo "./mkinstalldirs @mydataroot@ || exit 1" >> $$STAGE/setup.sh; \ 710 697 echo "chmod 700 @mydataroot@ || exit 1" >> $$STAGE/setup.sh; \ 711 if test -f $$STAGE/lib/modules; then \712 RVER=`uname -r`; \713 echo "chown root:root lib/modules/$$RVER/*" >> $$STAGE/setup.sh; \714 if test -d /lib/modules/$$RVER; then \715 echo "./mkinstalldirs /lib/modules/$$RVER" >> $$STAGE/setup.sh; \716 echo "cp -p lib/modules/$$RVER/* /lib/modules/$$RVER/" >> $$STAGE/setup.sh; \717 elif test -d /lib/modules/misc; then \718 echo "./mkinstalldirs /lib/modules/misc" >> $$STAGE/setup.sh; \719 echo "cp -p lib/modules/misc/* /lib/modules/misc/" >> $$STAGE/setup.sh; \720 elif test -d /lib/modules; then \721 echo "./mkinstalldirs /lib/modules/misc" >> $$STAGE/setup.sh; \722 echo "cp -p lib/modules/misc/* /lib/modules/misc/" >> $$STAGE/setup.sh; \723 fi; \724 echo "/sbin/depmod -a" >> $$STAGE/setup.sh; \725 fi; \726 698 temp=`echo $(sbindir) | sed s,^/,,`; \ 727 699 echo "chown root $$temp/*" >> $$STAGE/setup.sh; \ … … 828 800 echo $(mylogdir) | sed s,^/,, >> debian/dirs; \ 829 801 echo $(mylockdir) | sed s,^/,, >> debian/dirs; \ 830 if test "x@sh_lkm@" != x; then \831 RVER=`uname -r`; \832 if test -d /lib/modules/$$RVER; then \833 echo "lib/modules/$$RVER" >> debian/dirs; \834 elif test -d /lib/modules/misc; then \835 echo "lib/modules/misc" >> debian/dirs; \836 elif test -d /lib/modules; then \837 echo "lib/modules/misc" >> debian/dirs; \838 fi; \839 fi; \840 802 $(MAKE) deb-run 841 803 … … 857 819 echo $(mandir)/man8 | sed s,^/,, >> debian/dirs; \ 858 820 echo usr/share/doc/$(PACKAGE) >> debian/dirs; \ 859 if test "x@sh_lkm@" != x; then \860 RVER=`uname -r`; \861 if test -d /lib/modules/$$RVER; then \862 echo "lib/modules/$$RVER" >> debian/dirs; \863 elif test -d /lib/modules/misc; then \864 echo "lib/modules/misc" >> debian/dirs; \865 elif test -d /lib/modules; then \866 echo "lib/modules/misc" >> debian/dirs; \867 fi; \868 fi; \869 821 echo $(top_srcdir)/README > debian/docs; \ 870 822 echo $(top_srcdir)/test/testtiger.txt >> debian/docs; \ … … 876 828 echo $(top_srcdir)/docs/HOWTO-client+server.html >> debian/docs; \ 877 829 echo $(top_srcdir)/docs/HOWTO-samhain+GnuPG.html >> debian/docs; \ 878 echo $(top_srcdir)/docs/MANUAL-2_ 3.html.tar >> debian/docs; \879 echo $(top_srcdir)/docs/MANUAL-2_ 3.pdf >> debian/docs; \830 echo $(top_srcdir)/docs/MANUAL-2_4.html.tar >> debian/docs; \ 831 echo $(top_srcdir)/docs/MANUAL-2_4.pdf >> debian/docs; \ 880 832 echo $(top_srcdir)/docs/README.gcc_bug >> debian/docs; \ 881 833 echo $(top_srcdir)/docs/README.LZO >> debian/docs; \ … … 1155 1107 config_xor.h: config.h encode 1156 1108 @echo 'encode $(XOR_CODE) config.h'; \ 1157 sleep 1; \1158 1109 ./encode $(XOR_CODE) config.h; \ 1159 1110 mv x_config.h config_xor.h 1160 1111 1161 #.c.o: 1162 # @echo "./encode $(XOR_CODE) $< --> x_`echo $< |sed 's%.*/%%'`"; \ 1163 # ./encode $(XOR_CODE) $<; \ 1164 # echo "$(COMPILE) $(VFLAG) -o `echo $@ |sed 's%.*/%%'` -c x_`echo $< |sed 's%.*/%%'`"; \ 1165 # $(COMPILE) $(VFLAG) -o `echo $@ |sed 's%.*/%%'` -c x_`echo $< |sed 's%.*/%%'`; \ 1166 # rm x_`echo $< |sed 's%.*/%%'` 1167 1168 $(OBJECTS): encode internal.h 1112 1113 $(OBJECTS): encode internal.h config_xor.h 1169 1114 @echo "./encode $(XOR_CODE) $(srcsrc)/`echo $@ |sed 's%\.o$$%%'`.c --> x_`echo $@ |sed 's%\.o$$%%'`.c"; \ 1170 1115 ./encode $(XOR_CODE) $(srcsrc)/`echo $@ |sed 's%\.o$$%%'`.c; \ … … 1245 1190 gdb ./cutest 1246 1191 1247 samhain_hide.o: $(srcsrc)/samhain_hide.c samhain_erase.o1248 gcc @lkm_inc@ -I. -Wall -O2 -c $(srcsrc)/samhain_hide.c1249 1250 samhain_erase.o: $(srcsrc)/samhain_erase.c1251 gcc @lkm_inc@ -I. -Wall -O2 -c $(srcsrc)/samhain_erase.c1252 1253 # -- NEW --1254 samhain_hide.ko: $(srcsrc)/samhain_hide.c1255 @test -d m_comp || mkdir m_comp; \1256 echo "KVERSION := \$$(shell uname -r)" > m_comp/Makefile;\1257 echo "KSOURCE ?= /lib/modules/\$$(KVERSION)/build" >> m_comp/Makefile;\1258 echo "obj-m := samhain_hide.o" >> m_comp/Makefile;\1259 echo ".PHONY: modules install clean modules_add" >> m_comp/Makefile;\1260 echo "install : modules_add" >> m_comp/Makefile;\1261 echo "modules modules_install clean:" >> m_comp/Makefile;\1262 echo "T\$$(MAKE) -C \$$(KSOURCE) \$$@ SUBDIRS=\$$(CURDIR) KBUILD_VERBOSE=2" | tr T '\t' >> m_comp/Makefile;\1263 cp config.h m_comp/; \1264 cp $(srcsrc)/samhain_hide.c m_comp/; \1265 cd m_comp && $(MAKE) modules1266 @if test -f m_comp/samhain_hide.ko; then \1267 cp -p m_comp/samhain_hide.ko samhain_hide.ko; \1268 rm -rf m_comp/; \1269 else \1270 echo "Kernel module samhain_hide.ko not build"; \1271 exit 1; \1272 fi1273 1274 # -- NEW --1275 samhain_kmem.ko: $(srcsrc)/samhain_kmem.c1276 @test -d m_comp || mkdir m_comp; \1277 echo "KVERSION := \$$(shell uname -r)" > m_comp/Makefile;\1278 echo "KSOURCE ?= /lib/modules/\$$(KVERSION)/build" >> m_comp/Makefile;\1279 echo "obj-m := @install_name@_kmem.o" >> m_comp/Makefile;\1280 echo ".PHONY: modules install clean modules_add" >> m_comp/Makefile;\1281 echo "install : modules_add" >> m_comp/Makefile;\1282 echo "modules modules_install clean:" >> m_comp/Makefile;\1283 echo "T\$$(MAKE) -C \$$(KSOURCE) \$$@ SUBDIRS=\$$(CURDIR) KBUILD_VERBOSE=2" | tr T '\t' >> m_comp/Makefile;\1284 cp config.h m_comp/; \1285 cp $(srcsrc)/samhain_kmem.c m_comp/@install_name@_kmem.c; \1286 cd m_comp && $(MAKE) modules1287 @if test -f m_comp/@install_name@_kmem.ko; then \1288 cp -p m_comp/@install_name@_kmem.ko samhain_kmem.ko; \1289 rm -rf m_comp/; \1290 else \1291 echo "Kernel module samhain_kmem.ko not build"; \1292 exit 1; \1293 fi1294 1295 1296 # -- NEW --1297 lkm: @sh_lkm@1298 1299 1300 1301 # For kernel syscall monitoring1302 kern_head: Makefile $(top_srcdir)/include/kern_head.h $(srcsrc)/kern_head.c1303 @echo "$(BUILD_CC) -I. -I./include -DSYSTEMMAP=\"@systemmap@\" -o kern_head $(srcsrc)/kern_head.c $(LIBS_KVM)"; \1304 $(BUILD_CC) -I. -I./include -DSYSTEMMAP=\"@systemmap@\" -o kern_head $(srcsrc)/kern_head.c $(LIBS_KVM)1305 1306 sh_ks.h: kern_head1307 @sleep 1; \1308 ./kern_head > sh_ks.h1309 1310 sh_ks_xor.h: encode sh_ks.h1311 @echo 'encode $(XOR_CODE) sh_ks.h'; \1312 sleep 1; \1313 ./encode $(XOR_CODE) sh_ks.h; \1314 mv x_sh_ks.h sh_ks_xor.h1315 1192 1316 1193 # For bignum … … 1665 1542 -rm -f $(top_srcdir)/scripts/*~ 1666 1543 (cd $(top_srcdir)/init && rm -f $(INITFILES)) 1667 (cd $(top_srcdir)/scripts && rm -f $(SCRIPTFILES))1668 1544 -rm -rf $(distdir) 1669 1545 mkdir $(distdir) 1670 1546 -chmod 777 $(distdir) 1547 cp scripts/samhain.spec $(distdir)/samhain.spec; \ 1548 (cd $(top_srcdir)/scripts && rm -f $(SCRIPTFILES)) 1671 1549 @for file in $(DISTFILES); do \ 1672 1550 d=$(top_srcdir); \ … … 1675 1553 fi; \ 1676 1554 done; \ 1677 cp scripts/samhain.spec $(distdir)/samhain.spec; \1678 1555 rm -f $(distdir)/scripts/*.spec 1679 1556 … … 1726 1603 1727 1604 1728 samhain.o: $(srcsrc)/samhain.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_pthread.h $(srcinc)/sh_utils.h $(srcinc)/sh_error.h $(srcinc)/sh_unix.h $(srcinc)/sh_files.h $(srcinc)/sh_getopt.h $(srcinc)/sh_readconf.h $(srcinc)/sh_hash.h $(srcinc)/sh_ restrict.h $(srcinc)/sh_nmail.h $(srcinc)/sh_tiger.h $(srcinc)/sh_gpg.h $(srcinc)/sh_mem.h $(srcinc)/sh_forward.h $(srcinc)/sh_tools.h $(srcinc)/sh_hash.h $(srcinc)/sh_extern.h $(srcinc)/sh_modules.h $(srcinc)/sh_ignore.h $(srcinc)/sh_prelink.h sh_MK.h $(srcinc)/sh_schedule.h1729 sh_unix.o: $(srcsrc)/sh_unix.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_error.h $(srcinc)/sh_unix.h $(srcinc)/sh_utils.h $(srcinc)/sh_mem.h $(srcinc)/sh_hash.h $(srcinc)/sh_tools.h $(srcinc)/sh_restrict.h $(srcinc)/sh_ipvx.h $(srcinc)/sh_tiger.h $(srcinc)/sh_prelink.h $(srcinc)/sh_pthread.h $(srcinc)/sh_s tatic.h $(srcinc)/sh_prelude.h $(srcinc)/zAVLTree.h $(srcinc)/sh_ignore.h1605 samhain.o: $(srcsrc)/samhain.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_pthread.h $(srcinc)/sh_utils.h $(srcinc)/sh_error.h $(srcinc)/sh_unix.h $(srcinc)/sh_files.h $(srcinc)/sh_getopt.h $(srcinc)/sh_readconf.h $(srcinc)/sh_hash.h $(srcinc)/sh_dbIO.h $(srcinc)/sh_restrict.h $(srcinc)/sh_nmail.h $(srcinc)/sh_tiger.h $(srcinc)/sh_gpg.h $(srcinc)/sh_mem.h $(srcinc)/sh_xfer.h $(srcinc)/sh_tools.h $(srcinc)/sh_hash.h $(srcinc)/sh_extern.h $(srcinc)/sh_modules.h $(srcinc)/sh_ignore.h $(srcinc)/sh_prelink.h $(srcinc)/sh_sem.h sh_MK.h $(srcinc)/sh_schedule.h 1606 sh_unix.o: $(srcsrc)/sh_unix.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_error.h $(srcinc)/sh_unix.h $(srcinc)/sh_utils.h $(srcinc)/sh_mem.h $(srcinc)/sh_hash.h $(srcinc)/sh_tools.h $(srcinc)/sh_restrict.h $(srcinc)/sh_ipvx.h $(srcinc)/sh_tiger.h $(srcinc)/sh_prelink.h $(srcinc)/sh_pthread.h $(srcinc)/sh_sem.h $(srcinc)/sh_static.h $(srcinc)/sh_prelude.h $(srcinc)/zAVLTree.h $(srcinc)/sh_ignore.h 1730 1607 sh_utils.o: $(srcsrc)/sh_utils.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_error.h $(srcinc)/sh_utils.h $(srcinc)/sh_unix.h $(srcinc)/sh_tiger.h $(srcinc)/sh_entropy.h $(srcinc)/sh_pthread.h 1731 sh_error.o: $(srcsrc)/sh_error.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_cat.h $(srcinc)/sh_database.h $(srcinc)/sh_error.h $(srcinc)/sh_utils.h $(srcinc)/sh_unix.h $(srcinc)/sh_tiger.h $(srcinc)/sh_nmail.h $(srcinc)/sh_ forward.h $(srcinc)/sh_prelude.h $(srcinc)/sh_pthread.h $(srcinc)/sh_tools.h $(srcinc)/sh_extern.h $(srcinc)/sh_checksum.h1732 sh_files.o: $(srcsrc)/sh_files.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_pthread.h $(srcinc)/sh_error.h $(srcinc)/sh_utils.h $(srcinc)/sh_unix.h $(srcinc)/sh_files.h $(srcinc)/sh_tiger.h $(srcinc)/sh_hash.h $(srcinc)/sh_ignore.h $(srcinc)/sh_inotify.h $(srcinc)/zAVLTree.h $(srcinc)/ CuTest.h1733 sh_getopt.o: $(srcsrc)/sh_getopt.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_error.h $(srcinc)/sh_getopt.h $(srcinc)/sh_unix.h $(srcinc)/sh_files.h $(srcinc)/sh_utils.h $(srcinc)/sh_mail.h $(srcinc)/sh_ forward.h $(srcinc)/sh_hash.h $(srcinc)/sh_extern.h1734 sh_readconf.o: $(srcsrc)/sh_readconf.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_calls.h $(srcinc)/sh_error.h $(srcinc)/sh_extern.h $(srcinc)/sh_unix.h $(srcinc)/sh_files.h $(srcinc)/sh_ forward.h $(srcinc)/sh_gpg.h $(srcinc)/sh_hash.h $(srcinc)/sh_ignore.h $(srcinc)/sh_database.h $(srcinc)/sh_mail.h $(srcinc)/sh_modules.h $(srcinc)/sh_nmail.h $(srcinc)/sh_prelink.h $(srcinc)/sh_prelude.h $(srcinc)/sh_tiger.h $(srcinc)/sh_tools.h $(srcinc)/sh_utils.h $(srcinc)/sh_restrict.h1608 sh_error.o: $(srcsrc)/sh_error.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_cat.h $(srcinc)/sh_database.h $(srcinc)/sh_error.h $(srcinc)/sh_utils.h $(srcinc)/sh_unix.h $(srcinc)/sh_tiger.h $(srcinc)/sh_nmail.h $(srcinc)/sh_xfer.h $(srcinc)/sh_prelude.h $(srcinc)/sh_pthread.h $(srcinc)/sh_tools.h $(srcinc)/sh_extern.h $(srcinc)/sh_checksum.h 1609 sh_files.o: $(srcsrc)/sh_files.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_pthread.h $(srcinc)/sh_error.h $(srcinc)/sh_utils.h $(srcinc)/sh_unix.h $(srcinc)/sh_files.h $(srcinc)/sh_tiger.h $(srcinc)/sh_hash.h $(srcinc)/sh_ignore.h $(srcinc)/sh_inotify.h $(srcinc)/zAVLTree.h $(srcinc)/sh_dbIO.h $(srcinc)/CuTest.h 1610 sh_getopt.o: $(srcsrc)/sh_getopt.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_error.h $(srcinc)/sh_getopt.h $(srcinc)/sh_unix.h $(srcinc)/sh_files.h $(srcinc)/sh_utils.h $(srcinc)/sh_mail.h $(srcinc)/sh_xfer.h $(srcinc)/sh_hash.h $(srcinc)/sh_dbIO.h $(srcinc)/sh_dbCheck.h $(srcinc)/sh_dbCreate.h $(srcinc)/sh_sem.h $(srcinc)/sh_extern.h 1611 sh_readconf.o: $(srcsrc)/sh_readconf.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_calls.h $(srcinc)/sh_error.h $(srcinc)/sh_extern.h $(srcinc)/sh_unix.h $(srcinc)/sh_files.h $(srcinc)/sh_xfer.h $(srcinc)/sh_gpg.h $(srcinc)/sh_hash.h $(srcinc)/sh_dbIO.h $(srcinc)/sh_ignore.h $(srcinc)/sh_database.h $(srcinc)/sh_mail.h $(srcinc)/sh_modules.h $(srcinc)/sh_nmail.h $(srcinc)/sh_prelink.h $(srcinc)/sh_prelude.h $(srcinc)/sh_tiger.h $(srcinc)/sh_tools.h $(srcinc)/sh_utils.h $(srcinc)/sh_restrict.h $(srcinc)/sh_socket.h 1735 1612 sh_tiger0.o: $(srcsrc)/sh_tiger0.c Makefile config_xor.h $(srcinc)/sh_tiger.h $(srcinc)/sh_unix.h $(srcinc)/sh_error.h $(srcinc)/sh_utils.h $(srcinc)/sh_pthread.h $(srcinc)/sh_string.h $(srcinc)/sh_checksum.h 1736 1613 sh_tiger1.o: $(srcsrc)/sh_tiger1.c Makefile config_xor.h … … 1738 1615 sh_tiger1_64.o: $(srcsrc)/sh_tiger1_64.c Makefile config_xor.h 1739 1616 sh_tiger2_64.o: $(srcsrc)/sh_tiger2_64.c Makefile config_xor.h 1740 sh_hash.o: $(srcsrc)/sh_hash.c Makefile config_xor.h $(srcinc)/s h_hash.h $(srcinc)/sh_utils.h $(srcinc)/sh_error.h $(srcinc)/sh_tiger.h $(srcinc)/sh_gpg.h $(srcinc)/sh_unix.h $(srcinc)/sh_files.h $(srcinc)/sh_ignore.h $(srcinc)/sh_pthread.h $(srcinc)/sh_forward.h $(srcinc)/sh_hash.h $(srcinc)/sh_checksum.h1617 sh_hash.o: $(srcsrc)/sh_hash.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_utils.h $(srcinc)/sh_unix.h $(srcinc)/sh_dbIO_int.h $(srcinc)/sh_dbIO.h $(srcinc)/sh_hash.h $(srcinc)/sh_error.h $(srcinc)/sh_tiger.h $(srcinc)/sh_gpg.h $(srcinc)/sh_unix.h $(srcinc)/sh_files.h $(srcinc)/sh_ignore.h $(srcinc)/sh_pthread.h $(srcinc)/sh_xfer.h $(srcinc)/sh_hash.h $(srcinc)/sh_checksum.h 1741 1618 sh_mail.o: $(srcsrc)/sh_mail.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_error.h $(srcinc)/sh_unix.h $(srcinc)/sh_tiger.h $(srcinc)/sh_mail.h $(srcinc)/sh_utils.h $(srcinc)/sh_fifo.h $(srcinc)/sh_tools.h $(srcinc)/sh_pthread.h $(srcinc)/sh_filter.h $(srcinc)/sh_mail_int.h $(srcinc)/sh_nmail.h $(srcinc)/sh_ipvx.h $(srcinc)/sh_static.h $(srcinc)/sh_tools.h 1742 1619 sh_mem.o: $(srcsrc)/sh_mem.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_error.h $(srcinc)/sh_utils.h $(srcinc)/sh_mem.h $(srcinc)/sh_pthread.h 1743 1620 sh_entropy.o: $(srcsrc)/sh_entropy.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_utils.h $(srcinc)/sh_unix.h $(srcinc)/sh_tiger.h $(srcinc)/sh_calls.h $(srcinc)/sh_pthread.h $(srcinc)/sh_static.h $(srcinc)/sh_pthread.h $(srcinc)/CuTest.h 1744 1621 sh_forward.o: $(srcsrc)/sh_forward.c Makefile config_xor.h $(srcinc)/sh_ipvx.h $(srcinc)/samhain.h $(srcinc)/sh_tiger.h $(srcinc)/sh_utils.h $(srcinc)/sh_unix.h $(srcinc)/sh_forward.h $(srcinc)/sh_srp.h $(srcinc)/sh_fifo.h $(srcinc)/sh_tools.h $(srcinc)/sh_entropy.h $(srcinc)/sh_html.h $(srcinc)/sh_nmail.h $(srcinc)/sh_socket.h $(srcinc)/sh_static.h $(srcinc)/rijndael-api-fst.h $(srcinc)/sh_readconf.h $(srcinc)/zAVLTree.h $(srcinc)/sh_extern.h 1745 sh_modules.o: $(srcsrc)/sh_modules.c Makefile config_xor.h $(srcinc)/sh_modules.h $(srcinc)/sh_pthread.h $(srcinc)/sh_utmp.h $(srcinc)/sh_mounts.h $(srcinc)/sh_userfiles.h $(srcinc)/sh_ kern.h $(srcinc)/sh_suidchk.h $(srcinc)/sh_processcheck.h $(srcinc)/sh_portcheck.h $(srcinc)/sh_logmon.h $(srcinc)/sh_registry.h $(srcinc)/sh_fInotify.h1622 sh_modules.o: $(srcsrc)/sh_modules.c Makefile config_xor.h $(srcinc)/sh_modules.h $(srcinc)/sh_pthread.h $(srcinc)/sh_utmp.h $(srcinc)/sh_mounts.h $(srcinc)/sh_userfiles.h $(srcinc)/sh_suidchk.h $(srcinc)/sh_processcheck.h $(srcinc)/sh_portcheck.h $(srcinc)/sh_logmon.h $(srcinc)/sh_registry.h $(srcinc)/sh_fInotify.h 1746 1623 sh_utmp.o: $(srcsrc)/sh_utmp.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_utils.h $(srcinc)/sh_error.h $(srcinc)/sh_modules.h $(srcinc)/sh_utmp.h $(srcinc)/sh_pthread.h $(srcinc)/sh_inotify.h 1747 1624 sh_kern.o: $(srcsrc)/sh_kern.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_pthread.h $(srcinc)/sh_utils.h $(srcinc)/sh_error.h $(srcinc)/sh_modules.h $(srcinc)/sh_kern.h sh_ks_xor.h $(srcinc)/sh_unix.h $(srcinc)/sh_hash.h 1748 sh_suidchk.o: $(srcsrc)/sh_suidchk.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_pthread.h $(srcinc)/sh_utils.h $(srcinc)/sh_error.h $(srcinc)/sh_modules.h $(srcinc)/sh_suidchk.h $(srcinc)/sh_hash.h $(srcinc)/sh_ unix.h $(srcinc)/sh_files.h $(srcinc)/sh_schedule.h $(srcinc)/sh_calls.h $(srcinc)/zAVLTree.h1625 sh_suidchk.o: $(srcsrc)/sh_suidchk.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_pthread.h $(srcinc)/sh_utils.h $(srcinc)/sh_error.h $(srcinc)/sh_modules.h $(srcinc)/sh_suidchk.h $(srcinc)/sh_hash.h $(srcinc)/sh_dbIO.h $(srcinc)/sh_unix.h $(srcinc)/sh_files.h $(srcinc)/sh_schedule.h $(srcinc)/sh_calls.h $(srcinc)/zAVLTree.h 1749 1626 sh_srp.o: $(srcsrc)/sh_srp.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_tiger.h $(srcinc)/sh_mem.h $(srcinc)/sh_utils.h $(srcinc)/sh_srp.h $(srcinc)/bignum.h $(srcinc)/CuTest.h 1750 sh_fifo.o: $(srcsrc)/sh_fifo.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_mem.h $(srcinc)/sh_unix.h $(srcinc)/sh_utils.h $(srcinc)/sh_string.h $(srcinc)/sh_fifo.h 1627 sh_fifo.o: $(srcsrc)/sh_fifo.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_mem.h $(srcinc)/sh_unix.h $(srcinc)/sh_utils.h $(srcinc)/sh_string.h $(srcinc)/sh_fifo.h $(srcinc)/CuTest.h 1751 1628 sh_tools.o: $(srcsrc)/sh_tools.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_mem.h $(srcinc)/sh_error.h $(srcinc)/sh_tools.h $(srcinc)/sh_utils.h $(srcinc)/sh_tiger.h $(srcinc)/sh_static.h $(srcinc)/sh_pthread.h $(srcinc)/sh_ipvx.h $(srcinc)/rijndael-api-fst.h $(srcinc)/rijndael-api-fst.h 1752 sh_html.o: $(srcsrc)/sh_html.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_ forward.h $(srcinc)/sh_error.h $(srcinc)/sh_unix.h $(srcinc)/sh_utils.h $(srcinc)/sh_html.h $(srcinc)/zAVLTree.h1753 sh_gpg.o: $(srcsrc)/sh_gpg.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_utils.h $(srcinc)/sh_error.h $(srcinc)/sh_tiger.h $(srcinc)/sh_static.h 1629 sh_html.o: $(srcsrc)/sh_html.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_xfer.h $(srcinc)/sh_error.h $(srcinc)/sh_unix.h $(srcinc)/sh_utils.h $(srcinc)/sh_html.h $(srcinc)/zAVLTree.h 1630 sh_gpg.o: $(srcsrc)/sh_gpg.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_utils.h $(srcinc)/sh_error.h $(srcinc)/sh_tiger.h $(srcinc)/sh_static.h $(srcinc)/sh_gpg.h 1754 1631 sh_cat.o: $(srcsrc)/sh_cat.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_error.h $(srcinc)/sh_cat.h 1755 1632 sh_calls.o: $(srcsrc)/sh_calls.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_error.h $(srcinc)/sh_calls.h $(srcinc)/sh_ipvx.h $(srcinc)/sh_sub.h $(srcinc)/sh_utils.h … … 1757 1634 sh_database.o: $(srcsrc)/sh_database.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_cat.h $(srcinc)/sh_error.h $(srcinc)/sh_utils.h 1758 1635 sh_err_log.o: $(srcsrc)/sh_err_log.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_error.h $(srcinc)/sh_utils.h $(srcinc)/sh_tiger.h 1759 sh_err_console.o: $(srcsrc)/sh_err_console.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_error.h $(srcinc)/sh_utils.h 1636 sh_err_console.o: $(srcsrc)/sh_err_console.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_error.h $(srcinc)/sh_utils.h $(srcinc)/sh_sem.h 1760 1637 sh_err_syslog.o: $(srcsrc)/sh_err_syslog.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_error.h 1761 sh_schedule.o: $(srcsrc)/sh_schedule.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_mem.h $(srcinc)/sh_ schedule.h1638 sh_schedule.o: $(srcsrc)/sh_schedule.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_mem.h $(srcinc)/sh_error_min.h $(srcinc)/sh_schedule.h 1762 1639 bignum.o: $(srcsrc)/bignum.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/bignum.h 1763 1640 mkhdr.o: $(srcsrc)/mkhdr.c Makefile config.h … … 1772 1649 minilzo.o: $(srcsrc)/minilzo.c Makefile $(srcinc)/minilzo.h 1773 1650 slib.o: $(srcsrc)/slib.c Makefile config_xor.h $(srcinc)/slib.h $(srcinc)/sh_calls.h $(srcinc)/sh_static.h $(srcinc)/sh_pthread.h $(srcinc)/sh_string.h $(srcinc)/sh_mem.h 1774 rijndael-alg-fst.o: $(srcsrc)/rijndael-alg-fst.c Makefile config_xor.h $(srcinc)/rijndael-alg-fst.h $(srcinc)/rijndael-boxes-fst.h1651 rijndael-alg-fst.o: $(srcsrc)/rijndael-alg-fst.c Makefile config_xor.h $(srcinc)/rijndael-alg-fst.h 1775 1652 rijndael-api-fst.o: $(srcsrc)/rijndael-api-fst.c Makefile config_xor.h $(srcinc)/rijndael-api-fst.h 1776 1653 zAVLTree.o: $(srcsrc)/zAVLTree.c Makefile $(srcinc)/zAVLTree.h 1777 sh_socket.o: $(srcsrc)/sh_socket.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_socket.h $(srcinc)/sh_error.h $(srcinc)/sh_unix.h $(srcinc)/sh_calls.h $(srcinc)/sh_ utils.h $(srcinc)/zAVLTree.h $(srcinc)/sh_html.h $(srcinc)/sh_tools.h1654 sh_socket.o: $(srcsrc)/sh_socket.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_socket.h $(srcinc)/sh_error.h $(srcinc)/sh_unix.h $(srcinc)/sh_calls.h $(srcinc)/sh_guid.h $(srcinc)/sh_fifo.h $(srcinc)/sh_utils.h $(srcinc)/sh_utils.h $(srcinc)/zAVLTree.h $(srcinc)/sh_html.h $(srcinc)/sh_tools.h $(srcinc)/CuTest.h 1778 1655 sh_ignore.o: $(srcsrc)/sh_ignore.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_mem.h $(srcinc)/sh_error.h $(srcinc)/CuTest.h 1779 1656 yulectl.o: $(srcsrc)/yulectl.c Makefile config_xor.h … … 1812 1689 sh_filetype.o: $(srcsrc)/sh_filetype.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_mem.h $(srcinc)/sh_error_min.h $(srcinc)/sh_utils.h 1813 1690 sh_sub.o: $(srcsrc)/sh_sub.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_pthread.h 1814 sh_fInotify.o: $(srcsrc)/sh_fInotify.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_utils.h $(srcinc)/sh_modules.h $(srcinc)/sh_pthread.h $(srcinc)/sh_inotify.h $(srcinc)/sh_unix.h $(srcinc)/sh_hash.h $(srcinc)/sh_ files.h $(srcinc)/sh_ignore.h1691 sh_fInotify.o: $(srcsrc)/sh_fInotify.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_utils.h $(srcinc)/sh_modules.h $(srcinc)/sh_pthread.h $(srcinc)/sh_inotify.h $(srcinc)/sh_unix.h $(srcinc)/sh_hash.h $(srcinc)/sh_dbIO.h $(srcinc)/sh_files.h $(srcinc)/sh_ignore.h 1815 1692 sh_checksum.o: $(srcsrc)/sh_checksum.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_checksum.h $(srcinc)/sh_utils.h $(srcinc)/CuTest.h 1693 sh_guid.o: $(srcsrc)/sh_guid.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_utils.h $(srcinc)/CuTest.h 1694 sh_dbIO.o: $(srcsrc)/sh_dbIO.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_utils.h $(srcinc)/sh_dbIO_int.h $(srcinc)/sh_hash.h $(srcinc)/sh_dbIO.h $(srcinc)/sh_gpg.h $(srcinc)/sh_tiger.h $(srcinc)/sh_xfer.h $(srcinc)/sh_pthread.h $(srcinc)/sh_socket.h $(srcinc)/sh_files.h $(srcinc)/zAVLTree.h 1695 sh_dbCheck.o: $(srcsrc)/sh_dbCheck.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_unix.h $(srcinc)/sh_utils.h $(srcinc)/sh_hash.h $(srcinc)/sh_files.h $(srcinc)/sh_tiger.h $(srcinc)/sh_dbIO.h $(srcinc)/sh_dbIO_int.h $(srcinc)/sh_pthread.h 1696 sh_dbCreate.o: $(srcsrc)/sh_dbCreate.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_utils.h $(srcinc)/sh_hash.h $(srcinc)/sh_files.h $(srcinc)/sh_dbIO.h $(srcinc)/sh_dbIO_int.h $(srcinc)/sh_pthread.h $(srcinc)/sh_guid.h 1697 sh_xfer_client.o: $(srcsrc)/sh_xfer_client.c Makefile config_xor.h $(srcinc)/sh_ipvx.h $(srcinc)/samhain.h $(srcinc)/sh_tiger.h $(srcinc)/sh_utils.h $(srcinc)/sh_unix.h $(srcinc)/sh_xfer.h $(srcinc)/sh_srp.h $(srcinc)/sh_fifo.h $(srcinc)/sh_tools.h $(srcinc)/sh_entropy.h $(srcinc)/sh_html.h $(srcinc)/sh_nmail.h $(srcinc)/sh_socket.h $(srcinc)/sh_static.h $(srcinc)/rijndael-api-fst.h 1698 sh_xfer_server.o: $(srcsrc)/sh_xfer_server.c Makefile config_xor.h $(srcinc)/sh_ipvx.h $(srcinc)/samhain.h $(srcinc)/sh_tiger.h $(srcinc)/sh_utils.h $(srcinc)/sh_unix.h $(srcinc)/sh_xfer.h $(srcinc)/sh_srp.h $(srcinc)/sh_fifo.h $(srcinc)/sh_tools.h $(srcinc)/sh_entropy.h $(srcinc)/sh_html.h $(srcinc)/sh_nmail.h $(srcinc)/sh_socket.h $(srcinc)/sh_static.h $(srcinc)/sh_guid.h $(srcinc)/rijndael-api-fst.h $(srcinc)/sh_readconf.h $(srcinc)/zAVLTree.h $(srcinc)/sh_extern.h 1699 sh_xfer_syslog.o: $(srcsrc)/sh_xfer_syslog.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_tools.h $(srcinc)/sh_utils.h $(srcinc)/sh_ipvx.h 1700 sh_xload_client.o: $(srcsrc)/sh_xload_client.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_utils.h $(srcinc)/sh_fifo.h $(srcinc)/sh_guid.h 1701 sh_sem.o: $(srcsrc)/sh_sem.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_sem.h $(srcinc)/sh_error_min.h -
trunk/acconfig.h
r476 r481 375 375 /* Define if your vsnprintf is broken. */ 376 376 #undef HAVE_BROKEN_VSNPRINTF 377 378 /* Define if you have va_copy. */ 379 #undef VA_COPY 380 381 /* Define if va_list may be copied as array. */ 382 #undef VA_COPY_AS_ARRAY 377 383 378 384 /* Define if you need unix entropy gatherer. */ -
trunk/aclocal.m4
r476 r481 264 264 AC_MSG_RESULT($sh_cv_typedef) 265 265 if test "$sh_cv_typedef" = yes; then 266 AC_DEFINE( $2)266 AC_DEFINE([$2], [1], [Define if type is defined in stdint.h or inttypes.h]) 267 267 sh_$2=yes 268 268 else … … 276 276 dnl *** va_copy checks *** 277 277 dnl ********************** 278 # va_copy.m4 serial 1 (js-1.6.20070208) 279 280 dnl ## From the OpenWrt Project (http://openwrt.org) 281 dnl ## Project is GPL v2 282 dnl ## 283 dnl ## 284 dnl ## Check for C99 va_copy() implementation 285 dnl ## (and provide fallback implementation if neccessary) 286 dnl ## 287 dnl ## configure.in: 288 dnl ## AC_CHECK_VA_COPY 289 dnl ## foo.c: 290 dnl ## #include "config.h" 291 dnl ## [...] 292 dnl ## va_copy(d,s) 293 dnl ## 294 dnl ## This check is rather complex: first because we really have to 295 dnl ## try various possible implementations in sequence and second, we 296 dnl ## cannot define a macro in config.h with parameters directly. 297 dnl ## 298 299 dnl # test program for va_copy() implementation 300 changequote(<<,>>) 301 m4_define(__va_copy_test, <<[ 302 #include <stdlib.h> 303 #include <stdarg.h> 304 #include <string.h> 305 #define DO_VA_COPY(d, s) $1 306 void test(char *str, ...) 307 { 308 va_list ap, ap2; 309 int i; 310 va_start(ap, str); 311 DO_VA_COPY(ap2, ap); 312 for (i = 1; i <= 9; i++) { 313 int k = (int)va_arg(ap, int); 314 if (k != i) 315 abort(); 316 } 317 DO_VA_COPY(ap, ap2); 318 for (i = 1; i <= 9; i++) { 319 int k = (int)va_arg(ap, int); 320 if (k != i) 321 abort(); 322 } 323 va_end(ap); 324 } 325 int main(int argc, char *argv[]) 326 { 327 test("test", 1, 2, 3, 4, 5, 6, 7, 8, 9); 328 exit(0); 329 } 330 ]>>) 331 changequote([,]) 332 333 dnl # test driver for va_copy() implementation 334 m4_define(__va_copy_check, [ 335 AH_VERBATIM($1, 336 [/* Predefined possible va_copy() implementation (id: $1) */ 337 #define __VA_COPY_USE_$1(d, s) $2]) 338 if test ".$ac_cv_va_copy" = .; then 339 AC_TRY_RUN(__va_copy_test($2), [ac_cv_va_copy="$1"]) 340 fi 278 AC_DEFUN([SL_CHECK_VA_COPY], 279 [AC_MSG_CHECKING(for va_copy()) 280 AC_CACHE_VAL(sh_cv_va_copy,[ 281 AC_TRY_RUN([ 282 #include <stdarg.h> 283 void f (int i, ...) { 284 va_list args1, args2; 285 va_start (args1, i); 286 va_copy (args2, args1); 287 if (va_arg (args2, int) != 42) 288 exit (1); 289 if (va_arg (args1, int) != 42) 290 exit (1); 291 va_end (args1); va_end (args2); 292 } 293 int main() { 294 f (0, 42); 295 return 0; 296 }], 297 sh_cv_va_copy=yes 298 , 299 sh_cv_va_copy=no 300 , 301 sh_cv_va_copy=no) 341 302 ]) 342 343 dnl # Autoconf check for va_copy() implementation checking 344 AC_DEFUN([AC_CHECK_VA_COPY],[ 345 dnl # provide Autoconf display check message 346 AC_MSG_CHECKING(for va_copy() function) 347 dnl # check for various implementations in priorized sequence 348 AC_CACHE_VAL(ac_cv_va_copy, [ 349 ac_cv_va_copy="" 350 dnl # 1. check for standardized C99 macro 351 __va_copy_check(C99, [va_copy((d), (s))]) 352 dnl # 2. check for alternative/deprecated GCC macro 353 __va_copy_check(GCM, [VA_COPY((d), (s))]) 354 dnl # 3. check for internal GCC macro (high-level define) 355 __va_copy_check(GCH, [__va_copy((d), (s))]) 356 dnl # 4. check for internal GCC macro (built-in function) 357 __va_copy_check(GCB, [__builtin_va_copy((d), (s))]) 358 dnl # 5. check for assignment approach (assuming va_list is a struct) 359 __va_copy_check(ASS, [do { (d) = (s); } while (0)]) 360 dnl # 6. check for assignment approach (assuming va_list is a pointer) 361 __va_copy_check(ASP, [do { *(d) = *(s); } while (0)]) 362 dnl # 7. check for memory copying approach (assuming va_list is a struct) 363 __va_copy_check(CPS, [memcpy((void *)&(d), (void *)&(s)), sizeof((s))]) 364 dnl # 8. check for memory copying approach (assuming va_list is a pointer) 365 __va_copy_check(CPP, [memcpy((void *)(d), (void *)(s)), sizeof(*(s))]) 366 if test ".$ac_cv_va_copy" = .; then 367 AC_ERROR([no working implementation found]) 368 fi 369 ]) 370 dnl # optionally activate the fallback implementation 371 if test ".$ac_cv_va_copy" = ".C99"; then 372 AC_DEFINE(HAVE_VA_COPY, 1, [Define if va_copy() macro exists (and no fallback implementation is required)]) 373 fi 374 dnl # declare which fallback implementation to actually use 375 AC_DEFINE_UNQUOTED([__VA_COPY_USE], [__VA_COPY_USE_$ac_cv_va_copy], 376 [Define to id of used va_copy() implementation]) 377 dnl # provide activation hook for fallback implementation 378 AH_VERBATIM([__VA_COPY_ACTIVATION], 379 [/* Optional va_copy() implementation activation */ 380 #ifndef HAVE_VA_COPY 381 #define va_copy(d, s) __VA_COPY_USE(d, s) 382 #endif 303 AC_MSG_RESULT($sh_cv_va_copy) 304 AC_MSG_CHECKING(for __va_copy()) 305 AC_CACHE_VAL(sh_cv___va_copy,[ 306 AC_TRY_RUN([ 307 #include <stdarg.h> 308 void f (int i, ...) { 309 va_list args1, args2; 310 va_start (args1, i); 311 __va_copy (args2, args1); 312 if (va_arg (args2, int) != 42) 313 exit (1); 314 if (va_arg (args1, int) != 42) 315 exit (1); 316 va_end (args1); va_end (args2); 317 } 318 int main() { 319 f (0, 42); 320 return 0; 321 }], 322 sh_cv___va_copy=yes 323 , 324 sh_cv___va_copy=no 325 , 326 sh_cv___va_copy=no) 383 327 ]) 384 dnl # provide Autoconf display result message 385 if test ".$ac_cv_va_copy" = ".C99"; then 386 AC_MSG_RESULT([yes]) 387 else 388 AC_MSG_RESULT([no (using fallback implementation)]) 389 fi 328 AC_MSG_RESULT($sh_cv___va_copy) 329 AC_MSG_CHECKING(whether va_lists can be copied by value) 330 AC_CACHE_VAL(sh_cv_va_val_copy,[ 331 AC_TRY_RUN([ 332 #include <stdarg.h> 333 void f (int i, ...) { 334 va_list args1, args2; 335 va_start (args1, i); 336 args2 = args1; 337 if (va_arg (args2, int) != 42) 338 exit (1); 339 if (va_arg (args1, int) != 42) 340 exit (1); 341 va_end (args1); va_end (args2); 342 } 343 int main() { 344 f (0, 42); 345 return 0; 346 }], 347 sh_cv_va_val_copy=yes 348 , 349 sh_cv_va_val_copy=no 350 , 351 sh_cv_va_val_copy=no) 352 ]) 353 if test "x$sh_cv_va_copy" = "xyes"; then 354 AC_DEFINE(VA_COPY, va_copy) 355 else if test "x$sh_cv___va_copy" = "xyes"; then 356 AC_DEFINE(VA_COPY, __va_copy) 357 fi 358 fi 359 if test "x$sh_cv_va_val_copy" = "xno"; then 360 AC_DEFINE(VA_COPY_AS_ARRAY) 361 fi 362 AC_MSG_RESULT($sh_cv_va_val_copy) 390 363 ]) 391 364 -
trunk/config.guess
r378 r481 1 1 #! /bin/sh 2 2 # Attempt to guess a canonical system name. 3 # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 4 # 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 5 # Free Software Foundation, Inc. 6 7 timestamp='2009-12-30' 3 # Copyright 1992-2014 Free Software Foundation, Inc. 4 5 timestamp='2014-03-23' 8 6 9 7 # This file is free software; you can redistribute it and/or modify it 10 8 # under the terms of the GNU General Public License as published by 11 # the Free Software Foundation; either version 2of the License, or9 # the Free Software Foundation; either version 3 of the License, or 12 10 # (at your option) any later version. 13 11 # … … 18 16 # 19 17 # You should have received a copy of the GNU General Public License 20 # along with this program; if not, write to the Free Software 21 # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 22 # 02110-1301, USA. 18 # along with this program; if not, see <http://www.gnu.org/licenses/>. 23 19 # 24 20 # As a special exception to the GNU General Public License, if you 25 21 # distribute this file as part of a program that contains a 26 22 # configuration script generated by Autoconf, you may include it under 27 # the same distribution terms that you use for the rest of that program. 28 29 30 # Originally written by Per Bothner. Please send patches (context 31 # diff format) to <config-patches@gnu.org> and include a ChangeLog 32 # entry. 23 # the same distribution terms that you use for the rest of that 24 # program. This Exception is an additional permission under section 7 25 # of the GNU General Public License, version 3 ("GPLv3"). 33 26 # 34 # This script attempts to guess a canonical system name similar to 35 # config.sub. If it succeeds, it prints the system name on stdout, and 36 # exits with 0. Otherwise, it exits with 1. 27 # Originally written by Per Bothner. 37 28 # 38 29 # You can get the latest version of this script from: 39 30 # http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD 31 # 32 # Please send patches with a ChangeLog entry to config-patches@gnu.org. 33 40 34 41 35 me=`echo "$0" | sed -e 's,.*/,,'` … … 57 51 58 52 Originally written by Per Bothner. 59 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 60 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free 61 Software Foundation, Inc. 53 Copyright 1992-2014 Free Software Foundation, Inc. 62 54 63 55 This is free software; see the source for copying conditions. There is NO … … 141 133 UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown 142 134 135 case "${UNAME_SYSTEM}" in 136 Linux|GNU|GNU/*) 137 # If the system lacks a compiler, then just pick glibc. 138 # We could probably try harder. 139 LIBC=gnu 140 141 eval $set_cc_for_build 142 cat <<-EOF > $dummy.c 143 #include <features.h> 144 #if defined(__UCLIBC__) 145 LIBC=uclibc 146 #elif defined(__dietlibc__) 147 LIBC=dietlibc 148 #else 149 LIBC=gnu 150 #endif 151 EOF 152 eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC' | sed 's, ,,g'` 153 ;; 154 esac 155 143 156 # Note: order is significant - the case branches are not exclusive. 144 157 … … 146 159 *:NetBSD:*:*) 147 160 # NetBSD (nbsd) targets should (where applicable) match one or 148 # more of the tup ples: *-*-netbsdelf*, *-*-netbsdaout*,161 # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*, 149 162 # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently 150 163 # switched to ELF, *-*-netbsd* would select the old … … 182 195 ;; 183 196 *) 184 197 os=netbsd 185 198 ;; 186 199 esac … … 203 216 echo "${machine}-${os}${release}" 204 217 exit ;; 218 *:Bitrig:*:*) 219 UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'` 220 echo ${UNAME_MACHINE_ARCH}-unknown-bitrig${UNAME_RELEASE} 221 exit ;; 205 222 *:OpenBSD:*:*) 206 223 UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` … … 225 242 ;; 226 243 *5.*) 227 244 UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` 228 245 ;; 229 246 esac … … 271 288 # 1.2 uses "1.2" for uname -r. 272 289 echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` 273 exit ;; 290 # Reset EXIT trap before exiting to avoid spurious non-zero exit code. 291 exitcode=$? 292 trap '' 0 293 exit $exitcode ;; 274 294 Alpha\ *:Windows_NT*:*) 275 295 # How do we know it's Interix rather than the generic POSIX subsystem? … … 297 317 exit ;; 298 318 *:OS400:*:*) 299 319 echo powerpc-ibm-os400 300 320 exit ;; 301 321 arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) 302 322 echo arm-acorn-riscix${UNAME_RELEASE} 303 323 exit ;; 304 arm :riscos:*:*|arm:RISCOS:*:*)324 arm*:riscos:*:*|arm*:RISCOS:*:*) 305 325 echo arm-unknown-riscos 306 326 exit ;; … … 396 416 # be no problem. 397 417 atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) 398 418 echo m68k-atari-mint${UNAME_RELEASE} 399 419 exit ;; 400 420 atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) 401 421 echo m68k-atari-mint${UNAME_RELEASE} 402 422 exit ;; 403 423 *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) 404 424 echo m68k-atari-mint${UNAME_RELEASE} 405 425 exit ;; 406 426 milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) 407 408 427 echo m68k-milan-mint${UNAME_RELEASE} 428 exit ;; 409 429 hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) 410 411 430 echo m68k-hades-mint${UNAME_RELEASE} 431 exit ;; 412 432 *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) 413 414 433 echo m68k-unknown-mint${UNAME_RELEASE} 434 exit ;; 415 435 m68k:machten:*:*) 416 436 echo m68k-apple-machten${UNAME_RELEASE} … … 482 502 exit ;; 483 503 AViiON:dgux:*:*) 484 485 504 # DG/UX returns AViiON for all architectures 505 UNAME_PROCESSOR=`/usr/bin/uname -p` 486 506 if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] 487 507 then … … 496 516 echo i586-dg-dgux${UNAME_RELEASE} 497 517 fi 498 518 exit ;; 499 519 M88*:DolphinOS:*:*) # DolphinOS (SVR3) 500 520 echo m88k-dolphin-sysv3 … … 553 573 fi 554 574 exit ;; 555 *:AIX:*:[456 ])575 *:AIX:*:[4567]) 556 576 IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` 557 577 if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then … … 596 616 if [ -x /usr/bin/getconf ]; then 597 617 sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` 598 599 600 601 602 603 604 605 618 sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` 619 case "${sc_cpu_version}" in 620 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 621 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 622 532) # CPU_PA_RISC2_0 623 case "${sc_kernel_bits}" in 624 32) HP_ARCH="hppa2.0n" ;; 625 64) HP_ARCH="hppa2.0w" ;; 606 626 '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 607 608 627 esac ;; 628 esac 609 629 fi 610 630 if [ "${HP_ARCH}" = "" ]; then 611 631 eval $set_cc_for_build 612 sed 's/^ 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 632 sed 's/^ //' << EOF >$dummy.c 633 634 #define _HPUX_SOURCE 635 #include <stdlib.h> 636 #include <unistd.h> 637 638 int main () 639 { 640 #if defined(_SC_KERNEL_BITS) 641 long bits = sysconf(_SC_KERNEL_BITS); 642 #endif 643 long cpu = sysconf (_SC_CPU_VERSION); 644 645 switch (cpu) 646 { 647 case CPU_PA_RISC1_0: puts ("hppa1.0"); break; 648 case CPU_PA_RISC1_1: puts ("hppa1.1"); break; 649 case CPU_PA_RISC2_0: 650 #if defined(_SC_KERNEL_BITS) 651 switch (bits) 652 { 653 case 64: puts ("hppa2.0w"); break; 654 case 32: puts ("hppa2.0n"); break; 655 default: puts ("hppa2.0"); break; 656 } break; 657 #else /* !defined(_SC_KERNEL_BITS) */ 658 puts ("hppa2.0"); break; 659 #endif 660 default: puts ("hppa1.0"); break; 661 } 662 exit (0); 663 } 644 664 EOF 645 665 (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` … … 732 752 C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) 733 753 echo c1-convex-bsd 734 754 exit ;; 735 755 C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) 736 756 if getsysinfo -f scalar_acc … … 738 758 else echo c2-convex-bsd 739 759 fi 740 760 exit ;; 741 761 C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) 742 762 echo c34-convex-bsd 743 763 exit ;; 744 764 C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) 745 765 echo c38-convex-bsd 746 766 exit ;; 747 767 C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) 748 768 echo c4-convex-bsd 749 769 exit ;; 750 770 CRAY*Y-MP:*:*:*) 751 771 echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' … … 771 791 F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) 772 792 FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` 773 774 775 776 793 FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` 794 FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` 795 echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" 796 exit ;; 777 797 5000:UNIX_System_V:4.*:*) 778 779 780 798 FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` 799 FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` 800 echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" 781 801 exit ;; 782 802 i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) … … 790 810 exit ;; 791 811 *:FreeBSD:*:*) 792 case ${UNAME_MACHINE} in 793 pc98) 794 echo i386-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; 812 UNAME_PROCESSOR=`/usr/bin/uname -p` 813 case ${UNAME_PROCESSOR} in 795 814 amd64) 796 815 echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; 797 816 *) 798 echo ${UNAME_ MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;817 echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; 799 818 esac 800 819 exit ;; … … 802 821 echo ${UNAME_MACHINE}-pc-cygwin 803 822 exit ;; 823 *:MINGW64*:*) 824 echo ${UNAME_MACHINE}-pc-mingw64 825 exit ;; 804 826 *:MINGW*:*) 805 827 echo ${UNAME_MACHINE}-pc-mingw32 806 828 exit ;; 829 *:MSYS*:*) 830 echo ${UNAME_MACHINE}-pc-msys 831 exit ;; 807 832 i*:windows32*:*) 808 809 833 # uname -m includes "-pc" on this system. 834 echo ${UNAME_MACHINE}-mingw32 810 835 exit ;; 811 836 i*:PW*:*) … … 813 838 exit ;; 814 839 *:Interix*:*) 815 840 case ${UNAME_MACHINE} in 816 841 x86) 817 842 echo i586-pc-interix${UNAME_RELEASE} … … 850 875 *:GNU:*:*) 851 876 # the GNU system 852 echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown- gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`877 echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-${LIBC}`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` 853 878 exit ;; 854 879 *:GNU/*:*:*) 855 880 # other systems with GNU libc and userland 856 echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`- gnu881 echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-${LIBC} 857 882 exit ;; 858 883 i*86:Minix:*:*) 859 884 echo ${UNAME_MACHINE}-pc-minix 885 exit ;; 886 aarch64:Linux:*:*) 887 echo ${UNAME_MACHINE}-unknown-linux-${LIBC} 888 exit ;; 889 aarch64_be:Linux:*:*) 890 UNAME_MACHINE=aarch64_be 891 echo ${UNAME_MACHINE}-unknown-linux-${LIBC} 860 892 exit ;; 861 893 alpha:Linux:*:*) … … 868 900 EV67) UNAME_MACHINE=alphaev67 ;; 869 901 EV68*) UNAME_MACHINE=alphaev68 ;; 870 902 esac 871 903 objdump --private-headers /bin/sh | grep -q ld.so.1 872 if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi 873 echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} 904 if test "$?" = 0 ; then LIBC="gnulibc1" ; fi 905 echo ${UNAME_MACHINE}-unknown-linux-${LIBC} 906 exit ;; 907 arc:Linux:*:* | arceb:Linux:*:*) 908 echo ${UNAME_MACHINE}-unknown-linux-${LIBC} 874 909 exit ;; 875 910 arm*:Linux:*:*) … … 878 913 | grep -q __ARM_EABI__ 879 914 then 880 echo ${UNAME_MACHINE}-unknown-linux- gnu915 echo ${UNAME_MACHINE}-unknown-linux-${LIBC} 881 916 else 882 echo ${UNAME_MACHINE}-unknown-linux-gnueabi 917 if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ 918 | grep -q __ARM_PCS_VFP 919 then 920 echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabi 921 else 922 echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabihf 923 fi 883 924 fi 884 925 exit ;; 885 926 avr32*:Linux:*:*) 886 echo ${UNAME_MACHINE}-unknown-linux- gnu927 echo ${UNAME_MACHINE}-unknown-linux-${LIBC} 887 928 exit ;; 888 929 cris:Linux:*:*) 889 echo cris-axis-linux-gnu930 echo ${UNAME_MACHINE}-axis-linux-${LIBC} 890 931 exit ;; 891 932 crisv32:Linux:*:*) 892 echo crisv32-axis-linux-gnu933 echo ${UNAME_MACHINE}-axis-linux-${LIBC} 893 934 exit ;; 894 935 frv:Linux:*:*) 895 echo frv-unknown-linux-gnu 936 echo ${UNAME_MACHINE}-unknown-linux-${LIBC} 937 exit ;; 938 hexagon:Linux:*:*) 939 echo ${UNAME_MACHINE}-unknown-linux-${LIBC} 896 940 exit ;; 897 941 i*86:Linux:*:*) 898 LIBC=gnu 899 eval $set_cc_for_build 900 sed 's/^ //' << EOF >$dummy.c 901 #ifdef __dietlibc__ 902 LIBC=dietlibc 903 #endif 904 EOF 905 eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'` 906 echo "${UNAME_MACHINE}-pc-linux-${LIBC}" 942 echo ${UNAME_MACHINE}-pc-linux-${LIBC} 907 943 exit ;; 908 944 ia64:Linux:*:*) 909 echo ${UNAME_MACHINE}-unknown-linux- gnu945 echo ${UNAME_MACHINE}-unknown-linux-${LIBC} 910 946 exit ;; 911 947 m32r*:Linux:*:*) 912 echo ${UNAME_MACHINE}-unknown-linux- gnu948 echo ${UNAME_MACHINE}-unknown-linux-${LIBC} 913 949 exit ;; 914 950 m68*:Linux:*:*) 915 echo ${UNAME_MACHINE}-unknown-linux- gnu951 echo ${UNAME_MACHINE}-unknown-linux-${LIBC} 916 952 exit ;; 917 953 mips:Linux:*:* | mips64:Linux:*:*) … … 932 968 EOF 933 969 eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'` 934 test x"${CPU}" != x && { echo "${CPU}-unknown-linux- gnu"; exit; }970 test x"${CPU}" != x && { echo "${CPU}-unknown-linux-${LIBC}"; exit; } 935 971 ;; 936 or32:Linux:*:*) 937 echo or32-unknown-linux-gnu 972 openrisc*:Linux:*:*) 973 echo or1k-unknown-linux-${LIBC} 974 exit ;; 975 or32:Linux:*:* | or1k*:Linux:*:*) 976 echo ${UNAME_MACHINE}-unknown-linux-${LIBC} 938 977 exit ;; 939 978 padre:Linux:*:*) 940 echo sparc-unknown-linux- gnu979 echo sparc-unknown-linux-${LIBC} 941 980 exit ;; 942 981 parisc64:Linux:*:* | hppa64:Linux:*:*) 943 echo hppa64-unknown-linux- gnu982 echo hppa64-unknown-linux-${LIBC} 944 983 exit ;; 945 984 parisc:Linux:*:* | hppa:Linux:*:*) 946 985 # Look for CPU level 947 986 case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in 948 PA7*) echo hppa1.1-unknown-linux- gnu;;949 PA8*) echo hppa2.0-unknown-linux- gnu;;950 *) echo hppa-unknown-linux- gnu;;987 PA7*) echo hppa1.1-unknown-linux-${LIBC} ;; 988 PA8*) echo hppa2.0-unknown-linux-${LIBC} ;; 989 *) echo hppa-unknown-linux-${LIBC} ;; 951 990 esac 952 991 exit ;; 953 992 ppc64:Linux:*:*) 954 echo powerpc64-unknown-linux- gnu993 echo powerpc64-unknown-linux-${LIBC} 955 994 exit ;; 956 995 ppc:Linux:*:*) 957 echo powerpc-unknown-linux-gnu 996 echo powerpc-unknown-linux-${LIBC} 997 exit ;; 998 ppc64le:Linux:*:*) 999 echo powerpc64le-unknown-linux-${LIBC} 1000 exit ;; 1001 ppcle:Linux:*:*) 1002 echo powerpcle-unknown-linux-${LIBC} 958 1003 exit ;; 959 1004 s390:Linux:*:* | s390x:Linux:*:*) 960 echo ${UNAME_MACHINE}-ibm-linux 1005 echo ${UNAME_MACHINE}-ibm-linux-${LIBC} 961 1006 exit ;; 962 1007 sh64*:Linux:*:*) 963 echo ${UNAME_MACHINE}-unknown-linux-gnu 1008 echo ${UNAME_MACHINE}-unknown-linux-${LIBC} 964 1009 exit ;; 965 1010 sh*:Linux:*:*) 966 echo ${UNAME_MACHINE}-unknown-linux- gnu1011 echo ${UNAME_MACHINE}-unknown-linux-${LIBC} 967 1012 exit ;; 968 1013 sparc:Linux:*:* | sparc64:Linux:*:*) 969 echo ${UNAME_MACHINE}-unknown-linux-gnu 1014 echo ${UNAME_MACHINE}-unknown-linux-${LIBC} 1015 exit ;; 1016 tile*:Linux:*:*) 1017 echo ${UNAME_MACHINE}-unknown-linux-${LIBC} 970 1018 exit ;; 971 1019 vax:Linux:*:*) 972 echo ${UNAME_MACHINE}-dec-linux- gnu1020 echo ${UNAME_MACHINE}-dec-linux-${LIBC} 973 1021 exit ;; 974 1022 x86_64:Linux:*:*) 975 echo x86_64-unknown-linux-gnu1023 echo ${UNAME_MACHINE}-unknown-linux-${LIBC} 976 1024 exit ;; 977 1025 xtensa*:Linux:*:*) 978 echo ${UNAME_MACHINE}-unknown-linux-gnu 1026 echo ${UNAME_MACHINE}-unknown-linux-${LIBC} 979 1027 exit ;; 980 1028 i*86:DYNIX/ptx:4*:*) … … 985 1033 exit ;; 986 1034 i*86:UNIX_SV:4.2MP:2.*) 987 988 989 1035 # Unixware is an offshoot of SVR4, but it has its own version 1036 # number series starting with 2... 1037 # I am not positive that other SVR4 systems won't match this, 990 1038 # I just have to hope. -- rms. 991 1039 # Use sysv4.2uw... so that sysv4* matches it. 992 1040 echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} 993 1041 exit ;; … … 1021 1069 exit ;; 1022 1070 i*86:*:5:[678]*) 1023 1071 # UnixWare 7.x, OpenUNIX and OpenServer 6. 1024 1072 case `/bin/uname -X | grep "^Machine"` in 1025 1073 *486*) UNAME_MACHINE=i486 ;; … … 1049 1097 pc:*:*:*) 1050 1098 # Left here for compatibility: 1051 1052 1099 # uname -m prints for DJGPP always 'pc', but it prints nothing about 1100 # the processor, so we play safe by assuming i586. 1053 1101 # Note: whatever this is, it MUST be the same as what config.sub 1054 1102 # prints for the "djgpp" host, or else GDB configury will decide that 1055 1103 # this is a cross-build. 1056 1104 echo i586-pc-msdosdjgpp 1057 1105 exit ;; 1058 1106 Intel:Mach:3*:*) 1059 1107 echo i386-pc-mach3 … … 1090 1138 && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; 1091 1139 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) 1092 1093 1140 /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ 1141 && { echo i486-ncr-sysv4; exit; } ;; 1094 1142 NCR*:*:4.2:* | MPRAS*:*:4.2:*) 1095 1143 OS_REL='.3' … … 1134 1182 fi 1135 1183 exit ;; 1136 PENTIUM:*:4.0*:*) 1137 1138 1139 1184 PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort 1185 # says <Richard.M.Bartel@ccMail.Census.GOV> 1186 echo i586-unisys-sysv4 1187 exit ;; 1140 1188 *:UNIX_System_V:4*:FTX*) 1141 1189 # From Gerald Hewes <hewes@openmarket.com>. … … 1163 1211 R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) 1164 1212 if [ -d /usr/nec ]; then 1165 1213 echo mips-nec-sysv${UNAME_RELEASE} 1166 1214 else 1167 1168 fi 1169 1215 echo mips-unknown-sysv${UNAME_RELEASE} 1216 fi 1217 exit ;; 1170 1218 BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. 1171 1219 echo powerpc-be-beos … … 1180 1228 echo i586-pc-haiku 1181 1229 exit ;; 1230 x86_64:Haiku:*:*) 1231 echo x86_64-unknown-haiku 1232 exit ;; 1182 1233 SX-4:SUPER-UX:*:*) 1183 1234 echo sx4-nec-superux${UNAME_RELEASE} … … 1206 1257 *:Darwin:*:*) 1207 1258 UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown 1208 case $UNAME_PROCESSOR in 1209 i386) 1210 eval $set_cc_for_build 1211 if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then 1212 if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ 1213 (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ 1214 grep IS_64BIT_ARCH >/dev/null 1215 then 1216 UNAME_PROCESSOR="x86_64" 1217 fi 1218 fi ;; 1219 unknown) UNAME_PROCESSOR=powerpc ;; 1220 esac 1259 eval $set_cc_for_build 1260 if test "$UNAME_PROCESSOR" = unknown ; then 1261 UNAME_PROCESSOR=powerpc 1262 fi 1263 if test `echo "$UNAME_RELEASE" | sed -e 's/\..*//'` -le 10 ; then 1264 if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then 1265 if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ 1266 (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ 1267 grep IS_64BIT_ARCH >/dev/null 1268 then 1269 case $UNAME_PROCESSOR in 1270 i386) UNAME_PROCESSOR=x86_64 ;; 1271 powerpc) UNAME_PROCESSOR=powerpc64 ;; 1272 esac 1273 fi 1274 fi 1275 elif test "$UNAME_PROCESSOR" = i386 ; then 1276 # Avoid executing cc on OS X 10.9, as it ships with a stub 1277 # that puts up a graphical alert prompting to install 1278 # developer tools. Any system running Mac OS X 10.7 or 1279 # later (Darwin 11 and later) is required to have a 64-bit 1280 # processor. This is not true of the ARM version of Darwin 1281 # that Apple uses in portable devices. 1282 UNAME_PROCESSOR=x86_64 1283 fi 1221 1284 echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} 1222 1285 exit ;; … … 1232 1295 echo i386-pc-qnx 1233 1296 exit ;; 1234 NSE-?:NONSTOP_KERNEL:*:*) 1297 NEO-?:NONSTOP_KERNEL:*:*) 1298 echo neo-tandem-nsk${UNAME_RELEASE} 1299 exit ;; 1300 NSE-*:NONSTOP_KERNEL:*:*) 1235 1301 echo nse-tandem-nsk${UNAME_RELEASE} 1236 1302 exit ;; … … 1277 1343 exit ;; 1278 1344 SEI:*:*:SEIUX) 1279 1345 echo mips-sei-seiux${UNAME_RELEASE} 1280 1346 exit ;; 1281 1347 *:DragonFly:*:*) … … 1283 1349 exit ;; 1284 1350 *:*VMS:*:*) 1285 1351 UNAME_MACHINE=`(uname -p) 2>/dev/null` 1286 1352 case "${UNAME_MACHINE}" in 1287 1353 A*) echo alpha-dec-vms ; exit ;; … … 1301 1367 echo ${UNAME_MACHINE}-pc-aros 1302 1368 exit ;; 1369 x86_64:VMkernel:*:*) 1370 echo ${UNAME_MACHINE}-unknown-esx 1371 exit ;; 1303 1372 esac 1304 1305 #echo '(No uname command or uname output not recognized.)' 1>&21306 #echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&21307 1308 eval $set_cc_for_build1309 cat >$dummy.c <<EOF1310 #ifdef _SEQUENT_1311 # include <sys/types.h>1312 # include <sys/utsname.h>1313 #endif1314 main ()1315 {1316 #if defined (sony)1317 #if defined (MIPSEB)1318 /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed,1319 I don't know.... */1320 printf ("mips-sony-bsd\n"); exit (0);1321 #else1322 #include <sys/param.h>1323 printf ("m68k-sony-newsos%s\n",1324 #ifdef NEWSOS41325 "4"1326 #else1327 ""1328 #endif1329 ); exit (0);1330 #endif1331 #endif1332 1333 #if defined (__arm) && defined (__acorn) && defined (__unix)1334 printf ("arm-acorn-riscix\n"); exit (0);1335 #endif1336 1337 #if defined (hp300) && !defined (hpux)1338 printf ("m68k-hp-bsd\n"); exit (0);1339 #endif1340 1341 #if defined (NeXT)1342 #if !defined (__ARCHITECTURE__)1343 #define __ARCHITECTURE__ "m68k"1344 #endif1345 int version;1346 version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;1347 if (version < 4)1348 printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);1349 else1350 printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version);1351 exit (0);1352 #endif1353 1354 #if defined (MULTIMAX) || defined (n16)1355 #if defined (UMAXV)1356 printf ("ns32k-encore-sysv\n"); exit (0);1357 #else1358 #if defined (CMU)1359 printf ("ns32k-encore-mach\n"); exit (0);1360 #else1361 printf ("ns32k-encore-bsd\n"); exit (0);1362 #endif1363 #endif1364 #endif1365 1366 #if defined (__386BSD__)1367 printf ("i386-pc-bsd\n"); exit (0);1368 #endif1369 1370 #if defined (sequent)1371 #if defined (i386)1372 printf ("i386-sequent-dynix\n"); exit (0);1373 #endif1374 #if defined (ns32000)1375 printf ("ns32k-sequent-dynix\n"); exit (0);1376 #endif1377 #endif1378 1379 #if defined (_SEQUENT_)1380 struct utsname un;1381 1382 uname(&un);1383 1384 if (strncmp(un.version, "V2", 2) == 0) {1385 printf ("i386-sequent-ptx2\n"); exit (0);1386 }1387 if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */1388 printf ("i386-sequent-ptx1\n"); exit (0);1389 }1390 printf ("i386-sequent-ptx\n"); exit (0);1391 1392 #endif1393 1394 #if defined (vax)1395 # if !defined (ultrix)1396 # include <sys/param.h>1397 # if defined (BSD)1398 # if BSD == 431399 printf ("vax-dec-bsd4.3\n"); exit (0);1400 # else1401 # if BSD == 1990061402 printf ("vax-dec-bsd4.3reno\n"); exit (0);1403 # else1404 printf ("vax-dec-bsd\n"); exit (0);1405 # endif1406 # endif1407 # else1408 printf ("vax-dec-bsd\n"); exit (0);1409 # endif1410 # else1411 printf ("vax-dec-ultrix\n"); exit (0);1412 # endif1413 #endif1414 1415 #if defined (alliant) && defined (i860)1416 printf ("i860-alliant-bsd\n"); exit (0);1417 #endif1418 1419 exit (1);1420 }1421 EOF1422 1423 $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` &&1424 { echo "$SYSTEM_NAME"; exit; }1425 1426 # Apollos put the system type in the environment.1427 1428 test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; }1429 1430 # Convex versions that predate uname can use getsysinfo(1)1431 1432 if [ -x /usr/convex/getsysinfo ]1433 then1434 case `getsysinfo -f cpu_type` in1435 c1*)1436 echo c1-convex-bsd1437 exit ;;1438 c2*)1439 if getsysinfo -f scalar_acc1440 then echo c32-convex-bsd1441 else echo c2-convex-bsd1442 fi1443 exit ;;1444 c34*)1445 echo c34-convex-bsd1446 exit ;;1447 c38*)1448 echo c38-convex-bsd1449 exit ;;1450 c4*)1451 echo c4-convex-bsd1452 exit ;;1453 esac1454 fi1455 1373 1456 1374 cat >&2 <<EOF -
trunk/config.sub
r378 r481 1 1 #! /bin/sh 2 2 # Configuration validation subroutine script. 3 # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 4 # 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 5 # Free Software Foundation, Inc. 6 7 timestamp='2010-01-22' 8 9 # This file is (in principle) common to ALL GNU software. 10 # The presence of a machine in this file suggests that SOME GNU software 11 # can handle that machine. It does not imply ALL GNU software can. 12 # 13 # This file is free software; you can redistribute it and/or modify 14 # it under the terms of the GNU General Public License as published by 15 # the Free Software Foundation; either version 2 of the License, or 3 # Copyright 1992-2014 Free Software Foundation, Inc. 4 5 timestamp='2014-09-11' 6 7 # This file is free software; you can redistribute it and/or modify it 8 # under the terms of the GNU General Public License as published by 9 # the Free Software Foundation; either version 3 of the License, or 16 10 # (at your option) any later version. 17 11 # 18 # This program is distributed in the hope that it will be useful, 19 # butWITHOUT ANY WARRANTY; without even the implied warranty of20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 # G NU General Public License for more details.12 # This program is distributed in the hope that it will be useful, but 13 # WITHOUT ANY WARRANTY; without even the implied warranty of 14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 # General Public License for more details. 22 16 # 23 17 # You should have received a copy of the GNU General Public License 24 # along with this program; if not, write to the Free Software 25 # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 26 # 02110-1301, USA. 18 # along with this program; if not, see <http://www.gnu.org/licenses/>. 27 19 # 28 20 # As a special exception to the GNU General Public License, if you 29 21 # distribute this file as part of a program that contains a 30 22 # configuration script generated by Autoconf, you may include it under 31 # the same distribution terms that you use for the rest of that program. 32 33 34 # Please send patches to <config-patches@gnu.org>. Submit a context 35 # diff and a properly formatted GNU ChangeLog entry. 23 # the same distribution terms that you use for the rest of that 24 # program. This Exception is an additional permission under section 7 25 # of the GNU General Public License, version 3 ("GPLv3"). 26 27 28 # Please send patches with a ChangeLog entry to config-patches@gnu.org. 36 29 # 37 30 # Configuration subroutine to validate and canonicalize a configuration type. … … 76 69 GNU config.sub ($timestamp) 77 70 78 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 79 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free 80 Software Foundation, Inc. 71 Copyright 1992-2014 Free Software Foundation, Inc. 81 72 82 73 This is free software; see the source for copying conditions. There is NO … … 125 116 maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` 126 117 case $maybe_os in 127 nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \ 128 uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \ 118 nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \ 119 linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ 120 knetbsd*-gnu* | netbsd*-gnu* | \ 129 121 kopensolaris*-gnu* | \ 130 122 storm-chaos* | os2-emx* | rtmk-nova*) 131 123 os=-$maybe_os 132 124 basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` 125 ;; 126 android-linux) 127 os=-linux-android 128 basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown 133 129 ;; 134 130 *) … … 154 150 -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ 155 151 -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ 156 -apple | -axis | -knuth | -cray | -microblaze )152 -apple | -axis | -knuth | -cray | -microblaze*) 157 153 os= 158 154 basic_machine=$1 159 155 ;; 160 161 156 -bluegene*) 157 os=-cnk 162 158 ;; 163 159 -sim | -cisco | -oki | -wec | -winbond) … … 175 171 basic_machine=$1 176 172 ;; 177 178 173 -chorusrdb) 174 os=-chorusrdb 179 175 basic_machine=$1 180 176 ;; 181 177 -hiux*) 182 178 os=-hiuxwe2 … … 222 218 -isc*) 223 219 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` 220 ;; 221 -lynx*178) 222 os=-lynxos178 223 ;; 224 -lynx*5) 225 os=-lynxos5 224 226 ;; 225 227 -lynx*) … … 247 249 1750a | 580 \ 248 250 | a29k \ 251 | aarch64 | aarch64_be \ 249 252 | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ 250 253 | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ 251 254 | am33_2.0 \ 252 | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \ 255 | arc | arceb \ 256 | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \ 257 | avr | avr32 \ 258 | be32 | be64 \ 253 259 | bfin \ 254 | c4x | c lipper \260 | c4x | c8051 | clipper \ 255 261 | d10v | d30v | dlx | dsp16xx \ 262 | epiphany \ 256 263 | fido | fr30 | frv \ 257 264 | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ 265 | hexagon \ 258 266 | i370 | i860 | i960 | ia64 \ 259 267 | ip2k | iq2000 \ 268 | k1om \ 269 | le32 | le64 \ 260 270 | lm32 \ 261 271 | m32c | m32r | m32rle | m68000 | m68k | m88k \ 262 | maxq | mb | microblaze | m core | mep | metag \272 | maxq | mb | microblaze | microblazeel | mcore | mep | metag \ 263 273 | mips | mipsbe | mipseb | mipsel | mipsle \ 264 274 | mips16 \ … … 274 284 | mipsisa32 | mipsisa32el \ 275 285 | mipsisa32r2 | mipsisa32r2el \ 286 | mipsisa32r6 | mipsisa32r6el \ 276 287 | mipsisa64 | mipsisa64el \ 277 288 | mipsisa64r2 | mipsisa64r2el \ 289 | mipsisa64r6 | mipsisa64r6el \ 278 290 | mipsisa64sb1 | mipsisa64sb1el \ 279 291 | mipsisa64sr71k | mipsisa64sr71kel \ 292 | mipsr5900 | mipsr5900el \ 280 293 | mipstx39 | mipstx39el \ 281 294 | mn10200 | mn10300 \ … … 283 296 | mt \ 284 297 | msp430 \ 285 | nios | nios2 \ 298 | nds32 | nds32le | nds32be \ 299 | nios | nios2 | nios2eb | nios2el \ 286 300 | ns16k | ns32k \ 287 | o r32 \301 | open8 | or1k | or1knd | or32 \ 288 302 | pdp10 | pdp11 | pj | pjl \ 289 | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe\303 | powerpc | powerpc64 | powerpc64le | powerpcle \ 290 304 | pyramid \ 291 | rx \ 305 | riscv32 | riscv64 \ 306 | rl78 | rx \ 292 307 | score \ 293 308 | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ … … 295 310 | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ 296 311 | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ 297 | spu | strongarm\298 | tahoe | t humb | tic4x | tic80 | tron \312 | spu \ 313 | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \ 299 314 | ubicom32 \ 300 | v850 | v850e \315 | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \ 301 316 | we32k \ 302 | x86 | xc16x | xs cale | xscalee[bl] | xstormy16 | xtensa \317 | x86 | xc16x | xstormy16 | xtensa \ 303 318 | z8k | z80) 304 319 basic_machine=$basic_machine-unknown 305 320 ;; 306 m6811 | m68hc11 | m6812 | m68hc12 | picochip) 307 # Motorola 68HC11/12. 321 c54x) 322 basic_machine=tic54x-unknown 323 ;; 324 c55x) 325 basic_machine=tic55x-unknown 326 ;; 327 c6x) 328 basic_machine=tic6x-unknown 329 ;; 330 m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | nvptx | picochip) 308 331 basic_machine=$basic_machine-unknown 309 332 os=-none … … 313 336 ms1) 314 337 basic_machine=mt-unknown 338 ;; 339 340 strongarm | thumb | xscale) 341 basic_machine=arm-unknown 342 ;; 343 xgate) 344 basic_machine=$basic_machine-unknown 345 os=-none 346 ;; 347 xscaleeb) 348 basic_machine=armeb-unknown 349 ;; 350 351 xscaleel) 352 basic_machine=armel-unknown 315 353 ;; 316 354 … … 329 367 580-* \ 330 368 | a29k-* \ 369 | aarch64-* | aarch64_be-* \ 331 370 | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ 332 371 | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ 333 | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \372 | alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \ 334 373 | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ 335 374 | avr-* | avr32-* \ 375 | be32-* | be64-* \ 336 376 | bfin-* | bs2000-* \ 337 | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-*\338 | c lipper-* | craynv-* | cydra-* \377 | c[123]* | c30-* | [cjt]90-* | c4x-* \ 378 | c8051-* | clipper-* | craynv-* | cydra-* \ 339 379 | d10v-* | d30v-* | dlx-* \ 340 380 | elxsi-* \ … … 342 382 | h8300-* | h8500-* \ 343 383 | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ 384 | hexagon-* \ 344 385 | i*86-* | i860-* | i960-* | ia64-* \ 345 386 | ip2k-* | iq2000-* \ 387 | k1om-* \ 388 | le32-* | le64-* \ 346 389 | lm32-* \ 347 390 | m32c-* | m32r-* | m32rle-* \ 348 391 | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ 349 | m88110-* | m88k-* | maxq-* | mcore-* | metag-* | microblaze-* \ 392 | m88110-* | m88k-* | maxq-* | mcore-* | metag-* \ 393 | microblaze-* | microblazeel-* \ 350 394 | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ 351 395 | mips16-* \ … … 361 405 | mipsisa32-* | mipsisa32el-* \ 362 406 | mipsisa32r2-* | mipsisa32r2el-* \ 407 | mipsisa32r6-* | mipsisa32r6el-* \ 363 408 | mipsisa64-* | mipsisa64el-* \ 364 409 | mipsisa64r2-* | mipsisa64r2el-* \ 410 | mipsisa64r6-* | mipsisa64r6el-* \ 365 411 | mipsisa64sb1-* | mipsisa64sb1el-* \ 366 412 | mipsisa64sr71k-* | mipsisa64sr71kel-* \ 413 | mipsr5900-* | mipsr5900el-* \ 367 414 | mipstx39-* | mipstx39el-* \ 368 415 | mmix-* \ 369 416 | mt-* \ 370 417 | msp430-* \ 371 | nios-* | nios2-* \ 418 | nds32-* | nds32le-* | nds32be-* \ 419 | nios-* | nios2-* | nios2eb-* | nios2el-* \ 372 420 | none-* | np1-* | ns16k-* | ns32k-* \ 421 | open8-* \ 422 | or1k*-* \ 373 423 | orion-* \ 374 424 | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ 375 | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-*\425 | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ 376 426 | pyramid-* \ 377 | r omp-* | rs6000-* | rx-* \427 | rl78-* | romp-* | rs6000-* | rx-* \ 378 428 | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ 379 429 | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ 380 430 | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ 381 431 | sparclite-* \ 382 | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | s trongarm-* | sv1-* | sx?-* \383 | tahoe-* | thumb-*\432 | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx?-* \ 433 | tahoe-* \ 384 434 | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ 385 | tile -* | tilegx-* \435 | tile*-* \ 386 436 | tron-* \ 387 437 | ubicom32-* \ 388 | v850-* | v850e-* | vax-* \ 438 | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \ 439 | vax-* \ 389 440 | we32k-* \ 390 | x86-* | x86_64-* | xc16x-* | xps100-* | xscale-* | xscalee[bl]-*\441 | x86-* | x86_64-* | xc16x-* | xps100-* \ 391 442 | xstormy16-* | xtensa*-* \ 392 443 | ymp-* \ … … 413 464 os=-udi 414 465 ;; 415 466 abacus) 416 467 basic_machine=abacus-unknown 417 468 ;; … … 483 534 os=-cnk 484 535 ;; 536 c54x-*) 537 basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'` 538 ;; 539 c55x-*) 540 basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'` 541 ;; 542 c6x-*) 543 basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'` 544 ;; 485 545 c90) 486 546 basic_machine=c90-cray 487 547 os=-unicos 488 548 ;; 489 549 cegcc) 490 550 basic_machine=arm-unknown 491 551 os=-cegcc … … 519 579 os=-unicosmp 520 580 ;; 521 cr16 )581 cr16 | cr16-*) 522 582 basic_machine=cr16-unknown 523 583 os=-elf … … 677 737 basic_machine=i370-ibm 678 738 ;; 679 # I'm not sure what "Sysv32" means. Should this be sysv3.2?680 739 i*86v32) 681 740 basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` … … 735 794 os=-sysv 736 795 ;; 737 microblaze)796 microblaze*) 738 797 basic_machine=microblaze-xilinx 739 798 ;; 799 mingw64) 800 basic_machine=x86_64-pc 801 os=-mingw64 802 ;; 740 803 mingw32) 741 basic_machine=i 386-pc804 basic_machine=i686-pc 742 805 os=-mingw32 743 806 ;; … … 767 830 os=-morphos 768 831 ;; 832 moxiebox) 833 basic_machine=moxie-unknown 834 os=-moxiebox 835 ;; 769 836 msdos) 770 837 basic_machine=i386-pc … … 774 841 basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` 775 842 ;; 843 msys) 844 basic_machine=i686-pc 845 os=-msys 846 ;; 776 847 mvs) 777 848 basic_machine=i370-ibm 778 849 os=-mvs 850 ;; 851 nacl) 852 basic_machine=le32-unknown 853 os=-nacl 779 854 ;; 780 855 ncr3000) … … 842 917 basic_machine=np1-gould 843 918 ;; 919 neo-tandem) 920 basic_machine=neo-tandem 921 ;; 922 nse-tandem) 923 basic_machine=nse-tandem 924 ;; 844 925 nsr-tandem) 845 926 basic_machine=nsr-tandem … … 924 1005 power) basic_machine=power-ibm 925 1006 ;; 926 ppc) basic_machine=powerpc-unknown 927 ;; 928 ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` 1007 ppc | ppcbe) basic_machine=powerpc-unknown 1008 ;; 1009 ppc-* | ppcbe-*) 1010 basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` 929 1011 ;; 930 1012 ppcle | powerpclittle | ppc-le | powerpc-little) … … 951 1033 os=-pw32 952 1034 ;; 953 rdos) 1035 rdos | rdos64) 1036 basic_machine=x86_64-pc 1037 os=-rdos 1038 ;; 1039 rdos32) 954 1040 basic_machine=i386-pc 955 1041 os=-rdos … … 1020 1106 os=-sysv4 1021 1107 ;; 1108 strongarm-* | thumb-*) 1109 basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'` 1110 ;; 1022 1111 sun2) 1023 1112 basic_machine=m68000-sun … … 1076 1165 os=-unicos 1077 1166 ;; 1078 tic54x | c54x*)1079 basic_machine=tic54x-unknown1080 os=-coff1081 ;;1082 tic55x | c55x*)1083 basic_machine=tic55x-unknown1084 os=-coff1085 ;;1086 tic6x | c6x*)1087 basic_machine=tic6x-unknown1088 os=-coff1089 ;;1090 # This must be matched before tile*.1091 tilegx*)1092 basic_machine=tilegx-unknown1093 os=-linux-gnu1094 ;;1095 1167 tile*) 1096 basic_machine= tile-unknown1168 basic_machine=$basic_machine-unknown 1097 1169 os=-linux-gnu 1098 1170 ;; … … 1163 1235 xps | xps100) 1164 1236 basic_machine=xps100-honeywell 1237 ;; 1238 xscale-* | xscalee[bl]-*) 1239 basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'` 1165 1240 ;; 1166 1241 ymp) … … 1261 1336 then 1262 1337 case $os in 1263 1264 1338 # First match some system type aliases 1339 # that might get confused with valid system types. 1265 1340 # -solaris* is a basic system type, with this one exception. 1266 1267 1341 -auroraux) 1342 os=-auroraux 1268 1343 ;; 1269 1344 -solaris1 | -solaris1.*) … … 1289 1364 | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\ 1290 1365 | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ 1291 | -sym* | -kopensolaris* \1366 | -sym* | -kopensolaris* | -plan9* \ 1292 1367 | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ 1293 1368 | -aos* | -aros* \ … … 1295 1370 | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ 1296 1371 | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ 1297 | - openbsd* | -solidbsd* \1372 | -bitrig* | -openbsd* | -solidbsd* \ 1298 1373 | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ 1299 1374 | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ … … 1301 1376 | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ 1302 1377 | -chorusos* | -chorusrdb* | -cegcc* \ 1303 | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ 1304 | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \ 1305 | -uxpv* | -beos* | -mpeix* | -udk* \ 1378 | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ 1379 | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \ 1380 | -linux-newlib* | -linux-musl* | -linux-uclibc* \ 1381 | -uxpv* | -beos* | -mpeix* | -udk* | -moxiebox* \ 1306 1382 | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ 1307 1383 | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ … … 1310 1386 | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ 1311 1387 | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ 1312 | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* )1388 | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* | -tirtos*) 1313 1389 # Remember, each alternative MUST END IN *, to match a version number. 1314 1390 ;; … … 1349 1425 os=-openedition 1350 1426 ;; 1351 1427 -os400*) 1352 1428 os=-os400 1353 1429 ;; … … 1398 1474 os=-sysv4 1399 1475 ;; 1400 1476 -tpf*) 1401 1477 os=-tpf 1402 1478 ;; … … 1434 1510 os=-aros 1435 1511 ;; 1436 -kaos*)1437 os=-kaos1438 ;;1439 1512 -zvmoe) 1440 1513 os=-zvmoe … … 1443 1516 os=-dicos 1444 1517 ;; 1445 1446 1518 -nacl*) 1519 ;; 1447 1520 -none) 1448 1521 ;; … … 1467 1540 1468 1541 case $basic_machine in 1469 1542 score-*) 1470 1543 os=-elf 1471 1544 ;; 1472 1545 spu-*) 1473 1546 os=-elf 1474 1547 ;; … … 1482 1555 os=-aout 1483 1556 ;; 1484 c4x-* | tic4x-*) 1485 os=-coff 1557 c4x-* | tic4x-*) 1558 os=-coff 1559 ;; 1560 c8051-*) 1561 os=-elf 1562 ;; 1563 hexagon-*) 1564 os=-elf 1565 ;; 1566 tic54x-*) 1567 os=-coff 1568 ;; 1569 tic55x-*) 1570 os=-coff 1571 ;; 1572 tic6x-*) 1573 os=-coff 1486 1574 ;; 1487 1575 # This must come before the *-dec entry. … … 1503 1591 m68000-sun) 1504 1592 os=-sunos3 1505 # This also exists in the configure program, but was not the1506 # default.1507 # os=-sunos41508 1593 ;; 1509 1594 m68*-cisco) 1510 1595 os=-aout 1511 1596 ;; 1512 1597 mep-*) 1513 1598 os=-elf 1514 1599 ;; … … 1537 1622 os=-aix 1538 1623 ;; 1539 1624 *-knuth) 1540 1625 os=-mmixware 1541 1626 ;; -
trunk/configure.ac
r477 r481 12 12 dnl start 13 13 dnl 14 AM_INIT_AUTOMAKE(samhain, 3.1.6)14 AM_INIT_AUTOMAKE(samhain, 4.0.0.rc1) 15 15 AC_DEFINE([SAMHAIN], 1, [Application is samhain]) 16 16 AC_CANONICAL_HOST … … 40 40 41 41 AC_HEADER_STDC 42 dnl 43 dnl first one is a dummy because of an autoconf bug 44 dnl (no HAVE_... for first one) 45 dnl 46 AC_CHECK_HEADERS([sys/ipc.h sys/msg.h sys/uio.h fcntl.h]) 42 43 AC_CHECK_HEADERS([sys/ipc.h sys/sem.h sys/msg.h sys/uio.h fcntl.h]) 47 44 48 45 … … 395 392 ) 396 393 AC_CHECK_FUNC(statfs, AC_DEFINE(HAVE_STATFS) statfs="yes", statfs="no") 397 AC_CHECK_VA_COPY394 SL_CHECK_VA_COPY 398 395 AC_CHECK_FUNCS(vsnprintf, [SL_CHECK_VSNPRINTF]) 399 396 AC_CHECK_MLOCK … … 532 529 SH_CHECK_TYPEDEF(long long, HAVE_LONG_LONG) 533 530 SH_CHECK_TYPEDEF(uint16_t, HAVE_UINT16_T) 531 SH_CHECK_TYPEDEF(uint32_t, HAVE_UINT32_T) 534 532 SH_CHECK_TYPEDEF(uint64_t, HAVE_UINT64_T) 535 533 if test "$sh_HAVE_LONG_LONG" = "yes"; then … … 946 944 mytclient="-DSH_WITH_CLIENT" 947 945 yulectl_prg= 946 samhainadmin_prg= 948 947 setpwd_prg="samhain_setpwd" 949 948 sh_main_prg="samhain" … … 958 957 mytclient="-DSH_WITH_SERVER" 959 958 yulectl_prg="yulectl" 959 samhainadmin_prg="scripts/samhainadmin.pl" 960 960 setpwd_prg="samhain_setpwd" 961 961 sh_main_prg="yule" … … 968 968 mytclient="-DSH_STANDALONE" 969 969 yulectl_prg= 970 samhainadmin_prg= 970 971 setpwd_prg= 971 972 sh_main_prg="samhain" … … 981 982 setpwd_prg= 982 983 yulectl_prg= 984 samhainadmin_prg= 983 985 sh_main_prg="samhain" 984 986 dnl AC_CHECK_HEADER(sys/capability.h, … … 990 992 AC_SUBST(setpwd_prg) 991 993 AC_SUBST(yulectl_prg) 994 AC_SUBST(samhainadmin_prg) 992 995 AC_SUBST(sh_main_prg) 993 996 AC_SUBST(mytclient) … … 1013 1016 LIBS="${tmp_LIBS}" 1014 1017 fi 1015 AC_DEFINE(SH_COMPILE_STATIC, 1, [Define if compiling static]) 1016 if test "x$GCC" = "xyes"; then 1017 sh_no_gcc_static=no 1018 LDFLAGS="$LDFLAGS -static" 1018 1019 if test "x$GCC" = "xyes"; 1020 then 1021 case "$host_os" in 1022 1023 *solaris*) 1024 AC_MSG_WARN([option --enable-static ignored on Solaris]) 1025 ;; 1026 1027 *) 1028 AC_DEFINE(SH_COMPILE_STATIC, 1, [Define if compiling static]) 1029 sh_no_gcc_static=no 1030 LDFLAGS="$LDFLAGS -static" 1031 ;; 1032 esac 1019 1033 else 1034 AC_DEFINE(SH_COMPILE_STATIC, 1, [Define if compiling static]) 1020 1035 sh_no_gcc_static=yes 1021 1036 case "$host_os" in … … 1744 1759 fi 1745 1760 1746 dnl if test ! -z "`echo "$CFLAGS" | grep "\-O2" 2> /dev/null`" ; then 1747 dnl CFLAGS=`echo $CFLAGS | sed 's%\-O2%\-O3%' ` 1748 dnl fi 1749 1761 dnl -W is the older name for -Wextra 1762 1763 1750 1764 if test -z "`echo "$CFLAGS" | grep "\-Wall" 2> /dev/null`" ; then 1751 CFLAGS="$CFLAGS -Wall -W " 1765 case "$host_os" in 1766 *solaris*) 1767 CFLAGS="$CFLAGS -Wall -W -Wno-missing-braces " 1768 ;; 1769 *) 1770 CFLAGS="$CFLAGS -Wall -W " 1771 ;; 1772 esac 1752 1773 fi 1753 1774 … … 1864 1885 if test "x${enable_encrypt}" = xno; then 1865 1886 myencrypt=no 1866 elif test "x${enable_encrypt}" = "x1"; then1867 myencrypt=11868 1887 fi 1869 1888 ] … … 1872 1891 AC_DEFINE(SH_ENCRYPT) 1873 1892 AC_DEFINE(SH_ENCRYPT_2) 1874 elif test "x${myencrypt}" = "x1"; then1875 AC_DEFINE(SH_ENCRYPT)1876 1893 fi 1877 1894 … … 2068 2085 AC_SUBST(need_user_install) 2069 2086 2070 sh_insmod_cmd=": # no kernel module"2071 sh_insmod_pre=": # no kernel module"2072 sh_lkm=""2073 lkm_inc=""2074 khidemap="/boot/System.map"2075 sh_syscalltable="0x0"2076 AC_ARG_ENABLE(khide,2077 [ --enable-khide=SYSTEM_MAP use kernel module to hide (Linux only)[[/boot/System.map]]],2078 [2079 if test "x${enable_khide}" != xno; then2080 2081 kernel_testsupport=`uname -r | sed s,^3.*,LINUX3,`2082 if test "x${kernel_testsupport}" = "xLINUX3"; then2083 AC_MSG_ERROR([The --enable-khide option is not supported on Linux kernel version 3.x or above.])2084 fi2085 2086 if test "x${enableval}" != "xyes"; then2087 khidemap="${enableval}"2088 fi2089 sh_syscalltable=`egrep '(D|d|R|r) sys_call_table' ${khidemap} | awk '{print $1}'`2090 if test x"$sh_syscalltable" = x; then2091 AC_MSG_ERROR([Option --enable-khide cannot be used since the symbol sys_call_table was not found in ${khidemap}.])2092 fi2093 sh_syscalltable="0x${sh_syscalltable}"2094 install_name_len=`echo ${install_name} | awk '{ print(length()); }'`2095 if test "${install_name_len}" -gt 15 ; then2096 AC_MSG_ERROR([If --enable-khide is used, install_name must not exceed a length of 15 chars.])2097 fi2098 AC_DEFINE(SH_USE_LKM)2099 AC_DEFINE_UNQUOTED(SH_MAGIC_HIDE, "${install_name}")2100 2101 # -- NEW --2102 kernel_version=`uname -r | sed s,2.6.*,LINUX26,`2103 kernel_numeric=`uname -r | sed 's%-%.%g' | sed 's%_%.%g' | awk -F. '{ print $1*65536+$2*256+$3 }'`2104 AC_DEFINE_UNQUOTED(SH_KERNEL_NUMERIC, ${kernel_numeric}, [Kernel number])2105 2106 if test x"$kernel_version" = xLINUX262107 then2108 AC_MSG_CHECKING([for modlist_lock])2109 sh_modlist_lock=`egrep ['[bd] modlist_lock$'] ${khidemap} | awk '{print $1}'`2110 if test x"$sh_modlist_lock" = x; then2111 AC_MSG_RESULT(no)2112 else2113 sh_modlist_lock="0x${sh_modlist_lock}"2114 AC_MSG_RESULT([${sh_modlist_lock}])2115 AC_DEFINE_UNQUOTED(SH_MODLIST_LOCK, ${sh_modlist_lock}, [The address of the modules list spinlock])2116 fi2117 2118 AC_MSG_CHECKING([for module_mutex])2119 sh_modlist_mutex=`egrep ['[bd] module_mutex$'] ${khidemap} | awk '{print $1}'`2120 if test x"$sh_modlist_mutex" = x; then2121 AC_MSG_RESULT(no)2122 else2123 sh_modlist_mutex="0x${sh_modlist_mutex}"2124 AC_MSG_RESULT([${sh_modlist_mutex}])2125 AC_DEFINE_UNQUOTED(SH_MODLIST_MUTEX, ${sh_modlist_mutex}, [The address of the modules list mutex])2126 fi2127 2128 sh_list_modules=`egrep 'd modules$' ${khidemap} | awk '{print $1}'`2129 if test x"$sh_list_modules" = x; then2130 AC_MSG_ERROR([Option --enable-khide cannot be used, since the symbol modules was not found in ${khidemap}.])2131 fi2132 sh_list_modules="0x${sh_list_modules}"2133 AC_DEFINE_UNQUOTED(SH_LIST_MODULES, ${sh_list_modules}, [The address of the modules list])2134 2135 AC_DEFINE(LINUX26, 1, [Define if kernel is 2.6])2136 sh_insmod_cmd="modprobe ${install_name}_hide"2137 sh_lkm="samhain_hide.ko"2138 else2139 sh_insmod_cmd="insmod ${install_name}_hide; insmod ${install_name}_erase; rmmod ${install_name}_erase"2140 sh_lkm="samhain_hide.o samhain_erase.o"2141 fi2142 # -- END NEW --2143 2144 kvers=`uname -r`2145 if test -f /lib/modules/${kvers}/build/include/linux/kernel.h; then2146 lkm_inc="-I/lib/modules/${kvers}/build/include"2147 else2148 AC_MSG_WARN([--enable-khide: /lib/modules/${kvers}/build/include/linux not found])2149 AC_MSG_WARN([--enable-khide: You may need to install the kernel-source])2150 AC_MSG_WARN([--enable-khide: headers for the currently-running kernel.])2151 fi2152 2153 AC_MSG_CHECKING([for 2.4 vanilla kernel])2154 sh_is_vanilla_kernel=yes2155 if test -f /lib/modules/${kvers}/build/include/linux/sched.h; then2156 grep 'next_task,' /lib/modules/${kvers}/build/include/linux/sched.h >/dev/null 2>&1 || sh_is_vanilla_kernel=no2157 fi2158 if test x"${sh_is_vanilla_kernel}" = xno; then2159 AC_MSG_RESULT(no)2160 else2161 AC_MSG_RESULT(yes)2162 AC_DEFINE(SH_VANILLA_KERNEL)2163 fi2164 2165 fi2166 ]2167 )2168 2169 2087 AC_SUBST(install_name) 2170 2088 AC_SUBST(INSTALL_NAME) … … 2194 2112 ) 2195 2113 2196 2197 systemmap="/boot/System.map"2198 sh_libkvm=""2199 AC_ARG_WITH(kcheck,2200 [ --with-kcheck[[=SYSTEM_MAP]] check Linux/FreeBSD/OpenBSD kernel integrity [[/boot/System.map]]],2201 [2202 if test "x${withval}" != "xno"; then2203 AC_DEFINE(SH_USE_KERN)2204 2205 kernel_numeric=`uname -r | sed 's%-%.%g' | sed 's%_%.%g' | awk -F. '{ print $1*65536+$2*256+$3 }'`2206 AC_DEFINE_UNQUOTED(SH_KERNEL_NUMBER, ${kernel_numeric}, [Kernel number])2207 2208 kernelversion=`uname -r`2209 AC_DEFINE_UNQUOTED(SH_KERNEL_VERSION, _("${kernelversion}"), [Define the kernel version])2210 2211 if test "x${withval}" != "xyes"; then2212 systemmap="${withval}"2213 fi2214 2215 if test "x${cross_compiling}" = xyes; then2216 :2217 elif test "x$selectconfig" = "xfreebsd"; then2218 LIBS="$LIBS -lkvm"2219 sh_libkvm="-lkvm"2220 elif test -f "${systemmap}"; then2221 2222 test_kmap_open=no2223 2224 if test -c /dev/kmem; then2225 AC_MSG_CHECKING([whether /dev/kmem is useable])2226 dd bs=4 count=16 if=/dev/kmem of=/dev/null >/dev/null 2>&12227 if test $? -eq 0; then2228 test_kmap_open=yes2229 fi2230 AC_MSG_RESULT([${test_kmap_open}])2231 fi2232 2233 if test x"${test_kmap_open}" = xno; then2234 # need kernel module2235 2236 if test -f /lib/modules/${kernelversion}/build/include/linux/kernel.h; then2237 lkm_inc="-I/lib/modules/${kernelversion}/build/include"2238 else2239 AC_MSG_WARN([--enable-khide: /lib/modules/${kernelversion}/build/include/linux not found])2240 AC_MSG_WARN([--enable-khide: You may need to install the kernel-source])2241 AC_MSG_WARN([--enable-khide: headers for the currently-running kernel.])2242 fi2243 2244 AC_MSG_CHECKING([for vmlist_lock])2245 sh_vmlist_lock=`egrep ['[bdBD] vmlist_lock$'] ${systemmap} | awk '{print $1}'`2246 if test x"$sh_vmlist_lock" = x; then2247 AC_MSG_RESULT(no)2248 else2249 sh_vmlist_lock="0x${sh_vmlist_lock}"2250 AC_MSG_RESULT([${sh_vmlist_lock}])2251 AC_DEFINE_UNQUOTED(SH_VMLIST_LOCK, ${sh_vmlist_lock}, [The address of the vmlist spinlock])2252 fi2253 2254 AC_MSG_CHECKING([for vmlist])2255 sh_vmlist=`egrep ['[bdBD] vmlist$'] ${systemmap} | awk '{print $1}'`2256 if test x"$sh_vmlist" = x; then2257 AC_MSG_RESULT(no)2258 else2259 sh_vmlist="0x${sh_vmlist}"2260 AC_MSG_RESULT([${sh_vmlist}])2261 AC_DEFINE_UNQUOTED(SH_VMLIST, ${sh_vmlist}, [The address of the vmlist])2262 fi2263 2264 sh_lkm="${sh_lkm} samhain_kmem.ko"2265 sh_insmod_pre="modprobe ${install_name}_kmem"2266 2267 fi2268 else2269 AC_MSG_ERROR([Option --with-kcheck=systemmap cannot be used, because system map ${systemmap} does not exist.])2270 fi2271 fi2272 ]2273 )2274 2275 AC_SUBST(lkm_inc)2276 AC_SUBST(sh_lkm)2277 AC_SUBST(sh_insmod_cmd)2278 AC_SUBST(sh_insmod_pre)2279 2280 AC_SUBST(systemmap)2281 AC_SUBST(sh_libkvm)2282 2114 2283 2115 AC_ARG_ENABLE(base, … … 2425 2257 ) 2426 2258 2259 2260 2427 2261 AC_ARG_WITH(keyid, 2428 2262 [ --with-keyid=KEYID specify KeyID (0x...) for GPG/PGP functions [[none]]], … … 2896 2730 echo " Configuration file: ${myconffile}" 2897 2731 echo " Manual pages: ${mandir}" 2898 echo " Data: ${mydataroot}" 2732 echo " Data directory: ${mydataroot}" 2733 echo " Database file: ${mydatafile}" 2899 2734 echo " PID file: ${mylockfile}" 2900 2735 echo " Log file: ${mylogfile}" -
trunk/depend.dep
r452 r481 1 1 2 2 # DO NOT DELETE THIS LINE 3 samhain.o: $(srcsrc)/samhain.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_pthread.h $(srcinc)/sh_utils.h $(srcinc)/sh_error.h $(srcinc)/sh_unix.h $(srcinc)/sh_files.h $(srcinc)/sh_getopt.h $(srcinc)/sh_readconf.h $(srcinc)/sh_hash.h $(srcinc)/sh_ restrict.h $(srcinc)/sh_nmail.h $(srcinc)/sh_tiger.h $(srcinc)/sh_gpg.h $(srcinc)/sh_mem.h $(srcinc)/sh_forward.h $(srcinc)/sh_tools.h $(srcinc)/sh_hash.h $(srcinc)/sh_extern.h $(srcinc)/sh_modules.h $(srcinc)/sh_ignore.h $(srcinc)/sh_prelink.h sh_MK.h $(srcinc)/sh_schedule.h4 sh_unix.o: $(srcsrc)/sh_unix.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_error.h $(srcinc)/sh_unix.h $(srcinc)/sh_utils.h $(srcinc)/sh_mem.h $(srcinc)/sh_hash.h $(srcinc)/sh_tools.h $(srcinc)/sh_restrict.h $(srcinc)/sh_ipvx.h $(srcinc)/sh_tiger.h $(srcinc)/sh_prelink.h $(srcinc)/sh_pthread.h $(srcinc)/sh_s tatic.h $(srcinc)/sh_prelude.h $(srcinc)/zAVLTree.h $(srcinc)/sh_ignore.h3 samhain.o: $(srcsrc)/samhain.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_pthread.h $(srcinc)/sh_utils.h $(srcinc)/sh_error.h $(srcinc)/sh_unix.h $(srcinc)/sh_files.h $(srcinc)/sh_getopt.h $(srcinc)/sh_readconf.h $(srcinc)/sh_hash.h $(srcinc)/sh_dbIO.h $(srcinc)/sh_restrict.h $(srcinc)/sh_nmail.h $(srcinc)/sh_tiger.h $(srcinc)/sh_gpg.h $(srcinc)/sh_mem.h $(srcinc)/sh_xfer.h $(srcinc)/sh_tools.h $(srcinc)/sh_hash.h $(srcinc)/sh_extern.h $(srcinc)/sh_modules.h $(srcinc)/sh_ignore.h $(srcinc)/sh_prelink.h $(srcinc)/sh_sem.h sh_MK.h $(srcinc)/sh_schedule.h 4 sh_unix.o: $(srcsrc)/sh_unix.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_error.h $(srcinc)/sh_unix.h $(srcinc)/sh_utils.h $(srcinc)/sh_mem.h $(srcinc)/sh_hash.h $(srcinc)/sh_tools.h $(srcinc)/sh_restrict.h $(srcinc)/sh_ipvx.h $(srcinc)/sh_tiger.h $(srcinc)/sh_prelink.h $(srcinc)/sh_pthread.h $(srcinc)/sh_sem.h $(srcinc)/sh_static.h $(srcinc)/sh_prelude.h $(srcinc)/zAVLTree.h $(srcinc)/sh_ignore.h 5 5 sh_utils.o: $(srcsrc)/sh_utils.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_error.h $(srcinc)/sh_utils.h $(srcinc)/sh_unix.h $(srcinc)/sh_tiger.h $(srcinc)/sh_entropy.h $(srcinc)/sh_pthread.h 6 sh_error.o: $(srcsrc)/sh_error.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_cat.h $(srcinc)/sh_database.h $(srcinc)/sh_error.h $(srcinc)/sh_utils.h $(srcinc)/sh_unix.h $(srcinc)/sh_tiger.h $(srcinc)/sh_nmail.h $(srcinc)/sh_ forward.h $(srcinc)/sh_prelude.h $(srcinc)/sh_pthread.h $(srcinc)/sh_tools.h $(srcinc)/sh_extern.h $(srcinc)/sh_checksum.h7 sh_files.o: $(srcsrc)/sh_files.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_pthread.h $(srcinc)/sh_error.h $(srcinc)/sh_utils.h $(srcinc)/sh_unix.h $(srcinc)/sh_files.h $(srcinc)/sh_tiger.h $(srcinc)/sh_hash.h $(srcinc)/sh_ignore.h $(srcinc)/sh_inotify.h $(srcinc)/zAVLTree.h $(srcinc)/ CuTest.h8 sh_getopt.o: $(srcsrc)/sh_getopt.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_error.h $(srcinc)/sh_getopt.h $(srcinc)/sh_unix.h $(srcinc)/sh_files.h $(srcinc)/sh_utils.h $(srcinc)/sh_mail.h $(srcinc)/sh_ forward.h $(srcinc)/sh_hash.h $(srcinc)/sh_extern.h9 sh_readconf.o: $(srcsrc)/sh_readconf.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_calls.h $(srcinc)/sh_error.h $(srcinc)/sh_extern.h $(srcinc)/sh_unix.h $(srcinc)/sh_files.h $(srcinc)/sh_ forward.h $(srcinc)/sh_gpg.h $(srcinc)/sh_hash.h $(srcinc)/sh_ignore.h $(srcinc)/sh_database.h $(srcinc)/sh_mail.h $(srcinc)/sh_modules.h $(srcinc)/sh_nmail.h $(srcinc)/sh_prelink.h $(srcinc)/sh_prelude.h $(srcinc)/sh_tiger.h $(srcinc)/sh_tools.h $(srcinc)/sh_utils.h $(srcinc)/sh_restrict.h6 sh_error.o: $(srcsrc)/sh_error.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_cat.h $(srcinc)/sh_database.h $(srcinc)/sh_error.h $(srcinc)/sh_utils.h $(srcinc)/sh_unix.h $(srcinc)/sh_tiger.h $(srcinc)/sh_nmail.h $(srcinc)/sh_xfer.h $(srcinc)/sh_prelude.h $(srcinc)/sh_pthread.h $(srcinc)/sh_tools.h $(srcinc)/sh_extern.h $(srcinc)/sh_checksum.h 7 sh_files.o: $(srcsrc)/sh_files.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_pthread.h $(srcinc)/sh_error.h $(srcinc)/sh_utils.h $(srcinc)/sh_unix.h $(srcinc)/sh_files.h $(srcinc)/sh_tiger.h $(srcinc)/sh_hash.h $(srcinc)/sh_ignore.h $(srcinc)/sh_inotify.h $(srcinc)/zAVLTree.h $(srcinc)/sh_dbIO.h $(srcinc)/CuTest.h 8 sh_getopt.o: $(srcsrc)/sh_getopt.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_error.h $(srcinc)/sh_getopt.h $(srcinc)/sh_unix.h $(srcinc)/sh_files.h $(srcinc)/sh_utils.h $(srcinc)/sh_mail.h $(srcinc)/sh_xfer.h $(srcinc)/sh_hash.h $(srcinc)/sh_dbIO.h $(srcinc)/sh_dbCheck.h $(srcinc)/sh_dbCreate.h $(srcinc)/sh_sem.h $(srcinc)/sh_extern.h 9 sh_readconf.o: $(srcsrc)/sh_readconf.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_calls.h $(srcinc)/sh_error.h $(srcinc)/sh_extern.h $(srcinc)/sh_unix.h $(srcinc)/sh_files.h $(srcinc)/sh_xfer.h $(srcinc)/sh_gpg.h $(srcinc)/sh_hash.h $(srcinc)/sh_dbIO.h $(srcinc)/sh_ignore.h $(srcinc)/sh_database.h $(srcinc)/sh_mail.h $(srcinc)/sh_modules.h $(srcinc)/sh_nmail.h $(srcinc)/sh_prelink.h $(srcinc)/sh_prelude.h $(srcinc)/sh_tiger.h $(srcinc)/sh_tools.h $(srcinc)/sh_utils.h $(srcinc)/sh_restrict.h $(srcinc)/sh_socket.h 10 10 sh_tiger0.o: $(srcsrc)/sh_tiger0.c Makefile config_xor.h $(srcinc)/sh_tiger.h $(srcinc)/sh_unix.h $(srcinc)/sh_error.h $(srcinc)/sh_utils.h $(srcinc)/sh_pthread.h $(srcinc)/sh_string.h $(srcinc)/sh_checksum.h 11 11 sh_tiger1.o: $(srcsrc)/sh_tiger1.c Makefile config_xor.h … … 13 13 sh_tiger1_64.o: $(srcsrc)/sh_tiger1_64.c Makefile config_xor.h 14 14 sh_tiger2_64.o: $(srcsrc)/sh_tiger2_64.c Makefile config_xor.h 15 sh_hash.o: $(srcsrc)/sh_hash.c Makefile config_xor.h $(srcinc)/s h_hash.h $(srcinc)/sh_utils.h $(srcinc)/sh_error.h $(srcinc)/sh_tiger.h $(srcinc)/sh_gpg.h $(srcinc)/sh_unix.h $(srcinc)/sh_files.h $(srcinc)/sh_ignore.h $(srcinc)/sh_pthread.h $(srcinc)/sh_forward.h $(srcinc)/sh_hash.h $(srcinc)/sh_checksum.h15 sh_hash.o: $(srcsrc)/sh_hash.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_utils.h $(srcinc)/sh_unix.h $(srcinc)/sh_dbIO_int.h $(srcinc)/sh_dbIO.h $(srcinc)/sh_hash.h $(srcinc)/sh_error.h $(srcinc)/sh_tiger.h $(srcinc)/sh_gpg.h $(srcinc)/sh_unix.h $(srcinc)/sh_files.h $(srcinc)/sh_ignore.h $(srcinc)/sh_pthread.h $(srcinc)/sh_xfer.h $(srcinc)/sh_hash.h $(srcinc)/sh_checksum.h 16 16 sh_mail.o: $(srcsrc)/sh_mail.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_error.h $(srcinc)/sh_unix.h $(srcinc)/sh_tiger.h $(srcinc)/sh_mail.h $(srcinc)/sh_utils.h $(srcinc)/sh_fifo.h $(srcinc)/sh_tools.h $(srcinc)/sh_pthread.h $(srcinc)/sh_filter.h $(srcinc)/sh_mail_int.h $(srcinc)/sh_nmail.h $(srcinc)/sh_ipvx.h $(srcinc)/sh_static.h $(srcinc)/sh_tools.h 17 17 sh_mem.o: $(srcsrc)/sh_mem.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_error.h $(srcinc)/sh_utils.h $(srcinc)/sh_mem.h $(srcinc)/sh_pthread.h 18 18 sh_entropy.o: $(srcsrc)/sh_entropy.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_utils.h $(srcinc)/sh_unix.h $(srcinc)/sh_tiger.h $(srcinc)/sh_calls.h $(srcinc)/sh_pthread.h $(srcinc)/sh_static.h $(srcinc)/sh_pthread.h $(srcinc)/CuTest.h 19 19 sh_forward.o: $(srcsrc)/sh_forward.c Makefile config_xor.h $(srcinc)/sh_ipvx.h $(srcinc)/samhain.h $(srcinc)/sh_tiger.h $(srcinc)/sh_utils.h $(srcinc)/sh_unix.h $(srcinc)/sh_forward.h $(srcinc)/sh_srp.h $(srcinc)/sh_fifo.h $(srcinc)/sh_tools.h $(srcinc)/sh_entropy.h $(srcinc)/sh_html.h $(srcinc)/sh_nmail.h $(srcinc)/sh_socket.h $(srcinc)/sh_static.h $(srcinc)/rijndael-api-fst.h $(srcinc)/sh_readconf.h $(srcinc)/zAVLTree.h $(srcinc)/sh_extern.h 20 sh_modules.o: $(srcsrc)/sh_modules.c Makefile config_xor.h $(srcinc)/sh_modules.h $(srcinc)/sh_pthread.h $(srcinc)/sh_utmp.h $(srcinc)/sh_mounts.h $(srcinc)/sh_userfiles.h $(srcinc)/sh_ kern.h $(srcinc)/sh_suidchk.h $(srcinc)/sh_processcheck.h $(srcinc)/sh_portcheck.h $(srcinc)/sh_logmon.h $(srcinc)/sh_registry.h $(srcinc)/sh_fInotify.h20 sh_modules.o: $(srcsrc)/sh_modules.c Makefile config_xor.h $(srcinc)/sh_modules.h $(srcinc)/sh_pthread.h $(srcinc)/sh_utmp.h $(srcinc)/sh_mounts.h $(srcinc)/sh_userfiles.h $(srcinc)/sh_suidchk.h $(srcinc)/sh_processcheck.h $(srcinc)/sh_portcheck.h $(srcinc)/sh_logmon.h $(srcinc)/sh_registry.h $(srcinc)/sh_fInotify.h 21 21 sh_utmp.o: $(srcsrc)/sh_utmp.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_utils.h $(srcinc)/sh_error.h $(srcinc)/sh_modules.h $(srcinc)/sh_utmp.h $(srcinc)/sh_pthread.h $(srcinc)/sh_inotify.h 22 22 sh_kern.o: $(srcsrc)/sh_kern.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_pthread.h $(srcinc)/sh_utils.h $(srcinc)/sh_error.h $(srcinc)/sh_modules.h $(srcinc)/sh_kern.h sh_ks_xor.h $(srcinc)/sh_unix.h $(srcinc)/sh_hash.h 23 sh_suidchk.o: $(srcsrc)/sh_suidchk.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_pthread.h $(srcinc)/sh_utils.h $(srcinc)/sh_error.h $(srcinc)/sh_modules.h $(srcinc)/sh_suidchk.h $(srcinc)/sh_hash.h $(srcinc)/sh_ unix.h $(srcinc)/sh_files.h $(srcinc)/sh_schedule.h $(srcinc)/sh_calls.h $(srcinc)/zAVLTree.h23 sh_suidchk.o: $(srcsrc)/sh_suidchk.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_pthread.h $(srcinc)/sh_utils.h $(srcinc)/sh_error.h $(srcinc)/sh_modules.h $(srcinc)/sh_suidchk.h $(srcinc)/sh_hash.h $(srcinc)/sh_dbIO.h $(srcinc)/sh_unix.h $(srcinc)/sh_files.h $(srcinc)/sh_schedule.h $(srcinc)/sh_calls.h $(srcinc)/zAVLTree.h 24 24 sh_srp.o: $(srcsrc)/sh_srp.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_tiger.h $(srcinc)/sh_mem.h $(srcinc)/sh_utils.h $(srcinc)/sh_srp.h $(srcinc)/bignum.h $(srcinc)/CuTest.h 25 sh_fifo.o: $(srcsrc)/sh_fifo.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_mem.h $(srcinc)/sh_unix.h $(srcinc)/sh_utils.h $(srcinc)/sh_string.h $(srcinc)/sh_fifo.h 25 sh_fifo.o: $(srcsrc)/sh_fifo.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_mem.h $(srcinc)/sh_unix.h $(srcinc)/sh_utils.h $(srcinc)/sh_string.h $(srcinc)/sh_fifo.h $(srcinc)/CuTest.h 26 26 sh_tools.o: $(srcsrc)/sh_tools.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_mem.h $(srcinc)/sh_error.h $(srcinc)/sh_tools.h $(srcinc)/sh_utils.h $(srcinc)/sh_tiger.h $(srcinc)/sh_static.h $(srcinc)/sh_pthread.h $(srcinc)/sh_ipvx.h $(srcinc)/rijndael-api-fst.h $(srcinc)/rijndael-api-fst.h 27 sh_html.o: $(srcsrc)/sh_html.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_ forward.h $(srcinc)/sh_error.h $(srcinc)/sh_unix.h $(srcinc)/sh_utils.h $(srcinc)/sh_html.h $(srcinc)/zAVLTree.h28 sh_gpg.o: $(srcsrc)/sh_gpg.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_utils.h $(srcinc)/sh_error.h $(srcinc)/sh_tiger.h $(srcinc)/sh_static.h 27 sh_html.o: $(srcsrc)/sh_html.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_xfer.h $(srcinc)/sh_error.h $(srcinc)/sh_unix.h $(srcinc)/sh_utils.h $(srcinc)/sh_html.h $(srcinc)/zAVLTree.h 28 sh_gpg.o: $(srcsrc)/sh_gpg.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_utils.h $(srcinc)/sh_error.h $(srcinc)/sh_tiger.h $(srcinc)/sh_static.h $(srcinc)/sh_gpg.h 29 29 sh_cat.o: $(srcsrc)/sh_cat.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_error.h $(srcinc)/sh_cat.h 30 30 sh_calls.o: $(srcsrc)/sh_calls.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_error.h $(srcinc)/sh_calls.h $(srcinc)/sh_ipvx.h $(srcinc)/sh_sub.h $(srcinc)/sh_utils.h … … 32 32 sh_database.o: $(srcsrc)/sh_database.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_cat.h $(srcinc)/sh_error.h $(srcinc)/sh_utils.h 33 33 sh_err_log.o: $(srcsrc)/sh_err_log.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_error.h $(srcinc)/sh_utils.h $(srcinc)/sh_tiger.h 34 sh_err_console.o: $(srcsrc)/sh_err_console.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_error.h $(srcinc)/sh_utils.h 34 sh_err_console.o: $(srcsrc)/sh_err_console.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_error.h $(srcinc)/sh_utils.h $(srcinc)/sh_sem.h 35 35 sh_err_syslog.o: $(srcsrc)/sh_err_syslog.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_error.h 36 sh_schedule.o: $(srcsrc)/sh_schedule.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_mem.h $(srcinc)/sh_ schedule.h36 sh_schedule.o: $(srcsrc)/sh_schedule.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_mem.h $(srcinc)/sh_error_min.h $(srcinc)/sh_schedule.h 37 37 bignum.o: $(srcsrc)/bignum.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/bignum.h 38 38 mkhdr.o: $(srcsrc)/mkhdr.c Makefile config.h … … 47 47 minilzo.o: $(srcsrc)/minilzo.c Makefile $(srcinc)/minilzo.h 48 48 slib.o: $(srcsrc)/slib.c Makefile config_xor.h $(srcinc)/slib.h $(srcinc)/sh_calls.h $(srcinc)/sh_static.h $(srcinc)/sh_pthread.h $(srcinc)/sh_string.h $(srcinc)/sh_mem.h 49 rijndael-alg-fst.o: $(srcsrc)/rijndael-alg-fst.c Makefile config_xor.h $(srcinc)/rijndael-alg-fst.h $(srcinc)/rijndael-boxes-fst.h49 rijndael-alg-fst.o: $(srcsrc)/rijndael-alg-fst.c Makefile config_xor.h $(srcinc)/rijndael-alg-fst.h 50 50 rijndael-api-fst.o: $(srcsrc)/rijndael-api-fst.c Makefile config_xor.h $(srcinc)/rijndael-api-fst.h 51 51 zAVLTree.o: $(srcsrc)/zAVLTree.c Makefile $(srcinc)/zAVLTree.h 52 sh_socket.o: $(srcsrc)/sh_socket.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_socket.h $(srcinc)/sh_error.h $(srcinc)/sh_unix.h $(srcinc)/sh_calls.h $(srcinc)/sh_ utils.h $(srcinc)/zAVLTree.h $(srcinc)/sh_html.h $(srcinc)/sh_tools.h52 sh_socket.o: $(srcsrc)/sh_socket.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_socket.h $(srcinc)/sh_error.h $(srcinc)/sh_unix.h $(srcinc)/sh_calls.h $(srcinc)/sh_guid.h $(srcinc)/sh_fifo.h $(srcinc)/sh_utils.h $(srcinc)/sh_utils.h $(srcinc)/zAVLTree.h $(srcinc)/sh_html.h $(srcinc)/sh_tools.h $(srcinc)/CuTest.h 53 53 sh_ignore.o: $(srcsrc)/sh_ignore.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_mem.h $(srcinc)/sh_error.h $(srcinc)/CuTest.h 54 54 yulectl.o: $(srcsrc)/yulectl.c Makefile config_xor.h … … 89 89 sh_filetype.o: $(srcsrc)/sh_filetype.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_mem.h $(srcinc)/sh_error_min.h $(srcinc)/sh_utils.h 90 90 sh_sub.o: $(srcsrc)/sh_sub.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_pthread.h 91 sh_fInotify.o: $(srcsrc)/sh_fInotify.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_utils.h $(srcinc)/sh_modules.h $(srcinc)/sh_pthread.h $(srcinc)/sh_inotify.h $(srcinc)/sh_unix.h $(srcinc)/sh_hash.h $(srcinc)/sh_ files.h $(srcinc)/sh_ignore.h91 sh_fInotify.o: $(srcsrc)/sh_fInotify.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_utils.h $(srcinc)/sh_modules.h $(srcinc)/sh_pthread.h $(srcinc)/sh_inotify.h $(srcinc)/sh_unix.h $(srcinc)/sh_hash.h $(srcinc)/sh_dbIO.h $(srcinc)/sh_files.h $(srcinc)/sh_ignore.h 92 92 sh_checksum.o: $(srcsrc)/sh_checksum.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_checksum.h $(srcinc)/sh_utils.h $(srcinc)/CuTest.h 93 sh_guid.o: $(srcsrc)/sh_guid.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_utils.h $(srcinc)/CuTest.h 94 sh_dbIO.o: $(srcsrc)/sh_dbIO.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_utils.h $(srcinc)/sh_dbIO_int.h $(srcinc)/sh_hash.h $(srcinc)/sh_dbIO.h $(srcinc)/sh_gpg.h $(srcinc)/sh_tiger.h $(srcinc)/sh_xfer.h $(srcinc)/sh_pthread.h $(srcinc)/sh_socket.h $(srcinc)/sh_files.h $(srcinc)/zAVLTree.h 95 sh_dbCheck.o: $(srcsrc)/sh_dbCheck.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_unix.h $(srcinc)/sh_utils.h $(srcinc)/sh_hash.h $(srcinc)/sh_files.h $(srcinc)/sh_tiger.h $(srcinc)/sh_dbIO.h $(srcinc)/sh_dbIO_int.h $(srcinc)/sh_pthread.h 96 sh_dbCreate.o: $(srcsrc)/sh_dbCreate.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_utils.h $(srcinc)/sh_hash.h $(srcinc)/sh_files.h $(srcinc)/sh_dbIO.h $(srcinc)/sh_dbIO_int.h $(srcinc)/sh_pthread.h $(srcinc)/sh_guid.h 97 sh_xfer_client.o: $(srcsrc)/sh_xfer_client.c Makefile config_xor.h $(srcinc)/sh_ipvx.h $(srcinc)/samhain.h $(srcinc)/sh_tiger.h $(srcinc)/sh_utils.h $(srcinc)/sh_unix.h $(srcinc)/sh_xfer.h $(srcinc)/sh_srp.h $(srcinc)/sh_fifo.h $(srcinc)/sh_tools.h $(srcinc)/sh_entropy.h $(srcinc)/sh_html.h $(srcinc)/sh_nmail.h $(srcinc)/sh_socket.h $(srcinc)/sh_static.h $(srcinc)/rijndael-api-fst.h 98 sh_xfer_server.o: $(srcsrc)/sh_xfer_server.c Makefile config_xor.h $(srcinc)/sh_ipvx.h $(srcinc)/samhain.h $(srcinc)/sh_tiger.h $(srcinc)/sh_utils.h $(srcinc)/sh_unix.h $(srcinc)/sh_xfer.h $(srcinc)/sh_srp.h $(srcinc)/sh_fifo.h $(srcinc)/sh_tools.h $(srcinc)/sh_entropy.h $(srcinc)/sh_html.h $(srcinc)/sh_nmail.h $(srcinc)/sh_socket.h $(srcinc)/sh_static.h $(srcinc)/sh_guid.h $(srcinc)/rijndael-api-fst.h $(srcinc)/sh_readconf.h $(srcinc)/zAVLTree.h $(srcinc)/sh_extern.h 99 sh_xfer_syslog.o: $(srcsrc)/sh_xfer_syslog.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_tools.h $(srcinc)/sh_utils.h $(srcinc)/sh_ipvx.h 100 sh_xload_client.o: $(srcsrc)/sh_xload_client.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_utils.h $(srcinc)/sh_fifo.h $(srcinc)/sh_guid.h 101 sh_sem.o: $(srcsrc)/sh_sem.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_sem.h $(srcinc)/sh_error_min.h -
trunk/depend.sum
r452 r481 1 3192621362 1 2959213307 -
trunk/docs/Changelog
r476 r481 1 3.1.6: 2 * More modern and more complete VA_COPY autoconf macro 3 (from the openwrt project) 1 4.0.0: 2 * new -w CL option to wait on scan completion 3 * new option ReportCheckflags 4 * enhance testsuite to cover new functionality 5 * implement draft for change control integration: 6 * new database format to store change flags 7 * refactoring of db I/O and client/server code 8 * option StartupLoadDelay 9 * --create-database CL option 10 * --outfile CL option 11 * --binary, --list-filter CL options 12 * --verify-database CL option 13 * yulectl -c DELTA:<uuid> command 14 * option SetDeltaRetryCount 15 * option SetDeltaRetryInterval 16 * update documentation 17 * remove old/unused code 18 * fix compiler warnings with gcc 5.1.0 19 * update config.sub, config.guess 20 21 3.1.6 (08-06-2015): 4 22 * Modify testcompile.sh to remove 'smatch' and use 'clang' 5 23 instead. -
trunk/docs/README.UPGRADE
r297 r481 1 to 4.0.0 and higher: if you use "ReportCheckflags = yes" (off by default), 2 you need to change the database scheme: 3 4 -- mysql: 5 ALTER TABLE samhain.log ADD COLUMN checkflags_old BIGINT UNSIGNED; 6 ALTER TABLE samhain.log ADD COLUMN checkflags_new BIGINT UNSIGNED; 7 8 -- postgres: 9 ALTER TABLE samhain.log ADD COLUMN checkflags_old NUMERIC(20); 10 ALTER TABLE samhain.log ADD COLUMN checkflags_new NUMERIC(20); 11 12 --oracle: 13 ALTER TABLE samhain.log ADD checkflags_old NUMBER(20); 14 ALTER TABLE samhain.log ADD checkflags_new NUMBER(20); 15 1 16 to 2.8.0 and higher: samhain supports IPv6 now, which means that the 2 17 size of the 'ip' column in the database must be increased from … … 40 55 -- this may cause spurious warnings about modified links, if you check 41 56 against a database created with an earlier version of samhain 42 43 44 57 45 58 from lower to 2.3.x: the database scheme has changed slightly. -
trunk/include/rijndael-alg-fst.h
r230 r481 1 /* 2 * rijndael-alg-fst.h v2.3 April '2000 1 /* $NetBSD: rijndael-alg-fst.h,v 1.4 2005/12/11 12:20:52 christos Exp $ */ 2 /* $KAME: rijndael-alg-fst.h,v 1.5 2003/07/15 10:47:16 itojun Exp $ */ 3 /** 4 * rijndael-alg-fst.h 3 5 * 4 * Optimised ANSI C code6 * @version 3.0 (December 2000) 5 7 * 8 * Optimised ANSI C code for the Rijndael cipher (now AES) 9 * 10 * @author Vincent Rijmen <vincent.rijmen@esat.kuleuven.ac.be> 11 * @author Antoon Bosselaers <antoon.bosselaers@esat.kuleuven.ac.be> 12 * @author Paulo Barreto <paulo.barreto@terra.com.br> 13 * 14 * This code is hereby placed in the public domain. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ''AS IS'' AND ANY EXPRESS 17 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE 20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 26 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 6 27 */ 7 8 /*@-fixedformalarray@*/9 10 28 #ifndef __RIJNDAEL_ALG_FST_H 11 29 #define __RIJNDAEL_ALG_FST_H 12 30 13 #define MAXKC (256/32) 14 #define MAXROUNDS 14 15 16 /* USUAL_TYPES */ 17 #ifndef USUAL_TYPES 18 #define USUAL_TYPES 19 typedef unsigned char byte; 20 typedef unsigned char word8; 21 typedef unsigned short word16; 22 typedef unsigned int word32; 23 #endif 31 #define RIJNDAEL_MAXKC (256/32) 32 #define RIJNDAEL_MAXKB (256/8) 33 #define RIJNDAEL_MAXNR 14 24 34 25 35 #ifdef SH_ENCRYPT 26 36 27 int rijndaelKeySched(word8 k[MAXKC][4], word8 rk[MAXROUNDS+1][4][4], int ROUNDS); 28 29 int rijndaelKeyEncToDec(word8 W[MAXROUNDS+1][4][4], int ROUNDS); 30 31 int rijndaelEncrypt(word8 a[16], word8 b[16], word8 rk[MAXROUNDS+1][4][4], int ROUNDS); 32 33 34 int rijndaelDecrypt(word8 a[16], word8 b[16], word8 rk[MAXROUNDS+1][4][4], int ROUNDS); 35 36 #ifdef INTERMEDIATE_VALUE_KAT 37 int rijndaelEncryptRound(word8 a[4][4], word8 rk[MAXROUNDS+1][4][4], int ROUNDS, int rounds); 38 int rijndaelDecryptRound(word8 a[4][4], word8 rk[MAXROUNDS+1][4][4], int ROUNDS, int rounds); 39 #endif 37 int rijndaelKeySetupEnc(u32 rk[/*4*(Nr + 1)*/], const u8 cipherKey[], int keyBits); 38 int rijndaelKeySetupDec(u32 rk[/*4*(Nr + 1)*/], const u8 cipherKey[], int keyBits); 39 void rijndaelEncrypt(const u32 rk[/*4*(Nr + 1)*/], int Nr, const u8 pt[16], u8 ct[16]); 40 void rijndaelDecrypt(const u32 rk[/*4*(Nr + 1)*/], int Nr, const u8 ct[16], u8 pt[16]); 40 41 41 42 /* SH_ENCRYPT */ 42 43 #endif 43 44 /* __RIJNDAEL_ALG_FST_H */ 45 #endif 46 44 #endif /* __RIJNDAEL_ALG_FST_H */ -
trunk/include/rijndael-api-fst.h
r230 r481 1 /* 2 * rijndael-api-fst.h v2.3 April '2000 1 /* $NetBSD: rijndael-api-fst.h,v 1.8 2007/01/21 23:00:08 cbiere Exp $ */ 2 3 /** 4 * rijndael-api-fst.h 3 5 * 4 * Optimised ANSI C code6 * @version 2.9 (December 2000) 5 7 * 8 * Optimised ANSI C code for the Rijndael cipher (now AES) 9 * 10 * @author Vincent Rijmen <vincent.rijmen@esat.kuleuven.ac.be> 11 * @author Antoon Bosselaers <antoon.bosselaers@esat.kuleuven.ac.be> 12 * @author Paulo Barreto <paulo.barreto@terra.com.br> 13 * 14 * This code is hereby placed in the public domain. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ''AS IS'' AND ANY EXPRESS 17 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE 20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 26 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * 28 * Acknowledgements: 29 * 30 * We are deeply indebted to the following people for their bug reports, 31 * fixes, and improvement suggestions to this implementation. Though we 32 * tried to list all contributions, we apologise in advance for any 33 * missing reference. 34 * 35 * Andrew Bales <Andrew.Bales@Honeywell.com> 36 * Markus Friedl <markus.friedl@informatik.uni-erlangen.de> 37 * John Skodon <skodonj@webquill.com> 6 38 */ 7 39 … … 9 41 #define __RIJNDAEL_API_FST_H 10 42 43 /* Blocksize: 16 * 8 = 128; 128 * 1 = 128 */ 44 #define B_SIZ 16 45 #define BNUM 1 46 47 48 #if defined(UINT32) 49 typedef unsigned char u8; 50 typedef UINT32 u32; 51 #else 52 53 typedef unsigned char u8; 54 #if defined(HAVE_INT_32) 55 typedef unsigned int u32; 56 #elif defined(HAVE_LONG_32) 57 typedef unsigned long u32; 58 #elif defined(HAVE_SHORT_32) 59 typedef unsigned short u32; 60 #else 61 #error "No 32 bit integer type found" 62 #endif 63 64 #endif 65 11 66 #include "rijndael-alg-fst.h" 12 67 13 /* Defines: 14 Add any additional defines you need 15 */ 16 17 #define BNUM 1 18 #define B_SIZ 16 19 #define STRICT_ALIGN 1 /* For safety */ 20 21 68 /* Generic Defines */ 22 69 #define DIR_ENCRYPT 0 /* Are we encrpyting? */ 23 70 #define DIR_DECRYPT 1 /* Are we decrpyting? */ … … 33 80 #define BITSPERBLOCK 128 /* Default number of bits in a cipher block */ 34 81 35 /* Error Codes - CHANGE POSSIBLE: inclusion of additional error codes */ 36 82 /* Error Codes */ 37 83 #define BAD_KEY_DIR -1 /* Key direction is invalid, e.g., unknown value */ 38 84 #define BAD_KEY_MAT -2 /* Key material not of correct length */ … … 45 91 #define BAD_OTHER -9 /* Unknown error */ 46 92 47 /* CHANGE POSSIBLE: inclusion of algorithm specific defines */48 #define MAX_KEY_SIZE 64 /* # of ASCII char's needed to represent a key */49 #define MAX_IV_SIZE 16 /* # bytes needed to represent an IV */93 /* Algorithm-specific Defines */ 94 #define RIJNDAEL_MAX_KEY_SIZE 64 /* # of ASCII char's needed to represent a key */ 95 #define RIJNDAEL_MAX_IV_SIZE 16 /* # bytes needed to represent an IV */ 50 96 51 97 #ifdef SH_ENCRYPT 52 98 53 /* Typedefs :99 /* Typedefs */ 54 100 55 Typedef'ed data storage elements. Add any algorithm specific 56 parameters at the bottom of the structs as appropriate. 57 */ 58 59 typedef unsigned char RIJ_BYTE; 101 typedef unsigned char BYTE; 60 102 61 103 /* The structure for key information */ 62 104 typedef struct { 63 RIJ_BYTE direction; /* Key used for encrypting or decrypting? */ 64 int keyLen; /* Length of the key */ 65 char keyMaterial[MAX_KEY_SIZE+1]; /* Raw key data in ASCII, e.g., user input or KAT values */ 66 /* The following parameters are algorithm dependent, replace or add as necessary */ 67 int ROUNDS; /* key-length-dependent number of rounds */ 68 int blockLen; /* block length */ 69 word8 keySched[MAXROUNDS+1][4][4]; /* key schedule */ 105 u32 rk[4*(RIJNDAEL_MAXNR + 1)]; /* key schedule */ 106 u32 ek[4*(RIJNDAEL_MAXNR + 1)]; /* CFB1 key schedule (encryption only) */ 107 BYTE direction; /* Key used for encrypting or decrypting? */ 108 int keyLen; /* Length of the key */ 109 char keyMaterial[RIJNDAEL_MAX_KEY_SIZE+1]; /* Raw key data in ASCII, e.g., user input or KAT values */ 110 int Nr; /* key-length-dependent number of rounds */ 70 111 } keyInstance; 71 112 72 113 /* The structure for cipher information */ 73 114 typedef struct { /* changed order of the components */ 74 RIJ_BYTE mode; /* MODE_ECB, MODE_CBC, or MODE_CFB1 */ 75 RIJ_BYTE IV[MAX_IV_SIZE]; /* A possible Initialization Vector for ciphering */ 76 /* Add any algorithm specific parameters needed here */ 77 int blockLen; /* Sample: Handles non-128 bit block sizes (if available) */ 115 u32 IV[RIJNDAEL_MAX_IV_SIZE / sizeof(u32)]; 116 /* A possible Initialization Vector for ciphering */ 117 BYTE mode; /* MODE_ECB, MODE_CBC, or MODE_CFB1 */ 78 118 } cipherInstance; 79 119 80 120 /* Function prototypes */ 81 /* CHANGED: nothing82 TODO: implement the following extensions to setup 192-bit and 256-bit block lengths:83 makeKeyEx(): parameter blockLen added84 -- this parameter is absolutely necessary if you want to85 setup the round keys in a variable block length setting86 cipherInitEx(): parameter blockLen added (for obvious reasons)87 */88 121 89 int makeKey(keyInstance *key, RIJ_BYTE direction, int keyLen, char *keyMaterial);122 int rijndael_makeKey(keyInstance *, BYTE, int, const char *); 90 123 91 int cipherInit(cipherInstance *cipher, RIJ_BYTE mode, char *IV);124 int rijndael_cipherInit(cipherInstance *, BYTE, const char *); 92 125 93 int blockEncrypt(cipherInstance *cipher, keyInstance *key, 94 RIJ_BYTE *input, int inputLen, RIJ_BYTE *outBuffer); 126 int rijndael_blockEncrypt(cipherInstance *, keyInstance *, const BYTE *, int, BYTE *); 95 127 96 int blockDecrypt(cipherInstance *cipher, keyInstance *key, 97 RIJ_BYTE *input, int inputLen, RIJ_BYTE *outBuffer); 98 #ifdef INTERMEDIATE_VALUE_KAT 99 int cipherUpdateRounds(cipherInstance *cipher, keyInstance *key, 100 RIJ_BYTE *input, int inputLen, RIJ_BYTE *outBuffer, int rounds); 101 #endif 128 int rijndael_padEncrypt(cipherInstance *, keyInstance *, const BYTE *, int, BYTE *); 129 130 int rijndael_blockDecrypt(cipherInstance *, keyInstance *, const BYTE *, int, BYTE *); 131 132 int rijndael_padDecrypt(cipherInstance *, keyInstance *, const BYTE *, int, BYTE *); 102 133 103 134 /* SH_ENCRYPT */ 104 135 #endif 105 106 /* __RIJNDAEL_API_FST_H */ 107 #endif 136 #endif /* __RIJNDAEL_API_FST_H */ -
trunk/include/samhain.h
r459 r481 28 28 #endif 29 29 30 #if defined(__GNUC__) && (__GNUC__ >= 4) 31 #define SH_GNUC_SENTINEL __attribute__((__sentinel__)) 32 #else 33 #define SH_GNUC_SENTINEL 34 #endif 35 36 #if defined(__GNUC__) && (__GNUC__ >= 3) 37 #undef SH_GNUC_PURE 38 #define SH_GNUC_PURE __attribute__((pure)) 39 #undef SH_GNUC_CONST 40 #define SH_GNUC_CONST __attribute__((const)) 41 #undef SH_GNUC_NORETURN 42 #define SH_GNUC_NORETURN __attribute__((noreturn)) 43 #undef SH_GNUC_MALLOC 44 #define SH_GNUC_MALLOC __attribute__((malloc)) 45 #else 46 #undef SH_GNUC_PURE 47 #define SH_GNUC_PURE 48 #undef SH_GNUC_CONST 49 #define SH_GNUC_CONST 50 #undef SH_GNUC_NORETURN 51 #define SH_GNUC_NORETURN 52 #undef SH_GNUC_MALLOC 53 #define SH_GNUC_MALLOC 54 #endif 55 30 56 /************************************************** 31 57 * … … 57 83 58 84 /* end IPv6 */ 59 60 #define REPLACE_OLD61 85 62 86 /* Standard buffer sizes. … … 101 125 #define PW_LEN 8 102 126 103 #undef GOOD104 #define GOOD 1105 #undef BAD106 #define BAD 0107 #undef ON108 #define ON 1109 #undef OFF110 #define OFF 0111 127 #undef S_TRUE 112 128 #define S_TRUE 1 113 129 #undef S_FALSE 114 130 #define S_FALSE 0 131 132 #undef GOOD 133 #define GOOD S_TRUE 134 #undef BAD 135 #define BAD S_FALSE 136 137 138 #ifdef HAVE_INTTYPES_H 139 #include <inttypes.h> 140 #endif 141 #ifdef HAVE_STDINT_H 142 #include <stdint.h> 143 #endif 144 145 #if !defined(HAVE_UINT16_T) 146 #define UINT16 unsigned short 147 #else 148 #define UINT16 uint16_t 149 #endif 150 151 #if !defined(HAVE_UINT32_T) 115 152 116 153 /* An unsigned integer guaranteed to be 32 bit. … … 129 166 #endif 130 167 131 #ifdef HAVE_INTTYPES_H 132 #include <inttypes.h> 133 #endif 134 #ifdef HAVE_STDINT_H 135 #include <stdint.h> 136 #endif 137 138 #if !defined(HAVE_UINT16_T) 139 #define UINT16 unsigned short 140 #else 141 #define UINT16 uint16_t 168 #else 169 #define UINT32 uint32_t 170 #define SINT32 int32_t 171 142 172 #endif 143 173 … … 305 335 int client_severity; /* TRUE if client severity used */ 306 336 int client_class; /* TRUE if client class used */ 337 int hidefile; /* TRUE if file not shown in log */ 338 int inotify; /* Flags for inotify */ 307 339 int audit; 308 340 unsigned long aud_mask; 309 int hidefile; /* TRUE if file not shown in log */310 int inotify; /* Flags for inotify */311 341 } sh_sh_flag; 312 342 … … 347 377 /*@null@*//*@out@*/ char * timezone; 348 378 379 int delayload; 380 349 381 #ifdef SCREW_IT_UP 350 382 int sigtrap_max_duration; 351 383 #endif 352 384 385 char * outpath; 353 386 } sh_struct; 354 387 … … 365 398 extern volatile int sig_termfast; /* SIGTERM */ 366 399 extern volatile int sig_force_check; /* SIGTTOU */ 400 extern volatile int sh_load_delta_flag; 367 401 368 402 extern long int eintr__result; … … 420 454 #endif 421 455 422 #if defined(__GNUC__) && (__GNUC__ >= 4)423 #define SH_GNUC_SENTINEL __attribute__((__sentinel__))424 #else425 #define SH_GNUC_SENTINEL426 #endif427 428 #if defined(__GNUC__) && (__GNUC__ >= 3)429 #undef SH_GNUC_PURE430 #define SH_GNUC_PURE __attribute__((pure))431 #undef SH_GNUC_CONST432 #define SH_GNUC_CONST __attribute__((const))433 #undef SH_GNUC_NORETURN434 #define SH_GNUC_NORETURN __attribute__((noreturn))435 #undef SH_GNUC_MALLOC436 #define SH_GNUC_MALLOC __attribute__((malloc))437 #else438 #undef SH_GNUC_PURE439 #define SH_GNUC_PURE440 #undef SH_GNUC_CONST441 #define SH_GNUC_CONST442 #undef SH_GNUC_NORETURN443 #define SH_GNUC_NORETURN444 #undef SH_GNUC_MALLOC445 #define SH_GNUC_MALLOC446 #endif447 456 448 457 … … 481 490 #ifdef USE_SUID 482 491 #define MLOCK(a, b) \ 483 if ((skey != NULL) && skey->mlock_failed == S L_FALSE){ \492 if ((skey != NULL) && skey->mlock_failed == S_FALSE){ \ 484 493 (void) sl_set_suid(); \ 485 if (sh_unix_mlock(FIL__, __LINE__, a, b) < 0) skey->mlock_failed = S L_TRUE; \494 if (sh_unix_mlock(FIL__, __LINE__, a, b) < 0) skey->mlock_failed = S_TRUE; \ 486 495 (void) sl_unset_suid(); } 487 496 #else 488 497 #define MLOCK(a, b) \ 489 if ((skey != NULL) && skey->mlock_failed == S L_FALSE){ \490 if (sh_unix_mlock(FIL__, __LINE__, a, b) < 0) skey->mlock_failed = S L_TRUE; }498 if ((skey != NULL) && skey->mlock_failed == S_FALSE){ \ 499 if (sh_unix_mlock(FIL__, __LINE__, a, b) < 0) skey->mlock_failed = S_TRUE; } 491 500 #endif 492 501 #else … … 498 507 #ifdef USE_SUID 499 508 #define MUNLOCK(a, b) \ 500 if ((skey != NULL) && skey->mlock_failed == S L_FALSE){ \509 if ((skey != NULL) && skey->mlock_failed == S_FALSE){ \ 501 510 (void) sl_set_suid(); \ 502 511 (void) sh_unix_munlock( a, b );\ … … 504 513 #else 505 514 #define MUNLOCK(a, b) \ 506 if ((skey != NULL) && skey->mlock_failed == S L_FALSE){ \515 if ((skey != NULL) && skey->mlock_failed == S_FALSE){ \ 507 516 (void) sh_unix_munlock( a, b ); } 508 517 #endif -
trunk/include/sh_calls.h
r317 r481 30 30 31 31 /*@-fixedformalarray@*/ 32 33 #include "config_xor.h" 34 #if defined(__GNUC__) && (__GNUC__ >= 3) 35 #undef SH_GNUC_NORETURN 36 #define SH_GNUC_NORETURN __attribute__((noreturn)) 37 #else 38 #undef SH_GNUC_NORETURN 39 #define SH_GNUC_NORETURN 40 #endif 41 32 42 33 43 /* Set aud functions … … 83 93 int * o_noatime); 84 94 /*@noreturn@*/ 85 void aud_exit (const char * file, int line, int fd) ;95 void aud_exit (const char * file, int line, int fd) SH_GNUC_NORETURN; 86 96 /*@noreturn@*/ 87 void aud__exit (const char * file, int line, int fd) ;97 void aud__exit (const char * file, int line, int fd) SH_GNUC_NORETURN; 88 98 pid_t aud_fork (const char * file, int line); 89 99 int aud_pipe (const char * file, int line, int modus[2]); -
trunk/include/sh_cat.h
r294 r481 75 75 MSG_CHECK_0, 76 76 MSG_CHECK_1, 77 MSG_CHECK_2, 77 78 MSG_STAMP, 78 79 … … 80 81 MSG_D_DSTART, 81 82 MSG_D_FAIL, 82 83 MSG_D_DELTAOK, 84 MSG_D_DELTAFAIL, 83 85 84 86 #ifndef HAVE_URANDOM … … 98 100 MSG_SUID_QREPORT, 99 101 MSG_SUID_ERROR, 100 #endif101 102 #ifdef SH_USE_KERN103 /* FreeBSD */104 MSG_KERN_POLICY,105 MSG_KERN_POL_CO,106 107 /* Linux */108 MSG_KERN_SYSCALL,109 MSG_KERN_PROC,110 MSG_KERN_IDT,111 MSG_KERN_GATE,112 102 #endif 113 103 -
trunk/include/sh_error.h
r410 r481 178 178 int sh_error_setdebug (char * debug_s); 179 179 180 /* error messages181 */182 /*@owned@*/char * sh_error_message (int tellme, char * str, size_t len);183 184 180 /* switch on/off log to file temporarily 185 181 */ … … 198 194 void reset_count_dev_console(void); 199 195 196 /* close the message queue [no-op if !defined(WITH_MESSAGE_QUEUE)] 197 */ 198 void close_ipc (void); 199 200 200 #ifdef WITH_MESSAGE_QUEUE 201 /* close the message queue202 */203 void close_ipc (void);204 205 201 /* enable message queue 206 202 */ -
trunk/include/sh_error_min.h
r272 r481 35 35 int sh_error_convert_level (const char * str_s); 36 36 37 /* error messages 38 */ 39 char * sh_error_message (int tellme, char * str, size_t len); 40 37 41 #endif -
trunk/include/sh_extern.h
r415 r481 42 42 * executes shell command 43 43 */ 44 int sh_ext_popen_init (sh_tas_t * task, c har * command, char * argv0, ...) SH_GNUC_SENTINEL;44 int sh_ext_popen_init (sh_tas_t * task, const char * command, char * argv0, ...) SH_GNUC_SENTINEL; 45 45 46 46 /* … … 52 52 * -- Execute command, return first line of output 53 53 */ 54 char * sh_ext_popen_str (c har * command);54 char * sh_ext_popen_str (const char * command); 55 55 56 56 /* -
trunk/include/sh_fifo.h
r272 r481 33 33 } SH_FIFO; 34 34 35 #define SH_FIFO_INITIALIZER { NULL, NULL, 0 } 36 35 37 /***************************************************** 36 38 * … … 42 44 * 43 45 */ 44 #define fifo_init(fifo_p) { fifo_p->fifo_cts = 0; fifo_p->head_ptr = NULL; \45 fifo_p->tail_ptr = NULL; }46 #define fifo_init(fifo_p) { (fifo_p)->fifo_cts = 0; (fifo_p)->head_ptr = NULL; \ 47 (fifo_p)->tail_ptr = NULL; } 46 48 47 49 … … 50 52 * Returns: -1 if the list is full, 0 on success 51 53 */ 52 int push_list (SH_FIFO * fifo, char * indat, int in_i, const char * in_str); 54 int push_list (SH_FIFO * fifo, const char * indat, int in_i, const char * in_str); 55 #define sh_fifo_push(a, b) push_list((a), (b), 0, NULL) 53 56 54 57 /* Push an item on the tail of the list. … … 56 59 * Returns: -1 if the list is full, 0 on success 57 60 */ 58 int push_tail_list (SH_FIFO * fifo, char * indat, int in_i, const char * in_str); 61 int push_tail_list (SH_FIFO * fifo, const char * indat, int in_i, const char * in_str); 62 #define sh_fifo_push_tail(a, b) push_tail_list((a), (b), 0, NULL) 59 63 60 64 /* pop an item from the tail of the list … … 64 68 */ 65 69 char * pop_list (SH_FIFO * fifo); 70 #define sh_fifo_pop(a) pop_list((a)) 66 71 72 /* ---- Special functions -------------------------------------------------*/ 67 73 74 /* This is for eMail where different recipients may be eligible for * 75 * different subsets of messages. We need to delete all that were sent * 76 * to all intended recipients, and keep all with at least one failure. */ 77 78 /* Iterate over list and check for each if it is valid for 'tag'; 79 * i.e. (item->s_extra == tag). If yes, add to the returned string. 80 * If (okNull == False) then item->s_xtra must be defined 81 */ 68 82 sh_string * tag_list (SH_FIFO * fifo, char * tag, 69 83 int(*check)(int, const char*, const char*, const void*), 70 84 const void * info, int okNull); 85 86 /* Flag all tagged as candidate to keep */ 71 87 void rollback_list (SH_FIFO * fifo); 88 /* Flag all tagged as candidate to delete */ 72 89 void mark_list (SH_FIFO * fifo); 90 /* Remove all flags */ 73 91 void reset_list (SH_FIFO * fifo); 92 /* Delete all marked for delete that are not flagged for keep */ 74 93 int commit_list (SH_FIFO * fifo); 75 94 -
trunk/include/sh_files.h
r457 r481 31 31 }; 32 32 33 /* Fix the check flags 34 */ 35 void sh_files_fixup_mask (int class, unsigned long * check_flags); 36 37 /* Dequote a filename in the config file 38 */ 39 char * sh_files_parse_input(const char * str_s, size_t * len); 40 33 41 /* Check whether a file is in the config 34 42 */ … … 233 241 int sh_files_redef_allignore(const char * str); 234 242 235 ShFileType sh_files_filecheck (int class, unsigned long check_ mask,243 ShFileType sh_files_filecheck (int class, unsigned long check_flags, 236 244 const char * dirName, 237 245 const char * infileName, … … 239 247 int rsrcflag); 240 248 241 int sh_files_checkdir (int iclass, unsigned long check_ mask,249 int sh_files_checkdir (int iclass, unsigned long check_flags, 242 250 int idepth, char * iname, 243 251 char * relativeName); 244 252 245 253 int sh_files_search_file(char * name, int * class, 246 unsigned long *check_ mask, int * reported);254 unsigned long *check_flags, int * reported); 247 255 int sh_files_search_dir(char * name, int * class, 248 unsigned long *check_ mask, int *reported,256 unsigned long *check_flags, int *reported, 249 257 int * rdepth); 250 258 void sh_files_set_file_reported(const char * name); -
trunk/include/sh_gpg.h
r347 r481 23 23 #define SH_GPG_H 24 24 25 #define SIG_CONF 1 26 #define SIG_DATA 2 27 25 28 /* Top level function to verify file. 26 29 */ … … 30 33 * and/or database cannot be verified; otherwise returns 0 31 34 */ 32 int sh_gpg_check_sign (long file _1, long file_2, int what);35 int sh_gpg_check_sign (long file, int what); 33 36 34 37 /* log successful startup -
trunk/include/sh_hash.h
r458 r481 28 28 #include "sh_error.h" 29 29 30 /* the report_checkflags flag 31 */ 32 int get_report_checkflags(); 33 34 /* whether to report checkflags 35 */ 36 int set_report_checkflags(const char * c); 37 30 38 /* convert to policy string 31 39 */ … … 40 48 int hashreport_missing( char *fullpath, int level); 41 49 50 /* remove internal db record for a file (checks for some flags). 51 */ 52 void sh_hash_remove (const char * path); 53 42 54 /* remove internal db record for a file 43 55 */ 44 void sh_hash_remove (const char * path); 45 46 /* write database to stdout 47 */ 48 int sh_hash_pushdata_stdout (const char * str); 49 50 /* version string for database 51 */ 52 int sh_hash_version_string(const char * str); 56 void sh_hash_remove_unconditional (const char * path); 57 58 /* Insert a "null" record in-memory (representing a missing file). 59 */ 60 void sh_hash_insert_null(char * str); 61 62 #ifdef SH_DBIO_INT_H 63 /* Check for "null" record 64 */ 65 int sh_hash_is_null_record(sh_filestore_t * theFile); 66 #endif 53 67 54 68 /* Dont report on ctm/mtm change for directories … … 56 70 int sh_hash_loosedircheck(const char * str); 57 71 58 /* List database content59 */60 int sh_hash_list_db (const char * db_file);61 62 72 /* List database content for a single file 63 73 */ 64 74 int set_list_file (const char * c); 65 75 76 /* Set the path of that file 77 */ 78 char * get_list_file(); 79 66 80 /* List database content with full detail 67 81 */ … … 75 89 */ 76 90 void sh_hash_init (void); 91 92 /* Check init status 93 */ 94 int sh_hash_get_initialized(); 95 96 /* Read the database from disk and fill sh.data.hash with checksum. 97 */ 98 void sh_hash_init_and_checksum(); 99 100 /* Set status to 'database is read in'. 101 */ 102 void sh_hash_set_initialized(); 77 103 78 104 /* Check whether a file is present in the database. -
trunk/include/sh_html.h
r1 r481 53 53 int encf_flag; 54 54 int ency_flag; 55 int ivst_flag; 55 56 int status_now; 56 57 int status_arr[CLT_MAX]; -
trunk/include/sh_inotify.h
r373 r481 32 32 33 33 int sh_inotify_add_watch(char * filename, sh_watches * watches, int * errnum, 34 int class, unsigned long check_ mask, int type, int rdepth);34 int class, unsigned long check_flags, int type, int rdepth); 35 35 36 36 int sh_inotify_add_watch_later(const char * filename, sh_watches * watches, 37 37 int * errnum, 38 int class, unsigned long check_ mask,38 int class, unsigned long check_flags, 39 39 int type, int rdepth); 40 40 41 41 char * sh_inotify_pop_dormant(sh_watches * watches, int * class, 42 unsigned long * check_ mask, int * type, int * rdepth);42 unsigned long * check_flags, int * type, int * rdepth); 43 43 44 44 void sh_inotify_purge_dormant(sh_watches * watches); … … 47 47 48 48 char * sh_inotify_search_item(sh_watches * watches, int watch, 49 int * class, unsigned long * check_ mask,49 int * class, unsigned long * check_flags, 50 50 int * type, int * rdepth); 51 51 ssize_t sh_inotify_read(char * buffer, size_t count); -
trunk/include/sh_prelink.h
r102 r481 6 6 * alert_timeout: timeout for read 7 7 */ 8 int sh_prelink_run (char * path, char * file_hash, int alert_timeout );8 int sh_prelink_run (char * path, char * file_hash, int alert_timeout, unsigned long mask); 9 9 10 10 /* return S_TRUE if ELF file, S_FALSE otherwise -
trunk/include/sh_socket.h
r200 r481 8 8 9 9 #if defined (SH_WITH_CLIENT) 10 void sh_socket_server_cmd(const char * srvcmd); 10 char * sh_socket_get_uuid(int * errflag, unsigned int * count, time_t * last); 11 int sh_socket_store_uuid(const char * cmd); 12 int sh_socket_return_uuid(const char * uuid, unsigned int count, time_t last); 13 void sh_socket_server_cmd(const char * srvcmd); 14 int set_delta_retry_interval(const char * str); 15 int set_delta_retry_count(const char * str); 11 16 #endif 12 17 -
trunk/include/sh_tiger.h
r170 r481 44 44 int sh_tiger_get_hashtype (void); 45 45 46 /* set the hash fuction in use in the mask 47 */ 48 void sh_tiger_get_mask_hashtype(unsigned long * mask); 49 50 51 /* reset the hash function to the one in the mask 52 */ 53 void sh_tiger_set_hashtype_mask(unsigned long mask); 54 46 55 /* GnuPG-like format, returns allocated memory 47 56 */ -
trunk/include/sh_tools.h
r295 r481 8 8 */ 9 9 #define SH_PROTO_SRP (1 << 0) 10 #define SH_PROTO_IVA (1 << 1) 10 11 #define SH_PROTO_MSG (1 << 2) 11 12 #define SH_PROTO_BIG (1 << 3) 12 13 #define SH_PROTO_END (1 << 4) 13 #define SH_PROTO_EN C(1 << 5)14 #define SH_PROTO_EN1 (1 << 5) 14 15 #define SH_PROTO_EN2 (1 << 6) 16 #define SH_PROTO_ENC (SH_PROTO_EN1|SH_PROTO_EN2) 15 17 #define SH_MASK_ENC (SH_PROTO_ENC|SH_PROTO_EN2) 16 18 … … 44 46 #if defined (SH_WITH_SERVER) 45 47 48 unsigned char sh_tools_probe_store(unsigned char protocol, int * probe_flag); 49 46 50 int get_open_max (void); 47 51 48 void put_header (/*@out@*/unsigned char * head, int protocol,52 void put_header (/*@out@*/unsigned char * head, const int protocol, 49 53 unsigned long * length, char * u); 50 54 … … 59 63 /* returns allocated buffer 60 64 */ 61 char * get_client_conf_file (c har * peer, unsigned long * length);65 char * get_client_conf_file (const char * peer, unsigned long * length); 62 66 63 67 /* returns allocated buffer 64 68 */ 65 char * get_client_data_file (c har * peer, unsigned long * length);69 char * get_client_data_file (const char * peer, unsigned long * length); 66 70 71 /* returns allocated buffer 72 */ 73 char * get_client_uuid_file (const char * peer, unsigned long * length, const char * uuid); 67 74 #endif 75 68 76 69 77 unsigned long read_port (int sockfd, char *buf, unsigned long nbytes, … … 72 80 73 81 #if defined (SH_WITH_CLIENT) || defined(SH_WITH_SERVER) 82 83 void sh_tools_probe_reset(); 74 84 75 85 unsigned long write_port (int sockfd, char *buf, unsigned long nbytes, -
trunk/include/sh_trace.h
r1 r481 9 9 #define ASSERT(expr, expr1) \ 10 10 if (!(expr)) \ 11 fprintf(stderr, \ 11 { \ 12 fprintf(stderr, \ 12 13 SDG_AERRO, \ 13 FIL__, __LINE__, expr1 ); 14 FIL__, __LINE__, expr1 ); \ 15 abort(); \ 16 } 14 17 15 18 -
trunk/include/sh_unix.h
r425 r481 68 68 /* inode */ 69 69 #define MODI_INO (1 << 2) 70 70 71 /* user */ 71 72 #define MODI_USR (1 << 3) … … 74 75 /* mtime */ 75 76 #define MODI_MTM (1 << 5) 77 76 78 /* ctime */ 77 79 #define MODI_CTM (1 << 6) … … 80 82 /* size */ 81 83 #define MODI_SIZ (1 << 8) 84 82 85 /* file mode */ 83 86 #define MODI_MOD (1 << 9) … … 86 89 /* device type */ 87 90 #define MODI_RDEV (1 << 11) 91 88 92 /* size may grow */ 89 93 #define MODI_SGROW (1 << 12) 90 94 /* use prelink */ 91 95 #define MODI_PREL (1 << 13) 92 93 96 /* get content */ 94 97 #define MODI_TXT ((1 << 14)|MODI_CHK) … … 98 101 #define MODI_AUDIT (1 << 15) 99 102 #define MODI_AUDIT_ENABLED(a) (((a)&(1 << 15))!=0) 100 101 #define MODI_INIT 0xDA000000UL 102 #define MODI_INITIALIZED(a) (((a) & 0xFF000000UL) == MODI_INIT) 103 /* do not check */ 104 #define MODI_NOCHECK (1 << 16) 105 /* do not check */ 106 #define MODI_ALLIGNORE (1 << 17) 107 108 #define MODI_TIGER192 0x01000000UL 109 #define MODI_SHA1 0x02000000UL 110 #define MODI_MD5 0x03000000UL 111 #define MODI_SHA256 0x04000000UL 112 #define MODI_HASHTYPE 0x0F000000UL 113 114 #define MODI_INIT 0xD0000000UL 115 #define MODI_INITIALIZED(a) (((a) & 0xF0000000UL) == MODI_INIT) 116 117 #define MODI_SET(a, b) ((a) |= (b)) 118 #define MODI_CLEAR(a, b) ((a) &= ~(b)) 119 #define MODI_ISSET(a, b) (((a) & (b)) != 0) 103 120 104 121 #define SH_TXT_MAX 9200 … … 128 145 129 146 typedef struct file_struct { 130 unsigned long check_ mask;147 unsigned long check_flags; 131 148 int file_reported; 132 149 char fullpath[PATH_MAX]; … … 314 331 */ 315 332 int sh_check_rotated_log (const char * path, 316 UINT64 old_size, UINT64 old_inode, const char * old_hash );333 UINT64 old_size, UINT64 old_inode, const char * old_hash, unsigned long mask); 317 334 318 335 /* obtain file info -
trunk/include/slib.h
r428 r481 60 60 * TRUE, FALSE 61 61 */ 62 #define SL_TRUE 1 63 #define SL_FALSE 0 62 #if !defined(S_TRUE) 63 #define S_TRUE 1 64 #define S_FALSE 0 65 #endif 64 66 65 67 #define SH_GRBUF_SIZE 4096 -
trunk/init/samhain.startGentoo.in
r321 r481 9 9 start() { 10 10 ebegin "Starting @install_name@" 11 @sh_insmod_pre@12 11 /sbin/start-stop-daemon --start --quiet --exec @sbindir@/@install_name@ 13 12 eend $? 14 @sh_insmod_cmd@15 13 } 16 14 -
trunk/init/samhain.startLSB.in
r321 r481 87 87 case "$1" in 88 88 start) 89 #90 # Preloaded kernel module91 #92 @sh_insmod_pre@93 #94 89 ${DAEMON} start 95 90 ERRNUM=$? 96 #97 # The hiding kernel module98 #99 if [ $ERRNUM -eq 0 ]; then100 @sh_insmod_cmd@101 fi102 #103 91 SH_ACT="started" 104 92 ;; -
trunk/init/samhain.startLinux.in
r466 r481 1 1 #!/bin/bash 2 2 3 # chkconfig: 2345 99 10 3 4 # description: File Integrity Checking Daemon … … 8 9 # database: @mydatafile@ 9 10 # 11 12 ### BEGIN INIT INFO 13 # Provides: @install_name@ 14 # Required-Start: $syslog $network 15 # Required-Stop: $syslog $network 16 # Default-Start: 2 3 4 5 17 # Default-Stop: 0 1 6 18 # Short-Description: Keep an eye on stuff 19 # Description: Keep an eye on stuff 20 ### END INIT INFO 10 21 11 22 # For Debian … … 140 151 fi 141 152 # 142 # Preloaded kernel module143 #144 @sh_insmod_pre@145 #146 153 case "$DISTRO" in 147 154 debian) 148 155 echo -n "Starting ${NAME}" 149 ( /sbin/start-stop-daemon --start -- quiet --exec $DAEMON )156 ( /sbin/start-stop-daemon --start --oknodo --quiet --exec $DAEMON ) 150 157 RETVAL=$? 151 158 debian_end … … 183 190 ;; 184 191 esac 185 #186 # The hiding kernel module187 #188 if [ $RETVAL -eq 0 ]; then189 @sh_insmod_cmd@190 fi191 192 exit $RETVAL 192 193 ;; … … 196 197 debian) 197 198 echo -n "Stopping $NAME" 198 ( /sbin/start-stop-daemon --stop -- quiet --exec $DAEMON )199 ( /sbin/start-stop-daemon --stop --oknodo --quiet --exec $DAEMON ) 199 200 RETVAL=$? 200 201 debian_end -
trunk/man/samhain.8
r169 r481 1 .TH SAMHAIN 8 " 07 August 2004" "" "Samhain manual"1 .TH SAMHAIN 8 "26 June 2015" "" "Samhain manual" 2 2 .SH NAME 3 3 samhain \- check file integrity … … 21 21 } [\-D | \-\-daemon | \-\-foreground] [\-\-forever] [\-r DEPTH,\-\-recursion=DEPTH] [log-options] 22 22 23 .B samhain 24 [ \-p threshold ] { 25 .I \-\-verify\-database=database 26 } 27 28 .B samhain 29 [ \-p threshold ] { 30 .I \-\-create\-database=file\-list 31 } 32 33 34 23 35 .SS "LISTING THE DATABASE" 24 36 .PP … … 27 39 [\-a | \-\-full\-detail] 28 40 [\-\-delimited] 41 [\-\-binary] 42 [\-\-list\-filter=file] 29 43 \-d 30 44 .IR file | … … 245 259 configuration file. 246 260 261 .PP 262 .B samhain 263 [ \-p\ threshold ] 264 .I "\-\-verify\-database=database" 265 266 Check the filesystem against the database given as argument, 267 and exit with an appropriate exit status. The configuration file 268 will 269 .B not 270 be read. 271 272 .PP 273 .B samhain 274 [ \-p\ threshold ] 275 .I "\-\-create\-database=file\-list" 276 277 Initialize a database from the given file list. 278 The configuration file 279 will 280 .B not 281 be read. The policy used will be 282 .I ReadOnly. 283 File content will be stored for a file 284 if its path in the list is preceded with a 285 .B + 286 sign. 287 247 288 .SS "OPTIONS FOR LISTING THE DATABASE" 248 289 .PP … … 267 308 List all informations for each file, in a comma-separated format. 268 309 Must precede the \-d option. 310 .TP 311 [\-\-binary] 312 List data in the binary format of the database, thus writing another 313 database. 314 Must precede the \-d option. 315 .TP 316 .RI [\-\-list\-filter= file ] 317 Filter the output of the database listing by a list of files given 318 in a text file. Together with \-\-binary this allows to write a 319 partial database. Must precede the \-d option. 269 320 .TP 270 321 .RI [\-\-list\-file= file ] -
trunk/man/samhainrc.5
r169 r481 253 253 by same user, and logouts. 254 254 .TP 255 .I "[Kernel]"256 Configuration for detecting kernel rootkits.257 .br258 .BI KernelCheckActive= 0|1259 Switch off/on checking of kernel syscalls to detect kernel module rootkits.260 .br261 .BI KernelCheckInterval= val262 Interval (seconds) between checks.263 .br264 .BI SeverityKernel= val265 Severity level for clobbered kernel syscalls.266 .br267 .BI KernelCheckIDT= 0|1268 Whether to check the interrrupt descriptor table.269 .br270 .BI KernelSystemCall= address271 The address of system_call (grep system_call System.map).272 Required after a kernel update.273 .br274 .BI KernelProcRoot= address275 The address of proc_root (grep ' proc_root$' System.map).276 Required after a kernel update.277 .br278 .BI KernelProcRootIops= address279 The address of proc_root_inode_operations280 (grep proc_root_inode_operations System.map).281 Required after a kernel update.282 .br283 .BI KernelProcRootLookup= address284 The address of proc_root_lookup (grep proc_root_lookup System.map).285 Required after a kernel update.286 .TP287 255 .I "[SuidCheck]" 288 256 Settings for finding SUID/SGID files on disk. … … 473 441 Set type of message authentication code (HMAC). 474 442 Must be identical on client and server. 443 .br 444 .BI StartupLoadDelay= val 445 Defines the interval (in seconds) to wait after startup before 446 loading the databse from the server. Default is no wait. 475 447 .br 476 448 .BI SetLoopTime= val -
trunk/rules.deb.in
r425 r481 52 52 #chmod o-rX `pwd`/debian/tmp/var/log/samhain \ 53 53 # `pwd`/debian/tmp/var/run/samhain \ 54 # `pwd`/debian/tmp/var/ state/samhain \54 # `pwd`/debian/tmp/var/lib/samhain \ 55 55 # `pwd`/debian/tmp/etc/samhain 56 56 … … 78 78 dh_installdebconf 79 79 dh_installdocs 80 [ -f debian/@install_name@/usr/share/doc/@install_name@/MANUAL-2_ 3.html.tar ] && \80 [ -f debian/@install_name@/usr/share/doc/@install_name@/MANUAL-2_4.html.tar ] && \ 81 81 cd debian/@install_name@/usr/share/doc/@install_name@ && \ 82 tar xf MANUAL-2_ 3.html.tar && mv MANUAL-2_3manual.html && \83 rm -f MANUAL-2_ 3.html.tar && \84 mv MANUAL-2_ 3.pdf manual.pdf82 tar xf MANUAL-2_4.html.tar && mv MANUAL-2_4 manual.html && \ 83 rm -f MANUAL-2_4.html.tar && \ 84 mv MANUAL-2_4.pdf manual.pdf 85 85 dh_installexamples @top_srcdir@/scripts/example_pager.pl \ 86 86 @top_srcdir@/scripts/example_sms.pl \ -
trunk/samhain-install.sh.in
r442 r481 65 65 echo 'action = install-boot|install-data|install-user' 66 66 echo ' uninstall|purge|uninstall-boot' 67 echo ' uninstall-data|uninstall-man|uninstall-program |uninstall-lkm'67 echo ' uninstall-data|uninstall-man|uninstall-program' 68 68 echo 'samhain-install.sh --print-config <item>' 69 69 echo 'item = name | basekey | prefix | exec_prefix | sbin_dir | man_dir' … … 514 514 break;; 515 515 516 uninstall-lkm)517 act=ulkm518 break;;519 520 516 uninstall | remove | purge) 521 517 opts= … … 525 521 test x"$DESTDIR" = "x" || opts="$opts --destdir=$DESTDIR" 526 522 test x"$1" = "xpurge" && purge=yes 527 echo "$0 $opts uninstall-lkm"528 eval $0 $opts uninstall-lkm529 523 echo "$0 $opts uninstall-program" 530 524 eval $0 $opts uninstall-program … … 680 674 break 681 675 ;; 682 Linux/* )676 Linux/* | GNU/kFreeBSD/* | GNU/* ) 683 677 file=/etc/passwd 684 678 entry="${user}:*:${uid}:${gid}:${realname}:${home}:${shell}" … … 886 880 ;; 887 881 888 Linux/* )882 Linux/* | GNU/kFreeBSD* | GNU/* ) 889 883 rlv="2 3 4 5" 890 884 linkopt="-f -s" … … 1145 1139 fi 1146 1140 1147 if test x"${act}" = xulkm1148 then1149 RVER=`uname -r`1150 if test "x@sh_lkm@" != "x"; then1151 if test -d /lib/modules/$RVER; then1152 MODDIR="/lib/modules/$RVER"1153 elif test -d /lib/modules/misc; then1154 MODDIR="/lib/modules/misc"1155 elif test -d /lib/modules; then1156 MODDIR="/lib/modules/misc"1157 fi1158 # -- NEW --1159 ALLMODS="@sh_lkm@"1160 for p in $ALLMODS; do1161 test -z "$verbose" || echo " rm -f ${DESTDIR}${MODDIR}/`echo $p|sed '1162 s%samhain%@install_name@%'`"1163 rm -f ${DESTDIR}${MODDIR}/`echo $p|sed 's%samhain%@install_name@%'`1164 done1165 fi1166 fi1167 1168 1141 if test x"${act}" = xuprogram 1169 1142 then 1170 PROGRAMS="@setpwd_prg@ @stegin_prg@ @yulectl_prg@ @sh_main_prg@ "1143 PROGRAMS="@setpwd_prg@ @stegin_prg@ @yulectl_prg@ @sh_main_prg@ @samhainadmin_prg@" 1171 1144 for p in $PROGRAMS; do 1172 test -z "$verbose" || echo " rm -f ${DESTDIR}${sbindir}/`echo $p|sed 's%samhain%@install_name@%'|sed 's%yule%@install_name@%' `"1173 rm -f ${DESTDIR}${sbindir}/`echo $p|sed 's%samhain%@install_name@%'|sed 's%yule%@install_name@%' `1145 test -z "$verbose" || echo " rm -f ${DESTDIR}${sbindir}/`echo $p|sed 's%samhain%@install_name@%'|sed 's%yule%@install_name@%'|sed 's%.*/%%'`" 1146 rm -f ${DESTDIR}${sbindir}/`echo $p|sed 's%samhain%@install_name@%'|sed 's%yule%@install_name@%'|sed 's%.*/%%'` 1174 1147 done 1175 1148 test -z "$verbose" || echo $ECHO_N " ${SH_RMDIR} ${DESTDIR}${sbindir} ... $ECHO_C" -
trunk/samhain.spec.in
r418 r481 185 185 fi 186 186 187 %postun188 if [ "$1" = 0 ]; then189 # remove any kernel modules that might have been installed190 RVER=`uname -r`191 MODFILES=`ls /lib/modules/$RVER/@install_name@* 2>/dev/null`192 if test "x$MODFILES" = x; then193 :194 else195 rm -f /lib/modules/$RVER/@install_name@*196 fi197 fi198 187 199 188 … … 203 192 %dir @mylogdir@ 204 193 %doc docs/BUGS COPYING docs/Changelog docs/TODO 205 %doc LICENSE docs/FAQ.html docs/HOWTO* docs/MANUAL-2_ 3.* docs/README*194 %doc LICENSE docs/FAQ.html docs/HOWTO* docs/MANUAL-2_4.* docs/README* 206 195 @mydataroot@ 207 196 %if "%{withstg_prg}" == "xsamhain_stealth" -
trunk/samhainrc.freebsd
r387 r481 370 370 # SuidCheckQuarantineDelete = yes 371 371 372 # [Kernel]373 ##374 ## --- Check for loadable kernel module rootkits (Linux/FreeBSD only)375 ##376 377 ## Switch on/off378 #379 # KernelCheckActive = True380 381 ## Check interval (seconds); btw., the check is VERY fast382 #383 # KernelCheckInterval = 300384 385 ## Severity386 #387 # SeverityKernel = crit388 389 372 390 373 # [Utmp] -
trunk/samhainrc.linux
r387 r481 408 408 # SuidCheckQuarantineDelete = yes 409 409 410 #[Kernel]411 ##412 ## --- Check for loadable kernel module rootkits (Linux/FreeBSD only)413 ##414 415 ## Switch on/off416 #417 # KernelCheckActive = True418 419 ## Check interval (seconds); btw., the check is VERY fast420 #421 # KernelCheckInterval = 300422 423 ## Severity424 #425 # SeverityKernel = crit426 427 410 428 411 # [Utmp] -
trunk/samhainrc.netbsd
r387 r481 503 503 #checkmount=/tmp 504 504 505 #[Kernel]506 ##507 ## --- Check for loadable kernel module rootkits (Linux/FreeBSD only)508 ##509 510 ## Switch on/off511 #512 #KernelCheckActive = True513 514 ## Check interval (seconds); btw., the check is VERY fast515 #516 #KernelCheckInterval = 300517 518 ## Severity519 #520 #SeverityKernel = crit521 505 522 506 -
trunk/scripts/README
r121 r481 38 38 Run 'yuleadmin.pl -h' for usage instructions. 39 39 40 samhainrc_update.sh41 -------------------42 43 If you are using the --with-kcheck option on Linux, after a kernel44 update you need to change some option (addresses of kernel functions)45 in the samhainrc configuration file. The correct new addresses must46 be looked up in the System.map file47 48 This script will do this automatically. Run 'samhainrc_update.sh -h'49 for usage instructions. You may need to change the location of the50 samhainrc file by editing the line 'cfgfile="/etc/samhainrc"'51 at the beginning of the script.52 53 40 check_samhain.pl 54 41 ---------------- -
trunk/scripts/redhat_i386.client.spec.in
r412 r481 123 123 fi 124 124 125 %postun126 if [ "$1" = 0 ]; then127 # remove any kernel modules that might have been installed128 RVER=`uname -r`129 rm -f /lib/modules/$RVER/samhain*130 fi131 125 132 126 … … 136 130 %dir /var/log 137 131 #%doc docs/BUGS COPYING docs/Changelog docs/TODO 138 #%doc LICENSE docs/HOWTO* docs/MANUAL-2_ 3.* docs/README*132 #%doc LICENSE docs/HOWTO* docs/MANUAL-2_4.* docs/README* 139 133 /etc 140 134 /usr/local/sbin/samhain -
trunk/scripts/samhain.ebuild.in
r68 r481 69 69 dodoc docs/BUGS COPYING docs/Changelog LICENSE docs/README \ 70 70 docs/README.UPGRADE docs/sh_mounts.txt docs/sh_userfiles.txt \ 71 docs/MANUAL-2_ 3.ps docs/MANUAL-2_3.html.tar71 docs/MANUAL-2_4.ps docs/MANUAL-2_4.html.tar 72 72 73 73 dohtml docs/HOWTO-client+server.html docs/HOWTO-samhain+GnuPG.html \ -
trunk/scripts/samhain.spec.in
r412 r481 109 109 fi 110 110 111 %postun112 if [ "$1" = 0 ]; then113 # remove any kernel modules that might have been installed114 RVER=`uname -r`115 rm -f /lib/modules/$RVER/samhain*116 fi117 118 111 119 112 %files … … 122 115 %dir %{_localstatedir}/log 123 116 %doc docs/BUGS COPYING docs/Changelog docs/TODO 124 %doc LICENSE docs/HOWTO* docs/MANUAL-2_ 3.* docs/README*117 %doc LICENSE docs/HOWTO* docs/MANUAL-2_4.* docs/README* 125 118 %{_localstatedir}/lib/%{name} 126 119 %{_sbindir}/%{name} -
trunk/scripts/samhainadmin.pl.in
r415 r481 156 156 print " Set the passphrase for gpg. By default, gpg will ask.\n\n"; 157 157 158 print " -s secretkeyring --secretkeyring secretkeyring\n"; 159 print " Select an alternate secret keyring for gpg.\n"; 160 print " Will use '$ENV{'HOME'}/.gnupg/secring.gpg' by default.\n\n"; 158 print " -s gnupg_homedir --secretkeyring gnupg_homedir\n"; 159 print " Select an alternate gpg homedirectory to locate the secret keyring.\n"; 160 print " Will use '$ENV{'HOME'}/.gnupg/' by default.\n\n"; 161 162 print " -k keyid --keyid keyid\n"; 163 print " Select the keyid to use for signing.\n\n"; 161 164 162 165 print " -l --list\n"; … … 570 573 'p|passphrase=s', 571 574 's|secretkeyring=s', 575 'k|keyid=s', 572 576 'create-cfgfile', # -m F 573 577 'print-cfgfile', # -m f … … 584 588 } 585 589 590 if (defined($opts{'k'})) { 591 $TARGETKEYID = $opts{'k'}; 592 $KEYTAG = "--default-key"; 593 } 586 594 if (defined($opts{'c'})) { 587 595 $cfgfile = $opts{'c'}; -
trunk/sql_init/samhain.mysql.init
r392 r481 87 87 igroup_old BIGINT UNSIGNED, 88 88 igroup_new BIGINT UNSIGNED, 89 checkflags_old BIGINT UNSIGNED, 90 checkflags_new BIGINT UNSIGNED, 89 91 90 92 -
trunk/sql_init/samhain.oracle.init
r407 r481 74 74 igroup_old NUMBER(20), 75 75 igroup_new NUMBER(20), 76 checkflags_old NUMBER(20), 77 checkflags_new NUMBER(20), 76 78 acl_old VARCHAR2(4000), 77 79 acl_new VARCHAR2(4000) -
trunk/sql_init/samhain.postgres.init
r392 r481 81 81 igroup_old NUMERIC(20), 82 82 igroup_new NUMERIC(20), 83 checkflags_old NUMERIC(20), 84 checkflags_new NUMERIC(20), 83 85 84 86 acl_old TEXT, -
trunk/src/cutest_sh_tiger0.c
r444 r481 28 28 if (skey != NULL) 29 29 { 30 skey->mlock_failed = S L_FALSE;30 skey->mlock_failed = S_FALSE; 31 31 skey->rngI = BAD; 32 32 /* properly initialized later -
trunk/src/cutest_sh_unix.c
r474 r481 14 14 int j, i; 15 15 int sum; 16 #ifndef USE_SYSTEM_MALLOC 16 17 int i_malloc = malloc_count; 18 #endif 17 19 18 20 char * buf; … … 35 37 CuAssertStrEquals(tc, "testing realloctesting realloc", buf); 36 38 39 #ifndef USE_SYSTEM_MALLOC 37 40 i_malloc = malloc_count; 41 #endif 38 42 39 43 for (j = 0; j < 64; ++j) … … 60 64 CuAssertStrEquals(tc, "testing realloctesting realloc", buf); 61 65 66 #ifndef USE_SYSTEM_MALLOC 62 67 i_malloc = malloc_count; 68 #endif 63 69 64 70 for (j = 0; j < 64; ++j) … … 97 103 } 98 104 105 #ifndef USE_SYSTEM_MALLOC 99 106 i_malloc = malloc_count; 107 #endif 100 108 101 109 for (j = 0; j < nalloc; ++j) … … 122 130 for (j = 0; j < 32; ++j) 123 131 { 132 #ifndef USE_SYSTEM_MALLOC 124 133 i_malloc = malloc_count; 134 #endif 125 135 buf = malloc((j+1) * 1024 * 1024); 126 136 CuAssertPtrNotNull(tc, buf); -
trunk/src/cutest_sh_utils.c
r444 r481 531 531 } 532 532 533 -
trunk/src/cutest_zAVLTree.c
r452 r481 21 21 static zAVLKey ztest_intkey(void const *item) 22 22 { 23 return (&(( struct ztest *)item)->iname);23 return (&((const struct ztest *)item)->iname); 24 24 } 25 25 -
trunk/src/dnmalloc.c
r383 r481 220 220 #ifdef linux 221 221 #define HAVE_MREMAP 1 222 #define _GNU_SOURCE 222 #define _GNU_SOURCE 1 223 223 #else 224 224 #define HAVE_MREMAP 0 … … 310 310 char * i3 = "): "; 311 311 char * i5 = "\n"; 312 int res = 0; 313 314 iov[0].iov_base = i1; iov[0].iov_len = strlen(i1); 315 iov[1].iov_base = (char*) file; iov[1].iov_len = strlen(file); 316 iov[2].iov_base = i3; iov[2].iov_len = strlen(i3); 317 iov[3].iov_base = (char*) error; iov[3].iov_len = strlen(error); 318 iov[4].iov_base = i5; iov[4].iov_len = strlen(i5); 312 int res = 0; 313 char ifile[128]; 314 char ierr[128]; 315 316 strncpy(ifile, file, sizeof(ifile)); ifile[sizeof(ifile)-1] = '\0'; 317 strncpy(ierr, error, sizeof(ierr)); ierr[sizeof(ierr)-1] = '\0'; 318 319 iov[0].iov_base = i1; iov[0].iov_len = strlen(i1); 320 iov[1].iov_base = ifile; iov[1].iov_len = strlen(ifile); 321 iov[2].iov_base = i3; iov[2].iov_len = strlen(i3); 322 iov[3].iov_base = ierr; iov[3].iov_len = strlen(ierr); 323 iov[4].iov_base = i5; iov[4].iov_len = strlen(i5); 319 324 do { 320 325 res = writev(STDERR_FILENO, iov, 5); … … 343 348 344 349 static assert_handler_tp *assert_handler = NULL; 350 #ifndef NDEBUG 345 351 #define NDEBUG 352 #endif 346 353 #define assert(x) ((void)0) 347 354 … … 3764 3771 } /* not extended previous region */ 3765 3772 3766 /* Update statistics */ /* FIXME check this */3773 /* Update statistics */ 3767 3774 sum = av->sbrked_mem; 3768 3775 if (sum > (CHUNK_SIZE_T)(av->max_sbrked_mem)) -
trunk/src/rijndael-alg-fst.c
r440 r481 1 /* $NetBSD: rijndael-alg-fst.c,v 1.7 2005/12/11 12:20:52 christos Exp $ */ 2 /* $KAME: rijndael-alg-fst.c,v 1.10 2003/07/15 10:47:16 itojun Exp $ */ 3 /** 4 * rijndael-alg-fst.c 5 * 6 * @version 3.0 (December 2000) 7 * 8 * Optimised ANSI C code for the Rijndael cipher (now AES) 9 * 10 * @author Vincent Rijmen <vincent.rijmen@esat.kuleuven.ac.be> 11 * @author Antoon Bosselaers <antoon.bosselaers@esat.kuleuven.ac.be> 12 * @author Paulo Barreto <paulo.barreto@terra.com.br> 13 * 14 * This code is hereby placed in the public domain. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ''AS IS'' AND ANY EXPRESS 17 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE 20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 26 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29 #include "config_xor.h" 30 31 #include <sys/types.h> 32 #include <string.h> 33 34 #ifdef SH_ENCRYPT 35 36 typedef unsigned char u8; 37 #if defined(HAVE_INT_32) 38 typedef unsigned int u32; 39 #elif defined(HAVE_LONG_32) 40 typedef unsigned long u32; 41 #elif defined(HAVE_SHORT_32) 42 typedef unsigned short u32; 43 #else 44 #error "No 32 bit integer type found" 45 #endif 46 47 #include "rijndael-alg-fst.h" 48 49 #define FULL_UNROLL 1 1 50 /* 2 * rijndael-alg-fst.c v2.3 April '2000 51 Te0[x] = S [x].[02, 01, 01, 03]; 52 Te1[x] = S [x].[03, 02, 01, 01]; 53 Te2[x] = S [x].[01, 03, 02, 01]; 54 Te3[x] = S [x].[01, 01, 03, 02]; 55 Te4[x] = S [x].[01, 01, 01, 01]; 56 57 Td0[x] = Si[x].[0e, 09, 0d, 0b]; 58 Td1[x] = Si[x].[0b, 0e, 09, 0d]; 59 Td2[x] = Si[x].[0d, 0b, 0e, 09]; 60 Td3[x] = Si[x].[09, 0d, 0b, 0e]; 61 Td4[x] = Si[x].[01, 01, 01, 01]; 62 */ 63 64 static const u32 Te0[256] = { 65 0xc66363a5U, 0xf87c7c84U, 0xee777799U, 0xf67b7b8dU, 66 0xfff2f20dU, 0xd66b6bbdU, 0xde6f6fb1U, 0x91c5c554U, 67 0x60303050U, 0x02010103U, 0xce6767a9U, 0x562b2b7dU, 68 0xe7fefe19U, 0xb5d7d762U, 0x4dababe6U, 0xec76769aU, 69 0x8fcaca45U, 0x1f82829dU, 0x89c9c940U, 0xfa7d7d87U, 70 0xeffafa15U, 0xb25959ebU, 0x8e4747c9U, 0xfbf0f00bU, 71 0x41adadecU, 0xb3d4d467U, 0x5fa2a2fdU, 0x45afafeaU, 72 0x239c9cbfU, 0x53a4a4f7U, 0xe4727296U, 0x9bc0c05bU, 73 0x75b7b7c2U, 0xe1fdfd1cU, 0x3d9393aeU, 0x4c26266aU, 74 0x6c36365aU, 0x7e3f3f41U, 0xf5f7f702U, 0x83cccc4fU, 75 0x6834345cU, 0x51a5a5f4U, 0xd1e5e534U, 0xf9f1f108U, 76 0xe2717193U, 0xabd8d873U, 0x62313153U, 0x2a15153fU, 77 0x0804040cU, 0x95c7c752U, 0x46232365U, 0x9dc3c35eU, 78 0x30181828U, 0x379696a1U, 0x0a05050fU, 0x2f9a9ab5U, 79 0x0e070709U, 0x24121236U, 0x1b80809bU, 0xdfe2e23dU, 80 0xcdebeb26U, 0x4e272769U, 0x7fb2b2cdU, 0xea75759fU, 81 0x1209091bU, 0x1d83839eU, 0x582c2c74U, 0x341a1a2eU, 82 0x361b1b2dU, 0xdc6e6eb2U, 0xb45a5aeeU, 0x5ba0a0fbU, 83 0xa45252f6U, 0x763b3b4dU, 0xb7d6d661U, 0x7db3b3ceU, 84 0x5229297bU, 0xdde3e33eU, 0x5e2f2f71U, 0x13848497U, 85 0xa65353f5U, 0xb9d1d168U, 0x00000000U, 0xc1eded2cU, 86 0x40202060U, 0xe3fcfc1fU, 0x79b1b1c8U, 0xb65b5bedU, 87 0xd46a6abeU, 0x8dcbcb46U, 0x67bebed9U, 0x7239394bU, 88 0x944a4adeU, 0x984c4cd4U, 0xb05858e8U, 0x85cfcf4aU, 89 0xbbd0d06bU, 0xc5efef2aU, 0x4faaaae5U, 0xedfbfb16U, 90 0x864343c5U, 0x9a4d4dd7U, 0x66333355U, 0x11858594U, 91 0x8a4545cfU, 0xe9f9f910U, 0x04020206U, 0xfe7f7f81U, 92 0xa05050f0U, 0x783c3c44U, 0x259f9fbaU, 0x4ba8a8e3U, 93 0xa25151f3U, 0x5da3a3feU, 0x804040c0U, 0x058f8f8aU, 94 0x3f9292adU, 0x219d9dbcU, 0x70383848U, 0xf1f5f504U, 95 0x63bcbcdfU, 0x77b6b6c1U, 0xafdada75U, 0x42212163U, 96 0x20101030U, 0xe5ffff1aU, 0xfdf3f30eU, 0xbfd2d26dU, 97 0x81cdcd4cU, 0x180c0c14U, 0x26131335U, 0xc3ecec2fU, 98 0xbe5f5fe1U, 0x359797a2U, 0x884444ccU, 0x2e171739U, 99 0x93c4c457U, 0x55a7a7f2U, 0xfc7e7e82U, 0x7a3d3d47U, 100 0xc86464acU, 0xba5d5de7U, 0x3219192bU, 0xe6737395U, 101 0xc06060a0U, 0x19818198U, 0x9e4f4fd1U, 0xa3dcdc7fU, 102 0x44222266U, 0x542a2a7eU, 0x3b9090abU, 0x0b888883U, 103 0x8c4646caU, 0xc7eeee29U, 0x6bb8b8d3U, 0x2814143cU, 104 0xa7dede79U, 0xbc5e5ee2U, 0x160b0b1dU, 0xaddbdb76U, 105 0xdbe0e03bU, 0x64323256U, 0x743a3a4eU, 0x140a0a1eU, 106 0x924949dbU, 0x0c06060aU, 0x4824246cU, 0xb85c5ce4U, 107 0x9fc2c25dU, 0xbdd3d36eU, 0x43acacefU, 0xc46262a6U, 108 0x399191a8U, 0x319595a4U, 0xd3e4e437U, 0xf279798bU, 109 0xd5e7e732U, 0x8bc8c843U, 0x6e373759U, 0xda6d6db7U, 110 0x018d8d8cU, 0xb1d5d564U, 0x9c4e4ed2U, 0x49a9a9e0U, 111 0xd86c6cb4U, 0xac5656faU, 0xf3f4f407U, 0xcfeaea25U, 112 0xca6565afU, 0xf47a7a8eU, 0x47aeaee9U, 0x10080818U, 113 0x6fbabad5U, 0xf0787888U, 0x4a25256fU, 0x5c2e2e72U, 114 0x381c1c24U, 0x57a6a6f1U, 0x73b4b4c7U, 0x97c6c651U, 115 0xcbe8e823U, 0xa1dddd7cU, 0xe874749cU, 0x3e1f1f21U, 116 0x964b4bddU, 0x61bdbddcU, 0x0d8b8b86U, 0x0f8a8a85U, 117 0xe0707090U, 0x7c3e3e42U, 0x71b5b5c4U, 0xcc6666aaU, 118 0x904848d8U, 0x06030305U, 0xf7f6f601U, 0x1c0e0e12U, 119 0xc26161a3U, 0x6a35355fU, 0xae5757f9U, 0x69b9b9d0U, 120 0x17868691U, 0x99c1c158U, 0x3a1d1d27U, 0x279e9eb9U, 121 0xd9e1e138U, 0xebf8f813U, 0x2b9898b3U, 0x22111133U, 122 0xd26969bbU, 0xa9d9d970U, 0x078e8e89U, 0x339494a7U, 123 0x2d9b9bb6U, 0x3c1e1e22U, 0x15878792U, 0xc9e9e920U, 124 0x87cece49U, 0xaa5555ffU, 0x50282878U, 0xa5dfdf7aU, 125 0x038c8c8fU, 0x59a1a1f8U, 0x09898980U, 0x1a0d0d17U, 126 0x65bfbfdaU, 0xd7e6e631U, 0x844242c6U, 0xd06868b8U, 127 0x824141c3U, 0x299999b0U, 0x5a2d2d77U, 0x1e0f0f11U, 128 0x7bb0b0cbU, 0xa85454fcU, 0x6dbbbbd6U, 0x2c16163aU, 129 }; 130 static const u32 Te1[256] = { 131 0xa5c66363U, 0x84f87c7cU, 0x99ee7777U, 0x8df67b7bU, 132 0x0dfff2f2U, 0xbdd66b6bU, 0xb1de6f6fU, 0x5491c5c5U, 133 0x50603030U, 0x03020101U, 0xa9ce6767U, 0x7d562b2bU, 134 0x19e7fefeU, 0x62b5d7d7U, 0xe64dababU, 0x9aec7676U, 135 0x458fcacaU, 0x9d1f8282U, 0x4089c9c9U, 0x87fa7d7dU, 136 0x15effafaU, 0xebb25959U, 0xc98e4747U, 0x0bfbf0f0U, 137 0xec41adadU, 0x67b3d4d4U, 0xfd5fa2a2U, 0xea45afafU, 138 0xbf239c9cU, 0xf753a4a4U, 0x96e47272U, 0x5b9bc0c0U, 139 0xc275b7b7U, 0x1ce1fdfdU, 0xae3d9393U, 0x6a4c2626U, 140 0x5a6c3636U, 0x417e3f3fU, 0x02f5f7f7U, 0x4f83ccccU, 141 0x5c683434U, 0xf451a5a5U, 0x34d1e5e5U, 0x08f9f1f1U, 142 0x93e27171U, 0x73abd8d8U, 0x53623131U, 0x3f2a1515U, 143 0x0c080404U, 0x5295c7c7U, 0x65462323U, 0x5e9dc3c3U, 144 0x28301818U, 0xa1379696U, 0x0f0a0505U, 0xb52f9a9aU, 145 0x090e0707U, 0x36241212U, 0x9b1b8080U, 0x3ddfe2e2U, 146 0x26cdebebU, 0x694e2727U, 0xcd7fb2b2U, 0x9fea7575U, 147 0x1b120909U, 0x9e1d8383U, 0x74582c2cU, 0x2e341a1aU, 148 0x2d361b1bU, 0xb2dc6e6eU, 0xeeb45a5aU, 0xfb5ba0a0U, 149 0xf6a45252U, 0x4d763b3bU, 0x61b7d6d6U, 0xce7db3b3U, 150 0x7b522929U, 0x3edde3e3U, 0x715e2f2fU, 0x97138484U, 151 0xf5a65353U, 0x68b9d1d1U, 0x00000000U, 0x2cc1ededU, 152 0x60402020U, 0x1fe3fcfcU, 0xc879b1b1U, 0xedb65b5bU, 153 0xbed46a6aU, 0x468dcbcbU, 0xd967bebeU, 0x4b723939U, 154 0xde944a4aU, 0xd4984c4cU, 0xe8b05858U, 0x4a85cfcfU, 155 0x6bbbd0d0U, 0x2ac5efefU, 0xe54faaaaU, 0x16edfbfbU, 156 0xc5864343U, 0xd79a4d4dU, 0x55663333U, 0x94118585U, 157 0xcf8a4545U, 0x10e9f9f9U, 0x06040202U, 0x81fe7f7fU, 158 0xf0a05050U, 0x44783c3cU, 0xba259f9fU, 0xe34ba8a8U, 159 0xf3a25151U, 0xfe5da3a3U, 0xc0804040U, 0x8a058f8fU, 160 0xad3f9292U, 0xbc219d9dU, 0x48703838U, 0x04f1f5f5U, 161 0xdf63bcbcU, 0xc177b6b6U, 0x75afdadaU, 0x63422121U, 162 0x30201010U, 0x1ae5ffffU, 0x0efdf3f3U, 0x6dbfd2d2U, 163 0x4c81cdcdU, 0x14180c0cU, 0x35261313U, 0x2fc3ececU, 164 0xe1be5f5fU, 0xa2359797U, 0xcc884444U, 0x392e1717U, 165 0x5793c4c4U, 0xf255a7a7U, 0x82fc7e7eU, 0x477a3d3dU, 166 0xacc86464U, 0xe7ba5d5dU, 0x2b321919U, 0x95e67373U, 167 0xa0c06060U, 0x98198181U, 0xd19e4f4fU, 0x7fa3dcdcU, 168 0x66442222U, 0x7e542a2aU, 0xab3b9090U, 0x830b8888U, 169 0xca8c4646U, 0x29c7eeeeU, 0xd36bb8b8U, 0x3c281414U, 170 0x79a7dedeU, 0xe2bc5e5eU, 0x1d160b0bU, 0x76addbdbU, 171 0x3bdbe0e0U, 0x56643232U, 0x4e743a3aU, 0x1e140a0aU, 172 0xdb924949U, 0x0a0c0606U, 0x6c482424U, 0xe4b85c5cU, 173 0x5d9fc2c2U, 0x6ebdd3d3U, 0xef43acacU, 0xa6c46262U, 174 0xa8399191U, 0xa4319595U, 0x37d3e4e4U, 0x8bf27979U, 175 0x32d5e7e7U, 0x438bc8c8U, 0x596e3737U, 0xb7da6d6dU, 176 0x8c018d8dU, 0x64b1d5d5U, 0xd29c4e4eU, 0xe049a9a9U, 177 0xb4d86c6cU, 0xfaac5656U, 0x07f3f4f4U, 0x25cfeaeaU, 178 0xafca6565U, 0x8ef47a7aU, 0xe947aeaeU, 0x18100808U, 179 0xd56fbabaU, 0x88f07878U, 0x6f4a2525U, 0x725c2e2eU, 180 0x24381c1cU, 0xf157a6a6U, 0xc773b4b4U, 0x5197c6c6U, 181 0x23cbe8e8U, 0x7ca1ddddU, 0x9ce87474U, 0x213e1f1fU, 182 0xdd964b4bU, 0xdc61bdbdU, 0x860d8b8bU, 0x850f8a8aU, 183 0x90e07070U, 0x427c3e3eU, 0xc471b5b5U, 0xaacc6666U, 184 0xd8904848U, 0x05060303U, 0x01f7f6f6U, 0x121c0e0eU, 185 0xa3c26161U, 0x5f6a3535U, 0xf9ae5757U, 0xd069b9b9U, 186 0x91178686U, 0x5899c1c1U, 0x273a1d1dU, 0xb9279e9eU, 187 0x38d9e1e1U, 0x13ebf8f8U, 0xb32b9898U, 0x33221111U, 188 0xbbd26969U, 0x70a9d9d9U, 0x89078e8eU, 0xa7339494U, 189 0xb62d9b9bU, 0x223c1e1eU, 0x92158787U, 0x20c9e9e9U, 190 0x4987ceceU, 0xffaa5555U, 0x78502828U, 0x7aa5dfdfU, 191 0x8f038c8cU, 0xf859a1a1U, 0x80098989U, 0x171a0d0dU, 192 0xda65bfbfU, 0x31d7e6e6U, 0xc6844242U, 0xb8d06868U, 193 0xc3824141U, 0xb0299999U, 0x775a2d2dU, 0x111e0f0fU, 194 0xcb7bb0b0U, 0xfca85454U, 0xd66dbbbbU, 0x3a2c1616U, 195 }; 196 static const u32 Te2[256] = { 197 0x63a5c663U, 0x7c84f87cU, 0x7799ee77U, 0x7b8df67bU, 198 0xf20dfff2U, 0x6bbdd66bU, 0x6fb1de6fU, 0xc55491c5U, 199 0x30506030U, 0x01030201U, 0x67a9ce67U, 0x2b7d562bU, 200 0xfe19e7feU, 0xd762b5d7U, 0xabe64dabU, 0x769aec76U, 201 0xca458fcaU, 0x829d1f82U, 0xc94089c9U, 0x7d87fa7dU, 202 0xfa15effaU, 0x59ebb259U, 0x47c98e47U, 0xf00bfbf0U, 203 0xadec41adU, 0xd467b3d4U, 0xa2fd5fa2U, 0xafea45afU, 204 0x9cbf239cU, 0xa4f753a4U, 0x7296e472U, 0xc05b9bc0U, 205 0xb7c275b7U, 0xfd1ce1fdU, 0x93ae3d93U, 0x266a4c26U, 206 0x365a6c36U, 0x3f417e3fU, 0xf702f5f7U, 0xcc4f83ccU, 207 0x345c6834U, 0xa5f451a5U, 0xe534d1e5U, 0xf108f9f1U, 208 0x7193e271U, 0xd873abd8U, 0x31536231U, 0x153f2a15U, 209 0x040c0804U, 0xc75295c7U, 0x23654623U, 0xc35e9dc3U, 210 0x18283018U, 0x96a13796U, 0x050f0a05U, 0x9ab52f9aU, 211 0x07090e07U, 0x12362412U, 0x809b1b80U, 0xe23ddfe2U, 212 0xeb26cdebU, 0x27694e27U, 0xb2cd7fb2U, 0x759fea75U, 213 0x091b1209U, 0x839e1d83U, 0x2c74582cU, 0x1a2e341aU, 214 0x1b2d361bU, 0x6eb2dc6eU, 0x5aeeb45aU, 0xa0fb5ba0U, 215 0x52f6a452U, 0x3b4d763bU, 0xd661b7d6U, 0xb3ce7db3U, 216 0x297b5229U, 0xe33edde3U, 0x2f715e2fU, 0x84971384U, 217 0x53f5a653U, 0xd168b9d1U, 0x00000000U, 0xed2cc1edU, 218 0x20604020U, 0xfc1fe3fcU, 0xb1c879b1U, 0x5bedb65bU, 219 0x6abed46aU, 0xcb468dcbU, 0xbed967beU, 0x394b7239U, 220 0x4ade944aU, 0x4cd4984cU, 0x58e8b058U, 0xcf4a85cfU, 221 0xd06bbbd0U, 0xef2ac5efU, 0xaae54faaU, 0xfb16edfbU, 222 0x43c58643U, 0x4dd79a4dU, 0x33556633U, 0x85941185U, 223 0x45cf8a45U, 0xf910e9f9U, 0x02060402U, 0x7f81fe7fU, 224 0x50f0a050U, 0x3c44783cU, 0x9fba259fU, 0xa8e34ba8U, 225 0x51f3a251U, 0xa3fe5da3U, 0x40c08040U, 0x8f8a058fU, 226 0x92ad3f92U, 0x9dbc219dU, 0x38487038U, 0xf504f1f5U, 227 0xbcdf63bcU, 0xb6c177b6U, 0xda75afdaU, 0x21634221U, 228 0x10302010U, 0xff1ae5ffU, 0xf30efdf3U, 0xd26dbfd2U, 229 0xcd4c81cdU, 0x0c14180cU, 0x13352613U, 0xec2fc3ecU, 230 0x5fe1be5fU, 0x97a23597U, 0x44cc8844U, 0x17392e17U, 231 0xc45793c4U, 0xa7f255a7U, 0x7e82fc7eU, 0x3d477a3dU, 232 0x64acc864U, 0x5de7ba5dU, 0x192b3219U, 0x7395e673U, 233 0x60a0c060U, 0x81981981U, 0x4fd19e4fU, 0xdc7fa3dcU, 234 0x22664422U, 0x2a7e542aU, 0x90ab3b90U, 0x88830b88U, 235 0x46ca8c46U, 0xee29c7eeU, 0xb8d36bb8U, 0x143c2814U, 236 0xde79a7deU, 0x5ee2bc5eU, 0x0b1d160bU, 0xdb76addbU, 237 0xe03bdbe0U, 0x32566432U, 0x3a4e743aU, 0x0a1e140aU, 238 0x49db9249U, 0x060a0c06U, 0x246c4824U, 0x5ce4b85cU, 239 0xc25d9fc2U, 0xd36ebdd3U, 0xacef43acU, 0x62a6c462U, 240 0x91a83991U, 0x95a43195U, 0xe437d3e4U, 0x798bf279U, 241 0xe732d5e7U, 0xc8438bc8U, 0x37596e37U, 0x6db7da6dU, 242 0x8d8c018dU, 0xd564b1d5U, 0x4ed29c4eU, 0xa9e049a9U, 243 0x6cb4d86cU, 0x56faac56U, 0xf407f3f4U, 0xea25cfeaU, 244 0x65afca65U, 0x7a8ef47aU, 0xaee947aeU, 0x08181008U, 245 0xbad56fbaU, 0x7888f078U, 0x256f4a25U, 0x2e725c2eU, 246 0x1c24381cU, 0xa6f157a6U, 0xb4c773b4U, 0xc65197c6U, 247 0xe823cbe8U, 0xdd7ca1ddU, 0x749ce874U, 0x1f213e1fU, 248 0x4bdd964bU, 0xbddc61bdU, 0x8b860d8bU, 0x8a850f8aU, 249 0x7090e070U, 0x3e427c3eU, 0xb5c471b5U, 0x66aacc66U, 250 0x48d89048U, 0x03050603U, 0xf601f7f6U, 0x0e121c0eU, 251 0x61a3c261U, 0x355f6a35U, 0x57f9ae57U, 0xb9d069b9U, 252 0x86911786U, 0xc15899c1U, 0x1d273a1dU, 0x9eb9279eU, 253 0xe138d9e1U, 0xf813ebf8U, 0x98b32b98U, 0x11332211U, 254 0x69bbd269U, 0xd970a9d9U, 0x8e89078eU, 0x94a73394U, 255 0x9bb62d9bU, 0x1e223c1eU, 0x87921587U, 0xe920c9e9U, 256 0xce4987ceU, 0x55ffaa55U, 0x28785028U, 0xdf7aa5dfU, 257 0x8c8f038cU, 0xa1f859a1U, 0x89800989U, 0x0d171a0dU, 258 0xbfda65bfU, 0xe631d7e6U, 0x42c68442U, 0x68b8d068U, 259 0x41c38241U, 0x99b02999U, 0x2d775a2dU, 0x0f111e0fU, 260 0xb0cb7bb0U, 0x54fca854U, 0xbbd66dbbU, 0x163a2c16U, 261 }; 262 static const u32 Te3[256] = { 263 264 0x6363a5c6U, 0x7c7c84f8U, 0x777799eeU, 0x7b7b8df6U, 265 0xf2f20dffU, 0x6b6bbdd6U, 0x6f6fb1deU, 0xc5c55491U, 266 0x30305060U, 0x01010302U, 0x6767a9ceU, 0x2b2b7d56U, 267 0xfefe19e7U, 0xd7d762b5U, 0xababe64dU, 0x76769aecU, 268 0xcaca458fU, 0x82829d1fU, 0xc9c94089U, 0x7d7d87faU, 269 0xfafa15efU, 0x5959ebb2U, 0x4747c98eU, 0xf0f00bfbU, 270 0xadadec41U, 0xd4d467b3U, 0xa2a2fd5fU, 0xafafea45U, 271 0x9c9cbf23U, 0xa4a4f753U, 0x727296e4U, 0xc0c05b9bU, 272 0xb7b7c275U, 0xfdfd1ce1U, 0x9393ae3dU, 0x26266a4cU, 273 0x36365a6cU, 0x3f3f417eU, 0xf7f702f5U, 0xcccc4f83U, 274 0x34345c68U, 0xa5a5f451U, 0xe5e534d1U, 0xf1f108f9U, 275 0x717193e2U, 0xd8d873abU, 0x31315362U, 0x15153f2aU, 276 0x04040c08U, 0xc7c75295U, 0x23236546U, 0xc3c35e9dU, 277 0x18182830U, 0x9696a137U, 0x05050f0aU, 0x9a9ab52fU, 278 0x0707090eU, 0x12123624U, 0x80809b1bU, 0xe2e23ddfU, 279 0xebeb26cdU, 0x2727694eU, 0xb2b2cd7fU, 0x75759feaU, 280 0x09091b12U, 0x83839e1dU, 0x2c2c7458U, 0x1a1a2e34U, 281 0x1b1b2d36U, 0x6e6eb2dcU, 0x5a5aeeb4U, 0xa0a0fb5bU, 282 0x5252f6a4U, 0x3b3b4d76U, 0xd6d661b7U, 0xb3b3ce7dU, 283 0x29297b52U, 0xe3e33eddU, 0x2f2f715eU, 0x84849713U, 284 0x5353f5a6U, 0xd1d168b9U, 0x00000000U, 0xeded2cc1U, 285 0x20206040U, 0xfcfc1fe3U, 0xb1b1c879U, 0x5b5bedb6U, 286 0x6a6abed4U, 0xcbcb468dU, 0xbebed967U, 0x39394b72U, 287 0x4a4ade94U, 0x4c4cd498U, 0x5858e8b0U, 0xcfcf4a85U, 288 0xd0d06bbbU, 0xefef2ac5U, 0xaaaae54fU, 0xfbfb16edU, 289 0x4343c586U, 0x4d4dd79aU, 0x33335566U, 0x85859411U, 290 0x4545cf8aU, 0xf9f910e9U, 0x02020604U, 0x7f7f81feU, 291 0x5050f0a0U, 0x3c3c4478U, 0x9f9fba25U, 0xa8a8e34bU, 292 0x5151f3a2U, 0xa3a3fe5dU, 0x4040c080U, 0x8f8f8a05U, 293 0x9292ad3fU, 0x9d9dbc21U, 0x38384870U, 0xf5f504f1U, 294 0xbcbcdf63U, 0xb6b6c177U, 0xdada75afU, 0x21216342U, 295 0x10103020U, 0xffff1ae5U, 0xf3f30efdU, 0xd2d26dbfU, 296 0xcdcd4c81U, 0x0c0c1418U, 0x13133526U, 0xecec2fc3U, 297 0x5f5fe1beU, 0x9797a235U, 0x4444cc88U, 0x1717392eU, 298 0xc4c45793U, 0xa7a7f255U, 0x7e7e82fcU, 0x3d3d477aU, 299 0x6464acc8U, 0x5d5de7baU, 0x19192b32U, 0x737395e6U, 300 0x6060a0c0U, 0x81819819U, 0x4f4fd19eU, 0xdcdc7fa3U, 301 0x22226644U, 0x2a2a7e54U, 0x9090ab3bU, 0x8888830bU, 302 0x4646ca8cU, 0xeeee29c7U, 0xb8b8d36bU, 0x14143c28U, 303 0xdede79a7U, 0x5e5ee2bcU, 0x0b0b1d16U, 0xdbdb76adU, 304 0xe0e03bdbU, 0x32325664U, 0x3a3a4e74U, 0x0a0a1e14U, 305 0x4949db92U, 0x06060a0cU, 0x24246c48U, 0x5c5ce4b8U, 306 0xc2c25d9fU, 0xd3d36ebdU, 0xacacef43U, 0x6262a6c4U, 307 0x9191a839U, 0x9595a431U, 0xe4e437d3U, 0x79798bf2U, 308 0xe7e732d5U, 0xc8c8438bU, 0x3737596eU, 0x6d6db7daU, 309 0x8d8d8c01U, 0xd5d564b1U, 0x4e4ed29cU, 0xa9a9e049U, 310 0x6c6cb4d8U, 0x5656faacU, 0xf4f407f3U, 0xeaea25cfU, 311 0x6565afcaU, 0x7a7a8ef4U, 0xaeaee947U, 0x08081810U, 312 0xbabad56fU, 0x787888f0U, 0x25256f4aU, 0x2e2e725cU, 313 0x1c1c2438U, 0xa6a6f157U, 0xb4b4c773U, 0xc6c65197U, 314 0xe8e823cbU, 0xdddd7ca1U, 0x74749ce8U, 0x1f1f213eU, 315 0x4b4bdd96U, 0xbdbddc61U, 0x8b8b860dU, 0x8a8a850fU, 316 0x707090e0U, 0x3e3e427cU, 0xb5b5c471U, 0x6666aaccU, 317 0x4848d890U, 0x03030506U, 0xf6f601f7U, 0x0e0e121cU, 318 0x6161a3c2U, 0x35355f6aU, 0x5757f9aeU, 0xb9b9d069U, 319 0x86869117U, 0xc1c15899U, 0x1d1d273aU, 0x9e9eb927U, 320 0xe1e138d9U, 0xf8f813ebU, 0x9898b32bU, 0x11113322U, 321 0x6969bbd2U, 0xd9d970a9U, 0x8e8e8907U, 0x9494a733U, 322 0x9b9bb62dU, 0x1e1e223cU, 0x87879215U, 0xe9e920c9U, 323 0xcece4987U, 0x5555ffaaU, 0x28287850U, 0xdfdf7aa5U, 324 0x8c8c8f03U, 0xa1a1f859U, 0x89898009U, 0x0d0d171aU, 325 0xbfbfda65U, 0xe6e631d7U, 0x4242c684U, 0x6868b8d0U, 326 0x4141c382U, 0x9999b029U, 0x2d2d775aU, 0x0f0f111eU, 327 0xb0b0cb7bU, 0x5454fca8U, 0xbbbbd66dU, 0x16163a2cU, 328 }; 329 static const u32 Te4[256] = { 330 0x63636363U, 0x7c7c7c7cU, 0x77777777U, 0x7b7b7b7bU, 331 0xf2f2f2f2U, 0x6b6b6b6bU, 0x6f6f6f6fU, 0xc5c5c5c5U, 332 0x30303030U, 0x01010101U, 0x67676767U, 0x2b2b2b2bU, 333 0xfefefefeU, 0xd7d7d7d7U, 0xababababU, 0x76767676U, 334 0xcacacacaU, 0x82828282U, 0xc9c9c9c9U, 0x7d7d7d7dU, 335 0xfafafafaU, 0x59595959U, 0x47474747U, 0xf0f0f0f0U, 336 0xadadadadU, 0xd4d4d4d4U, 0xa2a2a2a2U, 0xafafafafU, 337 0x9c9c9c9cU, 0xa4a4a4a4U, 0x72727272U, 0xc0c0c0c0U, 338 0xb7b7b7b7U, 0xfdfdfdfdU, 0x93939393U, 0x26262626U, 339 0x36363636U, 0x3f3f3f3fU, 0xf7f7f7f7U, 0xccccccccU, 340 0x34343434U, 0xa5a5a5a5U, 0xe5e5e5e5U, 0xf1f1f1f1U, 341 0x71717171U, 0xd8d8d8d8U, 0x31313131U, 0x15151515U, 342 0x04040404U, 0xc7c7c7c7U, 0x23232323U, 0xc3c3c3c3U, 343 0x18181818U, 0x96969696U, 0x05050505U, 0x9a9a9a9aU, 344 0x07070707U, 0x12121212U, 0x80808080U, 0xe2e2e2e2U, 345 0xebebebebU, 0x27272727U, 0xb2b2b2b2U, 0x75757575U, 346 0x09090909U, 0x83838383U, 0x2c2c2c2cU, 0x1a1a1a1aU, 347 0x1b1b1b1bU, 0x6e6e6e6eU, 0x5a5a5a5aU, 0xa0a0a0a0U, 348 0x52525252U, 0x3b3b3b3bU, 0xd6d6d6d6U, 0xb3b3b3b3U, 349 0x29292929U, 0xe3e3e3e3U, 0x2f2f2f2fU, 0x84848484U, 350 0x53535353U, 0xd1d1d1d1U, 0x00000000U, 0xededededU, 351 0x20202020U, 0xfcfcfcfcU, 0xb1b1b1b1U, 0x5b5b5b5bU, 352 0x6a6a6a6aU, 0xcbcbcbcbU, 0xbebebebeU, 0x39393939U, 353 0x4a4a4a4aU, 0x4c4c4c4cU, 0x58585858U, 0xcfcfcfcfU, 354 0xd0d0d0d0U, 0xefefefefU, 0xaaaaaaaaU, 0xfbfbfbfbU, 355 0x43434343U, 0x4d4d4d4dU, 0x33333333U, 0x85858585U, 356 0x45454545U, 0xf9f9f9f9U, 0x02020202U, 0x7f7f7f7fU, 357 0x50505050U, 0x3c3c3c3cU, 0x9f9f9f9fU, 0xa8a8a8a8U, 358 0x51515151U, 0xa3a3a3a3U, 0x40404040U, 0x8f8f8f8fU, 359 0x92929292U, 0x9d9d9d9dU, 0x38383838U, 0xf5f5f5f5U, 360 0xbcbcbcbcU, 0xb6b6b6b6U, 0xdadadadaU, 0x21212121U, 361 0x10101010U, 0xffffffffU, 0xf3f3f3f3U, 0xd2d2d2d2U, 362 0xcdcdcdcdU, 0x0c0c0c0cU, 0x13131313U, 0xececececU, 363 0x5f5f5f5fU, 0x97979797U, 0x44444444U, 0x17171717U, 364 0xc4c4c4c4U, 0xa7a7a7a7U, 0x7e7e7e7eU, 0x3d3d3d3dU, 365 0x64646464U, 0x5d5d5d5dU, 0x19191919U, 0x73737373U, 366 0x60606060U, 0x81818181U, 0x4f4f4f4fU, 0xdcdcdcdcU, 367 0x22222222U, 0x2a2a2a2aU, 0x90909090U, 0x88888888U, 368 0x46464646U, 0xeeeeeeeeU, 0xb8b8b8b8U, 0x14141414U, 369 0xdedededeU, 0x5e5e5e5eU, 0x0b0b0b0bU, 0xdbdbdbdbU, 370 0xe0e0e0e0U, 0x32323232U, 0x3a3a3a3aU, 0x0a0a0a0aU, 371 0x49494949U, 0x06060606U, 0x24242424U, 0x5c5c5c5cU, 372 0xc2c2c2c2U, 0xd3d3d3d3U, 0xacacacacU, 0x62626262U, 373 0x91919191U, 0x95959595U, 0xe4e4e4e4U, 0x79797979U, 374 0xe7e7e7e7U, 0xc8c8c8c8U, 0x37373737U, 0x6d6d6d6dU, 375 0x8d8d8d8dU, 0xd5d5d5d5U, 0x4e4e4e4eU, 0xa9a9a9a9U, 376 0x6c6c6c6cU, 0x56565656U, 0xf4f4f4f4U, 0xeaeaeaeaU, 377 0x65656565U, 0x7a7a7a7aU, 0xaeaeaeaeU, 0x08080808U, 378 0xbabababaU, 0x78787878U, 0x25252525U, 0x2e2e2e2eU, 379 0x1c1c1c1cU, 0xa6a6a6a6U, 0xb4b4b4b4U, 0xc6c6c6c6U, 380 0xe8e8e8e8U, 0xddddddddU, 0x74747474U, 0x1f1f1f1fU, 381 0x4b4b4b4bU, 0xbdbdbdbdU, 0x8b8b8b8bU, 0x8a8a8a8aU, 382 0x70707070U, 0x3e3e3e3eU, 0xb5b5b5b5U, 0x66666666U, 383 0x48484848U, 0x03030303U, 0xf6f6f6f6U, 0x0e0e0e0eU, 384 0x61616161U, 0x35353535U, 0x57575757U, 0xb9b9b9b9U, 385 0x86868686U, 0xc1c1c1c1U, 0x1d1d1d1dU, 0x9e9e9e9eU, 386 0xe1e1e1e1U, 0xf8f8f8f8U, 0x98989898U, 0x11111111U, 387 0x69696969U, 0xd9d9d9d9U, 0x8e8e8e8eU, 0x94949494U, 388 0x9b9b9b9bU, 0x1e1e1e1eU, 0x87878787U, 0xe9e9e9e9U, 389 0xcecececeU, 0x55555555U, 0x28282828U, 0xdfdfdfdfU, 390 0x8c8c8c8cU, 0xa1a1a1a1U, 0x89898989U, 0x0d0d0d0dU, 391 0xbfbfbfbfU, 0xe6e6e6e6U, 0x42424242U, 0x68686868U, 392 0x41414141U, 0x99999999U, 0x2d2d2d2dU, 0x0f0f0f0fU, 393 0xb0b0b0b0U, 0x54545454U, 0xbbbbbbbbU, 0x16161616U, 394 }; 395 static const u32 Td0[256] = { 396 0x51f4a750U, 0x7e416553U, 0x1a17a4c3U, 0x3a275e96U, 397 0x3bab6bcbU, 0x1f9d45f1U, 0xacfa58abU, 0x4be30393U, 398 0x2030fa55U, 0xad766df6U, 0x88cc7691U, 0xf5024c25U, 399 0x4fe5d7fcU, 0xc52acbd7U, 0x26354480U, 0xb562a38fU, 400 0xdeb15a49U, 0x25ba1b67U, 0x45ea0e98U, 0x5dfec0e1U, 401 0xc32f7502U, 0x814cf012U, 0x8d4697a3U, 0x6bd3f9c6U, 402 0x038f5fe7U, 0x15929c95U, 0xbf6d7aebU, 0x955259daU, 403 0xd4be832dU, 0x587421d3U, 0x49e06929U, 0x8ec9c844U, 404 0x75c2896aU, 0xf48e7978U, 0x99583e6bU, 0x27b971ddU, 405 0xbee14fb6U, 0xf088ad17U, 0xc920ac66U, 0x7dce3ab4U, 406 0x63df4a18U, 0xe51a3182U, 0x97513360U, 0x62537f45U, 407 0xb16477e0U, 0xbb6bae84U, 0xfe81a01cU, 0xf9082b94U, 408 0x70486858U, 0x8f45fd19U, 0x94de6c87U, 0x527bf8b7U, 409 0xab73d323U, 0x724b02e2U, 0xe31f8f57U, 0x6655ab2aU, 410 0xb2eb2807U, 0x2fb5c203U, 0x86c57b9aU, 0xd33708a5U, 411 0x302887f2U, 0x23bfa5b2U, 0x02036abaU, 0xed16825cU, 412 0x8acf1c2bU, 0xa779b492U, 0xf307f2f0U, 0x4e69e2a1U, 413 0x65daf4cdU, 0x0605bed5U, 0xd134621fU, 0xc4a6fe8aU, 414 0x342e539dU, 0xa2f355a0U, 0x058ae132U, 0xa4f6eb75U, 415 0x0b83ec39U, 0x4060efaaU, 0x5e719f06U, 0xbd6e1051U, 416 0x3e218af9U, 0x96dd063dU, 0xdd3e05aeU, 0x4de6bd46U, 417 0x91548db5U, 0x71c45d05U, 0x0406d46fU, 0x605015ffU, 418 0x1998fb24U, 0xd6bde997U, 0x894043ccU, 0x67d99e77U, 419 0xb0e842bdU, 0x07898b88U, 0xe7195b38U, 0x79c8eedbU, 420 0xa17c0a47U, 0x7c420fe9U, 0xf8841ec9U, 0x00000000U, 421 0x09808683U, 0x322bed48U, 0x1e1170acU, 0x6c5a724eU, 422 0xfd0efffbU, 0x0f853856U, 0x3daed51eU, 0x362d3927U, 423 0x0a0fd964U, 0x685ca621U, 0x9b5b54d1U, 0x24362e3aU, 424 0x0c0a67b1U, 0x9357e70fU, 0xb4ee96d2U, 0x1b9b919eU, 425 0x80c0c54fU, 0x61dc20a2U, 0x5a774b69U, 0x1c121a16U, 426 0xe293ba0aU, 0xc0a02ae5U, 0x3c22e043U, 0x121b171dU, 427 0x0e090d0bU, 0xf28bc7adU, 0x2db6a8b9U, 0x141ea9c8U, 428 0x57f11985U, 0xaf75074cU, 0xee99ddbbU, 0xa37f60fdU, 429 0xf701269fU, 0x5c72f5bcU, 0x44663bc5U, 0x5bfb7e34U, 430 0x8b432976U, 0xcb23c6dcU, 0xb6edfc68U, 0xb8e4f163U, 431 0xd731dccaU, 0x42638510U, 0x13972240U, 0x84c61120U, 432 0x854a247dU, 0xd2bb3df8U, 0xaef93211U, 0xc729a16dU, 433 0x1d9e2f4bU, 0xdcb230f3U, 0x0d8652ecU, 0x77c1e3d0U, 434 0x2bb3166cU, 0xa970b999U, 0x119448faU, 0x47e96422U, 435 0xa8fc8cc4U, 0xa0f03f1aU, 0x567d2cd8U, 0x223390efU, 436 0x87494ec7U, 0xd938d1c1U, 0x8ccaa2feU, 0x98d40b36U, 437 0xa6f581cfU, 0xa57ade28U, 0xdab78e26U, 0x3fadbfa4U, 438 0x2c3a9de4U, 0x5078920dU, 0x6a5fcc9bU, 0x547e4662U, 439 0xf68d13c2U, 0x90d8b8e8U, 0x2e39f75eU, 0x82c3aff5U, 440 0x9f5d80beU, 0x69d0937cU, 0x6fd52da9U, 0xcf2512b3U, 441 0xc8ac993bU, 0x10187da7U, 0xe89c636eU, 0xdb3bbb7bU, 442 0xcd267809U, 0x6e5918f4U, 0xec9ab701U, 0x834f9aa8U, 443 0xe6956e65U, 0xaaffe67eU, 0x21bccf08U, 0xef15e8e6U, 444 0xbae79bd9U, 0x4a6f36ceU, 0xea9f09d4U, 0x29b07cd6U, 445 0x31a4b2afU, 0x2a3f2331U, 0xc6a59430U, 0x35a266c0U, 446 0x744ebc37U, 0xfc82caa6U, 0xe090d0b0U, 0x33a7d815U, 447 0xf104984aU, 0x41ecdaf7U, 0x7fcd500eU, 0x1791f62fU, 448 0x764dd68dU, 0x43efb04dU, 0xccaa4d54U, 0xe49604dfU, 449 0x9ed1b5e3U, 0x4c6a881bU, 0xc12c1fb8U, 0x4665517fU, 450 0x9d5eea04U, 0x018c355dU, 0xfa877473U, 0xfb0b412eU, 451 0xb3671d5aU, 0x92dbd252U, 0xe9105633U, 0x6dd64713U, 452 0x9ad7618cU, 0x37a10c7aU, 0x59f8148eU, 0xeb133c89U, 453 0xcea927eeU, 0xb761c935U, 0xe11ce5edU, 0x7a47b13cU, 454 0x9cd2df59U, 0x55f2733fU, 0x1814ce79U, 0x73c737bfU, 455 0x53f7cdeaU, 0x5ffdaa5bU, 0xdf3d6f14U, 0x7844db86U, 456 0xcaaff381U, 0xb968c43eU, 0x3824342cU, 0xc2a3405fU, 457 0x161dc372U, 0xbce2250cU, 0x283c498bU, 0xff0d9541U, 458 0x39a80171U, 0x080cb3deU, 0xd8b4e49cU, 0x6456c190U, 459 0x7bcb8461U, 0xd532b670U, 0x486c5c74U, 0xd0b85742U, 460 }; 461 static const u32 Td1[256] = { 462 0x5051f4a7U, 0x537e4165U, 0xc31a17a4U, 0x963a275eU, 463 0xcb3bab6bU, 0xf11f9d45U, 0xabacfa58U, 0x934be303U, 464 0x552030faU, 0xf6ad766dU, 0x9188cc76U, 0x25f5024cU, 465 0xfc4fe5d7U, 0xd7c52acbU, 0x80263544U, 0x8fb562a3U, 466 0x49deb15aU, 0x6725ba1bU, 0x9845ea0eU, 0xe15dfec0U, 467 0x02c32f75U, 0x12814cf0U, 0xa38d4697U, 0xc66bd3f9U, 468 0xe7038f5fU, 0x9515929cU, 0xebbf6d7aU, 0xda955259U, 469 0x2dd4be83U, 0xd3587421U, 0x2949e069U, 0x448ec9c8U, 470 0x6a75c289U, 0x78f48e79U, 0x6b99583eU, 0xdd27b971U, 471 0xb6bee14fU, 0x17f088adU, 0x66c920acU, 0xb47dce3aU, 472 0x1863df4aU, 0x82e51a31U, 0x60975133U, 0x4562537fU, 473 0xe0b16477U, 0x84bb6baeU, 0x1cfe81a0U, 0x94f9082bU, 474 0x58704868U, 0x198f45fdU, 0x8794de6cU, 0xb7527bf8U, 475 0x23ab73d3U, 0xe2724b02U, 0x57e31f8fU, 0x2a6655abU, 476 0x07b2eb28U, 0x032fb5c2U, 0x9a86c57bU, 0xa5d33708U, 477 0xf2302887U, 0xb223bfa5U, 0xba02036aU, 0x5ced1682U, 478 0x2b8acf1cU, 0x92a779b4U, 0xf0f307f2U, 0xa14e69e2U, 479 0xcd65daf4U, 0xd50605beU, 0x1fd13462U, 0x8ac4a6feU, 480 0x9d342e53U, 0xa0a2f355U, 0x32058ae1U, 0x75a4f6ebU, 481 0x390b83ecU, 0xaa4060efU, 0x065e719fU, 0x51bd6e10U, 482 0xf93e218aU, 0x3d96dd06U, 0xaedd3e05U, 0x464de6bdU, 483 0xb591548dU, 0x0571c45dU, 0x6f0406d4U, 0xff605015U, 484 0x241998fbU, 0x97d6bde9U, 0xcc894043U, 0x7767d99eU, 485 0xbdb0e842U, 0x8807898bU, 0x38e7195bU, 0xdb79c8eeU, 486 0x47a17c0aU, 0xe97c420fU, 0xc9f8841eU, 0x00000000U, 487 0x83098086U, 0x48322bedU, 0xac1e1170U, 0x4e6c5a72U, 488 0xfbfd0effU, 0x560f8538U, 0x1e3daed5U, 0x27362d39U, 489 0x640a0fd9U, 0x21685ca6U, 0xd19b5b54U, 0x3a24362eU, 490 0xb10c0a67U, 0x0f9357e7U, 0xd2b4ee96U, 0x9e1b9b91U, 491 0x4f80c0c5U, 0xa261dc20U, 0x695a774bU, 0x161c121aU, 492 0x0ae293baU, 0xe5c0a02aU, 0x433c22e0U, 0x1d121b17U, 493 0x0b0e090dU, 0xadf28bc7U, 0xb92db6a8U, 0xc8141ea9U, 494 0x8557f119U, 0x4caf7507U, 0xbbee99ddU, 0xfda37f60U, 495 0x9ff70126U, 0xbc5c72f5U, 0xc544663bU, 0x345bfb7eU, 496 0x768b4329U, 0xdccb23c6U, 0x68b6edfcU, 0x63b8e4f1U, 497 0xcad731dcU, 0x10426385U, 0x40139722U, 0x2084c611U, 498 0x7d854a24U, 0xf8d2bb3dU, 0x11aef932U, 0x6dc729a1U, 499 0x4b1d9e2fU, 0xf3dcb230U, 0xec0d8652U, 0xd077c1e3U, 500 0x6c2bb316U, 0x99a970b9U, 0xfa119448U, 0x2247e964U, 501 0xc4a8fc8cU, 0x1aa0f03fU, 0xd8567d2cU, 0xef223390U, 502 0xc787494eU, 0xc1d938d1U, 0xfe8ccaa2U, 0x3698d40bU, 503 0xcfa6f581U, 0x28a57adeU, 0x26dab78eU, 0xa43fadbfU, 504 0xe42c3a9dU, 0x0d507892U, 0x9b6a5fccU, 0x62547e46U, 505 0xc2f68d13U, 0xe890d8b8U, 0x5e2e39f7U, 0xf582c3afU, 506 0xbe9f5d80U, 0x7c69d093U, 0xa96fd52dU, 0xb3cf2512U, 507 0x3bc8ac99U, 0xa710187dU, 0x6ee89c63U, 0x7bdb3bbbU, 508 0x09cd2678U, 0xf46e5918U, 0x01ec9ab7U, 0xa8834f9aU, 509 0x65e6956eU, 0x7eaaffe6U, 0x0821bccfU, 0xe6ef15e8U, 510 0xd9bae79bU, 0xce4a6f36U, 0xd4ea9f09U, 0xd629b07cU, 511 0xaf31a4b2U, 0x312a3f23U, 0x30c6a594U, 0xc035a266U, 512 0x37744ebcU, 0xa6fc82caU, 0xb0e090d0U, 0x1533a7d8U, 513 0x4af10498U, 0xf741ecdaU, 0x0e7fcd50U, 0x2f1791f6U, 514 0x8d764dd6U, 0x4d43efb0U, 0x54ccaa4dU, 0xdfe49604U, 515 0xe39ed1b5U, 0x1b4c6a88U, 0xb8c12c1fU, 0x7f466551U, 516 0x049d5eeaU, 0x5d018c35U, 0x73fa8774U, 0x2efb0b41U, 517 0x5ab3671dU, 0x5292dbd2U, 0x33e91056U, 0x136dd647U, 518 0x8c9ad761U, 0x7a37a10cU, 0x8e59f814U, 0x89eb133cU, 519 0xeecea927U, 0x35b761c9U, 0xede11ce5U, 0x3c7a47b1U, 520 0x599cd2dfU, 0x3f55f273U, 0x791814ceU, 0xbf73c737U, 521 0xea53f7cdU, 0x5b5ffdaaU, 0x14df3d6fU, 0x867844dbU, 522 0x81caaff3U, 0x3eb968c4U, 0x2c382434U, 0x5fc2a340U, 523 0x72161dc3U, 0x0cbce225U, 0x8b283c49U, 0x41ff0d95U, 524 0x7139a801U, 0xde080cb3U, 0x9cd8b4e4U, 0x906456c1U, 525 0x617bcb84U, 0x70d532b6U, 0x74486c5cU, 0x42d0b857U, 526 }; 527 static const u32 Td2[256] = { 528 0xa75051f4U, 0x65537e41U, 0xa4c31a17U, 0x5e963a27U, 529 0x6bcb3babU, 0x45f11f9dU, 0x58abacfaU, 0x03934be3U, 530 0xfa552030U, 0x6df6ad76U, 0x769188ccU, 0x4c25f502U, 531 0xd7fc4fe5U, 0xcbd7c52aU, 0x44802635U, 0xa38fb562U, 532 0x5a49deb1U, 0x1b6725baU, 0x0e9845eaU, 0xc0e15dfeU, 533 0x7502c32fU, 0xf012814cU, 0x97a38d46U, 0xf9c66bd3U, 534 0x5fe7038fU, 0x9c951592U, 0x7aebbf6dU, 0x59da9552U, 535 0x832dd4beU, 0x21d35874U, 0x692949e0U, 0xc8448ec9U, 536 0x896a75c2U, 0x7978f48eU, 0x3e6b9958U, 0x71dd27b9U, 537 0x4fb6bee1U, 0xad17f088U, 0xac66c920U, 0x3ab47dceU, 538 0x4a1863dfU, 0x3182e51aU, 0x33609751U, 0x7f456253U, 539 0x77e0b164U, 0xae84bb6bU, 0xa01cfe81U, 0x2b94f908U, 540 0x68587048U, 0xfd198f45U, 0x6c8794deU, 0xf8b7527bU, 541 0xd323ab73U, 0x02e2724bU, 0x8f57e31fU, 0xab2a6655U, 542 0x2807b2ebU, 0xc2032fb5U, 0x7b9a86c5U, 0x08a5d337U, 543 0x87f23028U, 0xa5b223bfU, 0x6aba0203U, 0x825ced16U, 544 0x1c2b8acfU, 0xb492a779U, 0xf2f0f307U, 0xe2a14e69U, 545 0xf4cd65daU, 0xbed50605U, 0x621fd134U, 0xfe8ac4a6U, 546 0x539d342eU, 0x55a0a2f3U, 0xe132058aU, 0xeb75a4f6U, 547 0xec390b83U, 0xefaa4060U, 0x9f065e71U, 0x1051bd6eU, 548 549 0x8af93e21U, 0x063d96ddU, 0x05aedd3eU, 0xbd464de6U, 550 0x8db59154U, 0x5d0571c4U, 0xd46f0406U, 0x15ff6050U, 551 0xfb241998U, 0xe997d6bdU, 0x43cc8940U, 0x9e7767d9U, 552 0x42bdb0e8U, 0x8b880789U, 0x5b38e719U, 0xeedb79c8U, 553 0x0a47a17cU, 0x0fe97c42U, 0x1ec9f884U, 0x00000000U, 554 0x86830980U, 0xed48322bU, 0x70ac1e11U, 0x724e6c5aU, 555 0xfffbfd0eU, 0x38560f85U, 0xd51e3daeU, 0x3927362dU, 556 0xd9640a0fU, 0xa621685cU, 0x54d19b5bU, 0x2e3a2436U, 557 0x67b10c0aU, 0xe70f9357U, 0x96d2b4eeU, 0x919e1b9bU, 558 0xc54f80c0U, 0x20a261dcU, 0x4b695a77U, 0x1a161c12U, 559 0xba0ae293U, 0x2ae5c0a0U, 0xe0433c22U, 0x171d121bU, 560 0x0d0b0e09U, 0xc7adf28bU, 0xa8b92db6U, 0xa9c8141eU, 561 0x198557f1U, 0x074caf75U, 0xddbbee99U, 0x60fda37fU, 562 0x269ff701U, 0xf5bc5c72U, 0x3bc54466U, 0x7e345bfbU, 563 0x29768b43U, 0xc6dccb23U, 0xfc68b6edU, 0xf163b8e4U, 564 0xdccad731U, 0x85104263U, 0x22401397U, 0x112084c6U, 565 0x247d854aU, 0x3df8d2bbU, 0x3211aef9U, 0xa16dc729U, 566 0x2f4b1d9eU, 0x30f3dcb2U, 0x52ec0d86U, 0xe3d077c1U, 567 0x166c2bb3U, 0xb999a970U, 0x48fa1194U, 0x642247e9U, 568 0x8cc4a8fcU, 0x3f1aa0f0U, 0x2cd8567dU, 0x90ef2233U, 569 0x4ec78749U, 0xd1c1d938U, 0xa2fe8ccaU, 0x0b3698d4U, 570 0x81cfa6f5U, 0xde28a57aU, 0x8e26dab7U, 0xbfa43fadU, 571 0x9de42c3aU, 0x920d5078U, 0xcc9b6a5fU, 0x4662547eU, 572 0x13c2f68dU, 0xb8e890d8U, 0xf75e2e39U, 0xaff582c3U, 573 0x80be9f5dU, 0x937c69d0U, 0x2da96fd5U, 0x12b3cf25U, 574 0x993bc8acU, 0x7da71018U, 0x636ee89cU, 0xbb7bdb3bU, 575 0x7809cd26U, 0x18f46e59U, 0xb701ec9aU, 0x9aa8834fU, 576 0x6e65e695U, 0xe67eaaffU, 0xcf0821bcU, 0xe8e6ef15U, 577 0x9bd9bae7U, 0x36ce4a6fU, 0x09d4ea9fU, 0x7cd629b0U, 578 0xb2af31a4U, 0x23312a3fU, 0x9430c6a5U, 0x66c035a2U, 579 0xbc37744eU, 0xcaa6fc82U, 0xd0b0e090U, 0xd81533a7U, 580 0x984af104U, 0xdaf741ecU, 0x500e7fcdU, 0xf62f1791U, 581 0xd68d764dU, 0xb04d43efU, 0x4d54ccaaU, 0x04dfe496U, 582 0xb5e39ed1U, 0x881b4c6aU, 0x1fb8c12cU, 0x517f4665U, 583 0xea049d5eU, 0x355d018cU, 0x7473fa87U, 0x412efb0bU, 584 0x1d5ab367U, 0xd25292dbU, 0x5633e910U, 0x47136dd6U, 585 0x618c9ad7U, 0x0c7a37a1U, 0x148e59f8U, 0x3c89eb13U, 586 0x27eecea9U, 0xc935b761U, 0xe5ede11cU, 0xb13c7a47U, 587 0xdf599cd2U, 0x733f55f2U, 0xce791814U, 0x37bf73c7U, 588 0xcdea53f7U, 0xaa5b5ffdU, 0x6f14df3dU, 0xdb867844U, 589 0xf381caafU, 0xc43eb968U, 0x342c3824U, 0x405fc2a3U, 590 0xc372161dU, 0x250cbce2U, 0x498b283cU, 0x9541ff0dU, 591 0x017139a8U, 0xb3de080cU, 0xe49cd8b4U, 0xc1906456U, 592 0x84617bcbU, 0xb670d532U, 0x5c74486cU, 0x5742d0b8U, 593 }; 594 static const u32 Td3[256] = { 595 0xf4a75051U, 0x4165537eU, 0x17a4c31aU, 0x275e963aU, 596 0xab6bcb3bU, 0x9d45f11fU, 0xfa58abacU, 0xe303934bU, 597 0x30fa5520U, 0x766df6adU, 0xcc769188U, 0x024c25f5U, 598 0xe5d7fc4fU, 0x2acbd7c5U, 0x35448026U, 0x62a38fb5U, 599 0xb15a49deU, 0xba1b6725U, 0xea0e9845U, 0xfec0e15dU, 600 0x2f7502c3U, 0x4cf01281U, 0x4697a38dU, 0xd3f9c66bU, 601 0x8f5fe703U, 0x929c9515U, 0x6d7aebbfU, 0x5259da95U, 602 0xbe832dd4U, 0x7421d358U, 0xe0692949U, 0xc9c8448eU, 603 0xc2896a75U, 0x8e7978f4U, 0x583e6b99U, 0xb971dd27U, 604 0xe14fb6beU, 0x88ad17f0U, 0x20ac66c9U, 0xce3ab47dU, 605 0xdf4a1863U, 0x1a3182e5U, 0x51336097U, 0x537f4562U, 606 0x6477e0b1U, 0x6bae84bbU, 0x81a01cfeU, 0x082b94f9U, 607 0x48685870U, 0x45fd198fU, 0xde6c8794U, 0x7bf8b752U, 608 0x73d323abU, 0x4b02e272U, 0x1f8f57e3U, 0x55ab2a66U, 609 0xeb2807b2U, 0xb5c2032fU, 0xc57b9a86U, 0x3708a5d3U, 610 0x2887f230U, 0xbfa5b223U, 0x036aba02U, 0x16825cedU, 611 0xcf1c2b8aU, 0x79b492a7U, 0x07f2f0f3U, 0x69e2a14eU, 612 0xdaf4cd65U, 0x05bed506U, 0x34621fd1U, 0xa6fe8ac4U, 613 0x2e539d34U, 0xf355a0a2U, 0x8ae13205U, 0xf6eb75a4U, 614 0x83ec390bU, 0x60efaa40U, 0x719f065eU, 0x6e1051bdU, 615 0x218af93eU, 0xdd063d96U, 0x3e05aeddU, 0xe6bd464dU, 616 0x548db591U, 0xc45d0571U, 0x06d46f04U, 0x5015ff60U, 617 0x98fb2419U, 0xbde997d6U, 0x4043cc89U, 0xd99e7767U, 618 0xe842bdb0U, 0x898b8807U, 0x195b38e7U, 0xc8eedb79U, 619 0x7c0a47a1U, 0x420fe97cU, 0x841ec9f8U, 0x00000000U, 620 0x80868309U, 0x2bed4832U, 0x1170ac1eU, 0x5a724e6cU, 621 0x0efffbfdU, 0x8538560fU, 0xaed51e3dU, 0x2d392736U, 622 0x0fd9640aU, 0x5ca62168U, 0x5b54d19bU, 0x362e3a24U, 623 0x0a67b10cU, 0x57e70f93U, 0xee96d2b4U, 0x9b919e1bU, 624 0xc0c54f80U, 0xdc20a261U, 0x774b695aU, 0x121a161cU, 625 0x93ba0ae2U, 0xa02ae5c0U, 0x22e0433cU, 0x1b171d12U, 626 0x090d0b0eU, 0x8bc7adf2U, 0xb6a8b92dU, 0x1ea9c814U, 627 0xf1198557U, 0x75074cafU, 0x99ddbbeeU, 0x7f60fda3U, 628 0x01269ff7U, 0x72f5bc5cU, 0x663bc544U, 0xfb7e345bU, 629 0x4329768bU, 0x23c6dccbU, 0xedfc68b6U, 0xe4f163b8U, 630 0x31dccad7U, 0x63851042U, 0x97224013U, 0xc6112084U, 631 0x4a247d85U, 0xbb3df8d2U, 0xf93211aeU, 0x29a16dc7U, 632 0x9e2f4b1dU, 0xb230f3dcU, 0x8652ec0dU, 0xc1e3d077U, 633 0xb3166c2bU, 0x70b999a9U, 0x9448fa11U, 0xe9642247U, 634 0xfc8cc4a8U, 0xf03f1aa0U, 0x7d2cd856U, 0x3390ef22U, 635 0x494ec787U, 0x38d1c1d9U, 0xcaa2fe8cU, 0xd40b3698U, 636 0xf581cfa6U, 0x7ade28a5U, 0xb78e26daU, 0xadbfa43fU, 637 0x3a9de42cU, 0x78920d50U, 0x5fcc9b6aU, 0x7e466254U, 638 0x8d13c2f6U, 0xd8b8e890U, 0x39f75e2eU, 0xc3aff582U, 639 0x5d80be9fU, 0xd0937c69U, 0xd52da96fU, 0x2512b3cfU, 640 0xac993bc8U, 0x187da710U, 0x9c636ee8U, 0x3bbb7bdbU, 641 0x267809cdU, 0x5918f46eU, 0x9ab701ecU, 0x4f9aa883U, 642 0x956e65e6U, 0xffe67eaaU, 0xbccf0821U, 0x15e8e6efU, 643 0xe79bd9baU, 0x6f36ce4aU, 0x9f09d4eaU, 0xb07cd629U, 644 0xa4b2af31U, 0x3f23312aU, 0xa59430c6U, 0xa266c035U, 645 0x4ebc3774U, 0x82caa6fcU, 0x90d0b0e0U, 0xa7d81533U, 646 0x04984af1U, 0xecdaf741U, 0xcd500e7fU, 0x91f62f17U, 647 0x4dd68d76U, 0xefb04d43U, 0xaa4d54ccU, 0x9604dfe4U, 648 0xd1b5e39eU, 0x6a881b4cU, 0x2c1fb8c1U, 0x65517f46U, 649 0x5eea049dU, 0x8c355d01U, 0x877473faU, 0x0b412efbU, 650 0x671d5ab3U, 0xdbd25292U, 0x105633e9U, 0xd647136dU, 651 0xd7618c9aU, 0xa10c7a37U, 0xf8148e59U, 0x133c89ebU, 652 0xa927eeceU, 0x61c935b7U, 0x1ce5ede1U, 0x47b13c7aU, 653 0xd2df599cU, 0xf2733f55U, 0x14ce7918U, 0xc737bf73U, 654 0xf7cdea53U, 0xfdaa5b5fU, 0x3d6f14dfU, 0x44db8678U, 655 0xaff381caU, 0x68c43eb9U, 0x24342c38U, 0xa3405fc2U, 656 0x1dc37216U, 0xe2250cbcU, 0x3c498b28U, 0x0d9541ffU, 657 0xa8017139U, 0x0cb3de08U, 0xb4e49cd8U, 0x56c19064U, 658 0xcb84617bU, 0x32b670d5U, 0x6c5c7448U, 0xb85742d0U, 659 }; 660 static const u32 Td4[256] = { 661 0x52525252U, 0x09090909U, 0x6a6a6a6aU, 0xd5d5d5d5U, 662 0x30303030U, 0x36363636U, 0xa5a5a5a5U, 0x38383838U, 663 0xbfbfbfbfU, 0x40404040U, 0xa3a3a3a3U, 0x9e9e9e9eU, 664 0x81818181U, 0xf3f3f3f3U, 0xd7d7d7d7U, 0xfbfbfbfbU, 665 0x7c7c7c7cU, 0xe3e3e3e3U, 0x39393939U, 0x82828282U, 666 0x9b9b9b9bU, 0x2f2f2f2fU, 0xffffffffU, 0x87878787U, 667 0x34343434U, 0x8e8e8e8eU, 0x43434343U, 0x44444444U, 668 0xc4c4c4c4U, 0xdedededeU, 0xe9e9e9e9U, 0xcbcbcbcbU, 669 0x54545454U, 0x7b7b7b7bU, 0x94949494U, 0x32323232U, 670 0xa6a6a6a6U, 0xc2c2c2c2U, 0x23232323U, 0x3d3d3d3dU, 671 0xeeeeeeeeU, 0x4c4c4c4cU, 0x95959595U, 0x0b0b0b0bU, 672 0x42424242U, 0xfafafafaU, 0xc3c3c3c3U, 0x4e4e4e4eU, 673 0x08080808U, 0x2e2e2e2eU, 0xa1a1a1a1U, 0x66666666U, 674 0x28282828U, 0xd9d9d9d9U, 0x24242424U, 0xb2b2b2b2U, 675 0x76767676U, 0x5b5b5b5bU, 0xa2a2a2a2U, 0x49494949U, 676 0x6d6d6d6dU, 0x8b8b8b8bU, 0xd1d1d1d1U, 0x25252525U, 677 0x72727272U, 0xf8f8f8f8U, 0xf6f6f6f6U, 0x64646464U, 678 0x86868686U, 0x68686868U, 0x98989898U, 0x16161616U, 679 0xd4d4d4d4U, 0xa4a4a4a4U, 0x5c5c5c5cU, 0xccccccccU, 680 0x5d5d5d5dU, 0x65656565U, 0xb6b6b6b6U, 0x92929292U, 681 0x6c6c6c6cU, 0x70707070U, 0x48484848U, 0x50505050U, 682 0xfdfdfdfdU, 0xededededU, 0xb9b9b9b9U, 0xdadadadaU, 683 0x5e5e5e5eU, 0x15151515U, 0x46464646U, 0x57575757U, 684 0xa7a7a7a7U, 0x8d8d8d8dU, 0x9d9d9d9dU, 0x84848484U, 685 0x90909090U, 0xd8d8d8d8U, 0xababababU, 0x00000000U, 686 0x8c8c8c8cU, 0xbcbcbcbcU, 0xd3d3d3d3U, 0x0a0a0a0aU, 687 0xf7f7f7f7U, 0xe4e4e4e4U, 0x58585858U, 0x05050505U, 688 0xb8b8b8b8U, 0xb3b3b3b3U, 0x45454545U, 0x06060606U, 689 0xd0d0d0d0U, 0x2c2c2c2cU, 0x1e1e1e1eU, 0x8f8f8f8fU, 690 0xcacacacaU, 0x3f3f3f3fU, 0x0f0f0f0fU, 0x02020202U, 691 0xc1c1c1c1U, 0xafafafafU, 0xbdbdbdbdU, 0x03030303U, 692 0x01010101U, 0x13131313U, 0x8a8a8a8aU, 0x6b6b6b6bU, 693 0x3a3a3a3aU, 0x91919191U, 0x11111111U, 0x41414141U, 694 0x4f4f4f4fU, 0x67676767U, 0xdcdcdcdcU, 0xeaeaeaeaU, 695 0x97979797U, 0xf2f2f2f2U, 0xcfcfcfcfU, 0xcecececeU, 696 0xf0f0f0f0U, 0xb4b4b4b4U, 0xe6e6e6e6U, 0x73737373U, 697 0x96969696U, 0xacacacacU, 0x74747474U, 0x22222222U, 698 0xe7e7e7e7U, 0xadadadadU, 0x35353535U, 0x85858585U, 699 0xe2e2e2e2U, 0xf9f9f9f9U, 0x37373737U, 0xe8e8e8e8U, 700 0x1c1c1c1cU, 0x75757575U, 0xdfdfdfdfU, 0x6e6e6e6eU, 701 0x47474747U, 0xf1f1f1f1U, 0x1a1a1a1aU, 0x71717171U, 702 0x1d1d1d1dU, 0x29292929U, 0xc5c5c5c5U, 0x89898989U, 703 0x6f6f6f6fU, 0xb7b7b7b7U, 0x62626262U, 0x0e0e0e0eU, 704 0xaaaaaaaaU, 0x18181818U, 0xbebebebeU, 0x1b1b1b1bU, 705 0xfcfcfcfcU, 0x56565656U, 0x3e3e3e3eU, 0x4b4b4b4bU, 706 0xc6c6c6c6U, 0xd2d2d2d2U, 0x79797979U, 0x20202020U, 707 0x9a9a9a9aU, 0xdbdbdbdbU, 0xc0c0c0c0U, 0xfefefefeU, 708 0x78787878U, 0xcdcdcdcdU, 0x5a5a5a5aU, 0xf4f4f4f4U, 709 0x1f1f1f1fU, 0xddddddddU, 0xa8a8a8a8U, 0x33333333U, 710 0x88888888U, 0x07070707U, 0xc7c7c7c7U, 0x31313131U, 711 0xb1b1b1b1U, 0x12121212U, 0x10101010U, 0x59595959U, 712 0x27272727U, 0x80808080U, 0xececececU, 0x5f5f5f5fU, 713 0x60606060U, 0x51515151U, 0x7f7f7f7fU, 0xa9a9a9a9U, 714 0x19191919U, 0xb5b5b5b5U, 0x4a4a4a4aU, 0x0d0d0d0dU, 715 0x2d2d2d2dU, 0xe5e5e5e5U, 0x7a7a7a7aU, 0x9f9f9f9fU, 716 0x93939393U, 0xc9c9c9c9U, 0x9c9c9c9cU, 0xefefefefU, 717 0xa0a0a0a0U, 0xe0e0e0e0U, 0x3b3b3b3bU, 0x4d4d4d4dU, 718 0xaeaeaeaeU, 0x2a2a2a2aU, 0xf5f5f5f5U, 0xb0b0b0b0U, 719 0xc8c8c8c8U, 0xebebebebU, 0xbbbbbbbbU, 0x3c3c3c3cU, 720 0x83838383U, 0x53535353U, 0x99999999U, 0x61616161U, 721 0x17171717U, 0x2b2b2b2bU, 0x04040404U, 0x7e7e7e7eU, 722 0xbabababaU, 0x77777777U, 0xd6d6d6d6U, 0x26262626U, 723 0xe1e1e1e1U, 0x69696969U, 0x14141414U, 0x63636363U, 724 0x55555555U, 0x21212121U, 0x0c0c0c0cU, 0x7d7d7d7dU, 725 }; 726 static const u32 rcon[] = { 727 0x01000000, 0x02000000, 0x04000000, 0x08000000, 728 0x10000000, 0x20000000, 0x40000000, 0x80000000, 729 0x1B000000, 0x36000000, /* for 128-bit blocks, Rijndael never uses more than 10 rcon values */ 730 }; 731 732 733 #ifdef _MSC_VER 734 #define SWAP(x) (_lrotl(x, 8) & 0x00ff00ff | _lrotr(x, 8) & 0xff00ff00) 735 #define GETU32(p) SWAP(*((u32 *)(p))) 736 #define PUTU32(ct, st) { *((u32 *)(ct)) = SWAP((st)); } 737 #else 738 #define GETU32(pt) (((u32)(pt)[0] << 24) ^ ((u32)(pt)[1] << 16) ^ ((u32)(pt)[2] << 8) ^ ((u32)(pt)[3])) 739 #define PUTU32(ct, st) { (ct)[0] = (u8)((st) >> 24); (ct)[1] = (u8)((st) >> 16); (ct)[2] = (u8)((st) >> 8); (ct)[3] = (u8)(st); } 740 #endif 741 742 /** 743 * Expand the cipher key into the encryption key schedule. 3 744 * 4 * Optimised ANSI C code 5 * 6 * authors: v1.0: Antoon Bosselaers 7 * v2.0: Vincent Rijmen 8 * v2.3: Paulo Barreto 9 * 10 * This code is placed in the public domain. 745 * @return the number of rounds for the given cipher key size. 11 746 */ 12 13 #include "config_xor.h" 14 15 #include <stdio.h> 16 #include <stdlib.h> 17 #include <string.h> 18 19 #ifdef SH_ENCRYPT 20 21 #include "rijndael-alg-fst.h" 22 23 #include "rijndael-boxes-fst.h" 24 25 #if defined(GCC_VERSION_MAJOR) 26 #if (GCC_VERSION_MAJOR > 4) || ((GCC_VERSION_MAJOR == 4) && (GCC_VERSION_MINOR > 4)) 27 #pragma GCC diagnostic ignored "-Wstrict-aliasing" 28 #endif 29 #endif 30 31 int rijndaelKeySched(word8 k[MAXKC][4], word8 W[MAXROUNDS+1][4][4], int ROUNDS) { 32 /* Calculate the necessary round keys 33 * The number of calculations depends on keyBits and blockBits 34 */ 35 int j, r, t, rconpointer = 0; 36 word8 tk[MAXKC][4] = { { 0 } }; /* init for llvm/clang analyzer */ 37 int KC = ROUNDS - 6; 38 word32 tmp; 39 40 for (j = KC-1; j >= 0; j--) { 41 memmove( &(tk[j]), &(k[j]), sizeof(word32)); 42 } 43 r = 0; 44 t = 0; 45 46 /* copy values into round key array */ 47 for (j = 0; (j < KC) && (r < ROUNDS + 1); ) { 48 for (; (j < KC) && (t < 4); j++, t++) { 49 memmove( &(W[r][t]), &(tk[j]), sizeof(word32)); 50 } 51 if (t == 4) { 52 r++; 53 t = 0; 747 int rijndaelKeySetupEnc(u32 rk[/*4*(Nr + 1)*/], const u8 cipherKey[], int keyBits) { 748 int i = 0; 749 u32 temp; 750 751 rk[0] = GETU32(cipherKey ); 752 rk[1] = GETU32(cipherKey + 4); 753 rk[2] = GETU32(cipherKey + 8); 754 rk[3] = GETU32(cipherKey + 12); 755 if (keyBits == 128) { 756 for (;;) { 757 temp = rk[3]; 758 rk[4] = rk[0] ^ 759 (Te4[(temp >> 16) & 0xff] & 0xff000000) ^ 760 (Te4[(temp >> 8) & 0xff] & 0x00ff0000) ^ 761 (Te4[(temp ) & 0xff] & 0x0000ff00) ^ 762 (Te4[(temp >> 24) ] & 0x000000ff) ^ 763 rcon[i]; 764 rk[5] = rk[1] ^ rk[4]; 765 rk[6] = rk[2] ^ rk[5]; 766 rk[7] = rk[3] ^ rk[6]; 767 if (++i == 10) { 768 return 10; 769 } 770 rk += 4; 54 771 } 55 772 } 56 57 while (r < ROUNDS + 1) { /* while not enough round key material calculated */ 58 /* calculate new values */ 59 tk[0][0] ^= S[tk[KC-1][1]]; 60 tk[0][1] ^= S[tk[KC-1][2]]; 61 tk[0][2] ^= S[tk[KC-1][3]]; 62 tk[0][3] ^= S[tk[KC-1][0]]; 63 tk[0][0] ^= rcon[rconpointer++]; 64 65 if (KC != 8) { 66 for (j = 1; j < KC; j++) { 67 tmp = *((word32*)tk[j-1]); 68 *((word32*)tk[j]) ^= tmp; 773 rk[4] = GETU32(cipherKey + 16); 774 rk[5] = GETU32(cipherKey + 20); 775 if (keyBits == 192) { 776 for (;;) { 777 temp = rk[ 5]; 778 rk[ 6] = rk[ 0] ^ 779 (Te4[(temp >> 16) & 0xff] & 0xff000000) ^ 780 (Te4[(temp >> 8) & 0xff] & 0x00ff0000) ^ 781 (Te4[(temp ) & 0xff] & 0x0000ff00) ^ 782 (Te4[(temp >> 24) ] & 0x000000ff) ^ 783 rcon[i]; 784 rk[ 7] = rk[ 1] ^ rk[ 6]; 785 rk[ 8] = rk[ 2] ^ rk[ 7]; 786 rk[ 9] = rk[ 3] ^ rk[ 8]; 787 if (++i == 8) { 788 return 12; 69 789 } 70 } else { 71 for (j = 1; j < KC/2; j++) { 72 tmp = *((word32*)tk[j-1]); 73 *((word32*)tk[j]) ^= tmp; 790 rk[10] = rk[ 4] ^ rk[ 9]; 791 rk[11] = rk[ 5] ^ rk[10]; 792 rk += 6; 793 } 794 } 795 rk[6] = GETU32(cipherKey + 24); 796 rk[7] = GETU32(cipherKey + 28); 797 if (keyBits == 256) { 798 for (;;) { 799 temp = rk[ 7]; 800 rk[ 8] = rk[ 0] ^ 801 (Te4[(temp >> 16) & 0xff] & 0xff000000) ^ 802 (Te4[(temp >> 8) & 0xff] & 0x00ff0000) ^ 803 (Te4[(temp ) & 0xff] & 0x0000ff00) ^ 804 (Te4[(temp >> 24) ] & 0x000000ff) ^ 805 rcon[i]; 806 rk[ 9] = rk[ 1] ^ rk[ 8]; 807 rk[10] = rk[ 2] ^ rk[ 9]; 808 rk[11] = rk[ 3] ^ rk[10]; 809 if (++i == 7) { 810 return 14; 74 811 } 75 tk[KC/2][0] ^= S[tk[KC/2 - 1][0]]; 76 tk[KC/2][1] ^= S[tk[KC/2 - 1][1]]; 77 tk[KC/2][2] ^= S[tk[KC/2 - 1][2]]; 78 tk[KC/2][3] ^= S[tk[KC/2 - 1][3]]; 79 for (j = KC/2 + 1; j < KC; j++) { 80 tmp = *((word32*)tk[j-1]); 81 *((word32*)tk[j]) ^= tmp; 82 } 83 } 84 /* copy values into round key array */ 85 for (j = 0; (j < KC) && (r < ROUNDS + 1); ) { 86 for (; (j < KC) && (t < 4); j++, t++) { 87 memmove( &(W[r][t]), &(tk[j]), sizeof(word32)); 88 } 89 if (t == 4) { 90 r++; 91 t = 0; 92 } 93 } 94 } 812 temp = rk[11]; 813 rk[12] = rk[ 4] ^ 814 (Te4[(temp >> 24) ] & 0xff000000) ^ 815 (Te4[(temp >> 16) & 0xff] & 0x00ff0000) ^ 816 (Te4[(temp >> 8) & 0xff] & 0x0000ff00) ^ 817 (Te4[(temp ) & 0xff] & 0x000000ff); 818 rk[13] = rk[ 5] ^ rk[12]; 819 rk[14] = rk[ 6] ^ rk[13]; 820 rk[15] = rk[ 7] ^ rk[14]; 821 822 rk += 8; 823 } 824 } 95 825 return 0; 96 826 } 97 827 98 int rijndaelKeyEncToDec(word8 W[MAXROUNDS+1][4][4], int ROUNDS) { 99 int r; 100 word8 *w; 101 102 for (r = 1; r < ROUNDS; r++) { 103 w = W[r][0]; 104 *((word32*)w) = 105 *((word32*)U1[w[0]]) 106 ^ *((word32*)U2[w[1]]) 107 ^ *((word32*)U3[w[2]]) 108 ^ *((word32*)U4[w[3]]); 109 110 w = W[r][1]; 111 *((word32*)w) = 112 *((word32*)U1[w[0]]) 113 ^ *((word32*)U2[w[1]]) 114 ^ *((word32*)U3[w[2]]) 115 ^ *((word32*)U4[w[3]]); 116 117 w = W[r][2]; 118 *((word32*)w) = 119 *((word32*)U1[w[0]]) 120 ^ *((word32*)U2[w[1]]) 121 ^ *((word32*)U3[w[2]]) 122 ^ *((word32*)U4[w[3]]); 123 124 w = W[r][3]; 125 *((word32*)w) = 126 *((word32*)U1[w[0]]) 127 ^ *((word32*)U2[w[1]]) 128 ^ *((word32*)U3[w[2]]) 129 ^ *((word32*)U4[w[3]]); 828 /** 829 * Expand the cipher key into the decryption key schedule. 830 * 831 * @return the number of rounds for the given cipher key size. 832 */ 833 int rijndaelKeySetupDec(u32 rk[/*4*(Nr + 1)*/], const u8 cipherKey[], int keyBits) { 834 int Nr, i, j; 835 u32 temp; 836 837 /* expand the cipher key: */ 838 Nr = rijndaelKeySetupEnc(rk, cipherKey, keyBits); 839 /* invert the order of the round keys: */ 840 for (i = 0, j = 4*Nr; i < j; i += 4, j -= 4) { 841 temp = rk[i ]; rk[i ] = rk[j ]; rk[j ] = temp; 842 temp = rk[i + 1]; rk[i + 1] = rk[j + 1]; rk[j + 1] = temp; 843 temp = rk[i + 2]; rk[i + 2] = rk[j + 2]; rk[j + 2] = temp; 844 temp = rk[i + 3]; rk[i + 3] = rk[j + 3]; rk[j + 3] = temp; 130 845 } 131 return 0; 132 } 133 134 /** 135 * Encrypt a single block. 136 */ 137 int rijndaelEncrypt(word8 a[16], word8 b[16], word8 rk[MAXROUNDS+1][4][4], int ROUNDS) { 138 int r; 139 union { 140 word32 tem4[4]; 141 word8 temp[4][4]; 142 } tmpU; 143 tmpU.tem4[0] = tmpU.tem4[1] = tmpU.tem4[2] = tmpU.tem4[3] = 0; 144 145 tmpU.tem4[0] = *((word32*)(a )) ^ *((word32*)rk[0][0]); 146 tmpU.tem4[1] = *((word32*)(a+ 4)) ^ *((word32*)rk[0][1]); 147 tmpU.tem4[2] = *((word32*)(a+ 8)) ^ *((word32*)rk[0][2]); 148 tmpU.tem4[3] = *((word32*)(a+12)) ^ *((word32*)rk[0][3]); 149 *((word32*)(b )) = *((word32*)T1[tmpU.temp[0][0]]) 150 ^ *((word32*)T2[tmpU.temp[1][1]]) 151 ^ *((word32*)T3[tmpU.temp[2][2]]) 152 ^ *((word32*)T4[tmpU.temp[3][3]]); 153 *((word32*)(b + 4)) = *((word32*)T1[tmpU.temp[1][0]]) 154 ^ *((word32*)T2[tmpU.temp[2][1]]) 155 ^ *((word32*)T3[tmpU.temp[3][2]]) 156 ^ *((word32*)T4[tmpU.temp[0][3]]); 157 *((word32*)(b + 8)) = *((word32*)T1[tmpU.temp[2][0]]) 158 ^ *((word32*)T2[tmpU.temp[3][1]]) 159 ^ *((word32*)T3[tmpU.temp[0][2]]) 160 ^ *((word32*)T4[tmpU.temp[1][3]]); 161 *((word32*)(b +12)) = *((word32*)T1[tmpU.temp[3][0]]) 162 ^ *((word32*)T2[tmpU.temp[0][1]]) 163 ^ *((word32*)T3[tmpU.temp[1][2]]) 164 ^ *((word32*)T4[tmpU.temp[2][3]]); 165 for (r = 1; r < ROUNDS-1; r++) { 166 tmpU.tem4[0] = *((word32*)(b )) ^ *((word32*)rk[r][0]); 167 tmpU.tem4[1] = *((word32*)(b+ 4)) ^ *((word32*)rk[r][1]); 168 tmpU.tem4[2] = *((word32*)(b+ 8)) ^ *((word32*)rk[r][2]); 169 tmpU.tem4[3] = *((word32*)(b+12)) ^ *((word32*)rk[r][3]); 170 171 *((word32*)(b )) = *((word32*)T1[tmpU.temp[0][0]]) 172 ^ *((word32*)T2[tmpU.temp[1][1]]) 173 ^ *((word32*)T3[tmpU.temp[2][2]]) 174 ^ *((word32*)T4[tmpU.temp[3][3]]); 175 *((word32*)(b + 4)) = *((word32*)T1[tmpU.temp[1][0]]) 176 ^ *((word32*)T2[tmpU.temp[2][1]]) 177 ^ *((word32*)T3[tmpU.temp[3][2]]) 178 ^ *((word32*)T4[tmpU.temp[0][3]]); 179 *((word32*)(b + 8)) = *((word32*)T1[tmpU.temp[2][0]]) 180 ^ *((word32*)T2[tmpU.temp[3][1]]) 181 ^ *((word32*)T3[tmpU.temp[0][2]]) 182 ^ *((word32*)T4[tmpU.temp[1][3]]); 183 *((word32*)(b +12)) = *((word32*)T1[tmpU.temp[3][0]]) 184 ^ *((word32*)T2[tmpU.temp[0][1]]) 185 ^ *((word32*)T3[tmpU.temp[1][2]]) 186 ^ *((word32*)T4[tmpU.temp[2][3]]); 846 /* apply the inverse MixColumn transform to all round keys but the first and the last: */ 847 for (i = 1; i < Nr; i++) { 848 rk += 4; 849 rk[0] = 850 Td0[Te4[(rk[0] >> 24) ] & 0xff] ^ 851 Td1[Te4[(rk[0] >> 16) & 0xff] & 0xff] ^ 852 Td2[Te4[(rk[0] >> 8) & 0xff] & 0xff] ^ 853 Td3[Te4[(rk[0] ) & 0xff] & 0xff]; 854 rk[1] = 855 Td0[Te4[(rk[1] >> 24) ] & 0xff] ^ 856 Td1[Te4[(rk[1] >> 16) & 0xff] & 0xff] ^ 857 Td2[Te4[(rk[1] >> 8) & 0xff] & 0xff] ^ 858 Td3[Te4[(rk[1] ) & 0xff] & 0xff]; 859 rk[2] = 860 Td0[Te4[(rk[2] >> 24) ] & 0xff] ^ 861 Td1[Te4[(rk[2] >> 16) & 0xff] & 0xff] ^ 862 Td2[Te4[(rk[2] >> 8) & 0xff] & 0xff] ^ 863 Td3[Te4[(rk[2] ) & 0xff] & 0xff]; 864 rk[3] = 865 Td0[Te4[(rk[3] >> 24) ] & 0xff] ^ 866 Td1[Te4[(rk[3] >> 16) & 0xff] & 0xff] ^ 867 Td2[Te4[(rk[3] >> 8) & 0xff] & 0xff] ^ 868 Td3[Te4[(rk[3] ) & 0xff] & 0xff]; 187 869 } 188 /* last round is special */ 189 tmpU.tem4[0] = *((word32*)(b )) ^ *((word32*)rk[ROUNDS-1][0]); 190 tmpU.tem4[1] = *((word32*)(b+ 4)) ^ *((word32*)rk[ROUNDS-1][1]); 191 tmpU.tem4[2] = *((word32*)(b+ 8)) ^ *((word32*)rk[ROUNDS-1][2]); 192 tmpU.tem4[3] = *((word32*)(b+12)) ^ *((word32*)rk[ROUNDS-1][3]); 193 b[ 0] = T1[tmpU.temp[0][0]][1]; 194 b[ 1] = T1[tmpU.temp[1][1]][1]; 195 b[ 2] = T1[tmpU.temp[2][2]][1]; 196 b[ 3] = T1[tmpU.temp[3][3]][1]; 197 b[ 4] = T1[tmpU.temp[1][0]][1]; 198 b[ 5] = T1[tmpU.temp[2][1]][1]; 199 b[ 6] = T1[tmpU.temp[3][2]][1]; 200 b[ 7] = T1[tmpU.temp[0][3]][1]; 201 b[ 8] = T1[tmpU.temp[2][0]][1]; 202 b[ 9] = T1[tmpU.temp[3][1]][1]; 203 b[10] = T1[tmpU.temp[0][2]][1]; 204 b[11] = T1[tmpU.temp[1][3]][1]; 205 b[12] = T1[tmpU.temp[3][0]][1]; 206 b[13] = T1[tmpU.temp[0][1]][1]; 207 b[14] = T1[tmpU.temp[1][2]][1]; 208 b[15] = T1[tmpU.temp[2][3]][1]; 209 *((word32*)(b )) ^= *((word32*)rk[ROUNDS][0]); 210 *((word32*)(b+ 4)) ^= *((word32*)rk[ROUNDS][1]); 211 *((word32*)(b+ 8)) ^= *((word32*)rk[ROUNDS][2]); 212 *((word32*)(b+12)) ^= *((word32*)rk[ROUNDS][3]); 213 214 return 0; 870 return Nr; 215 871 } 216 872 217 /** 218 * Decrypt a single block. 219 */ 220 int rijndaelDecrypt(word8 a[16], word8 b[16], word8 rk[MAXROUNDS+1][4][4], int ROUNDS) { 221 int r; 222 union { 223 word32 tem4[4]; 224 word8 temp[4][4]; 225 } tmpU; 226 tmpU.tem4[0] = tmpU.tem4[1] = tmpU.tem4[2] = tmpU.tem4[3] = 0; 227 228 tmpU.tem4[0] = *((word32*)(a )) ^ *((word32*)rk[ROUNDS][0]); 229 tmpU.tem4[1] = *((word32*)(a+ 4)) ^ *((word32*)rk[ROUNDS][1]); 230 tmpU.tem4[2] = *((word32*)(a+ 8)) ^ *((word32*)rk[ROUNDS][2]); 231 tmpU.tem4[3] = *((word32*)(a+12)) ^ *((word32*)rk[ROUNDS][3]); 232 233 *((word32*)(b )) = *((word32*)T5[tmpU.temp[0][0]]) 234 ^ *((word32*)T6[tmpU.temp[3][1]]) 235 ^ *((word32*)T7[tmpU.temp[2][2]]) 236 ^ *((word32*)T8[tmpU.temp[1][3]]); 237 *((word32*)(b+ 4)) = *((word32*)T5[tmpU.temp[1][0]]) 238 ^ *((word32*)T6[tmpU.temp[0][1]]) 239 ^ *((word32*)T7[tmpU.temp[3][2]]) 240 ^ *((word32*)T8[tmpU.temp[2][3]]); 241 *((word32*)(b+ 8)) = *((word32*)T5[tmpU.temp[2][0]]) 242 ^ *((word32*)T6[tmpU.temp[1][1]]) 243 ^ *((word32*)T7[tmpU.temp[0][2]]) 244 ^ *((word32*)T8[tmpU.temp[3][3]]); 245 *((word32*)(b+12)) = *((word32*)T5[tmpU.temp[3][0]]) 246 ^ *((word32*)T6[tmpU.temp[2][1]]) 247 ^ *((word32*)T7[tmpU.temp[1][2]]) 248 ^ *((word32*)T8[tmpU.temp[0][3]]); 249 for (r = ROUNDS-1; r > 1; r--) { 250 tmpU.tem4[0] = *((word32*)(b )) ^ *((word32*)rk[r][0]); 251 tmpU.tem4[1] = *((word32*)(b+ 4)) ^ *((word32*)rk[r][1]); 252 tmpU.tem4[2] = *((word32*)(b+ 8)) ^ *((word32*)rk[r][2]); 253 tmpU.tem4[3] = *((word32*)(b+12)) ^ *((word32*)rk[r][3]); 254 *((word32*)(b )) = *((word32*)T5[tmpU.temp[0][0]]) 255 ^ *((word32*)T6[tmpU.temp[3][1]]) 256 ^ *((word32*)T7[tmpU.temp[2][2]]) 257 ^ *((word32*)T8[tmpU.temp[1][3]]); 258 *((word32*)(b+ 4)) = *((word32*)T5[tmpU.temp[1][0]]) 259 ^ *((word32*)T6[tmpU.temp[0][1]]) 260 ^ *((word32*)T7[tmpU.temp[3][2]]) 261 ^ *((word32*)T8[tmpU.temp[2][3]]); 262 *((word32*)(b+ 8)) = *((word32*)T5[tmpU.temp[2][0]]) 263 ^ *((word32*)T6[tmpU.temp[1][1]]) 264 ^ *((word32*)T7[tmpU.temp[0][2]]) 265 ^ *((word32*)T8[tmpU.temp[3][3]]); 266 *((word32*)(b+12)) = *((word32*)T5[tmpU.temp[3][0]]) 267 ^ *((word32*)T6[tmpU.temp[2][1]]) 268 ^ *((word32*)T7[tmpU.temp[1][2]]) 269 ^ *((word32*)T8[tmpU.temp[0][3]]); 270 } 271 /* last round is special */ 272 tmpU.tem4[0] = *((word32*)(b )) ^ *((word32*)rk[1][0]); 273 tmpU.tem4[1] = *((word32*)(b+ 4)) ^ *((word32*)rk[1][1]); 274 tmpU.tem4[2] = *((word32*)(b+ 8)) ^ *((word32*)rk[1][2]); 275 tmpU.tem4[3] = *((word32*)(b+12)) ^ *((word32*)rk[1][3]); 276 b[ 0] = S5[tmpU.temp[0][0]]; 277 b[ 1] = S5[tmpU.temp[3][1]]; 278 b[ 2] = S5[tmpU.temp[2][2]]; 279 b[ 3] = S5[tmpU.temp[1][3]]; 280 b[ 4] = S5[tmpU.temp[1][0]]; 281 b[ 5] = S5[tmpU.temp[0][1]]; 282 b[ 6] = S5[tmpU.temp[3][2]]; 283 b[ 7] = S5[tmpU.temp[2][3]]; 284 b[ 8] = S5[tmpU.temp[2][0]]; 285 b[ 9] = S5[tmpU.temp[1][1]]; 286 b[10] = S5[tmpU.temp[0][2]]; 287 b[11] = S5[tmpU.temp[3][3]]; 288 b[12] = S5[tmpU.temp[3][0]]; 289 b[13] = S5[tmpU.temp[2][1]]; 290 b[14] = S5[tmpU.temp[1][2]]; 291 b[15] = S5[tmpU.temp[0][3]]; 292 *((word32*)(b )) ^= *((word32*)rk[0][0]); 293 *((word32*)(b+ 4)) ^= *((word32*)rk[0][1]); 294 *((word32*)(b+ 8)) ^= *((word32*)rk[0][2]); 295 *((word32*)(b+12)) ^= *((word32*)rk[0][3]); 296 297 return 0; 873 void rijndaelEncrypt(const u32 rk[/*4*(Nr + 1)*/], int Nr, const u8 pt[16], u8 ct[16]) { 874 u32 s0, s1, s2, s3, t0, t1, t2, t3; 875 #ifndef FULL_UNROLL 876 int r; 877 #endif /* ?FULL_UNROLL */ 878 879 /* 880 * map byte array block to cipher state 881 * and add initial round key: 882 */ 883 s0 = GETU32(pt ) ^ rk[0]; 884 s1 = GETU32(pt + 4) ^ rk[1]; 885 s2 = GETU32(pt + 8) ^ rk[2]; 886 s3 = GETU32(pt + 12) ^ rk[3]; 887 #ifdef FULL_UNROLL 888 /* round 1: */ 889 t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >> 8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[ 4]; 890 t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >> 8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[ 5]; 891 t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >> 8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[ 6]; 892 t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >> 8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[ 7]; 893 /* round 2: */ 894 s0 = Te0[t0 >> 24] ^ Te1[(t1 >> 16) & 0xff] ^ Te2[(t2 >> 8) & 0xff] ^ Te3[t3 & 0xff] ^ rk[ 8]; 895 s1 = Te0[t1 >> 24] ^ Te1[(t2 >> 16) & 0xff] ^ Te2[(t3 >> 8) & 0xff] ^ Te3[t0 & 0xff] ^ rk[ 9]; 896 s2 = Te0[t2 >> 24] ^ Te1[(t3 >> 16) & 0xff] ^ Te2[(t0 >> 8) & 0xff] ^ Te3[t1 & 0xff] ^ rk[10]; 897 s3 = Te0[t3 >> 24] ^ Te1[(t0 >> 16) & 0xff] ^ Te2[(t1 >> 8) & 0xff] ^ Te3[t2 & 0xff] ^ rk[11]; 898 /* round 3: */ 899 t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >> 8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[12]; 900 t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >> 8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[13]; 901 t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >> 8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[14]; 902 t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >> 8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[15]; 903 /* round 4: */ 904 s0 = Te0[t0 >> 24] ^ Te1[(t1 >> 16) & 0xff] ^ Te2[(t2 >> 8) & 0xff] ^ Te3[t3 & 0xff] ^ rk[16]; 905 s1 = Te0[t1 >> 24] ^ Te1[(t2 >> 16) & 0xff] ^ Te2[(t3 >> 8) & 0xff] ^ Te3[t0 & 0xff] ^ rk[17]; 906 s2 = Te0[t2 >> 24] ^ Te1[(t3 >> 16) & 0xff] ^ Te2[(t0 >> 8) & 0xff] ^ Te3[t1 & 0xff] ^ rk[18]; 907 s3 = Te0[t3 >> 24] ^ Te1[(t0 >> 16) & 0xff] ^ Te2[(t1 >> 8) & 0xff] ^ Te3[t2 & 0xff] ^ rk[19]; 908 /* round 5: */ 909 t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >> 8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[20]; 910 t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >> 8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[21]; 911 t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >> 8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[22]; 912 t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >> 8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[23]; 913 /* round 6: */ 914 s0 = Te0[t0 >> 24] ^ Te1[(t1 >> 16) & 0xff] ^ Te2[(t2 >> 8) & 0xff] ^ Te3[t3 & 0xff] ^ rk[24]; 915 s1 = Te0[t1 >> 24] ^ Te1[(t2 >> 16) & 0xff] ^ Te2[(t3 >> 8) & 0xff] ^ Te3[t0 & 0xff] ^ rk[25]; 916 s2 = Te0[t2 >> 24] ^ Te1[(t3 >> 16) & 0xff] ^ Te2[(t0 >> 8) & 0xff] ^ Te3[t1 & 0xff] ^ rk[26]; 917 s3 = Te0[t3 >> 24] ^ Te1[(t0 >> 16) & 0xff] ^ Te2[(t1 >> 8) & 0xff] ^ Te3[t2 & 0xff] ^ rk[27]; 918 /* round 7: */ 919 t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >> 8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[28]; 920 t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >> 8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[29]; 921 t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >> 8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[30]; 922 t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >> 8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[31]; 923 /* round 8: */ 924 s0 = Te0[t0 >> 24] ^ Te1[(t1 >> 16) & 0xff] ^ Te2[(t2 >> 8) & 0xff] ^ Te3[t3 & 0xff] ^ rk[32]; 925 s1 = Te0[t1 >> 24] ^ Te1[(t2 >> 16) & 0xff] ^ Te2[(t3 >> 8) & 0xff] ^ Te3[t0 & 0xff] ^ rk[33]; 926 s2 = Te0[t2 >> 24] ^ Te1[(t3 >> 16) & 0xff] ^ Te2[(t0 >> 8) & 0xff] ^ Te3[t1 & 0xff] ^ rk[34]; 927 s3 = Te0[t3 >> 24] ^ Te1[(t0 >> 16) & 0xff] ^ Te2[(t1 >> 8) & 0xff] ^ Te3[t2 & 0xff] ^ rk[35]; 928 /* round 9: */ 929 t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >> 8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[36]; 930 t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >> 8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[37]; 931 t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >> 8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[38]; 932 t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >> 8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[39]; 933 if (Nr > 10) { 934 /* round 10: */ 935 s0 = Te0[t0 >> 24] ^ Te1[(t1 >> 16) & 0xff] ^ Te2[(t2 >> 8) & 0xff] ^ Te3[t3 & 0xff] ^ rk[40]; 936 s1 = Te0[t1 >> 24] ^ Te1[(t2 >> 16) & 0xff] ^ Te2[(t3 >> 8) & 0xff] ^ Te3[t0 & 0xff] ^ rk[41]; 937 s2 = Te0[t2 >> 24] ^ Te1[(t3 >> 16) & 0xff] ^ Te2[(t0 >> 8) & 0xff] ^ Te3[t1 & 0xff] ^ rk[42]; 938 s3 = Te0[t3 >> 24] ^ Te1[(t0 >> 16) & 0xff] ^ Te2[(t1 >> 8) & 0xff] ^ Te3[t2 & 0xff] ^ rk[43]; 939 /* round 11: */ 940 t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >> 8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[44]; 941 t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >> 8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[45]; 942 t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >> 8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[46]; 943 t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >> 8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[47]; 944 if (Nr > 12) { 945 /* round 12: */ 946 s0 = Te0[t0 >> 24] ^ Te1[(t1 >> 16) & 0xff] ^ Te2[(t2 >> 8) & 0xff] ^ Te3[t3 & 0xff] ^ rk[48]; 947 s1 = Te0[t1 >> 24] ^ Te1[(t2 >> 16) & 0xff] ^ Te2[(t3 >> 8) & 0xff] ^ Te3[t0 & 0xff] ^ rk[49]; 948 s2 = Te0[t2 >> 24] ^ Te1[(t3 >> 16) & 0xff] ^ Te2[(t0 >> 8) & 0xff] ^ Te3[t1 & 0xff] ^ rk[50]; 949 s3 = Te0[t3 >> 24] ^ Te1[(t0 >> 16) & 0xff] ^ Te2[(t1 >> 8) & 0xff] ^ Te3[t2 & 0xff] ^ rk[51]; 950 /* round 13: */ 951 t0 = Te0[s0 >> 24] ^ Te1[(s1 >> 16) & 0xff] ^ Te2[(s2 >> 8) & 0xff] ^ Te3[s3 & 0xff] ^ rk[52]; 952 t1 = Te0[s1 >> 24] ^ Te1[(s2 >> 16) & 0xff] ^ Te2[(s3 >> 8) & 0xff] ^ Te3[s0 & 0xff] ^ rk[53]; 953 t2 = Te0[s2 >> 24] ^ Te1[(s3 >> 16) & 0xff] ^ Te2[(s0 >> 8) & 0xff] ^ Te3[s1 & 0xff] ^ rk[54]; 954 t3 = Te0[s3 >> 24] ^ Te1[(s0 >> 16) & 0xff] ^ Te2[(s1 >> 8) & 0xff] ^ Te3[s2 & 0xff] ^ rk[55]; 955 } 956 } 957 rk += Nr << 2; 958 #else /* !FULL_UNROLL */ 959 /* 960 * Nr - 1 full rounds: 961 */ 962 r = Nr >> 1; 963 for (;;) { 964 t0 = 965 Te0[(s0 >> 24) ] ^ 966 Te1[(s1 >> 16) & 0xff] ^ 967 Te2[(s2 >> 8) & 0xff] ^ 968 Te3[(s3 ) & 0xff] ^ 969 rk[4]; 970 t1 = 971 Te0[(s1 >> 24) ] ^ 972 Te1[(s2 >> 16) & 0xff] ^ 973 Te2[(s3 >> 8) & 0xff] ^ 974 Te3[(s0 ) & 0xff] ^ 975 rk[5]; 976 t2 = 977 Te0[(s2 >> 24) ] ^ 978 Te1[(s3 >> 16) & 0xff] ^ 979 Te2[(s0 >> 8) & 0xff] ^ 980 Te3[(s1 ) & 0xff] ^ 981 rk[6]; 982 t3 = 983 Te0[(s3 >> 24) ] ^ 984 Te1[(s0 >> 16) & 0xff] ^ 985 Te2[(s1 >> 8) & 0xff] ^ 986 Te3[(s2 ) & 0xff] ^ 987 rk[7]; 988 989 rk += 8; 990 if (--r == 0) { 991 break; 992 } 993 994 s0 = 995 Te0[(t0 >> 24) ] ^ 996 Te1[(t1 >> 16) & 0xff] ^ 997 Te2[(t2 >> 8) & 0xff] ^ 998 Te3[(t3 ) & 0xff] ^ 999 rk[0]; 1000 s1 = 1001 Te0[(t1 >> 24) ] ^ 1002 Te1[(t2 >> 16) & 0xff] ^ 1003 Te2[(t3 >> 8) & 0xff] ^ 1004 Te3[(t0 ) & 0xff] ^ 1005 rk[1]; 1006 s2 = 1007 Te0[(t2 >> 24) ] ^ 1008 Te1[(t3 >> 16) & 0xff] ^ 1009 Te2[(t0 >> 8) & 0xff] ^ 1010 Te3[(t1 ) & 0xff] ^ 1011 rk[2]; 1012 s3 = 1013 Te0[(t3 >> 24) ] ^ 1014 Te1[(t0 >> 16) & 0xff] ^ 1015 Te2[(t1 >> 8) & 0xff] ^ 1016 Te3[(t2 ) & 0xff] ^ 1017 rk[3]; 1018 } 1019 #endif /* ?FULL_UNROLL */ 1020 /* 1021 * apply last round and 1022 * map cipher state to byte array block: 1023 */ 1024 s0 = 1025 (Te4[(t0 >> 24) ] & 0xff000000) ^ 1026 (Te4[(t1 >> 16) & 0xff] & 0x00ff0000) ^ 1027 (Te4[(t2 >> 8) & 0xff] & 0x0000ff00) ^ 1028 (Te4[(t3 ) & 0xff] & 0x000000ff) ^ 1029 rk[0]; 1030 PUTU32(ct , s0); 1031 s1 = 1032 (Te4[(t1 >> 24) ] & 0xff000000) ^ 1033 (Te4[(t2 >> 16) & 0xff] & 0x00ff0000) ^ 1034 (Te4[(t3 >> 8) & 0xff] & 0x0000ff00) ^ 1035 (Te4[(t0 ) & 0xff] & 0x000000ff) ^ 1036 rk[1]; 1037 PUTU32(ct + 4, s1); 1038 s2 = 1039 (Te4[(t2 >> 24) ] & 0xff000000) ^ 1040 (Te4[(t3 >> 16) & 0xff] & 0x00ff0000) ^ 1041 (Te4[(t0 >> 8) & 0xff] & 0x0000ff00) ^ 1042 (Te4[(t1 ) & 0xff] & 0x000000ff) ^ 1043 rk[2]; 1044 PUTU32(ct + 8, s2); 1045 s3 = 1046 (Te4[(t3 >> 24) ] & 0xff000000) ^ 1047 (Te4[(t0 >> 16) & 0xff] & 0x00ff0000) ^ 1048 (Te4[(t1 >> 8) & 0xff] & 0x0000ff00) ^ 1049 (Te4[(t2 ) & 0xff] & 0x000000ff) ^ 1050 rk[3]; 1051 PUTU32(ct + 12, s3); 298 1052 } 299 1053 300 #ifdef INTERMEDIATE_VALUE_KAT 301 /** 302 * Encrypt only a certain number of rounds. 303 * Only used in the Intermediate Value Known Answer Test. 304 */ 305 int rijndaelEncryptRound(word8 a[4][4], word8 rk[MAXROUNDS+1][4][4], int ROUNDS, int rounds) { 306 int r; 307 word8 temp[4][4]; 308 309 /* make number of rounds sane */ 310 if (rounds > ROUNDS) { 311 rounds = ROUNDS; 312 } 313 314 *((word32*)a[0]) = *((word32*)a[0]) ^ *((word32*)rk[0][0]); 315 *((word32*)a[1]) = *((word32*)a[1]) ^ *((word32*)rk[0][1]); 316 *((word32*)a[2]) = *((word32*)a[2]) ^ *((word32*)rk[0][2]); 317 *((word32*)a[3]) = *((word32*)a[3]) ^ *((word32*)rk[0][3]); 318 319 for (r = 1; (r <= rounds) && (r < ROUNDS); r++) { 320 *((word32*)temp[0]) = *((word32*)T1[a[0][0]]) 321 ^ *((word32*)T2[a[1][1]]) 322 ^ *((word32*)T3[a[2][2]]) 323 ^ *((word32*)T4[a[3][3]]); 324 *((word32*)temp[1]) = *((word32*)T1[a[1][0]]) 325 ^ *((word32*)T2[a[2][1]]) 326 ^ *((word32*)T3[a[3][2]]) 327 ^ *((word32*)T4[a[0][3]]); 328 *((word32*)temp[2]) = *((word32*)T1[a[2][0]]) 329 ^ *((word32*)T2[a[3][1]]) 330 ^ *((word32*)T3[a[0][2]]) 331 ^ *((word32*)T4[a[1][3]]); 332 *((word32*)temp[3]) = *((word32*)T1[a[3][0]]) 333 ^ *((word32*)T2[a[0][1]]) 334 ^ *((word32*)T3[a[1][2]]) 335 ^ *((word32*)T4[a[2][3]]); 336 *((word32*)a[0]) = *((word32*)temp[0]) ^ *((word32*)rk[r][0]); 337 *((word32*)a[1]) = *((word32*)temp[1]) ^ *((word32*)rk[r][1]); 338 *((word32*)a[2]) = *((word32*)temp[2]) ^ *((word32*)rk[r][2]); 339 *((word32*)a[3]) = *((word32*)temp[3]) ^ *((word32*)rk[r][3]); 340 } 341 if (rounds == ROUNDS) { 342 /* last round is special */ 343 temp[0][0] = T1[a[0][0]][1]; 344 temp[0][1] = T1[a[1][1]][1]; 345 temp[0][2] = T1[a[2][2]][1]; 346 temp[0][3] = T1[a[3][3]][1]; 347 temp[1][0] = T1[a[1][0]][1]; 348 temp[1][1] = T1[a[2][1]][1]; 349 temp[1][2] = T1[a[3][2]][1]; 350 temp[1][3] = T1[a[0][3]][1]; 351 temp[2][0] = T1[a[2][0]][1]; 352 temp[2][1] = T1[a[3][1]][1]; 353 temp[2][2] = T1[a[0][2]][1]; 354 temp[2][3] = T1[a[1][3]][1]; 355 temp[3][0] = T1[a[3][0]][1]; 356 temp[3][1] = T1[a[0][1]][1]; 357 temp[3][2] = T1[a[1][2]][1]; 358 temp[3][3] = T1[a[2][3]][1]; 359 *((word32*)a[0]) = *((word32*)temp[0]) ^ *((word32*)rk[ROUNDS][0]); 360 *((word32*)a[1]) = *((word32*)temp[1]) ^ *((word32*)rk[ROUNDS][1]); 361 *((word32*)a[2]) = *((word32*)temp[2]) ^ *((word32*)rk[ROUNDS][2]); 362 *((word32*)a[3]) = *((word32*)temp[3]) ^ *((word32*)rk[ROUNDS][3]); 363 } 364 365 return 0; 366 } 367 #endif /* INTERMEDIATE_VALUE_KAT */ 368 369 #ifdef INTERMEDIATE_VALUE_KAT 370 /** 371 * Decrypt only a certain number of rounds. 372 * Only used in the Intermediate Value Known Answer Test. 373 * Operations rearranged such that the intermediate values 374 * of decryption correspond with the intermediate values 375 * of encryption. 376 */ 377 int rijndaelDecryptRound(word8 a[4][4], word8 rk[MAXROUNDS+1][4][4], int ROUNDS, int rounds) { 378 int r, i; 379 word8 temp[4], shift; 380 381 /* make number of rounds sane */ 382 if (rounds > ROUNDS) { 383 rounds = ROUNDS; 384 } 385 /* first round is special: */ 386 *(word32 *)a[0] ^= *(word32 *)rk[ROUNDS][0]; 387 *(word32 *)a[1] ^= *(word32 *)rk[ROUNDS][1]; 388 *(word32 *)a[2] ^= *(word32 *)rk[ROUNDS][2]; 389 *(word32 *)a[3] ^= *(word32 *)rk[ROUNDS][3]; 390 for (i = 0; i < 4; i++) { 391 a[i][0] = Si[a[i][0]]; 392 a[i][1] = Si[a[i][1]]; 393 a[i][2] = Si[a[i][2]]; 394 a[i][3] = Si[a[i][3]]; 395 } 396 for (i = 1; i < 4; i++) { 397 shift = (4 - i) & 3; 398 temp[0] = a[(0 + shift) & 3][i]; 399 temp[1] = a[(1 + shift) & 3][i]; 400 temp[2] = a[(2 + shift) & 3][i]; 401 temp[3] = a[(3 + shift) & 3][i]; 402 a[0][i] = temp[0]; 403 a[1][i] = temp[1]; 404 a[2][i] = temp[2]; 405 a[3][i] = temp[3]; 406 } 407 /* ROUNDS-1 ordinary rounds */ 408 for (r = ROUNDS-1; r > rounds; r--) { 409 *(word32 *)a[0] ^= *(word32 *)rk[r][0]; 410 *(word32 *)a[1] ^= *(word32 *)rk[r][1]; 411 *(word32 *)a[2] ^= *(word32 *)rk[r][2]; 412 *(word32 *)a[3] ^= *(word32 *)rk[r][3]; 413 414 *((word32*)a[0]) = 415 *((word32*)U1[a[0][0]]) 416 ^ *((word32*)U2[a[0][1]]) 417 ^ *((word32*)U3[a[0][2]]) 418 ^ *((word32*)U4[a[0][3]]); 419 420 *((word32*)a[1]) = 421 *((word32*)U1[a[1][0]]) 422 ^ *((word32*)U2[a[1][1]]) 423 ^ *((word32*)U3[a[1][2]]) 424 ^ *((word32*)U4[a[1][3]]); 425 426 *((word32*)a[2]) = 427 *((word32*)U1[a[2][0]]) 428 ^ *((word32*)U2[a[2][1]]) 429 ^ *((word32*)U3[a[2][2]]) 430 ^ *((word32*)U4[a[2][3]]); 431 432 *((word32*)a[3]) = 433 *((word32*)U1[a[3][0]]) 434 ^ *((word32*)U2[a[3][1]]) 435 ^ *((word32*)U3[a[3][2]]) 436 ^ *((word32*)U4[a[3][3]]); 437 for (i = 0; i < 4; i++) { 438 a[i][0] = Si[a[i][0]]; 439 a[i][1] = Si[a[i][1]]; 440 a[i][2] = Si[a[i][2]]; 441 a[i][3] = Si[a[i][3]]; 442 } 443 for (i = 1; i < 4; i++) { 444 shift = (4 - i) & 3; 445 temp[0] = a[(0 + shift) & 3][i]; 446 temp[1] = a[(1 + shift) & 3][i]; 447 temp[2] = a[(2 + shift) & 3][i]; 448 temp[3] = a[(3 + shift) & 3][i]; 449 a[0][i] = temp[0]; 450 a[1][i] = temp[1]; 451 a[2][i] = temp[2]; 452 a[3][i] = temp[3]; 453 } 454 } 455 if (rounds == 0) { 456 /* End with the extra key addition */ 457 *(word32 *)a[0] ^= *(word32 *)rk[0][0]; 458 *(word32 *)a[1] ^= *(word32 *)rk[0][1]; 459 *(word32 *)a[2] ^= *(word32 *)rk[0][2]; 460 *(word32 *)a[3] ^= *(word32 *)rk[0][3]; 461 } 462 return 0; 1054 void rijndaelDecrypt(const u32 rk[/*4*(Nr + 1)*/], int Nr, const u8 ct[16], u8 pt[16]) { 1055 u32 s0, s1, s2, s3, t0, t1, t2, t3; 1056 #ifndef FULL_UNROLL 1057 int r; 1058 #endif /* ?FULL_UNROLL */ 1059 1060 /* 1061 * map byte array block to cipher state 1062 * and add initial round key: 1063 */ 1064 s0 = GETU32(ct ) ^ rk[0]; 1065 s1 = GETU32(ct + 4) ^ rk[1]; 1066 s2 = GETU32(ct + 8) ^ rk[2]; 1067 s3 = GETU32(ct + 12) ^ rk[3]; 1068 #ifdef FULL_UNROLL 1069 /* round 1: */ 1070 t0 = Td0[s0 >> 24] ^ Td1[(s3 >> 16) & 0xff] ^ Td2[(s2 >> 8) & 0xff] ^ Td3[s1 & 0xff] ^ rk[ 4]; 1071 t1 = Td0[s1 >> 24] ^ Td1[(s0 >> 16) & 0xff] ^ Td2[(s3 >> 8) & 0xff] ^ Td3[s2 & 0xff] ^ rk[ 5]; 1072 t2 = Td0[s2 >> 24] ^ Td1[(s1 >> 16) & 0xff] ^ Td2[(s0 >> 8) & 0xff] ^ Td3[s3 & 0xff] ^ rk[ 6]; 1073 t3 = Td0[s3 >> 24] ^ Td1[(s2 >> 16) & 0xff] ^ Td2[(s1 >> 8) & 0xff] ^ Td3[s0 & 0xff] ^ rk[ 7]; 1074 /* round 2: */ 1075 s0 = Td0[t0 >> 24] ^ Td1[(t3 >> 16) & 0xff] ^ Td2[(t2 >> 8) & 0xff] ^ Td3[t1 & 0xff] ^ rk[ 8]; 1076 s1 = Td0[t1 >> 24] ^ Td1[(t0 >> 16) & 0xff] ^ Td2[(t3 >> 8) & 0xff] ^ Td3[t2 & 0xff] ^ rk[ 9]; 1077 s2 = Td0[t2 >> 24] ^ Td1[(t1 >> 16) & 0xff] ^ Td2[(t0 >> 8) & 0xff] ^ Td3[t3 & 0xff] ^ rk[10]; 1078 s3 = Td0[t3 >> 24] ^ Td1[(t2 >> 16) & 0xff] ^ Td2[(t1 >> 8) & 0xff] ^ Td3[t0 & 0xff] ^ rk[11]; 1079 /* round 3: */ 1080 t0 = Td0[s0 >> 24] ^ Td1[(s3 >> 16) & 0xff] ^ Td2[(s2 >> 8) & 0xff] ^ Td3[s1 & 0xff] ^ rk[12]; 1081 t1 = Td0[s1 >> 24] ^ Td1[(s0 >> 16) & 0xff] ^ Td2[(s3 >> 8) & 0xff] ^ Td3[s2 & 0xff] ^ rk[13]; 1082 t2 = Td0[s2 >> 24] ^ Td1[(s1 >> 16) & 0xff] ^ Td2[(s0 >> 8) & 0xff] ^ Td3[s3 & 0xff] ^ rk[14]; 1083 t3 = Td0[s3 >> 24] ^ Td1[(s2 >> 16) & 0xff] ^ Td2[(s1 >> 8) & 0xff] ^ Td3[s0 & 0xff] ^ rk[15]; 1084 /* round 4: */ 1085 s0 = Td0[t0 >> 24] ^ Td1[(t3 >> 16) & 0xff] ^ Td2[(t2 >> 8) & 0xff] ^ Td3[t1 & 0xff] ^ rk[16]; 1086 s1 = Td0[t1 >> 24] ^ Td1[(t0 >> 16) & 0xff] ^ Td2[(t3 >> 8) & 0xff] ^ Td3[t2 & 0xff] ^ rk[17]; 1087 s2 = Td0[t2 >> 24] ^ Td1[(t1 >> 16) & 0xff] ^ Td2[(t0 >> 8) & 0xff] ^ Td3[t3 & 0xff] ^ rk[18]; 1088 s3 = Td0[t3 >> 24] ^ Td1[(t2 >> 16) & 0xff] ^ Td2[(t1 >> 8) & 0xff] ^ Td3[t0 & 0xff] ^ rk[19]; 1089 /* round 5: */ 1090 t0 = Td0[s0 >> 24] ^ Td1[(s3 >> 16) & 0xff] ^ Td2[(s2 >> 8) & 0xff] ^ Td3[s1 & 0xff] ^ rk[20]; 1091 t1 = Td0[s1 >> 24] ^ Td1[(s0 >> 16) & 0xff] ^ Td2[(s3 >> 8) & 0xff] ^ Td3[s2 & 0xff] ^ rk[21]; 1092 t2 = Td0[s2 >> 24] ^ Td1[(s1 >> 16) & 0xff] ^ Td2[(s0 >> 8) & 0xff] ^ Td3[s3 & 0xff] ^ rk[22]; 1093 t3 = Td0[s3 >> 24] ^ Td1[(s2 >> 16) & 0xff] ^ Td2[(s1 >> 8) & 0xff] ^ Td3[s0 & 0xff] ^ rk[23]; 1094 /* round 6: */ 1095 s0 = Td0[t0 >> 24] ^ Td1[(t3 >> 16) & 0xff] ^ Td2[(t2 >> 8) & 0xff] ^ Td3[t1 & 0xff] ^ rk[24]; 1096 s1 = Td0[t1 >> 24] ^ Td1[(t0 >> 16) & 0xff] ^ Td2[(t3 >> 8) & 0xff] ^ Td3[t2 & 0xff] ^ rk[25]; 1097 s2 = Td0[t2 >> 24] ^ Td1[(t1 >> 16) & 0xff] ^ Td2[(t0 >> 8) & 0xff] ^ Td3[t3 & 0xff] ^ rk[26]; 1098 s3 = Td0[t3 >> 24] ^ Td1[(t2 >> 16) & 0xff] ^ Td2[(t1 >> 8) & 0xff] ^ Td3[t0 & 0xff] ^ rk[27]; 1099 /* round 7: */ 1100 t0 = Td0[s0 >> 24] ^ Td1[(s3 >> 16) & 0xff] ^ Td2[(s2 >> 8) & 0xff] ^ Td3[s1 & 0xff] ^ rk[28]; 1101 t1 = Td0[s1 >> 24] ^ Td1[(s0 >> 16) & 0xff] ^ Td2[(s3 >> 8) & 0xff] ^ Td3[s2 & 0xff] ^ rk[29]; 1102 t2 = Td0[s2 >> 24] ^ Td1[(s1 >> 16) & 0xff] ^ Td2[(s0 >> 8) & 0xff] ^ Td3[s3 & 0xff] ^ rk[30]; 1103 t3 = Td0[s3 >> 24] ^ Td1[(s2 >> 16) & 0xff] ^ Td2[(s1 >> 8) & 0xff] ^ Td3[s0 & 0xff] ^ rk[31]; 1104 /* round 8: */ 1105 s0 = Td0[t0 >> 24] ^ Td1[(t3 >> 16) & 0xff] ^ Td2[(t2 >> 8) & 0xff] ^ Td3[t1 & 0xff] ^ rk[32]; 1106 s1 = Td0[t1 >> 24] ^ Td1[(t0 >> 16) & 0xff] ^ Td2[(t3 >> 8) & 0xff] ^ Td3[t2 & 0xff] ^ rk[33]; 1107 s2 = Td0[t2 >> 24] ^ Td1[(t1 >> 16) & 0xff] ^ Td2[(t0 >> 8) & 0xff] ^ Td3[t3 & 0xff] ^ rk[34]; 1108 s3 = Td0[t3 >> 24] ^ Td1[(t2 >> 16) & 0xff] ^ Td2[(t1 >> 8) & 0xff] ^ Td3[t0 & 0xff] ^ rk[35]; 1109 /* round 9: */ 1110 t0 = Td0[s0 >> 24] ^ Td1[(s3 >> 16) & 0xff] ^ Td2[(s2 >> 8) & 0xff] ^ Td3[s1 & 0xff] ^ rk[36]; 1111 t1 = Td0[s1 >> 24] ^ Td1[(s0 >> 16) & 0xff] ^ Td2[(s3 >> 8) & 0xff] ^ Td3[s2 & 0xff] ^ rk[37]; 1112 t2 = Td0[s2 >> 24] ^ Td1[(s1 >> 16) & 0xff] ^ Td2[(s0 >> 8) & 0xff] ^ Td3[s3 & 0xff] ^ rk[38]; 1113 t3 = Td0[s3 >> 24] ^ Td1[(s2 >> 16) & 0xff] ^ Td2[(s1 >> 8) & 0xff] ^ Td3[s0 & 0xff] ^ rk[39]; 1114 if (Nr > 10) { 1115 /* round 10: */ 1116 s0 = Td0[t0 >> 24] ^ Td1[(t3 >> 16) & 0xff] ^ Td2[(t2 >> 8) & 0xff] ^ Td3[t1 & 0xff] ^ rk[40]; 1117 s1 = Td0[t1 >> 24] ^ Td1[(t0 >> 16) & 0xff] ^ Td2[(t3 >> 8) & 0xff] ^ Td3[t2 & 0xff] ^ rk[41]; 1118 s2 = Td0[t2 >> 24] ^ Td1[(t1 >> 16) & 0xff] ^ Td2[(t0 >> 8) & 0xff] ^ Td3[t3 & 0xff] ^ rk[42]; 1119 s3 = Td0[t3 >> 24] ^ Td1[(t2 >> 16) & 0xff] ^ Td2[(t1 >> 8) & 0xff] ^ Td3[t0 & 0xff] ^ rk[43]; 1120 /* round 11: */ 1121 t0 = Td0[s0 >> 24] ^ Td1[(s3 >> 16) & 0xff] ^ Td2[(s2 >> 8) & 0xff] ^ Td3[s1 & 0xff] ^ rk[44]; 1122 t1 = Td0[s1 >> 24] ^ Td1[(s0 >> 16) & 0xff] ^ Td2[(s3 >> 8) & 0xff] ^ Td3[s2 & 0xff] ^ rk[45]; 1123 t2 = Td0[s2 >> 24] ^ Td1[(s1 >> 16) & 0xff] ^ Td2[(s0 >> 8) & 0xff] ^ Td3[s3 & 0xff] ^ rk[46]; 1124 t3 = Td0[s3 >> 24] ^ Td1[(s2 >> 16) & 0xff] ^ Td2[(s1 >> 8) & 0xff] ^ Td3[s0 & 0xff] ^ rk[47]; 1125 if (Nr > 12) { 1126 /* round 12: */ 1127 s0 = Td0[t0 >> 24] ^ Td1[(t3 >> 16) & 0xff] ^ Td2[(t2 >> 8) & 0xff] ^ Td3[t1 & 0xff] ^ rk[48]; 1128 s1 = Td0[t1 >> 24] ^ Td1[(t0 >> 16) & 0xff] ^ Td2[(t3 >> 8) & 0xff] ^ Td3[t2 & 0xff] ^ rk[49]; 1129 s2 = Td0[t2 >> 24] ^ Td1[(t1 >> 16) & 0xff] ^ Td2[(t0 >> 8) & 0xff] ^ Td3[t3 & 0xff] ^ rk[50]; 1130 s3 = Td0[t3 >> 24] ^ Td1[(t2 >> 16) & 0xff] ^ Td2[(t1 >> 8) & 0xff] ^ Td3[t0 & 0xff] ^ rk[51]; 1131 /* round 13: */ 1132 t0 = Td0[s0 >> 24] ^ Td1[(s3 >> 16) & 0xff] ^ Td2[(s2 >> 8) & 0xff] ^ Td3[s1 & 0xff] ^ rk[52]; 1133 t1 = Td0[s1 >> 24] ^ Td1[(s0 >> 16) & 0xff] ^ Td2[(s3 >> 8) & 0xff] ^ Td3[s2 & 0xff] ^ rk[53]; 1134 t2 = Td0[s2 >> 24] ^ Td1[(s1 >> 16) & 0xff] ^ Td2[(s0 >> 8) & 0xff] ^ Td3[s3 & 0xff] ^ rk[54]; 1135 t3 = Td0[s3 >> 24] ^ Td1[(s2 >> 16) & 0xff] ^ Td2[(s1 >> 8) & 0xff] ^ Td3[s0 & 0xff] ^ rk[55]; 1136 } 1137 } 1138 rk += Nr << 2; 1139 #else /* !FULL_UNROLL */ 1140 /* 1141 * Nr - 1 full rounds: 1142 */ 1143 r = Nr >> 1; 1144 for (;;) { 1145 t0 = 1146 Td0[(s0 >> 24) ] ^ 1147 Td1[(s3 >> 16) & 0xff] ^ 1148 Td2[(s2 >> 8) & 0xff] ^ 1149 Td3[(s1 ) & 0xff] ^ 1150 rk[4]; 1151 t1 = 1152 Td0[(s1 >> 24) ] ^ 1153 Td1[(s0 >> 16) & 0xff] ^ 1154 Td2[(s3 >> 8) & 0xff] ^ 1155 Td3[(s2 ) & 0xff] ^ 1156 rk[5]; 1157 t2 = 1158 Td0[(s2 >> 24) ] ^ 1159 Td1[(s1 >> 16) & 0xff] ^ 1160 Td2[(s0 >> 8) & 0xff] ^ 1161 Td3[(s3 ) & 0xff] ^ 1162 rk[6]; 1163 t3 = 1164 Td0[(s3 >> 24) ] ^ 1165 Td1[(s2 >> 16) & 0xff] ^ 1166 Td2[(s1 >> 8) & 0xff] ^ 1167 Td3[(s0 ) & 0xff] ^ 1168 rk[7]; 1169 1170 rk += 8; 1171 if (--r == 0) { 1172 break; 1173 } 1174 1175 s0 = 1176 Td0[(t0 >> 24) ] ^ 1177 Td1[(t3 >> 16) & 0xff] ^ 1178 Td2[(t2 >> 8) & 0xff] ^ 1179 Td3[(t1 ) & 0xff] ^ 1180 rk[0]; 1181 s1 = 1182 Td0[(t1 >> 24) ] ^ 1183 Td1[(t0 >> 16) & 0xff] ^ 1184 Td2[(t3 >> 8) & 0xff] ^ 1185 Td3[(t2 ) & 0xff] ^ 1186 rk[1]; 1187 s2 = 1188 Td0[(t2 >> 24) ] ^ 1189 Td1[(t1 >> 16) & 0xff] ^ 1190 Td2[(t0 >> 8) & 0xff] ^ 1191 Td3[(t3 ) & 0xff] ^ 1192 rk[2]; 1193 s3 = 1194 Td0[(t3 >> 24) ] ^ 1195 Td1[(t2 >> 16) & 0xff] ^ 1196 Td2[(t1 >> 8) & 0xff] ^ 1197 Td3[(t0 ) & 0xff] ^ 1198 rk[3]; 1199 } 1200 #endif /* ?FULL_UNROLL */ 1201 /* 1202 * apply last round and 1203 * map cipher state to byte array block: 1204 */ 1205 s0 = 1206 (Td4[(t0 >> 24) ] & 0xff000000) ^ 1207 (Td4[(t3 >> 16) & 0xff] & 0x00ff0000) ^ 1208 (Td4[(t2 >> 8) & 0xff] & 0x0000ff00) ^ 1209 (Td4[(t1 ) & 0xff] & 0x000000ff) ^ 1210 rk[0]; 1211 PUTU32(pt , s0); 1212 s1 = 1213 (Td4[(t1 >> 24) ] & 0xff000000) ^ 1214 (Td4[(t0 >> 16) & 0xff] & 0x00ff0000) ^ 1215 (Td4[(t3 >> 8) & 0xff] & 0x0000ff00) ^ 1216 (Td4[(t2 ) & 0xff] & 0x000000ff) ^ 1217 rk[1]; 1218 PUTU32(pt + 4, s1); 1219 s2 = 1220 (Td4[(t2 >> 24) ] & 0xff000000) ^ 1221 (Td4[(t1 >> 16) & 0xff] & 0x00ff0000) ^ 1222 (Td4[(t0 >> 8) & 0xff] & 0x0000ff00) ^ 1223 (Td4[(t3 ) & 0xff] & 0x000000ff) ^ 1224 rk[2]; 1225 PUTU32(pt + 8, s2); 1226 s3 = 1227 (Td4[(t3 >> 24) ] & 0xff000000) ^ 1228 (Td4[(t2 >> 16) & 0xff] & 0x00ff0000) ^ 1229 (Td4[(t1 >> 8) & 0xff] & 0x0000ff00) ^ 1230 (Td4[(t0 ) & 0xff] & 0x000000ff) ^ 1231 rk[3]; 1232 PUTU32(pt + 12, s3); 463 1233 } 464 #endif /* INTERMEDIATE_VALUE_KAT */ 1234 465 1235 #endif -
trunk/src/rijndael-api-fst.c
r230 r481 1 /* 2 * rijndael-api-fst.c v2.3 April '2000 3 * 4 * Optimised ANSI C code 5 * 6 * authors: v1.0: Antoon Bosselaers 7 * v2.0: Vincent Rijmen 8 * v2.1: Vincent Rijmen 9 * v2.2: Vincent Rijmen 10 * v2.3: Paulo Barreto 11 * v2.4: Vincent Rijmen 12 * 13 * This code is placed in the public domain. 1 /* $NetBSD: rijndael-api-fst.c,v 1.24 2011/05/14 16:46:55 jmmv Exp $ */ 2 3 /** 4 * rijndael-api-fst.c 5 * 6 * @version 2.9 (December 2000) 7 * 8 * Optimised ANSI C code for the Rijndael cipher (now AES) 9 * 10 * @author Vincent Rijmen <vincent.rijmen@esat.kuleuven.ac.be> 11 * @author Antoon Bosselaers <antoon.bosselaers@esat.kuleuven.ac.be> 12 * @author Paulo Barreto <paulo.barreto@terra.com.br> 13 * 14 * This code is hereby placed in the public domain. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ''AS IS'' AND ANY EXPRESS 17 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE 20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 26 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * 28 * Acknowledgements: 29 * 30 * We are deeply indebted to the following people for their bug reports, 31 * fixes, and improvement suggestions to this implementation. Though we 32 * tried to list all contributions, we apologise in advance for any 33 * missing reference. 34 * 35 * Andrew Bales <Andrew.Bales@Honeywell.com> 36 * Markus Friedl <markus.friedl@informatik.uni-erlangen.de> 37 * John Skodon <skodonj@webquill.com> 14 38 */ 15 16 39 #include "config_xor.h" 17 40 18 #include <stdio.h>19 #include <assert.h>20 41 #include <stdlib.h> 21 42 #include <string.h> 22 43 44 23 45 #ifdef SH_ENCRYPT 24 46 25 47 #include "rijndael-api-fst.h" 26 48 27 int makeKey(keyInstance *key, RIJ_BYTE direction, int keyLen, char *keyMaterial) { 28 word8 k[MAXKC][4]; 29 int i; 30 char *keyMat; 31 32 if (key == NULL) { 33 return BAD_KEY_INSTANCE; 34 } 35 36 if ((direction == DIR_ENCRYPT) || (direction == DIR_DECRYPT)) { 37 key->direction = direction; 38 } else { 39 return BAD_KEY_DIR; 40 } 41 42 if ((keyLen == 128) || (keyLen == 192) || (keyLen == 256)) { 43 key->keyLen = keyLen; 44 } else { 45 return BAD_KEY_MAT; 46 } 47 48 if (keyMaterial != NULL) { 49 strncpy(key->keyMaterial, keyMaterial, keyLen/4); 50 } 51 52 key->ROUNDS = keyLen/32 + 6; 53 54 /* initialize key schedule: */ 55 keyMat = key->keyMaterial; 56 #ifndef BINARY_KEY_MATERIAL 57 for (i = 0; i < key->keyLen/8; i++) { 58 int t, j; 59 60 t = *keyMat++; 61 if ((t >= '0') && (t <= '9')) j = (t - '0') << 4; 62 else if ((t >= 'a') && (t <= 'f')) j = (t - 'a' + 10) << 4; 63 else if ((t >= 'A') && (t <= 'F')) j = (t - 'A' + 10) << 4; 64 else return BAD_KEY_MAT; 65 66 t = *keyMat++; 67 if ((t >= '0') && (t <= '9')) j ^= (t - '0'); 68 else if ((t >= 'a') && (t <= 'f')) j ^= (t - 'a' + 10); 69 else if ((t >= 'A') && (t <= 'F')) j ^= (t - 'A' + 10); 70 else return BAD_KEY_MAT; 71 72 k[i >> 2][i & 3] = (word8)j; 73 } 74 #else 75 for (i = 0; i < key->keyLen/8; i++) { 76 k[i >> 2][i & 3] = (word8)keyMat[i]; 77 } 78 #endif /* ?BINARY_KEY_MATERIAL */ 79 rijndaelKeySched(k, key->keySched, key->ROUNDS); 80 if (direction == DIR_DECRYPT) { 81 rijndaelKeyEncToDec(key->keySched, key->ROUNDS); 82 } 83 84 return TRUE; 85 } 86 87 int cipherInit(cipherInstance *cipher, RIJ_BYTE mode, char *IV) { 88 if ((mode == MODE_ECB) || (mode == MODE_CBC) || (mode == MODE_CFB1)) { 89 cipher->mode = mode; 90 } else { 91 return BAD_CIPHER_MODE; 92 } 93 if (IV != NULL) { 94 #ifndef BINARY_KEY_MATERIAL 95 int i; 96 for (i = 0; i < MAX_IV_SIZE; i++) { 97 int t, j; 98 99 t = IV[2*i]; 100 if ((t >= '0') && (t <= '9')) j = (t - '0') << 4; 101 else if ((t >= 'a') && (t <= 'f')) j = (t - 'a' + 10) << 4; 102 else if ((t >= 'A') && (t <= 'F')) j = (t - 'A' + 10) << 4; 103 else return BAD_CIPHER_INSTANCE; 104 105 t = IV[2*i+1]; 106 if ((t >= '0') && (t <= '9')) j ^= (t - '0'); 107 else if ((t >= 'a') && (t <= 'f')) j ^= (t - 'a' + 10); 108 else if ((t >= 'A') && (t <= 'F')) j ^= (t - 'A' + 10); 109 else return BAD_CIPHER_INSTANCE; 110 111 cipher->IV[i] = (word8)j; 112 } 113 #else 114 memcpy(cipher->IV, IV, MAX_IV_SIZE); 115 #endif /* ?BINARY_KEY_MATERIAL */ 116 } else { 117 memset(cipher->IV, 0, MAX_IV_SIZE); 118 } 119 return TRUE; 120 } 121 122 int blockEncrypt(cipherInstance *cipher, keyInstance *key, 123 RIJ_BYTE *input, int inputLen, RIJ_BYTE *outBuffer) { 124 int i, k, numBlocks; 125 union { 126 word32 bloc4[4]; 127 word8 block[16]; 128 } bb; 129 union { 130 word32 i4[4]; 131 word8 iv[4][4]; 132 } iu; 133 134 if (cipher == NULL || 135 key == NULL || 136 key->direction == DIR_DECRYPT) { 137 return BAD_CIPHER_STATE; 138 } 139 if (input == NULL || inputLen <= 0) { 140 return 0; /* nothing to do */ 141 } 142 143 numBlocks = inputLen/128; 144 145 switch (cipher->mode) { 146 case MODE_ECB: 147 for (i = numBlocks; i > 0; i--) { 148 rijndaelEncrypt(input, outBuffer, key->keySched, key->ROUNDS); 149 input += 16; 150 outBuffer += 16; 151 } 152 break; 153 154 case MODE_CBC: 155 /* fix the memory alignment for HP-UX 10.20 156 * R. Wichmann Mon Jun 18 22:36:55 CEST 2001 157 */ 158 #if STRICT_ALIGN 159 memcpy(iu.iv, cipher->IV, 16); 160 bb.bloc4[0] = iu.i4[0] ^ ((word32*)input)[0]; 161 bb.bloc4[1] = iu.i4[1] ^ ((word32*)input)[1]; 162 bb.bloc4[2] = iu.i4[2] ^ ((word32*)input)[2]; 163 bb.bloc4[3] = iu.i4[3] ^ ((word32*)input)[3]; 164 #else /* !STRICT_ALIGN */ 165 ((word32*)block)[0] = ((word32*)cipher->IV)[0] ^ ((word32*)input)[0]; 166 ((word32*)block)[1] = ((word32*)cipher->IV)[1] ^ ((word32*)input)[1]; 167 ((word32*)block)[2] = ((word32*)cipher->IV)[2] ^ ((word32*)input)[2]; 168 ((word32*)block)[3] = ((word32*)cipher->IV)[3] ^ ((word32*)input)[3]; 169 #endif /* ?STRICT_ALIGN */ 170 rijndaelEncrypt(bb.block, outBuffer, key->keySched, key->ROUNDS); 171 input += 16; 172 for (i = numBlocks - 1; i > 0; i--) { 173 bb.bloc4[0] = ((word32*)outBuffer)[0] ^ ((word32*)input)[0]; 174 bb.bloc4[1] = ((word32*)outBuffer)[1] ^ ((word32*)input)[1]; 175 bb.bloc4[2] = ((word32*)outBuffer)[2] ^ ((word32*)input)[2]; 176 bb.bloc4[3] = ((word32*)outBuffer)[3] ^ ((word32*)input)[3]; 177 outBuffer += 16; 178 rijndaelEncrypt(bb.block, outBuffer, key->keySched, key->ROUNDS); 179 input += 16; 180 } 181 break; 182 183 case MODE_CFB1: 184 #if STRICT_ALIGN 185 memcpy(iu.iv, cipher->IV, 16); 186 #else /* !STRICT_ALIGN */ 187 *((word32*)iv[0]) = *((word32*)(cipher->IV )); 188 *((word32*)iv[1]) = *((word32*)(cipher->IV+ 4)); 189 *((word32*)iv[2]) = *((word32*)(cipher->IV+ 8)); 190 *((word32*)iv[3]) = *((word32*)(cipher->IV+12)); 191 #endif /* ?STRICT_ALIGN */ 192 for (i = numBlocks; i > 0; i--) { 193 for (k = 0; k < 128; k++) { 194 bb.bloc4[0] = iu.i4[0]; 195 bb.bloc4[1] = iu.i4[1]; 196 bb.bloc4[2] = iu.i4[2]; 197 bb.bloc4[3] = iu.i4[3]; 198 rijndaelEncrypt(bb.block, bb.block, key->keySched, key->ROUNDS); 199 outBuffer[k/8] ^= (bb.block[0] & 0x80) >> (k & 7); 200 iu.iv[0][0] = (iu.iv[0][0] << 1) | (iu.iv[0][1] >> 7); 201 iu.iv[0][1] = (iu.iv[0][1] << 1) | (iu.iv[0][2] >> 7); 202 iu.iv[0][2] = (iu.iv[0][2] << 1) | (iu.iv[0][3] >> 7); 203 iu.iv[0][3] = (iu.iv[0][3] << 1) | (iu.iv[1][0] >> 7); 204 iu.iv[1][0] = (iu.iv[1][0] << 1) | (iu.iv[1][1] >> 7); 205 iu.iv[1][1] = (iu.iv[1][1] << 1) | (iu.iv[1][2] >> 7); 206 iu.iv[1][2] = (iu.iv[1][2] << 1) | (iu.iv[1][3] >> 7); 207 iu.iv[1][3] = (iu.iv[1][3] << 1) | (iu.iv[2][0] >> 7); 208 iu.iv[2][0] = (iu.iv[2][0] << 1) | (iu.iv[2][1] >> 7); 209 iu.iv[2][1] = (iu.iv[2][1] << 1) | (iu.iv[2][2] >> 7); 210 iu.iv[2][2] = (iu.iv[2][2] << 1) | (iu.iv[2][3] >> 7); 211 iu.iv[2][3] = (iu.iv[2][3] << 1) | (iu.iv[3][0] >> 7); 212 iu.iv[3][0] = (iu.iv[3][0] << 1) | (iu.iv[3][1] >> 7); 213 iu.iv[3][1] = (iu.iv[3][1] << 1) | (iu.iv[3][2] >> 7); 214 iu.iv[3][2] = (iu.iv[3][2] << 1) | (iu.iv[3][3] >> 7); 215 iu.iv[3][3] = (iu.iv[3][3] << 1) | ((outBuffer[k/8] >> (7-(k&7))) & 1); 216 } 217 } 218 break; 219 220 default: 221 return BAD_CIPHER_STATE; 222 } 223 224 return 128*numBlocks; 225 } 226 227 int blockDecrypt(cipherInstance *cipher, keyInstance *key, 228 RIJ_BYTE *input, int inputLen, RIJ_BYTE *outBuffer) { 229 int i, k, numBlocks; 230 union { 231 word32 bloc4[4]; 232 word8 block[16]; 233 } bb; 234 union { 235 word32 i4[4]; 236 word8 iv[4][4]; 237 } iu; 238 239 if (cipher == NULL || 240 key == NULL || 241 ((cipher->mode != MODE_CFB1) && (key->direction == DIR_ENCRYPT))) { 242 return BAD_CIPHER_STATE; 243 } 244 if (input == NULL || inputLen <= 0) { 245 return 0; /* nothing to do */ 246 } 247 248 numBlocks = inputLen/128; 249 250 switch (cipher->mode) { 251 case MODE_ECB: 252 for (i = numBlocks; i > 0; i--) { 253 rijndaelDecrypt(input, outBuffer, key->keySched, key->ROUNDS); 254 input += 16; 255 outBuffer += 16; 256 } 257 break; 258 259 case MODE_CBC: 260 #if STRICT_ALIGN 261 memcpy(iu.iv, cipher->IV, 16); 262 #else 263 *((word32*)iu.i4[0]) = *((word32*)(cipher->IV )); 264 *((word32*)iu.i4[1]) = *((word32*)(cipher->IV+ 4)); 265 *((word32*)iu.i4[2]) = *((word32*)(cipher->IV+ 8)); 266 *((word32*)iu.i4[3]) = *((word32*)(cipher->IV+12)); 49 static void xor16(u8 *d, const u8 *a, const u8* b) 50 { 51 size_t i; 52 53 for (i = 0; i < 4; i++) { 54 *d++ = *a++ ^ *b++; 55 *d++ = *a++ ^ *b++; 56 *d++ = *a++ ^ *b++; 57 *d++ = *a++ ^ *b++; 58 } 59 } 60 61 int 62 rijndael_makeKey(keyInstance *key, BYTE direction, int keyLen, 63 const char *keyMaterial) 64 { 65 u8 cipherKey[RIJNDAEL_MAXKB]; 66 int i; 67 68 if (key == NULL) { 69 return BAD_KEY_INSTANCE; 70 } 71 72 if ((direction == DIR_ENCRYPT) || (direction == DIR_DECRYPT)) { 73 key->direction = direction; 74 } else { 75 return BAD_KEY_DIR; 76 } 77 78 if ((keyLen == 128) || (keyLen == 192) || (keyLen == 256)) { 79 key->keyLen = keyLen; 80 } else { 81 return BAD_KEY_MAT; 82 } 83 84 if (keyMaterial != NULL) { 85 char temp[RIJNDAEL_MAX_KEY_SIZE]; 86 for (i = 0; i < key->keyLen/8; i++) { 87 int t, j; 88 89 t = *keyMaterial++; 90 if ((t >= '0') && (t <= '9')) j = (t - '0') << 4; 91 else if ((t >= 'a') && (t <= 'f')) j = (t - 'a' + 10) << 4; 92 else if ((t >= 'A') && (t <= 'F')) j = (t - 'A' + 10) << 4; 93 else return BAD_KEY_MAT; 94 95 t = *keyMaterial++; 96 if ((t >= '0') && (t <= '9')) j ^= (t - '0'); 97 else if ((t >= 'a') && (t <= 'f')) j ^= (t - 'a' + 10); 98 else if ((t >= 'A') && (t <= 'F')) j ^= (t - 'A' + 10); 99 else return BAD_KEY_MAT; 100 101 temp[i] = (u8)j; 102 } 103 104 /* memcpy(key->keyMaterial, keyMaterial, keyLen/8); */ 105 memcpy(key->keyMaterial, temp, keyLen/8); 106 } 107 108 /* initialize key schedule: */ 109 memcpy(cipherKey, key->keyMaterial, keyLen/8); 110 if (direction == DIR_ENCRYPT) { 111 key->Nr = rijndaelKeySetupEnc(key->rk, cipherKey, keyLen); 112 } else { 113 key->Nr = rijndaelKeySetupDec(key->rk, cipherKey, keyLen); 114 } 115 rijndaelKeySetupEnc(key->ek, cipherKey, keyLen); 116 return TRUE; 117 } 118 119 int 120 rijndael_cipherInit(cipherInstance *cipher, BYTE mode, const char *IV) 121 { 122 if ((mode == MODE_ECB) || (mode == MODE_CBC) || (mode == MODE_CFB1)) { 123 cipher->mode = mode; 124 } else { 125 return BAD_CIPHER_MODE; 126 } 127 if (IV != NULL) { 128 memcpy(cipher->IV, IV, RIJNDAEL_MAX_IV_SIZE); 129 } else { 130 memset(cipher->IV, 0, RIJNDAEL_MAX_IV_SIZE); 131 } 132 return TRUE; 133 } 134 135 int 136 rijndael_blockEncrypt(cipherInstance *cipher, keyInstance *key, 137 const BYTE *input, int inputLen, BYTE *outBuffer) 138 { 139 int i, k, t, numBlocks; 140 u8 block[16], *iv; 141 142 if (cipher == NULL || 143 key == NULL || 144 key->direction == DIR_DECRYPT) { 145 return BAD_CIPHER_STATE; 146 } 147 if (input == NULL || inputLen <= 0) { 148 return 0; /* nothing to do */ 149 } 150 151 numBlocks = inputLen/128; 152 153 switch (cipher->mode) { 154 case MODE_ECB: 155 for (i = numBlocks; i > 0; i--) { 156 rijndaelEncrypt(key->rk, key->Nr, input, outBuffer); 157 input += 16; 158 outBuffer += 16; 159 } 160 break; 161 162 case MODE_CBC: 163 iv = (u8 *)cipher->IV; 164 for (i = numBlocks; i > 0; i--) { 165 xor16(block, input, iv); 166 rijndaelEncrypt(key->rk, key->Nr, block, outBuffer); 167 iv = outBuffer; 168 input += 16; 169 outBuffer += 16; 170 } 171 break; 172 173 case MODE_CFB1: 174 iv = (u8 *)cipher->IV; 175 for (i = numBlocks; i > 0; i--) { 176 memcpy(outBuffer, input, 16); 177 for (k = 0; k < 128; k++) { 178 rijndaelEncrypt(key->ek, key->Nr, iv, block); 179 outBuffer[k >> 3] ^= 180 (block[0] & 0x80U) >> (k & 7); 181 for (t = 0; t < 15; t++) { 182 iv[t] = (iv[t] << 1) | (iv[t + 1] >> 7); 183 } 184 iv[15] = (iv[15] << 1) | 185 ((outBuffer[k >> 3] >> (7 - (k & 7))) & 1); 186 } 187 outBuffer += 16; 188 input += 16; 189 } 190 break; 191 192 default: 193 return BAD_CIPHER_STATE; 194 } 195 196 return 128 * numBlocks; 197 } 198 199 /** 200 * Encrypt data partitioned in octets, using RFC 2040-like padding. 201 * 202 * @param input data to be encrypted (octet sequence) 203 * @param inputOctets input length in octets (not bits) 204 * @param outBuffer encrypted output data 205 * 206 * @return length in octets (not bits) of the encrypted output buffer. 207 */ 208 int 209 rijndael_padEncrypt(cipherInstance *cipher, keyInstance *key, 210 const BYTE *input, int inputOctets, BYTE *outBuffer) 211 { 212 int i, numBlocks, padLen; 213 u8 block[16], *iv; 214 215 if (cipher == NULL || 216 key == NULL || 217 key->direction == DIR_DECRYPT) { 218 return BAD_CIPHER_STATE; 219 } 220 if (input == NULL || inputOctets <= 0) { 221 return 0; /* nothing to do */ 222 } 223 224 numBlocks = inputOctets / 16; 225 226 switch (cipher->mode) { 227 case MODE_ECB: 228 for (i = numBlocks; i > 0; i--) { 229 rijndaelEncrypt(key->rk, key->Nr, input, outBuffer); 230 input += 16; 231 outBuffer += 16; 232 } 233 padLen = 16 - (inputOctets - 16*numBlocks); 234 memcpy(block, input, 16 - padLen); 235 memset(block + 16 - padLen, padLen, padLen); 236 rijndaelEncrypt(key->rk, key->Nr, block, outBuffer); 237 break; 238 239 case MODE_CBC: 240 iv = (u8 *)cipher->IV; 241 for (i = numBlocks; i > 0; i--) { 242 xor16(block, input, iv); 243 rijndaelEncrypt(key->rk, key->Nr, block, outBuffer); 244 iv = outBuffer; 245 input += 16; 246 outBuffer += 16; 247 } 248 padLen = 16 - (inputOctets - 16*numBlocks); 249 for (i = 0; i < 16 - padLen; i++) { 250 block[i] = input[i] ^ iv[i]; 251 } 252 for (i = 16 - padLen; i < 16; i++) { 253 block[i] = (BYTE)padLen ^ iv[i]; 254 } 255 rijndaelEncrypt(key->rk, key->Nr, block, outBuffer); 256 break; 257 258 default: 259 return BAD_CIPHER_STATE; 260 } 261 262 return 16 * (numBlocks + 1); 263 } 264 265 int 266 rijndael_blockDecrypt(cipherInstance *cipher, keyInstance *key, 267 const BYTE *input, int inputLen, BYTE *outBuffer) 268 { 269 int i, k, t, numBlocks; 270 u8 block[16], *iv; 271 272 if (cipher == NULL || 273 key == NULL || 274 (cipher->mode != MODE_CFB1 && key->direction == DIR_ENCRYPT)) { 275 return BAD_CIPHER_STATE; 276 } 277 if (input == NULL || inputLen <= 0) { 278 return 0; /* nothing to do */ 279 } 280 281 numBlocks = inputLen/128; 282 283 switch (cipher->mode) { 284 case MODE_ECB: 285 for (i = numBlocks; i > 0; i--) { 286 rijndaelDecrypt(key->rk, key->Nr, input, outBuffer); 287 input += 16; 288 outBuffer += 16; 289 } 290 break; 291 292 case MODE_CBC: 293 iv = (u8 *)cipher->IV; 294 for (i = numBlocks; i > 0; i--) { 295 rijndaelDecrypt(key->rk, key->Nr, input, block); 296 xor16(block, block, iv); 297 if (numBlocks > 1) 298 memcpy(cipher->IV, input, 16); 299 memcpy(outBuffer, block, 16); 300 input += 16; 301 outBuffer += 16; 302 } 303 break; 304 305 case MODE_CFB1: 306 iv = (u8 *)cipher->IV; 307 for (i = numBlocks; i > 0; i--) { 308 memcpy(outBuffer, input, 16); 309 for (k = 0; k < 128; k++) { 310 rijndaelEncrypt(key->ek, key->Nr, iv, block); 311 for (t = 0; t < 15; t++) { 312 iv[t] = (iv[t] << 1) | (iv[t + 1] >> 7); 313 } 314 iv[15] = (iv[15] << 1) | 315 ((input[k >> 3] >> (7 - (k & 7))) & 1); 316 outBuffer[k >> 3] ^= (block[0] & 0x80U) >> 317 (k & 7); 318 } 319 outBuffer += 16; 320 input += 16; 321 } 322 break; 323 324 default: 325 return BAD_CIPHER_STATE; 326 } 327 328 return 128 * numBlocks; 329 } 330 331 int 332 rijndael_padDecrypt(cipherInstance *cipher, keyInstance *key, 333 const BYTE *input, int inputOctets, BYTE *outBuffer) 334 { 335 int i, numBlocks, padLen; 336 u8 block[16], *iv; 337 338 if (cipher == NULL || 339 key == NULL || 340 key->direction == DIR_ENCRYPT) { 341 return BAD_CIPHER_STATE; 342 } 343 if (input == NULL || inputOctets <= 0) { 344 return 0; /* nothing to do */ 345 } 346 if (inputOctets % 16 != 0) { 347 return BAD_DATA; 348 } 349 350 numBlocks = inputOctets/16; 351 352 switch (cipher->mode) { 353 case MODE_ECB: 354 /* all blocks but last */ 355 for (i = numBlocks - 1; i > 0; i--) { 356 rijndaelDecrypt(key->rk, key->Nr, input, outBuffer); 357 input += 16; 358 outBuffer += 16; 359 } 360 /* last block */ 361 rijndaelDecrypt(key->rk, key->Nr, input, block); 362 padLen = block[15]; 363 if (padLen >= 16) { 364 return BAD_DATA; 365 } 366 for (i = 16 - padLen; i < 16; i++) { 367 if (block[i] != padLen) { 368 return BAD_DATA; 369 } 370 } 371 memcpy(outBuffer, block, 16 - padLen); 372 break; 373 374 case MODE_CBC: 375 iv = (u8 *)cipher->IV; 376 /* all blocks but last */ 377 for (i = numBlocks - 1; i > 0; i--) { 378 rijndaelDecrypt(key->rk, key->Nr, input, block); 379 xor16(block, block, iv); 380 memcpy(cipher->IV, input, 16); 381 memcpy(outBuffer, block, 16); 382 input += 16; 383 outBuffer += 16; 384 } 385 /* last block */ 386 rijndaelDecrypt(key->rk, key->Nr, input, block); 387 xor16(block, block, iv); 388 padLen = block[15]; 389 if (padLen <= 0 || padLen > 16) { 390 return BAD_DATA; 391 } 392 for (i = 16 - padLen; i < 16; i++) { 393 if (block[i] != padLen) { 394 return BAD_DATA; 395 } 396 } 397 memcpy(outBuffer, block, 16 - padLen); 398 break; 399 400 default: 401 return BAD_CIPHER_STATE; 402 } 403 404 return 16 * numBlocks - padLen; 405 } 406 267 407 #endif 268 for (i = numBlocks; i > 0; i--) {269 rijndaelDecrypt(input, bb.block, key->keySched, key->ROUNDS);270 bb.bloc4[0] ^= iu.i4[0];271 bb.bloc4[1] ^= iu.i4[1];272 bb.bloc4[2] ^= iu.i4[2];273 bb.bloc4[3] ^= iu.i4[3];274 #if STRICT_ALIGN275 memcpy(iu.iv, input, 16);276 memcpy(outBuffer, bb.block, 16);277 #else278 *((word32*)iv[0]) = ((word32*)input)[0]; ((word32*)outBuffer)[0] = ((word32*)block)[0];279 *((word32*)iv[1]) = ((word32*)input)[1]; ((word32*)outBuffer)[1] = ((word32*)block)[1];280 *((word32*)iv[2]) = ((word32*)input)[2]; ((word32*)outBuffer)[2] = ((word32*)block)[2];281 *((word32*)iv[3]) = ((word32*)input)[3]; ((word32*)outBuffer)[3] = ((word32*)block)[3];282 #endif283 input += 16;284 outBuffer += 16;285 }286 break;287 288 case MODE_CFB1:289 #if STRICT_ALIGN290 memcpy(iu.iv, cipher->IV, 16);291 #else292 *((word32*)iv[0]) = *((word32*)(cipher->IV));293 *((word32*)iv[1]) = *((word32*)(cipher->IV+ 4));294 *((word32*)iv[2]) = *((word32*)(cipher->IV+ 8));295 *((word32*)iv[3]) = *((word32*)(cipher->IV+12));296 #endif297 for (i = numBlocks; i > 0; i--) {298 for (k = 0; k < 128; k++) {299 bb.bloc4[0] = iu.i4[0];300 bb.bloc4[1] = iu.i4[1];301 bb.bloc4[2] = iu.i4[2];302 bb.bloc4[3] = iu.i4[3];303 rijndaelEncrypt(bb.block, bb.block, key->keySched, key->ROUNDS);304 iu.iv[0][0] = (iu.iv[0][0] << 1) | (iu.iv[0][1] >> 7);305 iu.iv[0][1] = (iu.iv[0][1] << 1) | (iu.iv[0][2] >> 7);306 iu.iv[0][2] = (iu.iv[0][2] << 1) | (iu.iv[0][3] >> 7);307 iu.iv[0][3] = (iu.iv[0][3] << 1) | (iu.iv[1][0] >> 7);308 iu.iv[1][0] = (iu.iv[1][0] << 1) | (iu.iv[1][1] >> 7);309 iu.iv[1][1] = (iu.iv[1][1] << 1) | (iu.iv[1][2] >> 7);310 iu.iv[1][2] = (iu.iv[1][2] << 1) | (iu.iv[1][3] >> 7);311 iu.iv[1][3] = (iu.iv[1][3] << 1) | (iu.iv[2][0] >> 7);312 iu.iv[2][0] = (iu.iv[2][0] << 1) | (iu.iv[2][1] >> 7);313 iu.iv[2][1] = (iu.iv[2][1] << 1) | (iu.iv[2][2] >> 7);314 iu.iv[2][2] = (iu.iv[2][2] << 1) | (iu.iv[2][3] >> 7);315 iu.iv[2][3] = (iu.iv[2][3] << 1) | (iu.iv[3][0] >> 7);316 iu.iv[3][0] = (iu.iv[3][0] << 1) | (iu.iv[3][1] >> 7);317 iu.iv[3][1] = (iu.iv[3][1] << 1) | (iu.iv[3][2] >> 7);318 iu.iv[3][2] = (iu.iv[3][2] << 1) | (iu.iv[3][3] >> 7);319 iu.iv[3][3] = (iu.iv[3][3] << 1) | ((input[k/8] >> (7-(k&7))) & 1);320 outBuffer[k/8] ^= (bb.block[0] & 0x80) >> (k & 7);321 }322 }323 break;324 325 default:326 return BAD_CIPHER_STATE;327 }328 329 return 128*numBlocks;330 }331 #ifdef INTERMEDIATE_VALUE_KAT332 /**333 * cipherUpdateRounds:334 *335 * Encrypts/Decrypts exactly one full block a specified number of rounds.336 * Only used in the Intermediate Value Known Answer Test.337 *338 * Returns:339 * TRUE - on success340 * BAD_CIPHER_STATE - cipher in bad state (e.g., not initialized)341 */342 int cipherUpdateRounds(cipherInstance *cipher, keyInstance *key,343 RIJ_BYTE *input, int inputLen, RIJ_BYTE *outBuffer, int rounds) {344 int j;345 word8 block[4][4];346 347 if (cipher == NULL || key == NULL) {348 return BAD_CIPHER_STATE;349 }350 351 for (j = 3; j >= 0; j--) {352 /* parse input stream into rectangular array */353 *((word32*)block[j]) = *((word32*)(input+4*j));354 }355 356 switch (key->direction) {357 case DIR_ENCRYPT:358 rijndaelEncryptRound(block, key->keySched, key->ROUNDS, rounds);359 break;360 361 case DIR_DECRYPT:362 rijndaelDecryptRound(block, key->keySched, key->ROUNDS, rounds);363 break;364 365 default:366 return BAD_KEY_DIR;367 }368 369 for (j = 3; j >= 0; j--) {370 /* parse rectangular array into output ciphertext bytes */371 *((word32*)(outBuffer+4*j)) = *((word32*)block[j]);372 }373 374 return TRUE;375 }376 #endif /* INTERMEDIATE_VALUE_KAT */377 #endif -
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")); -
trunk/src/sh_calls.c
r473 r481 262 262 errno = error; 263 263 264 if (flag_err_debug == S L_TRUE)264 if (flag_err_debug == S_TRUE) 265 265 { 266 266 char ipbuf[SH_IP_BUF]; … … 291 291 sh_ipvx_save(serv_addr, ss.ss_family, (struct sockaddr *) &ss); 292 292 293 if (flag_err_debug == S L_TRUE)293 if (flag_err_debug == S_TRUE) 294 294 { 295 295 char ipbuf[SH_IP_BUF]; … … 490 490 #endif 491 491 492 SL_ENTER(_("retry_msleep"));493 494 492 errno = 0; 495 493 if (millisec > 999) millisec = 999; … … 511 509 #else 512 510 if (sec > 0) 513 { 514 sleep (sec); /* nanosleep not available */ 515 } 516 else 517 { 511 sleep (sec); /* nanosleep not available */ 512 else { 518 513 #ifdef HAVE_USLEEP 519 if (millisec > 0) 520 { 521 usleep(1000 * millisec); 522 } 514 if (millisec > 0) 515 usleep(1000 * millisec); 523 516 #else 524 if (millisec > 0) 525 { 526 sleep (1); 527 } 528 #endif 529 } 530 #endif 531 SL_RETURN(result, _("retry_msleep")); 517 if (millisec > 0) 518 sleep (1); 519 #endif 520 } 521 #endif 522 return result; 532 523 } 533 524 … … 835 826 836 827 /*@noreturn@*/ 837 void aud_exit (const char * file, int line, int fd)828 void aud_exit (const char * file, int line, int exitval) 838 829 { 839 830 if (sh.flag.audit != 0 && (sh.flag.aud_mask & AUD_EXIT) != 0) 840 831 sh_error_handle ((-1), file, line, 0, MSG_AUD_EXIT, 841 (long) fd);832 (long) exitval); 842 833 843 834 SL_ENTER(_("aud_exit")); 844 835 845 sh.flag.exit = fd;846 exit( fd);836 sh.flag.exit = exitval; 837 exit(exitval); 847 838 } 848 839 849 840 /*@noreturn@*/ 850 void aud__exit (const char * file, int line, int fd)841 void aud__exit (const char * file, int line, int exitval) 851 842 { 852 843 if (sh.flag.audit != 0 && (sh.flag.aud_mask & AUD_EXIT) != 0) 853 844 sh_error_handle ((-1), file, line, 0, MSG_AUD_EXIT, 854 (long) fd);845 (long) exitval); 855 846 856 847 SL_ENTER(_("aud__exit")); 857 848 858 sh.flag.exit = fd;859 _exit( fd);849 sh.flag.exit = exitval; 850 _exit(exitval); 860 851 } 861 852 -
trunk/src/sh_cat.c
r403 r481 70 70 { MSG_CHECK_0, SH_ERR_WARN, RUN, N_("msg=\"No files or directories defined for checking\"")}, 71 71 { MSG_CHECK_1, SH_ERR_STAMP, STAMP, N_("msg=\"File check completed.\" time=\"%ld\" kBps=\"%f\"")}, 72 { MSG_CHECK_2, SH_ERR_STAMP, STAMP, N_("msg=\"File check starting.\"")}, 72 73 { MSG_STAMP, SH_ERR_STAMP, STAMP, N_("msg=\"---- TIMESTAMP ----\"")}, 73 74 … … 75 76 { MSG_D_DSTART, SH_ERR_INFO, RUN, N_("msg=\"Downloading database file\"")}, 76 77 { MSG_D_FAIL, SH_ERR_INFO, RUN, N_("msg=\"No file from server, trying local file\"")}, 78 { MSG_D_DELTAOK, SH_ERR_SEVERE, RUN, N_("msg=\"Delta database downloaded\", path=\"%s\"")}, 79 { MSG_D_DELTAFAIL, SH_ERR_SEVERE, RUN, N_("msg=\"Delta database download failed\", path=\"%s\"")}, 77 80 78 81 … … 93 96 { MSG_SUID_QREPORT,SH_ERR_SEVERE, EVENT, N_("msg=\"Quarantine report: %s\" path=\"%s\"") }, 94 97 { MSG_SUID_ERROR, SH_ERR_SEVERE, EVENT, N_("msg=\"Quarantine error: %s\"") }, 95 #endif96 97 #ifdef SH_USE_KERN98 /* FreeBSD */99 { MSG_KERN_POLICY, SH_ERR_SEVERE, EVENT, N_("msg=\"POLICY [Kernel] BSD syscall table: new: %#lx old: %#lx\" syscall=\"%03d %s\"") },100 { MSG_KERN_POL_CO, SH_ERR_SEVERE, EVENT, N_("msg=\"POLICY [Kernel] BSD syscall code: new: %#x,%#x old: %#x,%#x\" syscall=\"%03d %s\"") },101 102 /* Linux */103 { MSG_KERN_SYSCALL,SH_ERR_SEVERE, EVENT, N_("msg=\"POLICY [Kernel] SYSCALL modified syscall\" syscall=\"%03d %s\" %s") },104 { MSG_KERN_PROC, SH_ERR_SEVERE, EVENT, N_("msg=\"POLICY [Kernel] PROC modified proc filesystem: %s\"") },105 { MSG_KERN_IDT, SH_ERR_SEVERE, EVENT, N_("msg=\"POLICY [Kernel] IDT modified interrupt %03d: new: 0x%-8.8lx %-9s %3d %c old: 0x%-8.8lx %-9s %3d %c\" %s") },106 { MSG_KERN_GATE, SH_ERR_SEVERE, EVENT, N_("msg=\"POLICY [Kernel] SYS_GATE modified system_call: new: %#x,%#x old: %#x,%#x\" syscall=\"%03d %s\" %s") },107 108 98 #endif 109 99 … … 411 401 { MSG_CHECK_0, SH_ERR_WARN, RUN, N_("msg=<No files or directories defined for checking>")}, 412 402 { MSG_CHECK_1, SH_ERR_STAMP, STAMP, N_("msg=<File check completed.>, time=<%ld>, kBps=<%f>")}, 403 { MSG_CHECK_2, SH_ERR_STAMP, STAMP, N_("msg=<File check starting.>")}, 413 404 { MSG_STAMP, SH_ERR_STAMP, STAMP, N_("msg=<---- TIMESTAMP ---->")}, 414 405 … … 416 407 { MSG_D_DSTART, SH_ERR_INFO, RUN, N_("msg=<Downloading database file>")}, 417 408 { MSG_D_FAIL, SH_ERR_INFO, RUN, N_("msg=<No file from server, trying local file>")}, 409 { MSG_D_DELTAOK, SH_ERR_SEVERE, RUN, N_("msg=<Delta database downloaded>, path=<%s>")}, 410 { MSG_D_DELTAFAIL, SH_ERR_SEVERE, RUN, N_("msg=<Delta database download failed>, path=<%s>")}, 418 411 419 412 -
trunk/src/sh_database.c
r454 r481 180 180 { NULL, N_("link_old"), 0, 49, MAX_PATH_STORE+1, 0, offsetof(struct dbins_, link_old)}, 181 181 { NULL, N_("link_new"), 0, 50, MAX_PATH_STORE+1, 0, offsetof(struct dbins_, link_new)}, 182 182 183 /* These go into dbins.ulong_data[n - START_SEC_LONGS] */ 183 184 { NULL, N_("size_old"), 0, 51, 0, 0, 0 }, 184 185 { NULL, N_("size_new"), 0, 52, 0, 0, 0 }, … … 201 202 { NULL, N_("port"), 0, 67, 0, 0, 0 }, 202 203 { NULL, N_("return_code"), 0, 68, 0, 0, 0 }, 203 /* { NULL, N_("userid"), 0, 69, 0, 0 }, old 'userid', 1.8.1 */ 204 205 { NULL, N_("host"), 0, 70, 64, 0, offsetof(struct dbins_, fromhost)}, 206 { NULL, N_("attr_old"), 0, 71, 16, 0, offsetof(struct dbins_, attr_old)}, 207 { NULL, N_("attr_new"), 0, 72, 16, 0, offsetof(struct dbins_, attr_new)}, 208 { NULL, N_("acl_old"), 0, 73, 1024, 0, offsetof(struct dbins_, acl_old)}, 209 { NULL, N_("acl_new"), 0, 74, 1024, 0, offsetof(struct dbins_, acl_new)}, 204 205 { NULL, N_("checkflags_old"), 0, 69, 0, 0, 0 }, 206 { NULL, N_("checkflags_new"), 0, 70, 0, 0, 0 }, 207 208 /* END_SEC_LONGS */ 209 210 { NULL, N_("host"), 0, 71, 64, 0, offsetof(struct dbins_, fromhost)}, 211 { NULL, N_("attr_old"), 0, 72, 16, 0, offsetof(struct dbins_, attr_old)}, 212 { NULL, N_("attr_new"), 0, 73, 16, 0, offsetof(struct dbins_, attr_new)}, 213 { NULL, N_("acl_old"), 0, 74, 1024, 0, offsetof(struct dbins_, acl_old)}, 214 { NULL, N_("acl_new"), 0, 75, 1024, 0, offsetof(struct dbins_, acl_new)}, 210 215 211 216 { NULL, NULL, 0, 0, 0, 0, 0 } 212 217 }; 213 218 214 #define SH_SLOT_HOST 70 219 #define SH_SLOT_CHECKFLAGS 69 220 221 /* need special attention b/o reserved SQL words */ 222 #define SH_SLOT_HOST 71 215 223 #define SH_SLOT_GROUP 7 224 225 /* these go into dbins.ulong_data[n-START_SEC_LONGS */ 216 226 #define START_SEC_LONGS 51 217 #define END_SEC_LONGS 68227 #define END_SEC_LONGS 70 218 228 219 229 #if defined(HAVE_INT_32) … … 1163 1173 } 1164 1174 1165 if (flag_err_debug == S L_TRUE)1175 if (flag_err_debug == S_TRUE) 1166 1176 { 1167 1177 p = mysql_info (db_conn); … … 1360 1370 while (attr_tab[i].attr != NULL) 1361 1371 { 1372 if (SH_SLOT_CHECKFLAGS == attr_tab[i].val) { 1373 if (db_entry->ulong_data[attr_tab[i].val-START_SEC_LONGS] == 0 && 1374 db_entry->ulong_data[attr_tab[i+1].val-START_SEC_LONGS] == 0) 1375 { i+= 2; continue; } 1376 } 1377 1362 1378 if (attr_tab[i].size != 0) 1363 1379 { … … 1728 1744 (size_t) res->size); 1729 1745 } 1730 else if (res->val >= START_SEC_LONGS )1746 else if (res->val >= START_SEC_LONGS && res->val <= END_SEC_LONGS) 1731 1747 { 1732 1748 db_entry->ulong_data[res->val-START_SEC_LONGS] 1733 = strtoul(&p[j+2], (char **) NULL, 10); 1734 /* atol(&p[j+2]); */ 1749 = strtoul(&p[j+2], (char **) NULL, 0); 1735 1750 } 1736 1751 -
trunk/src/sh_entropy.c
r473 r481 300 300 { 301 301 m_count = sl_read_timeout_fd(fd2, nbuf, nbytes, 302 timeout_val, S L_FALSE);302 timeout_val, S_FALSE); 303 303 if (m_count < 0) 304 304 m_count = 0; … … 337 337 338 338 #ifdef NAME_OF_DEV_URANDOM 339 m_count = read_mbytes ( 1, NAME_OF_DEV_RANDOM, nbuf, nbytes);339 m_count = read_mbytes ( 10, NAME_OF_DEV_URANDOM, nbuf, nbytes); 340 340 #else 341 m_count = read_mbytes (300, NAME_OF_DEV_RANDOM, nbuf, nbytes);341 m_count = read_mbytes (300, NAME_OF_DEV_RANDOM, nbuf, nbytes); 342 342 #endif 343 343 … … 346 346 #ifdef NAME_OF_DEV_URANDOM 347 347 sh_error_handle (SH_ERR_NOTICE, FIL__, __LINE__, EIO, MSG_NODEV, 348 (long) sh.real.uid, NAME_OF_DEV_ RANDOM);348 (long) sh.real.uid, NAME_OF_DEV_URANDOM); 349 349 #else 350 350 sh_error_handle ((-1), FIL__, __LINE__, EIO, MSG_NODEV, … … 353 353 } 354 354 355 #ifdef NAME_OF_DEV_ URANDOM355 #ifdef NAME_OF_DEV_RANDOM 356 356 if (m_count < nbytes) 357 357 { 358 i = read_mbytes(30 , NAME_OF_DEV_URANDOM, &nbuf[m_count], nbytes-m_count);358 i = read_mbytes(300, NAME_OF_DEV_RANDOM, &nbuf[m_count], nbytes-m_count); 359 359 if (i == 0) 360 360 sh_error_handle ((-1), FIL__, __LINE__, EIO, MSG_NODEV, 361 (long) sh.real.uid, NAME_OF_DEV_ URANDOM);361 (long) sh.real.uid, NAME_OF_DEV_RANDOM); 362 362 else 363 363 m_count += i; … … 601 601 /* don't leak file descriptors 602 602 */ 603 sh_unix_closeall (3, -1, S L_TRUE); /* in child process */603 sh_unix_closeall (3, -1, S_TRUE); /* in child process */ 604 604 605 605 /* zero priv info … … 942 942 } 943 943 944 #ifdef HAVE_GETTIMEOFDAY 945 { 946 unsigned short tseed[3]; 947 948 gettimeofday(&tv, 0); 949 tseed[0] = tv.tv_sec & 0xFFFF; 950 tseed[1] = tv.tv_usec & 0xFFFF; 951 tseed[2] = (tv.tv_sec ^ tv.tv_usec) >> 16; 952 keybuf = (char *) sh_tiger_hash_uint32 ((char *) tseed, 953 TIGER_DATA, sizeof(tseed), 954 kbuf, KEY_BYT/sizeof(UINT32)); 955 memset(addbuf, '\0', sizeof(addbuf)); 956 for (i = 0; i < KEY_BYT; ++i) 957 { 958 addbuf[i] = keybuf[i]; 959 addbuf[i+KEY_BYT] = skey->poolv[i]; 960 } 961 SH_MUTEX_LOCK_UNSAFE(mutex_skey); 962 for (i = 0; i < KEY_BYT; ++i) 963 skey->poolv[i] ^= keybuf[i]; 964 SH_MUTEX_UNLOCK_UNSAFE(mutex_skey); 965 } 966 #endif 967 944 968 if (bufcount > 0) 945 969 { … … 1002 1026 char bufy[9 * sizeof(UINT32) + 1]; 1003 1027 int status; 1004 1005 memset(skey->poolv, '\0', KEY_BYT); 1006 1007 status = sh_entropy (24, bufx); 1008 CuAssertTrue(tc, 0 == status); 1009 1010 memset(skey->poolv, '\0', KEY_BYT); 1011 1012 status = sh_entropy (24, bufy); 1013 CuAssertTrue(tc, 0 == status); 1014 1015 CuAssertTrue(tc, 0 != memcmp(bufx, bufy, 24)); 1028 int count; 1029 1030 for (count = 0; count < 20; ++count) 1031 { 1032 memset(skey->poolv, '\0', KEY_BYT); 1033 skey->poolc = 0; 1034 1035 status = sh_entropy (24, bufx); 1036 CuAssertTrue(tc, 0 == status); 1037 1038 memset(skey->poolv, '\0', KEY_BYT); 1039 skey->poolc = 0; 1040 1041 status = sh_entropy (24, bufy); 1042 CuAssertTrue(tc, 0 == status); 1043 1044 CuAssertTrue(tc, 0 != memcmp(bufx, bufy, 24)); 1045 } 1016 1046 } 1017 1047 #endif -
trunk/src/sh_err_console.c
r474 r481 25 25 #include "sh_error.h" 26 26 #include "sh_utils.h" 27 #include "sh_sem.h" 27 28 28 29 #undef FIL__ … … 36 37 37 38 extern int OnlyStderr; 38 39 39 40 40 #if !defined(O_NONBLOCK) … … 53 53 #include <sys/msg.h> 54 54 55 #if !defined(EIDRM) 56 #define EIDRM (EINVAL) 57 #endif 58 55 59 struct sh_msgbuf { 56 60 long mtype; … … 66 70 /* Open the SysV message queue, creating it when neccesary 67 71 */ 68 static int open_ ipc(void)72 static int open_queue(void) 69 73 { 70 74 key_t key; 71 75 #if defined(WITH_TPT) 72 int error = 0;73 76 char errbuf[SH_ERRBUF_SIZE]; 74 77 #endif 75 78 76 SL_ENTER(_("open_ ipc"));79 SL_ENTER(_("open_queue")); 77 80 78 81 /* get key 79 82 */ 80 key = ftok ("/tmp", '#'); 83 key = ftok (DEFAULT_DATAROOT, '#'); 84 81 85 if (key == (key_t) -1) 82 86 { 83 #if defined(WITH_TPT)84 error = errno;85 #endif86 87 TPT(( 0, FIL__, __LINE__, _("msg=<ftok: %s> errno=<%d>\n"), 87 sh_error_message(err or, errbuf, sizeof(errbuf)), error));88 SL_RETURN(-1, _("open_ ipc"));88 sh_error_message(errno, errbuf, sizeof(errbuf)), errno)); 89 SL_RETURN(-1, _("open_queue")); 89 90 } 90 91 … … 95 96 if (msgid < 0) 96 97 { 97 #if defined(WITH_TPT)98 error = errno;99 #endif100 98 TPT(( 0, FIL__, __LINE__, _("msg=<msgget: %s> errno=<%d>\n"), 101 sh_error_message(err or, errbuf, sizeof(errbuf)), error));102 SL_RETURN(-1, _("open_ ipc"));103 } 104 105 SL_RETURN(0, _("open_ ipc"));106 } 107 108 /* Close the SysV message queue 99 sh_error_message(errno, errbuf, sizeof(errbuf)), errno)); 100 SL_RETURN(-1, _("open_queue")); 101 } 102 103 SL_RETURN(0, _("open_queue")); 104 } 105 106 /* Close the SysV message queue and/or semaphore 109 107 */ 110 108 void close_ipc (void) 111 109 { 112 SL_ENTER(_("close_ipc"));113 114 110 if (msgid != (-1)) 115 111 (void) msgctl (msgid, IPC_RMID, NULL); 116 SL_RET0(_("close_ipc")); 112 sh_sem_close(); 113 return; 117 114 } 118 115 … … 128 125 } 129 126 130 /* #define MY_MAX_MSG 254 */131 127 #define MY_MAX_MSG 1022 128 129 static void remove_message() 130 { 131 int rc; 132 struct { 133 long mtype; /* Message type. */ 134 char mtext[128]; /* Message text. */ 135 } recv_msg; 136 137 recv_msg.mtype = 1; 138 do { 139 rc = msgrcv(msgid, &recv_msg, sizeof(recv_msg.mtext), 1, 140 MSG_NOERROR|IPC_NOWAIT); 141 } while (rc < 0 && errno == EINTR); 142 143 memset(&recv_msg, '\0', sizeof(recv_msg)); 144 return; 145 } 132 146 133 147 static int push_message_queue (const char * msg) … … 138 152 int count = 0; 139 153 #if defined(WITH_TPT) 140 int error = 0;141 154 char errbuf[SH_ERRBUF_SIZE]; 142 155 #endif … … 153 166 { 154 167 TPT(( 0, FIL__, __LINE__, _("msg=<msg_queue not open>\n"))); 155 status = open_ ipc();168 status = open_queue(); 156 169 } 157 170 158 171 if (status < 0) 159 172 { 160 TPT(( 0, FIL__, __LINE__, _("msg=<open_ ipc() failed>\n")));173 TPT(( 0, FIL__, __LINE__, _("msg=<open_queue() failed>\n"))); 161 174 SL_RETURN(-1, _("push_message_queue")); 162 175 } … … 165 178 * long mtype; 166 179 * char mtext[1]; <-- sizeof(mtext) will be 1+MY_MAX_MSG 167 * } 168 */ 180 * } */ 181 169 182 recv_msg = (struct sh_msgbuf*) SH_ALLOC(sizeof(struct sh_msgbuf)+MY_MAX_MSG); 170 183 recv_msg->mtype = 1; … … 177 190 if (count > 1) 178 191 { 192 memset(recv_msg, '\0', MY_MAX_MSG+1); 179 193 SH_FREE(recv_msg); 180 194 SL_RETURN(-1, _("push_message_queue")); 181 195 } 182 196 183 /* send the message 184 */ 185 do { 186 errno = 0; 197 do { errno = 0; 187 198 rc = msgsnd(msgid, recv_msg, strlen(recv_msg->mtext)+1, IPC_NOWAIT); 188 } 189 while (rc < 0 && errno == EINTR); 199 200 if (rc == -1 && errno == EAGAIN) 201 remove_message(); 202 } while (rc < 0 && (errno == EINTR && errno == EAGAIN)); 190 203 191 204 if (rc == -1 && errno != EAGAIN) 192 205 { 193 /* EIDRM is not in OpenBSD 194 */ 195 if (errno == EINVAL 196 #if defined(EIDRM) 197 || errno == EIDRM 198 #endif 199 ) 200 { 201 TPT(( 0, FIL__, __LINE__, _("msg=<msg_queue not open>\n"))); 202 status = open_ipc(); 203 if (status == 0) 204 { 205 ++count; 206 goto send_it; 207 } 208 } 209 else 210 { 211 #if defined(WITH_TPT) 212 error = errno; 213 #endif 214 TPT(( 0, FIL__, __LINE__, _("msg=<msgsnd: %s> errno=<%d>\n"), 215 sh_error_message(error, errbuf, sizeof(errbuf)), error)); 216 SH_FREE(recv_msg); 217 SL_RETURN(-1, _("push_message_queue")); 218 } 219 } 220 206 /* EIDRM is not in OpenBSD */ 207 if (errno == EINVAL || errno == EIDRM) { 208 TPT(( 0, FIL__, __LINE__, _("msg=<msg_queue not open>\n"))); 209 status = open_queue(); 210 if (status == 0) { 211 ++count; 212 goto send_it; } 213 } else { 214 TPT(( 0, FIL__, __LINE__, _("msg=<msgsnd: %s> errno=<%d>\n"), 215 sh_error_message(errno, errbuf, sizeof(errbuf)), errno)); 216 memset(recv_msg, '\0', MY_MAX_MSG+1); 217 SH_FREE(recv_msg); 218 SL_RETURN(-1, _("push_message_queue")); 219 } 220 } 221 222 memset(recv_msg, '\0', MY_MAX_MSG+1); 221 223 SH_FREE(recv_msg); 224 222 225 SL_RETURN(0, _("push_message_queue")); 223 226 } … … 234 237 #endif 235 238 239 #else /* no message queue */ 240 241 void close_ipc() { sh_sem_close(); return; } 242 236 243 #endif 237 244 … … 283 290 static int service_failure[2] = { 0, 0}; 284 291 int fd[2] = { -1, -1}; 285 int sflags;286 292 int cc; 287 293 size_t len; … … 331 337 { 332 338 fd[0] = open ( sh.srvcons.name, O_WRONLY|O_APPEND|O_NOCTTY|O_NONBLOCK); 333 if (fd[0] >= 0) {334 sflags = (int) retry_fcntl(FIL__, __LINE__, fd[0], F_GETFL, 0);335 if (sflags >= 0)336 {337 (void) retry_fcntl(FIL__, __LINE__, fd[0],338 F_SETFL, sflags & ~O_NONBLOCK);339 }340 }341 339 342 340 if (sh.srvcons.alt[0] != '\0') 343 341 { 344 342 fd[1] = open (sh.srvcons.alt, O_WRONLY|O_APPEND|O_NOCTTY|O_NONBLOCK); 345 if (fd[1] >= 0) { 346 sflags = (int) retry_fcntl(FIL__, __LINE__, fd[1], F_GETFL, 0); 347 if (sflags >= 0) 348 { 349 (void) retry_fcntl(FIL__, __LINE__, fd[1], 350 F_SETFL, sflags & ~O_NONBLOCK); 351 } 352 ccMax = 2; 353 } 343 ccMax = 2; 354 344 } 355 345 -
trunk/src/sh_err_log.c
r459 r481 770 770 771 771 #if defined(HAVE_MLOCK) && !defined(HAVE_BROKEN_MLOCK) 772 if (skey->mlock_failed == S L_FALSE)772 if (skey->mlock_failed == S_FALSE) 773 773 { 774 774 if ( (-1) == sh_unix_mlock( FIL__, __LINE__, log_msg.msg, 775 775 (size_t)(2*KEY_LEN + status + 32) ) ) 776 776 { 777 skey->mlock_failed = S L_TRUE;777 skey->mlock_failed = S_TRUE; 778 778 #if defined (SH_WITH_CLIENT) || defined (SH_STANDALONE) 779 779 sh_error_handle ((-1), FIL__, __LINE__, EPERM, MSG_MLOCK); … … 782 782 } 783 783 #else 784 if (skey->mlock_failed == S L_FALSE)785 { 786 skey->mlock_failed = S L_TRUE;784 if (skey->mlock_failed == S_FALSE) 785 { 786 skey->mlock_failed = S_TRUE; 787 787 #if defined (SH_WITH_CLIENT) || defined (SH_STANDALONE) 788 788 sh_error_handle ((-1), FIL__, __LINE__, EPERM, MSG_MLOCK); … … 1207 1207 int i; 1208 1208 1209 if (S L_TRUE == sl_ok_adds (gSave[0], sh.statistics.bytes_hashed))1209 if (S_TRUE == sl_ok_adds (gSave[0], sh.statistics.bytes_hashed)) 1210 1210 gSave[0] += sh.statistics.bytes_hashed; 1211 if (S L_TRUE == sl_ok_adds (gSave[1], sh.statistics.dirs_checked))1211 if (S_TRUE == sl_ok_adds (gSave[1], sh.statistics.dirs_checked)) 1212 1212 gSave[1] += sh.statistics.dirs_checked; 1213 if (S L_TRUE == sl_ok_adds (gSave[2], sh.statistics.files_checked))1213 if (S_TRUE == sl_ok_adds (gSave[2], sh.statistics.files_checked)) 1214 1214 gSave[2] += sh.statistics.files_checked; 1215 if (S L_TRUE == sl_ok_adds (gSave[3], sh.statistics.files_report))1215 if (S_TRUE == sl_ok_adds (gSave[3], sh.statistics.files_report)) 1216 1216 gSave[3] += sh.statistics.files_report; 1217 if (S L_TRUE == sl_ok_adds (gSave[4], sh.statistics.files_error))1217 if (S_TRUE == sl_ok_adds (gSave[4], sh.statistics.files_error)) 1218 1218 gSave[4] += sh.statistics.files_error; 1219 if (S L_TRUE == sl_ok_adds (gSave[5], sh.statistics.files_nodir))1219 if (S_TRUE == sl_ok_adds (gSave[5], sh.statistics.files_nodir)) 1220 1220 gSave[5] += sh.statistics.files_nodir; 1221 1221 -
trunk/src/sh_error.c
r476 r481 60 60 #include "sh_tiger.h" 61 61 #include "sh_nmail.h" 62 #include "sh_ forward.h"62 #include "sh_xfer.h" 63 63 #include "sh_prelude.h" 64 64 #include "sh_pthread.h" … … 77 77 extern int clt_class; 78 78 79 int flag_err_debug = S L_FALSE;80 int flag_err_info = S L_FALSE;79 int flag_err_debug = S_FALSE; 80 int flag_err_info = S_FALSE; 81 81 82 82 int ShDFLevel[SH_ERR_T_END]; … … 100 100 static int sh_error_init (void); 101 101 102 /*@owned@*//*@null@*/inline103 static c har * get_format(unsigned long msg_id, /*@out@*/int * priority,104 /*@out@*/unsigned int * class);102 inline 103 static const char * get_format(unsigned long msg_id, int * priority, 104 unsigned int * class); 105 105 106 106 static int sh_error_string (struct _log_t * lmsg, va_list vl); … … 177 177 { 178 178 if ((errFlags.loglevel & SH_ERR_ALL) != 0) 179 flag_err_debug = S L_TRUE;179 flag_err_debug = S_TRUE; 180 180 else if ((errFlags.printlevel & SH_ERR_ALL) != 0) 181 flag_err_debug = S L_TRUE;181 flag_err_debug = S_TRUE; 182 182 else if ((errFlags.maillevel & SH_ERR_ALL) != 0) 183 flag_err_debug = S L_TRUE;183 flag_err_debug = S_TRUE; 184 184 else if ((errFlags.exportlevel & SH_ERR_ALL) != 0) 185 flag_err_debug = S L_TRUE;185 flag_err_debug = S_TRUE; 186 186 else if ((errFlags.sysloglevel & SH_ERR_ALL) != 0) 187 flag_err_debug = S L_TRUE;187 flag_err_debug = S_TRUE; 188 188 else if ((errFlags.externallevel & SH_ERR_ALL) != 0) 189 flag_err_debug = S L_TRUE;189 flag_err_debug = S_TRUE; 190 190 else if ((errFlags.databaselevel & SH_ERR_ALL) != 0) 191 flag_err_debug = S L_TRUE;191 flag_err_debug = S_TRUE; 192 192 else if ((errFlags.preludelevel & SH_ERR_ALL) != 0) 193 flag_err_debug = S L_TRUE;193 flag_err_debug = S_TRUE; 194 194 else 195 flag_err_debug = S L_FALSE;195 flag_err_debug = S_FALSE; 196 196 return; 197 197 } … … 201 201 { 202 202 if ((errFlags.loglevel & SH_ERR_INFO) != 0) 203 flag_err_info = S L_TRUE;203 flag_err_info = S_TRUE; 204 204 else if ((errFlags.printlevel & SH_ERR_INFO) != 0) 205 flag_err_info = S L_TRUE;205 flag_err_info = S_TRUE; 206 206 else if ((errFlags.maillevel & SH_ERR_INFO) != 0) 207 flag_err_info = S L_TRUE;207 flag_err_info = S_TRUE; 208 208 else if ((errFlags.exportlevel & SH_ERR_INFO) != 0) 209 flag_err_info = S L_TRUE;209 flag_err_info = S_TRUE; 210 210 else if ((errFlags.sysloglevel & SH_ERR_INFO) != 0) 211 flag_err_info = S L_TRUE;211 flag_err_info = S_TRUE; 212 212 else if ((errFlags.externallevel & SH_ERR_INFO) != 0) 213 flag_err_info = S L_TRUE;213 flag_err_info = S_TRUE; 214 214 else if ((errFlags.databaselevel & SH_ERR_INFO) != 0) 215 flag_err_info = S L_TRUE;215 flag_err_info = S_TRUE; 216 216 else if ((errFlags.preludelevel & SH_ERR_INFO) != 0) 217 flag_err_info = S L_TRUE;217 flag_err_info = S_TRUE; 218 218 else 219 flag_err_info = S L_FALSE;219 flag_err_info = S_FALSE; 220 220 return; 221 221 } … … 230 230 SH_ERR_SEVERE | SH_ERR_FATAL); 231 231 dbg_flag = 1; 232 flag_err_debug = S L_TRUE;232 flag_err_debug = S_TRUE; 233 233 } 234 234 else { … … 935 935 int severity; 936 936 unsigned int class; 937 c har * fmt;937 const char * fmt; 938 938 volatile int sev = sev1; /* Avoids the 'clobbered by longjmp' warning. */ 939 939 … … 1286 1286 sl_snprintf(ex_msg, ex_len, _("%d?%u?%s"), 1287 1287 severity, class, lmsg->msg); 1288 retval = sh_ forward(ex_msg);1288 retval = sh_xfer_report (ex_msg); 1289 1289 SH_FREE(ex_msg); 1290 1290 export_block = 0; … … 1438 1438 int severity; 1439 1439 unsigned int class; 1440 c har * fmt;1440 const char * fmt; 1441 1441 int retval; 1442 1442 … … 1517 1517 */ 1518 1518 /*@owned@*/ /*@null@*/inline 1519 static c har * get_format(unsigned long msg_id, /*@out@*/ int * priority,1519 static const char * get_format(unsigned long msg_id, /*@out@*/ int * priority, 1520 1520 /*@out@*/unsigned int * class) 1521 1521 { … … 1532 1532 *priority = (int) msg_cat[i].priority; 1533 1533 *class = (unsigned int) msg_cat[i].class; 1534 SL_RETURN (((c har *) _(msg_cat[i].format)), _("get_format"));1534 SL_RETURN (((const char *) _(msg_cat[i].format)), _("get_format")); 1535 1535 } 1536 1536 ++i; … … 1573 1573 SL_RETURN( 0, _("sh_error_ehead")); 1574 1574 } 1575 1576 #if !defined(VA_COPY) 1577 #if defined(__GNUC__) && defined(__PPC__) && (defined(_CALL_SYSV) || defined(_WIN32)) 1578 #define VA_COPY(ap1, ap2) (*(ap1) = *(ap2)) 1579 #elif defined(VA_COPY_AS_ARRAY) 1580 #define VA_COPY(ap1, ap2) memmove ((ap1), (ap2), sizeof (va_list)) 1581 #else /* va_list is a pointer */ 1582 #define VA_COPY(ap1, ap2) ((ap1) = (ap2)) 1583 #endif 1584 #endif 1575 1585 1576 1586 … … 1707 1717 else 1708 1718 { 1709 /* use va_copy*/1710 /*@i@*/ va_copy(vl2, vl);1719 /* use VA_COPY */ 1720 /*@i@*/VA_COPY(vl2, vl); 1711 1721 len = sl_strlen(lmsg->msg); 1712 1722 /*@i@*/required = sl_vsnprintf(&(lmsg->msg[len]), … … 1769 1779 SH_ERR_STAMP | SH_ERR_ERR | SH_ERR_SEVERE | 1770 1780 SH_ERR_FATAL); 1771 flag_err_info = S L_TRUE;1781 flag_err_info = S_TRUE; 1772 1782 #endif 1773 1783 -
trunk/src/sh_extern.c
r440 r481 305 305 */ 306 306 #if !defined(PDGBFILE) 307 sh_unix_closeall (3, task->com_fd, S L_TRUE); /* in child process */307 sh_unix_closeall (3, task->com_fd, S_TRUE); /* in child process */ 308 308 #endif 309 309 … … 423 423 char str1[128]; 424 424 int ival = pfd; 425 int n = 0;426 int m = 0;425 unsigned int n = 0; 426 unsigned int m = 0; 427 427 428 428 if (ival < 0) ival = -ival; … … 633 633 { 634 634 task->exit_status = WEXITSTATUS(task->exit_status); 635 if ((flag_err_debug == S L_TRUE) || (task->exit_status != 0))635 if ((flag_err_debug == S_TRUE) || (task->exit_status != 0)) 636 636 sl_snprintf(infomsg, sizeof(infomsg), 637 637 _("Subprocess exited normally with status %d"), … … 687 687 /*@+bufferoverflowhigh@*/ 688 688 status = task->exit_status; 689 if (flag_err_debug == S L_TRUE)689 if (flag_err_debug == S_TRUE) 690 690 { 691 691 sh_error_handle(SH_ERR_ALL, FIL__, __LINE__, task->exit_status, … … 867 867 } 868 868 869 int sh_ext_popen_init (sh_tas_t * task, c har * command, char * argv0, ...)869 int sh_ext_popen_init (sh_tas_t * task, const char * command, char * argv0, ...) 870 870 { 871 871 va_list vl; … … 956 956 * ifconfig | grep -1 lo | tail -n 1 | sed s/.*inet addr:\([0-9.]*\)\(.*\)/\1/ 957 957 */ 958 char * sh_ext_popen_str (c har * command)958 char * sh_ext_popen_str (const char * command) 959 959 { 960 960 sh_tas_t task; -
trunk/src/sh_fInotify.c
r433 r481 35 35 #include "sh_unix.h" 36 36 #include "sh_hash.h" 37 #include "sh_dbIO.h" 37 38 #include "sh_files.h" 38 39 #include "sh_ignore.h" … … 111 112 static int sh_fInotify_process(struct inotify_event * event); 112 113 static int sh_fInotify_report(struct inotify_event * event, char * filename, 113 int class, unsigned long check_ mask, int ftype, int rdepth);114 int class, unsigned long check_flags, int ftype, int rdepth); 114 115 115 116 int sh_fInotify_init(struct mod_type * arg) … … 236 237 count2 = 0; /* Update baseline database. */ 237 238 if (sh.flag.checkSum == SH_CHECK_CHECK && sh.flag.update == S_TRUE) 238 sh_ hash_writeout();239 sh_dbIO_writeout_update (); 239 240 } 240 241 … … 329 330 int type; 330 331 int rdepth; 331 unsigned long check_ mask;332 unsigned long check_flags; 332 333 int retval; 333 334 int errnum; … … 349 350 350 351 while (NULL != (filename = sh_inotify_pop_dormant(&sh_file_watches, 351 &class, &check_ mask,352 &class, &check_flags, 352 353 &type, &rdepth))) 353 354 { 354 355 retval = sh_inotify_add_watch(filename, &sh_file_watches, &errnum, 355 class, check_ mask, type, rdepth);356 class, check_flags, type, rdepth); 356 357 357 358 if (retval < 0) … … 424 425 if (event->mask & IN_UNMOUNT) sl_strlcat(dbgbuf, "IN_UNMOUNT ", sizeof(dbgbuf)); 425 426 426 /* fprintf(stderr, "FIXME: %s\n", dbgbuf); */427 428 427 SH_MUTEX_LOCK(mutex_thread_nolog); 429 428 sh_error_handle(SH_ERR_ALL, FIL__, __LINE__, 0, MSG_E_SUBGEN, … … 437 436 int ftype; 438 437 int rdepth; 439 unsigned long check_ mask;438 unsigned long check_flags; 440 439 char * filename; 441 440 extern int flag_err_debug; 442 441 443 if (flag_err_debug == S L_TRUE)442 if (flag_err_debug == S_TRUE) 444 443 { 445 444 sh_fInotify_logmask(event); … … 449 448 { 450 449 filename = sh_inotify_search_item(&sh_file_watches, event->wd, 451 &class, &check_ mask, &ftype, &rdepth);450 &class, &check_flags, &ftype, &rdepth); 452 451 453 452 if (filename) 454 453 { 455 sh_fInotify_report(event, filename, class, check_ mask, ftype, rdepth);454 sh_fInotify_report(event, filename, class, check_flags, ftype, rdepth); 456 455 SH_FREE(filename); 457 456 } … … 488 487 } 489 488 490 void sh_fInotify_report_add(char * path, int class, unsigned long check_ mask)489 void sh_fInotify_report_add(char * path, int class, unsigned long check_flags) 491 490 { 492 491 if (S_FALSE == sh_ignore_chk_new(path)) … … 496 495 sh_files_clear_file_reported(path); 497 496 498 sh_files_search_file(path, &class, &check_ mask, &reported);497 sh_files_search_file(path, &class, &check_flags, &reported); 499 498 500 sh_files_filecheck (class, check_ mask, path, NULL,499 sh_files_filecheck (class, check_flags, path, NULL, 501 500 &reported, 0); 502 501 if (SH_FFLAG_REPORTED_SET(reported)) … … 521 520 static int sh_fInotify_report_change (struct inotify_event * event, 522 521 char * path, char * filename, 523 int class, unsigned long check_ mask, int ftype)522 int class, unsigned long check_flags, int ftype) 524 523 { 525 524 int reported; … … 529 528 if (S_FALSE == sh_ignore_chk_mod(path)) 530 529 { 531 ret = sh_files_search_file(path, &class, &check_ mask, &reported);530 ret = sh_files_search_file(path, &class, &check_flags, &reported); 532 531 533 532 if ((ret == 0) && (event->len > 0) && (ftype == SH_INOTIFY_FILE)) … … 537 536 else 538 537 { 539 sh_files_filecheck (class, check_ mask, filename,538 sh_files_filecheck (class, check_flags, filename, 540 539 (event->len > 0) ? event->name : NULL, 541 540 &reported, 0); … … 548 547 static int sh_fInotify_report_missing (struct inotify_event * event, 549 548 char * path, 550 int class, unsigned long check_ mask, int ftype)549 int class, unsigned long check_flags, int ftype) 551 550 { 552 551 int reported; … … 560 559 if (0 != hashreport_missing(path, level)) 561 560 { 562 int ret = sh_files_search_file(path, &class, &check_ mask, &reported);561 int ret = sh_files_search_file(path, &class, &check_flags, &reported); 563 562 564 563 if ((ret == 0) && (event->len > 0) && (ftype == SH_INOTIFY_FILE)) … … 578 577 } 579 578 580 #ifndef REPLACE_OLD581 sh_hash_set_visited_true(path);582 #else583 579 sh_hash_set_missing(path); 584 #endif 580 585 581 if (sh.flag.reportonce == S_TRUE) 586 582 sh_files_set_file_reported(path); … … 596 592 static int sh_fInotify_report_added (struct inotify_event * event, 597 593 char * path, char * filename, 598 int class, unsigned long check_ mask,594 int class, unsigned long check_flags, 599 595 int ftype, int rdepth) 600 596 { … … 608 604 sh_files_clear_file_reported(path); 609 605 610 ret = sh_files_search_file(path, &class, &check_ mask, &reported);606 ret = sh_files_search_file(path, &class, &check_flags, &reported); 611 607 612 608 if ((ret == 0) && (event->len > 0) && (ftype == SH_INOTIFY_FILE)) … … 618 614 int classD = class; 619 615 int reportedD = reported; 620 unsigned long check_ maskD = check_mask;616 unsigned long check_flagsD = check_flags; 621 617 622 618 if (event->mask & IN_ISDIR) 623 619 { 624 retD = sh_files_search_dir(path, &classD, &check_ maskD,620 retD = sh_files_search_dir(path, &classD, &check_flagsD, 625 621 &reportedD, &rdepthD); 626 622 if (retD != 0) … … 629 625 { 630 626 class = classD; 631 check_ mask = check_maskD;627 check_flags = check_flagsD; 632 628 } 633 629 } 634 630 } 635 631 636 sh_files_filecheck (class, check_ mask, filename,632 sh_files_filecheck (class, check_flags, filename, 637 633 (event->len > 0) ? event->name : NULL, 638 634 &reported, 0); … … 641 637 { 642 638 SH_INOTIFY_IFUSED( sh.flag.inotify |= SH_INOTIFY_INSCAN; ); 643 sh_files_checkdir (classD, check_ maskD, rdepthD,639 sh_files_checkdir (classD, check_flagsD, rdepthD, 644 640 path, (event->len > 0) ? event->name : NULL); 645 641 SH_INOTIFY_IFUSED( sh.flag.inotify &= ~SH_INOTIFY_INSCAN; ); … … 657 653 { 658 654 sh_inotify_add_watch(path, &sh_file_watches, &ret, 659 class, check_ mask,655 class, check_flags, 660 656 (event->mask & IN_ISDIR)?SH_INOTIFY_DIR:SH_INOTIFY_FILE, 661 657 rdepthD); … … 666 662 667 663 static int sh_fInotify_report(struct inotify_event * event, char * filename, 668 int class, unsigned long check_ mask, int ftype, int rdepth)664 int class, unsigned long check_flags, int ftype, int rdepth) 669 665 { 670 666 char * fullpath = NULL; … … 684 680 { 685 681 sh_fInotify_report_change (event, path, filename, 686 class, check_ mask, ftype);682 class, check_flags, ftype); 687 683 } 688 684 else if ((event->mask & (IN_DELETE|IN_DELETE_SELF|IN_MOVE_SELF|IN_MOVED_FROM)) != 0) 689 685 { 690 686 sh_fInotify_report_missing (event, path, 691 class, check_ mask, ftype);687 class, check_flags, ftype); 692 688 } 693 689 else if((event->mask & (IN_CREATE|IN_MOVED_TO)) != 0) 694 690 { 695 691 sh_fInotify_report_added (event, path, filename, 696 class, check_ mask,692 class, check_flags, 697 693 ftype, rdepth); 698 694 } -
trunk/src/sh_fifo.c
r272 r481 180 180 memset(getit->data, 0, len); 181 181 if (NULL != sl_strstr (getit->data, _("LOGKEY"))) 182 { 183 MUNLOCK(getit->data, (len+1)); 184 ; 185 } 182 MUNLOCK(getit->data, (len+1)); 186 183 if (getit->s_xtra) 187 184 SH_FREE(getit->s_xtra); … … 197 194 /* push an item on the head of the list 198 195 */ 199 int push_list (SH_FIFO * fifo, c har * indat, int in_i, const char * in_str)196 int push_list (SH_FIFO * fifo, const char * indat, int in_i, const char * in_str) 200 197 { 201 198 struct dlist * item; … … 224 221 225 222 if (NULL != sl_strstr (indat, _("LOGKEY"))) 226 { 227 MLOCK(item->data, (len+1)); 228 ; 229 } 223 MLOCK(item->data, (len+1)); 230 224 231 225 sl_strlcpy (item->data, indat, len+1); … … 260 254 /* push an item on the tail of the list 261 255 */ 262 int push_tail_list (SH_FIFO * fifo, c har * indat, int in_i, const char * in_str)256 int push_tail_list (SH_FIFO * fifo, const char * indat, int in_i, const char * in_str) 263 257 { 264 258 struct dlist * item; … … 287 281 288 282 if (NULL != sl_strstr (indat, _("LOGKEY"))) 289 { 290 MLOCK(item->data, (len+1)); 291 ; 292 } 283 MLOCK(item->data, (len+1)); 293 284 294 285 sl_strlcpy (item->data, indat, len+1); … … 318 309 ++(fifo->fifo_cts); 319 310 320 SL_RETURN(( 0), _("push_tail_list"));311 SL_RETURN((fifo->fifo_cts), _("push_tail_list")); 321 312 } 322 313 … … 356 347 357 348 if (NULL != sl_strstr (retval, _("LOGKEY"))) 358 { 359 MUNLOCK(getit->data, (len+1)); 360 ; 361 } 349 MUNLOCK(getit->data, (len+1)); 362 350 363 351 if (getit->s_xtra) … … 372 360 373 361 374 375 362 #ifdef SH_CUTEST 363 #include "CuTest.h" 364 365 void Test_fifo (CuTest *tc) { 366 367 SH_FIFO ff; 368 int ret; 369 char * p; 370 371 fifo_init(&ff); 372 373 p = sh_fifo_pop(&ff); 374 CuAssertPtrEquals(tc, NULL, p); 375 376 /* first sequence */ 377 ret = sh_fifo_push(&ff, "one"); 378 CuAssertIntEquals(tc,1,ret); 379 ret = sh_fifo_push(&ff, "two"); 380 CuAssertIntEquals(tc,2,ret); 381 ret = sh_fifo_push(&ff, "three"); 382 CuAssertIntEquals(tc,3,ret); 383 384 p = sh_fifo_pop(&ff); 385 CuAssertPtrNotNull(tc, p); 386 CuAssertStrEquals(tc,"one", p); 387 p = sh_fifo_pop(&ff); 388 CuAssertPtrNotNull(tc, p); 389 CuAssertStrEquals(tc,"two", p); 390 p = sh_fifo_pop(&ff); 391 CuAssertPtrNotNull(tc, p); 392 CuAssertStrEquals(tc,"three", p); 393 p = sh_fifo_pop(&ff); 394 CuAssertPtrEquals(tc, NULL, p); 395 396 /* second sequence */ 397 ret = sh_fifo_push(&ff, "one"); 398 CuAssertIntEquals(tc,1,ret); 399 p = sh_fifo_pop(&ff); 400 CuAssertPtrNotNull(tc, p); 401 CuAssertStrEquals(tc,"one", p); 402 ret = sh_fifo_push_tail(&ff, "one"); 403 CuAssertIntEquals(tc,1,ret); 404 p = sh_fifo_pop(&ff); 405 CuAssertPtrNotNull(tc, p); 406 CuAssertStrEquals(tc,"one", p); 407 p = sh_fifo_pop(&ff); 408 CuAssertPtrEquals(tc, NULL, p); 409 410 /* third sequence */ 411 ret = sh_fifo_push(&ff, "one"); 412 CuAssertIntEquals(tc,1,ret); 413 ret = sh_fifo_push(&ff, "two"); 414 CuAssertIntEquals(tc,2,ret); 415 ret = sh_fifo_push(&ff, "three"); 416 CuAssertIntEquals(tc,3,ret); 417 418 p = sh_fifo_pop(&ff); 419 CuAssertPtrNotNull(tc, p); 420 CuAssertStrEquals(tc,"one", p); 421 ret = sh_fifo_push_tail(&ff, p); 422 CuAssertIntEquals(tc,3,ret); 423 424 p = sh_fifo_pop(&ff); 425 CuAssertPtrNotNull(tc, p); 426 CuAssertStrEquals(tc,"one", p); 427 p = sh_fifo_pop(&ff); 428 CuAssertPtrNotNull(tc, p); 429 CuAssertStrEquals(tc,"two", p); 430 p = sh_fifo_pop(&ff); 431 CuAssertPtrNotNull(tc, p); 432 CuAssertStrEquals(tc,"three", p); 433 p = sh_fifo_pop(&ff); 434 CuAssertPtrEquals(tc, NULL, p); 435 } 436 437 #endif 438 439 440 441 -
trunk/src/sh_files.c
r465 r481 88 88 #include "sh_inotify.h" 89 89 #include "zAVLTree.h" 90 #include "sh_dbIO.h" 90 91 91 92 #undef FIL__ … … 211 212 } 212 213 214 char * sh_files_parse_input(const char * str_s, size_t * len) 215 { 216 char * p; 217 218 if (!str_s || *str_s == '\0') 219 return NULL; 220 221 *len = sl_strlen(str_s); 222 223 if ( (str_s[0] == '"' && str_s[*len-1] == '"' ) || 224 (str_s[0] == '\'' && str_s[*len-1] == '\'') ) 225 { 226 if (*len < 3) 227 return NULL; 228 --(*len); 229 p = sh_util_strdup_l(&str_s[1], *len); 230 p[*len-1] = '\0'; 231 --(*len); 232 } 233 else 234 { 235 p = sh_util_strdup_l(str_s, *len); 236 } 237 238 p = sh_files_C_dequote(p, len); 239 240 return p; 241 } 242 243 213 244 extern int flag_err_debug; 214 245 extern int flag_err_info; … … 251 282 char * name; 252 283 int class; 253 unsigned long check_ mask;284 unsigned long check_flags; 254 285 int rdepth; 255 286 short checked; … … 322 353 SL_RETURN((-1), _("sh_files_setrecursion")); 323 354 324 if (sh.flag.opts == 1)355 if (sh.flag.opts == S_TRUE) 325 356 reject = 1; 326 357 … … 380 411 tmp); 381 412 } 382 #ifndef REPLACE_OLD 383 /* this will tell that we have seen the file, and thus prevent 384 * deletion from the database, resulting in an incomplete 385 * message when the file reappears 386 */ 387 if (sh.flag.checkSum != SH_CHECK_INIT) 388 sh_hash_set_visited_true(ptr->name); 389 #else 413 390 414 if (sh.flag.checkSum != SH_CHECK_INIT) 391 415 sh_hash_set_missing(ptr->name); 392 #endif 416 393 417 if (sh.flag.reportonce == S_TRUE) 394 418 SET_SH_FFLAG_REPORTED(ptr->is_reported); … … 431 455 } 432 456 } 433 #ifndef REPLACE_OLD 434 if (sh.flag.checkSum != SH_CHECK_INIT) 435 sh_hash_set_visited_true(ptr->name); 436 #else 457 437 458 /* delete from database 438 459 */ 439 460 if (sh.flag.checkSum != SH_CHECK_INIT) 440 461 sh_hash_set_missing(ptr->name); 441 #endif442 462 } 443 463 else … … 494 514 495 515 496 if (flag_err_info == S L_TRUE)516 if (flag_err_info == S_TRUE) 497 517 { 498 518 char pstr[32]; … … 508 528 { 509 529 sh_inotify_add_watch_later(ptr->name, &sh_file_watches, NULL, 510 ptr->class, ptr->check_ mask,530 ptr->class, ptr->check_flags, 511 531 SH_INOTIFY_FILE, 0); 512 532 } … … 514 534 BREAKEXIT(sh_files_filecheck); 515 535 tmp_reported = ptr->is_reported; /* fix aliasing warning */ 516 status = sh_files_filecheck (ptr->class, ptr->check_ mask, dir, file,536 status = sh_files_filecheck (ptr->class, ptr->check_flags, dir, file, 517 537 &tmp_reported, 0); 518 538 ptr->is_reported = tmp_reported; … … 590 610 } 591 611 592 static void * sh_dummy_candidate;612 void * sh_dummy_621_candidate; 593 613 594 614 static char * intern_find_morespecific_dir(zAVLTree * tree, … … 605 625 return NULL; 606 626 607 sh_dummy_ candidate = (void *) &candidate;627 sh_dummy_621_candidate = (void *) &candidate; 608 628 609 629 SH_MUTEX_LOCK(mutex_zfiles); … … 1069 1089 1070 1090 int sh_files_push_file_int (int class, const char * str_s, size_t len, 1071 unsigned long check_ mask)1091 unsigned long check_flags) 1072 1092 { 1073 1093 dirstack_t * new_item_ptr; … … 1085 1105 new_item_ptr->name = fileName; 1086 1106 new_item_ptr->class = class; 1087 new_item_ptr->check_ mask = check_mask;1107 new_item_ptr->check_flags = check_flags; 1088 1108 new_item_ptr->rdepth = 0; 1089 1109 new_item_ptr->checked = S_FALSE; … … 1122 1142 { 1123 1143 int reported; 1124 unsigned long check_ mask= sh_files_maskof(class);1144 unsigned long check_flags = sh_files_maskof(class); 1125 1145 1126 1146 if ((sh.flag.inotify & SH_INOTIFY_INSCAN) != 0) 1127 1147 { 1128 sh_files_filecheck (class, check_ mask, str_s, NULL,1148 sh_files_filecheck (class, check_flags, str_s, NULL, 1129 1149 &reported, 0); 1130 1150 if (SH_FFLAG_REPORTED_SET(reported)) 1131 1151 sh_files_set_file_reported(str_s); 1132 1152 sh_inotify_add_watch_later(str_s, &sh_file_watches, NULL, 1133 class, check_ mask,1153 class, check_flags, 1134 1154 SH_INOTIFY_FILE, 0); 1135 1155 } 1136 1156 1137 if (MODI_AUDIT_ENABLED(check_ mask))1157 if (MODI_AUDIT_ENABLED(check_flags)) 1138 1158 { 1139 1159 sh_audit_mark(str_s); … … 1144 1164 } 1145 1165 1146 int sh_files_push_dir_int (int class, char * tail, size_t len, int rdepth, unsigned long check_ mask);1166 int sh_files_push_dir_int (int class, char * tail, size_t len, int rdepth, unsigned long check_flags); 1147 1167 1148 1168 #ifdef HAVE_GLOB_H … … 1151 1171 char * name; 1152 1172 int class; 1153 unsigned long check_ mask;1173 unsigned long check_flags; 1154 1174 int rdepth; 1155 1175 short type; … … 1160 1180 1161 1181 static int sh_files_pushglob (int class, int type, const char * p, int rdepth, 1162 unsigned long check_ mask_in, int flag)1182 unsigned long check_flags_in, int flag) 1163 1183 { 1164 1184 int globstatus = -1; … … 1167 1187 1168 1188 volatile int count = 0; 1169 volatile unsigned long check_ mask = (flag == 0) ? sh_files_maskof(class) : check_mask_in;1189 volatile unsigned long check_flags = (flag == 0) ? sh_files_maskof(class) : check_flags_in; 1170 1190 1171 1191 SL_ENTER(_("sh_files_pushglob")); … … 1190 1210 new_item_ptr->name = fileName; 1191 1211 new_item_ptr->class = class; 1192 new_item_ptr->check_ mask = check_mask;1212 new_item_ptr->check_flags = check_flags; 1193 1213 new_item_ptr->rdepth = rdepth; 1194 1214 new_item_ptr->type = type; … … 1219 1239 { 1220 1240 count += sh_files_push_file_int (class, pglob.gl_pathv[gloop], 1221 sl_strlen(pglob.gl_pathv[gloop]), check_ mask);1241 sl_strlen(pglob.gl_pathv[gloop]), check_flags); 1222 1242 } 1223 1243 else … … 1226 1246 1227 1247 count += sh_files_push_dir_int (class, pglob.gl_pathv[gloop], 1228 sl_strlen(pglob.gl_pathv[gloop]), rdepth, check_ mask);1248 sl_strlen(pglob.gl_pathv[gloop]), rdepth, check_flags); 1229 1249 } 1230 1250 } … … 1285 1305 sh_files_pushglob(testPattern->class, testPattern->type, 1286 1306 testPattern->name, testPattern->rdepth, 1287 testPattern->check_ mask, 1);1307 testPattern->check_flags, 1); 1288 1308 } 1289 1309 } … … 1306 1326 sh_files_pushglob(testPattern->class, testPattern->type, 1307 1327 testPattern->name, testPattern->rdepth, 1308 testPattern->check_ mask, 1);1328 testPattern->check_flags, 1); 1309 1329 } 1310 1330 SH_MUTEX_UNLOCK(mutex_zglob); … … 1370 1390 * is the only one -- and will stay the only one 1371 1391 */ 1372 if (sh.flag.opts == 1)1392 if (sh.flag.opts == S_TRUE) 1373 1393 { 1374 1394 sh_files_delfilestack (); … … 1378 1398 } 1379 1399 1380 if (str_s == NULL || str_s[0] == '\0') 1381 SL_RETURN((-1),_("sh_files_pushfile")); 1382 1383 len = sl_strlen(str_s); 1384 1385 if ( (str_s[0] == '"' && str_s[len-1] == '"' ) || 1386 (str_s[0] == '\'' && str_s[len-1] == '\'') ) 1387 { 1388 if (len < 3) 1389 SL_RETURN((-1),_("sh_files_pushfile")); 1390 --len; 1391 p = sh_util_strdup_l(&str_s[1], len); 1392 p[len-1] = '\0'; 1393 --len; 1394 } 1395 else 1396 { 1397 p = sh_util_strdup_l(str_s, len); 1398 } 1399 1400 p = sh_files_C_dequote(p, &len); 1400 p = sh_files_parse_input(str_s, &len); 1401 1401 if (!p || len == 0) 1402 1402 SL_RETURN((-1), _("sh_files_pushfile")); … … 1491 1491 } 1492 1492 1493 static void * sh_dummy_ptr;1493 void * sh_dummy_1493_ptr; 1494 1494 1495 1495 unsigned long sh_dirs_chk (int which) … … 1507 1507 SL_ENTER(_("sh_dirs_chk")); 1508 1508 1509 sh_dummy_ ptr = (void *) &ptr;1509 sh_dummy_1493_ptr = (void *) &ptr; 1510 1510 1511 1511 SH_MUTEX_RECURSIVE_INIT(mutex_zdirs); … … 1536 1536 BREAKEXIT(sh_files_filecheck); 1537 1537 tmp_reported = dst_ptr->is_reported; 1538 filetype = sh_files_filecheck (dst_ptr->class, dst_ptr->check_ mask,1538 filetype = sh_files_filecheck (dst_ptr->class, dst_ptr->check_flags, 1539 1539 ptr->name, 1540 1540 NULL, &tmp_reported, 0); … … 1555 1555 { 1556 1556 tmp_reported = ptr->is_reported; 1557 filetype = sh_files_filecheck (ptr->class, ptr->check_ mask,1557 filetype = sh_files_filecheck (ptr->class, ptr->check_flags, 1558 1558 ptr->name, NULL, &tmp_reported, 0); 1559 1559 ptr->is_reported = tmp_reported; … … 1562 1562 1563 1563 BREAKEXIT(sh_files_checkdir); 1564 status = sh_files_checkdir (ptr->class, ptr->check_ mask,1564 status = sh_files_checkdir (ptr->class, ptr->check_flags, 1565 1565 ptr->rdepth, ptr->name, 1566 1566 ptr->name); … … 1710 1710 } 1711 1711 1712 int sh_files_push_dir_int (int class, char * tail, size_t len, int rdepth, unsigned long check_ mask)1712 int sh_files_push_dir_int (int class, char * tail, size_t len, int rdepth, unsigned long check_flags) 1713 1713 { 1714 1714 zAVLTree * tree; … … 1726 1726 new_item_ptr->name = dirName; 1727 1727 new_item_ptr->class = class; 1728 new_item_ptr->check_ mask = check_mask;1728 new_item_ptr->check_flags = check_flags; 1729 1729 new_item_ptr->rdepth = rdepth; 1730 1730 new_item_ptr->checked = S_FALSE; … … 1776 1776 else 1777 1777 { 1778 if (MODI_AUDIT_ENABLED(check_ mask))1778 if (MODI_AUDIT_ENABLED(check_flags)) 1779 1779 { 1780 1780 sh_audit_mark(tail); … … 1794 1794 SL_ENTER(_("sh_files_pushdir")); 1795 1795 1796 if (sh.flag.opts == 1) {1796 if (sh.flag.opts == S_TRUE) { 1797 1797 sh_files_delfilestack (); 1798 1798 sh_files_deldirstack (); … … 1800 1800 } 1801 1801 1802 if (str_s == NULL || str_s[0] == '\0') 1802 p = sh_files_parse_input(str_s, &len); 1803 if (!p || len == 0) 1803 1804 SL_RETURN((-1),_("sh_files_pushdir")); 1804 1805 len = sl_strlen(str_s);1806 1807 if ( (str_s[0] == '"' && str_s[len-1] == '"' ) ||1808 (str_s[0] == '\'' && str_s[len-1] == '\'') )1809 {1810 if (len < 3)1811 SL_RETURN((-1),_("sh_files_pushdir"));1812 --len;1813 p = sh_util_strdup_l(&str_s[1], len);1814 p[len-1] = '\0';1815 --len;1816 }1817 else1818 {1819 p = sh_util_strdup_l(str_s, len);1820 }1821 1822 p = sh_files_C_dequote(p, &len);1823 if (!p || len == 0)1824 SL_RETURN((-1), _("sh_files_pushdir"));1825 1805 1826 1806 if (p[0] != '/') … … 2048 2028 * check the directory inode itself. 2049 2029 */ 2050 int sh_files_checkdir (int iclass, unsigned long check_ mask,2030 int sh_files_checkdir (int iclass, unsigned long check_flags, 2051 2031 int idepth, char * iname, 2052 2032 char * relativeName) … … 2073 2053 volatile int class_next; 2074 2054 volatile int file_class_next; 2075 volatile unsigned long check_ mask_next;2076 volatile unsigned long file_check_ mask_next;2055 volatile unsigned long check_flags_next; 2056 volatile unsigned long file_check_flags_next; 2077 2057 2078 2058 volatile int checked_flag = S_FALSE; … … 2114 2094 } 2115 2095 2116 if (flag_err_info == S L_TRUE)2096 if (flag_err_info == S_TRUE) 2117 2097 { 2118 2098 char pstr[32]; … … 2149 2129 theFile->attr_string = NULL; 2150 2130 theFile->link_path = NULL; 2151 theFile->check_ mask = check_mask;2131 theFile->check_flags = check_flags; 2152 2132 2153 2133 (void) relativeName; … … 2190 2170 { 2191 2171 sh_inotify_add_watch_later(iname, &sh_file_watches, &status, 2192 iclass, check_ mask, SH_INOTIFY_DIR, idepth);2172 iclass, check_flags, SH_INOTIFY_DIR, idepth); 2193 2173 } 2194 2174 … … 2301 2281 rdepth_next = rdepth - 1; 2302 2282 class_next = class; 2303 check_ mask_next = check_mask;2283 check_flags_next = check_flags; 2304 2284 file_class_next = class; 2305 file_check_ mask_next = check_mask;2285 file_check_flags_next = check_flags; 2306 2286 checked_flag = -1; 2307 2287 cchecked_flag = -1; … … 2322 2302 */ 2323 2303 file_class_next = dst_ptr->class; 2324 file_check_ mask_next = dst_ptr->check_mask;2304 file_check_flags_next = dst_ptr->check_flags; 2325 2305 checked_flag = dst_ptr->checked; 2326 2306 cchecked_flag = dst_ptr->childs_checked; … … 2338 2318 */ 2339 2319 file_class_next = dst_ptr->class; 2340 file_check_ mask_next = dst_ptr->check_mask;2320 file_check_flags_next = dst_ptr->check_flags; 2341 2321 checked_flag = dst_ptr->checked; 2342 2322 cchecked_flag = dst_ptr->childs_checked; … … 2355 2335 */ 2356 2336 file_class_next = dst_ptr->class; 2357 file_check_ mask_next = dst_ptr->check_mask;2337 file_check_flags_next = dst_ptr->check_flags; 2358 2338 checked_flag = dst_ptr->checked; 2359 2339 /* not set, hence always FALSE */ … … 2403 2383 */ 2404 2384 2405 checkit = sh_files_filecheck (file_class_next, file_check_ mask_next,2385 checkit = sh_files_filecheck (file_class_next, file_check_flags_next, 2406 2386 iname, 2407 2387 dirlist->sh_d_name, … … 2453 2433 rdepth_next = tmp_ptr->rdepth; 2454 2434 class_next = tmp_ptr->class; 2455 check_ mask_next = tmp_ptr->check_mask;2435 check_flags_next = tmp_ptr->check_flags; 2456 2436 /* 28. Aug 2001 reversed 2457 2437 */ … … 2471 2451 rdepth_next = tmp_ptr->rdepth; 2472 2452 class_next = tmp_ptr->class; 2473 check_ mask_next = tmp_ptr->check_mask;2453 check_flags_next = tmp_ptr->check_flags; 2474 2454 /* 28. Aug 2001 reversed 2475 2455 */ … … 2491 2471 if (cchecked_flag == S_FALSE) 2492 2472 { 2493 sh_files_checkdir (class_next, check_ mask_next, rdepth_next,2473 sh_files_checkdir (class_next, check_flags_next, rdepth_next, 2494 2474 tmpcat, dirlist->sh_d_name); 2495 2475 /* … … 2499 2479 } 2500 2480 else if (checked_flag == -1) 2501 sh_files_checkdir (class_next, check_ mask_next, rdepth_next,2481 sh_files_checkdir (class_next, check_flags_next, rdepth_next, 2502 2482 tmpcat, dirlist->sh_d_name); 2503 2483 … … 2532 2512 } while (dirlist != NULL); 2533 2513 2534 if (flag_err_info == S L_TRUE)2514 if (flag_err_info == S_TRUE) 2535 2515 { 2536 2516 sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_FI_DSUM, … … 2576 2556 } 2577 2557 2558 void sh_files_fixup_mask (int class, unsigned long * check_flags) 2559 { 2560 if (class == SH_LEVEL_ALLIGNORE) 2561 MODI_SET((*check_flags), MODI_ALLIGNORE); 2562 sh_tiger_get_mask_hashtype(check_flags); 2563 return; 2564 } 2565 2578 2566 int get_the_fd (SL_TICKET ticket); 2579 2567 … … 2589 2577 static void * sh_dummy_tmpdir; 2590 2578 2591 ShFileType sh_files_filecheck (int class, unsigned long check_ mask,2579 ShFileType sh_files_filecheck (int class, unsigned long check_flags, 2592 2580 const char * dirName, 2593 2581 const char * infileName, … … 2701 2689 */ 2702 2690 sl_strlcpy (theFile->fullpath, fullpath, PATH_MAX); 2703 theFile->check_ mask = check_mask/* sh_files_maskof(class) */;2691 theFile->check_flags = check_flags /* sh_files_maskof(class) */; 2704 2692 theFile->file_reported = (*reported); 2705 2693 theFile->attr_string = NULL; … … 2712 2700 fileName, 2713 2701 theFile, fileHash, class); 2714 2702 2715 2703 if (status != 0) 2716 2704 { … … 2732 2720 /* report 2733 2721 */ 2734 if ((flag_err_debug == S L_TRUE) && (theFile->c_mode[0] == '-'))2722 if ((flag_err_debug == S_TRUE) && (theFile->c_mode[0] == '-')) 2735 2723 { 2736 2724 tmpname = sh_util_safe_name (fullpath); /* fixed in 1.5.4 */ … … 2743 2731 ++sh.statistics.files_checked; 2744 2732 2745 if ( sh.flag.checkSum == SH_CHECK_INIT /* && sh.flag.update == S_FALSE */) 2746 { 2747 sh_hash_pushdata (theFile, fileHash); 2733 if ( sh.flag.checkSum == SH_CHECK_INIT) 2734 { 2735 if (class == SH_LEVEL_ALLIGNORE) 2736 MODI_SET(theFile->check_flags, MODI_ALLIGNORE); 2737 if (S_TRUE == sh_ignore_chk_mod(theFile->fullpath)) 2738 MODI_SET(theFile->check_flags, MODI_NOCHECK); 2739 sh_tiger_get_mask_hashtype(&(theFile->check_flags)); 2740 sh_dbIO_data_write (theFile, fileHash); 2748 2741 } 2749 2742 else if (sh.flag.checkSum == SH_CHECK_CHECK … … 2752 2745 ) 2753 2746 { 2747 if (sh.flag.update == S_TRUE) 2748 { 2749 if (class == SH_LEVEL_ALLIGNORE) 2750 MODI_SET(theFile->check_flags, MODI_ALLIGNORE); 2751 if (S_TRUE == sh_ignore_chk_mod(theFile->fullpath)) 2752 MODI_SET(theFile->check_flags, MODI_NOCHECK); 2753 sh_tiger_get_mask_hashtype(&(theFile->check_flags)); 2754 } 2754 2755 sh_hash_compdata (class, theFile, fileHash, NULL, -1); 2755 2756 } … … 2760 2761 */ 2761 2762 #if !defined(O_NOATIME) 2762 if (class == SH_LEVEL_NOIGNORE && (theFile->check_ mask& MODI_ATM) != 0)2763 if (class == SH_LEVEL_NOIGNORE && (theFile->check_flags & MODI_ATM) != 0) 2763 2764 { 2764 2765 utime_buf.actime = (time_t) theFile->atime; … … 2792 2793 if (S_TRUE == sh_unix_file_exists (testpath)) 2793 2794 { 2794 sh_files_filecheck (class, check_ mask, fullpath, rsrc, &dummy, 1);2795 sh_files_filecheck (class, check_flags, fullpath, rsrc, &dummy, 1); 2795 2796 } 2796 2797 } … … 2860 2861 */ 2861 2862 int sh_files_search_dir(char * name, int * class, 2862 unsigned long *check_ mask, int *reported,2863 unsigned long *check_flags, int *reported, 2863 2864 int * rdepth) 2864 2865 { … … 2877 2878 if (item) 2878 2879 { 2879 *check_ mask = item->check_mask;2880 *check_flags = item->check_flags; 2880 2881 *class = item->class; 2881 2882 *reported = item->is_reported; … … 2892 2893 if (item) 2893 2894 { 2894 *check_ mask = item->check_mask;2895 *check_flags = item->check_flags; 2895 2896 *class = item->class; 2896 2897 *reported = item->is_reported; … … 2914 2915 if (0 == fnmatch(testPattern->name, name, FNM_PATHNAME|FNM_PERIOD)) 2915 2916 { 2916 *check_ mask = testPattern->check_mask;2917 *check_flags = testPattern->check_flags; 2917 2918 *class = testPattern->class; 2918 2919 *rdepth = testPattern->rdepth; … … 2932 2933 2933 2934 int sh_files_search_file(char * name, int * class, 2934 unsigned long *check_ mask, int *reported)2935 unsigned long *check_flags, int *reported) 2935 2936 { 2936 2937 volatile int retval = 0; … … 2946 2947 if (item) 2947 2948 { 2948 *check_ mask = item->check_mask;2949 *check_flags = item->check_flags; 2949 2950 *class = item->class; 2950 2951 *reported = item->is_reported; … … 2966 2967 FNM_PATHNAME|FNM_PERIOD)) 2967 2968 { 2968 *check_ mask = testPattern->check_mask;2969 *check_flags = testPattern->check_flags; 2969 2970 *class = testPattern->class; 2970 2971 retval = 1; … … 3035 3036 { 3036 3037 if (0 == strcmp(name, pfilL->name) && 3037 (pfilL->check_ mask& MODI_ATM) == 0 &&3038 (pfilL->check_ mask& MODI_CTM) == 0 &&3039 (pfilL->check_ mask& MODI_MTM) == 0)3038 (pfilL->check_flags & MODI_ATM) == 0 && 3039 (pfilL->check_flags & MODI_CTM) == 0 && 3040 (pfilL->check_flags & MODI_MTM) == 0) 3040 3041 { 3041 3042 retval = 0; … … 3087 3088 (0 == strncmp(pfilL->name, pdirL->name, dlen))) 3088 3089 { 3089 if ((pdirL->check_ mask& MODI_ATM) != 0 ||3090 (pdirL->check_ mask& MODI_MTM) != 0 ||3091 (pdirL->check_ mask& MODI_CTM) != 0)3090 if ((pdirL->check_flags & MODI_ATM) != 0 || 3091 (pdirL->check_flags & MODI_MTM) != 0 || 3092 (pdirL->check_flags & MODI_CTM) != 0) 3092 3093 { 3093 3094 if (check_file (pdirL->name) != 0) -
trunk/src/sh_filetype.c
r454 r481 406 406 } 407 407 408 /* fprintf(stderr, "FIXME: %d %d %s ", dtype, length, type); */409 /**410 if (dtype == 0)411 fprintf(stderr, "%s\n", pattern);412 else413 {414 int k;415 for (k = 0; k < length; ++k)416 fprintf(stderr, "0x%X", (unsigned int) (pattern[k]));417 fprintf(stderr, "\n");418 }419 **/420 421 408 for (i = 0; i < n; ++i) 422 409 { … … 523 510 p = &buffer[sh_ftype_arr[i]->offset]; 524 511 525 #if 0526 {527 int dd;528 /* fprintf(stderr, "FIXME: %03d comp %d:%d ", i,529 sh_ftype_arr[i]->offset, sh_ftype_arr[i]->length); */530 for (dd = 0; dd < sh_ftype_arr[i]->length; ++dd) {531 fprintf(stderr, "0x%X ", sh_ftype_arr[i]->pattern[dd]);532 }533 for (dd = 0; dd < sh_ftype_arr[i]->length; ++dd) {534 fprintf(stderr, "0x%X ", p[dd]);535 }536 fprintf(stderr, "\n");537 }538 #endif539 540 512 if (0 == memcmp(p, sh_ftype_arr[i]->pattern, sh_ftype_arr[i]->length)) 541 513 { … … 582 554 long len; 583 555 584 len = sl_read_timeout (ft, buffer, sizeof(buffer), 12, S L_TRUE);556 len = sl_read_timeout (ft, buffer, sizeof(buffer), 12, S_TRUE); 585 557 586 558 sl_rewind(ft); -
trunk/src/sh_getopt.c
r467 r481 34 34 #include "sh_utils.h" 35 35 #include "sh_mail.h" 36 #include "sh_ forward.h"36 #include "sh_xfer.h" 37 37 #include "sh_hash.h" 38 #include "sh_dbIO.h" 39 #include "sh_dbCheck.h" 40 #include "sh_dbCreate.h" 41 #include "sh_sem.h" 38 42 39 43 #if defined(WITH_EXTERNAL) … … 64 68 #if defined (SH_WITH_CLIENT) || defined (SH_STANDALONE) 65 69 static int sh_getopt_forever (const char * dummy); 70 static int sh_getopt_outpath (const char * dummy); 66 71 #endif 67 72 static int sh_getopt_copyright (const char * dummy); … … 92 97 N_("Set the server port to connect to"), 93 98 HAS_ARG_YES, 94 sh_ forward_server_port },99 sh_xfer_server_port }, 95 100 { N_("server-host"), 96 101 '-', 97 102 N_("Set the server host to connect to"), 98 103 HAS_ARG_YES, 99 sh_ forward_setlogserver },104 sh_xfer_set_logserver }, 100 105 #endif 101 106 #ifdef SH_WITH_SERVER … … 109 114 N_("Log fully qualified name of client host"), 110 115 HAS_ARG_NO, 111 sh_ forward_set_strip },116 sh_xfer_set_strip }, 112 117 { N_("chroot"), 113 118 '-', … … 222 227 N_("Compute a client registry entry for password"), 223 228 HAS_ARG_YES, 224 sh_ forward_make_client },229 sh_xfer_make_client }, 225 230 { N_("gen-password"), 226 231 'G', 227 232 N_("Generate a random password"), 228 233 HAS_ARG_NO, 229 sh_ forward_create_password },234 sh_xfer_create_password }, 230 235 #endif 231 236 … … 236 241 HAS_ARG_NO, 237 242 sh_getopt_forever}, 243 { N_("outfile"), 244 'o', 245 N_("Pathname for output file"), 246 HAS_ARG_YES, 247 sh_getopt_outpath}, 238 248 { N_("list-file"), 239 249 '-', 240 N_("Modify -d to listcontent of a single file"),250 N_("Modify -d to show content of a single file"), 241 251 HAS_ARG_YES, 242 252 set_list_file}, 253 { N_("list-filter"), 254 '-', 255 N_("Modify -d to filter by file list given in text file"), 256 HAS_ARG_YES, 257 sh_dbIO_list_filter}, 243 258 { N_("full-detail"), 244 259 'a', 245 N_("Modify -d to listfull details"),260 N_("Modify -d to show full details"), 246 261 HAS_ARG_NO, 247 262 set_full_detail}, 248 263 { N_("delimited"), 249 264 '-', 250 N_("Modify -d to listfull details, comma delimited"),265 N_("Modify -d to show full details, comma delimited"), 251 266 HAS_ARG_NO, 252 267 set_list_delimited}, 268 { N_("binary"), 269 '-', 270 N_("Modify -d to output in binary database format"), 271 HAS_ARG_NO, 272 sh_dbIO_list_binary}, 253 273 { N_("list-database"), 254 274 'd', 255 275 N_("List database content (like ls -l)"), 256 276 HAS_ARG_YES, 257 sh_ hash_list_db},277 sh_dbIO_list_db}, 258 278 { N_("init2stdout"), 259 279 '-', 260 280 N_("Write database to stdout on init"), 261 281 HAS_ARG_NO, 262 sh_hash_pushdata_stdout}, 282 sh_dbIO_writeout_stdout}, 283 { N_("verify-database"), 284 '-', 285 N_("Verify the given database"), 286 HAS_ARG_YES, 287 sh_dbCheck_verify}, 288 { N_("create-database"), 289 '-', 290 N_("Create database from file list"), 291 HAS_ARG_YES, 292 sh_dbCreate}, 293 { N_("wait-on-check"), 294 'w', 295 N_("Timed wait for end of filecheck (0 for no timeout)"), 296 HAS_ARG_YES, 297 sh_sem_wait}, 263 298 #endif 264 299 { N_("trace-logfile"), … … 744 779 sh.flag.loop = S_TRUE; 745 780 SL_RETURN(0, _("sh_getopt_forever")); 781 } 782 783 static int sh_getopt_outpath (const char * str) 784 { 785 if (str) 786 { 787 if (sh.outpath) 788 SH_FREE(sh.outpath); 789 sh.outpath = sh_util_strdup(str); 790 return 0; 791 } 792 return -1; 746 793 } 747 794 #endif -
trunk/src/sh_gpg.c
r474 r481 60 60 #include "sh_static.h" 61 61 #endif 62 #include "sh_gpg.h" 62 63 63 64 static struct { … … 128 129 SL_ENTER(_("sh_gpg_checksum")); 129 130 130 #if defined(WITH_PGP)131 test_gpg = sh_tiger_hash_gpg (DEFAULT_PGP_PATH, checkfd, TIGER_NOLIM);132 #else133 131 test_gpg = sh_tiger_hash_gpg (DEFAULT_GPG_PATH, checkfd, TIGER_NOLIM); 134 #endif135 132 136 133 test_ptr1 = strchr(GPG_HASH, ':'); … … 252 249 char cc1[32]; 253 250 char cc2[32]; 254 #if defined(WITH_PGP) 255 char cc3[32]; 256 char cc0[3] = "-f"; 257 #endif 258 #if defined(WITH_GPG) 251 259 252 char cc0[2] = "-"; 260 253 char cc3[32]; 261 254 char cc4[SH_PATHBUF+32]; 262 255 char cc5[32]; 263 #endif 256 264 257 265 258 char * arg[9]; … … 279 272 SL_ENTER(_("sh_gpg_popen")); 280 273 281 #if defined(WITH_GPG)282 274 /* -- GnuPG -- */ 283 275 sl_strlcpy (path, DEFAULT_GPG_PATH, 256); … … 387 379 (void) mode; 388 380 (void) id; 389 #elif defined(WITH_PGP)390 /* -- PGP -- */391 sl_strlcpy (path, DEFAULT_PGP_PATH, 256);392 if (mode == 0)393 {394 sl_strlcpy (cc1, _("+language=en"), 32);395 sl_strlcpy (cc2, _("-o"), 32);396 sl_strlcpy (cc3, _("/dev/null"), 32);397 398 arg[0] = path;399 arg[1] = cc1;400 arg[2] = cc2;401 arg[3] = cc3;402 arg[4] = cc0;403 arg[5] = NULL;404 }405 else406 {407 sl_strlcpy (cc1, _("+language=en"), 32);408 sl_strlcpy (cc2, _("-kvc"), 32);409 410 arg[0] = path;411 arg[1] = cc1;412 arg[2] = cc2;413 arg[3] = id;414 arg[4] = NULL;415 arg[5] = NULL;416 }417 #endif418 381 419 382 /* use homedir of effective user … … 467 430 sl_close_fd (FIL__, __LINE__, pipedes[STDOUT_FILENO]); 468 431 469 470 #if defined(WITH_PGP)471 if (mode == 0)472 {473 if (retry_aud_dup2(FIL__, __LINE__, fd, STDIN_FILENO) < 0)474 {475 TPT(((0), FIL__, __LINE__, _("msg=<dup2 on fd failed>\n")));476 dlog(1, FIL__, __LINE__, _("Internal error: dup2 failed\n"));477 aud__exit(FIL__, __LINE__, EXIT_FAILURE);478 }479 }480 #else481 432 if (retry_aud_dup2(FIL__, __LINE__, fd, STDIN_FILENO) < 0) 482 433 { … … 485 436 aud__exit(FIL__, __LINE__, EXIT_FAILURE); 486 437 } 487 #endif488 438 489 439 /* don't leak file descriptors 490 440 */ 491 sh_unix_closeall (3, -1, S L_TRUE); /* in child process */492 493 if (flag_err_debug != S L_TRUE)441 sh_unix_closeall (3, -1, S_TRUE); /* in child process */ 442 443 if (flag_err_debug != S_TRUE) 494 444 { 495 445 if (NULL == freopen(_("/dev/null"), "r+", stderr)) … … 530 480 * -- emulate an fexecve with checksum testing 531 481 */ 532 #if defined(WITH_PGP)533 checkfd = sl_open_read(FIL__, __LINE__, DEFAULT_PGP_PATH, SL_NOPRIV);534 #else535 482 checkfd = sl_open_read(FIL__, __LINE__, DEFAULT_GPG_PATH, SL_NOPRIV); 536 #endif537 483 538 484 if (0 != sh_gpg_checksum(checkfd, 0)) … … 580 526 for (i = 0; i < myrand; ++i) 581 527 { 582 #if defined(WITH_PGP) 583 checkfd = sl_open_fastread(FIL__, __LINE__, DEFAULT_PGP_PATH, SL_NOPRIV); 584 #else 585 checkfd = sl_open_fastread(FIL__, __LINE__, DEFAULT_GPG_PATH, SL_NOPRIV); 586 #endif 528 checkfd = sl_open_fastread(FIL__, __LINE__, 529 DEFAULT_GPG_PATH, SL_NOPRIV); 530 587 531 if (0 != sh_gpg_checksum(checkfd, 0)) { 588 532 aud__exit(FIL__, __LINE__, EXIT_FAILURE); … … 591 535 } 592 536 #endif 593 594 595 #if defined(WITH_GPG) 537 596 538 retry_aud_execve (FIL__, __LINE__, DEFAULT_GPG_PATH, arg, envp); 597 539 dlog(1, FIL__, __LINE__, _("Unexpected error: execve %s failed\n"), 598 540 DEFAULT_GPG_PATH); 599 #elif defined(WITH_PGP)600 retry_aud_execve (FIL__, __LINE__, DEFAULT_PGP_PATH, arg, envp);601 #endif602 541 603 542 /* failed … … 659 598 sh_gpg_popen_t source; 660 599 int have_id = BAD, have_fp = BAD, status = 0; 661 #ifdef WITH_PGP662 char *ptr;663 #endif664 600 665 601 #ifdef HAVE_GPG_CHECKSUM … … 671 607 /* check whether GnuPG exists and has the correct checksum 672 608 */ 673 #if defined(WITH_GPG)674 675 609 TPT(((0), FIL__, __LINE__, _("msg=<Check signature>\n"))); 676 610 TPT(((0), FIL__, __LINE__, _("msg=<gpg is %s>\n"), DEFAULT_GPG_PATH)); … … 701 635 } 702 636 sl_close(checkfd); 703 #endif704 705 #elif defined(WITH_PGP)706 707 TPT(((0), FIL__, __LINE__, _("msg=<Check signature>\n")));708 TPT(((0), FIL__, __LINE__, _("msg=<pgp is %s>\n"), DEFAULT_PGP_PATH));709 710 if (0 != retry_lstat(FIL__, __LINE__, DEFAULT_PGP_PATH, &buf))711 {712 char errbuf[SH_ERRBUF_SIZE];713 714 status = errno;715 sh_error_handle(SH_ERR_ERR, FIL__, __LINE__, status, MSG_ERR_LSTAT,716 sh_error_message(status, errbuf, sizeof(errbuf)), DEFAULT_PGP_PATH);717 SL_RETURN( SH_GPG_BAD, _("sh_gpg_check_file_sign"));718 }719 if (0 != tf_trust_check (DEFAULT_PGP_PATH, SL_YESPRIV))720 SL_RETURN( SH_GPG_BAD, _("sh_gpg_check_file_sign"));721 722 #ifdef HAVE_GPG_CHECKSUM723 checkfd = sl_open_read(FIL__, __LINE__, DEFAULT_PGP_PATH, SL_YESPRIV);724 725 if (0 != sh_gpg_checksum(checkfd, 1))726 {727 sh_error_handle((-1), FIL__, __LINE__, 0, MSG_E_SUBGEN,728 _("Checksum mismatch"),729 _("gpg_check_file_sign"));730 sl_close(checkfd);731 SL_RETURN( SH_GPG_BAD, _("sh_gpg_check_file_sign"));732 }733 sl_close(checkfd);734 #endif735 736 637 #endif 737 638 … … 768 669 if (sl_strlen(line) < 18) 769 670 continue; 770 #if defined(WITH_GPG) 671 771 672 /* Sun May 27 18:40:05 CEST 2001 772 673 */ … … 821 722 have_fp = GOOD; 822 723 } 823 #elif defined(WITH_PGP)824 if (0 == sl_strncmp(_("Bad signature"), line, 13) ||825 0 == sl_strncmp(_("Error"), line, 5) ||826 0 == sl_strncmp(_("Malformed"), line, 9) ||827 0 == sl_strncmp(_("WARNING"), line, 7) ||828 0 == sl_strncmp(_("ERROR"), line, 5)829 )830 {831 have_fp = BAD; have_id = BAD;832 break;833 }834 if (0 == sl_strncmp(_("Good signature"), line, 14))835 {836 ptr = strchr ( line, '"');837 ++ptr;838 if (ptr)839 {840 sl_strlcpy (sign_id, ptr, SH_MINIBUF+1);841 sign_id[sl_strlen(sign_id)-1] = '\0'; /* remove trailing dot */842 sign_id[sl_strlen(sign_id)-2] = '\0'; /* remove trailing '"' */843 }844 else845 {846 sl_strlcpy (sign_id, _("(null)"), SH_MINIBUF+1);847 }848 have_id = GOOD;849 }850 #endif851 724 } 852 725 853 726 if (ferror(source.pipe) && errno == EAGAIN) 854 727 { 855 retry_msleep(0,10); /* sleep 10 ms to avoid starving the gpg child writing to the pipe */ 728 /* sleep 10 ms to avoid starving the gpg child writing to the pipe */ 729 retry_msleep(0,10); 856 730 clearerr(source.pipe); 857 731 goto xagain; … … 862 736 TPT(((0), FIL__, __LINE__, _("msg=<Close pipe>\n"))); 863 737 864 #ifdef WITH_PGP865 /* get the fingerprint */866 867 source.pipe = sh_gpg_popen ( &source, fd, 1, sign_id, homedir);868 if (NULL == source.pipe)869 {870 sh_error_handle((-1), FIL__, __LINE__, 0, MSG_E_SUBGEN,871 _("Could not open pipe for fp"),872 _("gpg_check_file_sign"));873 SL_RETURN( SH_GPG_BAD, _("sh_gpg_check_file_sign"));874 }875 876 TPT(((0), FIL__, __LINE__, _("msg=<Open pipe success>\n")));877 878 yagain:879 880 errno = 0;881 882 while (NULL != fgets(line, sizeof(line), source.pipe))883 {884 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_STRTOK_R)885 char * saveptr = NULL;886 #endif887 if (line[strlen(line)-1] == '\n')888 line[strlen(line)-1] = ' ';889 sh_error_handle(SH_ERR_ALL, FIL__, __LINE__, 0, MSG_E_SUBGEN,890 line,891 _("gpg_check_file_sign"));892 893 if (sl_strlen(line) < 18)894 continue;895 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_STRTOK_R)896 ptr = strtok_r (line, " ", &saveptr);897 #else898 ptr = strtok (line, " ");899 #endif900 while (ptr)901 {902 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_STRTOK_R)903 ptr = strtok_r (NULL, " ", &saveptr);904 #else905 ptr = strtok (NULL, " ");906 #endif907 if (ptr && 0 == sl_strncmp (ptr, _("fingerprint"), 11))908 {909 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_STRTOK_R)910 ptr = strtok_r (NULL, " ", &saveptr); /* to '=' */911 #else912 ptr = strtok (NULL, " "); /* to '=' */913 #endif914 sign_fp[0] = '\0';915 while (ptr)916 {917 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_STRTOK_R)918 ptr = strtok_r (NULL, " ", &saveptr); /* part of fingerprint */919 #else920 ptr = strtok (NULL, " "); /* part of fingerprint */921 #endif922 sl_strlcat (sign_fp, ptr, SH_MINIBUF+1);923 }924 /* sign_fp[sl_strlen(sign_fp)-1] = '\0'; remove trailing '\n' */925 if (sl_strlen(sign_fp) > 0)926 have_fp = GOOD;927 break;928 }929 }930 }931 932 if (ferror(source.pipe) && errno == EAGAIN)933 {934 retry_msleep(0,10); /* sleep 10 ms to avoid starving the gpg child writing to the pipe */935 clearerr(source.pipe);936 goto yagain;937 }938 939 sh_gpg_pclose (&source);940 #endif941 942 738 if (have_id == GOOD) 943 739 { 944 740 TPT(((0), FIL__, __LINE__, _("msg=<Got signator ID>\n"))); 945 ;946 741 } 947 742 if (have_fp == GOOD) 948 743 { 949 744 TPT(((0), FIL__, __LINE__, _("msg=<Got fingerprint>\n"))); 950 ;951 745 } 952 746 … … 969 763 int get_the_fd(SL_TICKET file_1); 970 764 971 int sh_gpg_check_sign (long file_1, long file_2, int what) 765 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && \ 766 defined(HAVE_GETPWNAM_R) 767 #define USE_GETPWNAM_R 1 768 #endif 769 770 int sh_gpg_check_sign (long file, int what) 972 771 { 973 772 int status = SH_GPG_BAD; 974 int fd 1= 0;975 int fd2 = 0; 773 int fd = 0; 774 976 775 static int smsg = S_FALSE; 977 776 char * tmp; 978 char * tmp2; 777 778 char * sig_id; 779 char * sig_fp; 979 780 980 781 char * homedir = sh.effective.home; 981 782 #if defined(SH_WITH_SERVER) 982 783 struct passwd * tempres; 983 #if defined( HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETPWNAM_R)784 #if defined(USE_GETPWNAM_R) 984 785 struct passwd pwd; 985 786 char * buffer = SH_ALLOC(SH_PWBUF_SIZE); … … 994 795 995 796 996 if (what == 0 || what == 1) 997 fd1 = get_the_fd(file_1); 998 if (what == 0 || what == 2) 999 fd2 = get_the_fd(file_2); 1000 1001 1002 if (fd1 < 0 || fd2 < 0) 1003 { 1004 TPT(((0), FIL__, __LINE__, _("msg=<GPG_CHECK: FD1 = %d>\n"), fd1)); 1005 TPT(((0), FIL__, __LINE__, _("msg=<GPG_CHECK: FD2 = %d>\n"), fd2)); 797 if (what == SIG_CONF) 798 fd = get_the_fd(file); 799 if (what == SIG_DATA) 800 fd = get_the_fd(file); 801 802 803 if (fd < 0) 804 { 805 TPT(((0), FIL__, __LINE__, _("msg=<GPG_CHECK: FD = %d>\n"), fd)); 1006 806 dlog(1, FIL__, __LINE__, 1007 807 _("This looks like an unexpected internal error.\n")); 1008 sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_EXIT_ABORT1, sh.prg_name); 1009 aud_exit (FIL__, __LINE__, EXIT_FAILURE); 808 #if defined(SH_WITH_SERVER) && defined(USE_GETPWNAM_R) 809 SH_FREE(buffer); 810 #endif 811 SL_RETURN( (-1), _("sh_gpg_check_sign")); 812 } 813 1010 814 #if defined(SH_WITH_SERVER) 1011 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETPWNAM_R) 1012 SH_FREE(buffer); 1013 #endif 1014 #endif 1015 SL_RETURN( (-1), _("sh_gpg_check_sign")); 1016 } 1017 1018 if (what == 0 || what == 1) 1019 { 1020 TPT(((0), FIL__, __LINE__, _("msg=<GPG_CHECK: FD1 = %d>\n"), fd1)); 1021 #if defined(SH_WITH_SERVER) 1022 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETPWNAM_R) 815 #if defined(USE_GETPWNAM_R) 1023 816 sh_getpwnam_r(DEFAULT_IDENT, &pwd, buffer, SH_PWBUF_SIZE, &tempres); 1024 817 #else 1025 818 tempres = sh_getpwnam(DEFAULT_IDENT); 1026 819 #endif 1027 1028 820 if ((tempres != NULL) && (0 == sl_ret_euid())) 1029 821 { … … 1032 824 } 1033 825 #endif 1034 status = sh_gpg_check_file_sign(fd1, gp.conf_id, gp.conf_fp, homedir, 1); 826 827 if (what == SIG_CONF) 828 { 829 TPT(((0), FIL__, __LINE__, _("msg=<GPG_CHECK: FD = %d>\n"), fd)); 830 status = sh_gpg_check_file_sign(fd, gp.conf_id, gp.conf_fp, homedir, 1); 1035 831 TPT(((0), FIL__, __LINE__, _("msg=<CONF SIGUSR: |%s|>\n"), gp.conf_id)); 1036 832 TPT(((0), FIL__, __LINE__, _("msg=<CONF SIGFP: |%s|>\n"), gp.conf_fp)); 1037 } 1038 1039 if ((what == 0 && SH_GPG_OK == status) || what == 2) 1040 { 1041 TPT(((0), FIL__, __LINE__, _("msg=<GPG_CHECK: FD2 = %d>\n"), fd2)); 1042 #if defined(SH_WITH_SERVER) 1043 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETPWNAM_R) 1044 sh_getpwnam_r(DEFAULT_IDENT, &pwd, buffer, SH_PWBUF_SIZE, &tempres); 1045 #else 1046 tempres = sh_getpwnam(DEFAULT_IDENT); 1047 #endif 1048 1049 if ((tempres != NULL) && (0 == sl_ret_euid())) 1050 { 1051 /* privileges not dropped yet*/ 1052 homedir = tempres->pw_dir; 1053 } 1054 #endif 1055 status = sh_gpg_check_file_sign(fd2, gp.data_id, gp.data_fp, homedir, 2); 833 sig_id = gp.conf_id; sig_fp = gp.conf_fp; 834 } 835 836 if (what == SIG_DATA) 837 { 838 TPT(((0), FIL__, __LINE__, _("msg=<GPG_CHECK: FD = %d>\n"), fd)); 839 status = sh_gpg_check_file_sign(fd, gp.data_id, gp.data_fp, homedir, 2); 1056 840 TPT(((0), FIL__, __LINE__, _("msg=<DATA SIGUSR: |%s|>\n"), gp.data_id)); 1057 841 TPT(((0), FIL__, __LINE__, _("msg=<DATA SIGFP: |%s|>\n"), gp.data_fp)); 842 sig_id = gp.data_id; sig_fp = gp.data_fp; 1058 843 } 1059 844 1060 if (SH_GPG_OK == status && what == 1)845 if (SH_GPG_OK == status) 1061 846 { 1062 847 #ifdef USE_FINGERPRINT 1063 if ((sl_strcmp(SH_GPG_FP, gp.conf_fp) == 0))848 if ((sl_strcmp(SH_GPG_FP, sig_fp) == 0)) 1064 849 { 1065 850 int i; 1066 851 1067 for(i = 0; i < (int) sl_strlen(gp.conf_fp); ++i) 1068 { 1069 if (gpgfp[i] != gp.conf_fp[i]) 1070 { 1071 sh_error_handle(SH_ERR_SEVERE, FIL__, __LINE__, 0, 1072 MSG_E_GPG_FP, 1073 gpgfp, gp.conf_fp); 1074 break; 1075 } 1076 } 1077 1078 if (smsg == S_FALSE) 1079 { 1080 tmp = sh_util_safe_name(gp.conf_id); 1081 sh_gpg_fill_startup (__LINE__, 1082 /* sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_START_GH, */ 852 for(i = 0; i < (int) sl_strlen(sig_fp); ++i) { 853 if (gpgfp[i] != sig_fp[i]) { 854 sh_error_handle(SH_ERR_SEVERE, FIL__, __LINE__, 0, 855 MSG_E_GPG_FP, gpgfp, sig_fp); 856 break; } 857 } 858 859 if (smsg == S_FALSE) { 860 tmp = sh_util_safe_name(sig_id); 861 sh_gpg_fill_startup (__LINE__, sh.prg_name, sh.real.uid, 862 (sh.flag.hidefile == S_TRUE) ? 863 _("(hidden)") : file_path('C', 'R'), 864 tmp, 865 sig_fp); 866 SH_FREE(tmp); } 867 smsg = S_TRUE; 868 869 #if defined(SH_WITH_SERVER) && defined(USE_GETPWNAM_R) 870 SH_FREE(buffer); 871 #endif 872 SL_RETURN(0, _("sh_gpg_check_sign")); 873 } 874 else 875 { 876 /* fp mismatch */ 877 dlog(1, FIL__, __LINE__, 878 _("The fingerprint of the signing key: %s\ndoes not match the compiled-in fingerprint: %s.\nTherefore the signature could not be verified.\n"), 879 sig_fp, SH_GPG_FP); 880 sh_error_handle((-1), FIL__, __LINE__, 0, MSG_E_SUBGEN, 881 _("Fingerprint mismatch"), _("gpg_check_sign")); 882 status = SH_GPG_BADSIGN; 883 } 884 #else /* ifdef USE_FINGERPRINT */ 885 if (smsg == S_FALSE) 886 { 887 tmp = sh_util_safe_name(sig_id); 888 sh_gpg_fill_startup (__LINE__, 1083 889 sh.prg_name, sh.real.uid, 1084 890 (sh.flag.hidefile == S_TRUE) ? 1085 891 _("(hidden)") : file_path('C', 'R'), 1086 tmp, 1087 gp.conf_fp); 1088 SH_FREE(tmp); 1089 } 1090 smsg = S_TRUE; 1091 #if defined(SH_WITH_SERVER) 1092 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETPWNAM_R) 1093 SH_FREE(buffer); 1094 #endif 1095 #endif 1096 SL_RETURN(0, _("sh_gpg_check_sign")); 1097 } 1098 else 1099 { 1100 /* fp mismatch 1101 */ 1102 dlog(1, FIL__, __LINE__, 1103 _("The fingerprint of the signing key: %s\ndoes not match the compiled-in fingerprint: %s.\nTherefore the signature could not be verified.\n"), 1104 gp.conf_fp, SH_GPG_FP); 1105 sh_error_handle((-1), FIL__, __LINE__, 0, MSG_E_SUBGEN, 1106 _("Fingerprint mismatch"), 1107 _("gpg_check_sign")); 1108 status = SH_GPG_BADSIGN; 1109 } 1110 #else 1111 if (smsg == S_FALSE) 1112 { 1113 tmp = sh_util_safe_name(gp.conf_id); 1114 sh_gpg_fill_startup (__LINE__, 1115 /* sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_START_GH, */ 1116 sh.prg_name, sh.real.uid, 1117 (sh.flag.hidefile == S_TRUE) ? 1118 _("(hidden)") : file_path('C', 'R'), 1119 tmp, 1120 gp.conf_fp); 892 tmp, sig_fp); 1121 893 SH_FREE(tmp); 1122 894 } 1123 895 smsg = S_TRUE; 1124 #if defined(SH_WITH_SERVER) 1125 #if defined( HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETPWNAM_R)896 897 #if defined(SH_WITH_SERVER) && defined(USE_GETPWNAM_R) 1126 898 SH_FREE(buffer); 1127 899 #endif 1128 #endif 900 1129 901 SL_RETURN(0, _("sh_gpg_check_sign")); 1130 #endif 1131 } 1132 1133 else if (SH_GPG_OK == status && (what == 2 || what == 0)) 1134 { 1135 if ((sl_strcmp(gp.data_id, gp.conf_id) == 0) && 1136 (sl_strcmp(gp.data_fp, gp.conf_fp) == 0)) 1137 { 1138 #if defined(SH_WITH_SERVER) 1139 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETPWNAM_R) 1140 SH_FREE(buffer); 1141 #endif 1142 #endif 1143 SL_RETURN(0, _("sh_gpg_check_sign")); 1144 } 1145 else 1146 { 1147 /* ID or fp not equal 1148 */ 1149 dlog(1, FIL__, __LINE__, 1150 _("The fingerprint or ID of the signing key is not the same for the\nconfiguration file and the file signature database.\nTherefore the signature could not be verified.\n")); 1151 tmp = sh_util_safe_name (gp.conf_id); 1152 tmp2 = sh_util_safe_name (gp.data_id); 1153 sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_START_GH2, 1154 sh.prg_name, sh.real.uid, 1155 (sh.flag.hidefile == S_TRUE) ? _("(hidden)") : file_path('C', 'R'), 1156 tmp, gp.conf_fp, 1157 (sh.flag.hidefile == S_TRUE) ? _("(hidden)") : file_path('D', 'R'), 1158 tmp2, gp.data_fp); 1159 SH_FREE(tmp); 1160 SH_FREE(tmp2); 1161 } 902 #endif /* !ifdef USE_FINGERPRINT */ 1162 903 } 1163 904 … … 1168 909 1169 910 #if defined(SH_WITH_SERVER) 1170 #if defined( HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETPWNAM_R)911 #if defined(USE_GETPWNAM_R) 1171 912 struct passwd e_pwd; 1172 913 char * e_buffer = SH_ALLOC(SH_PWBUF_SIZE); … … 1186 927 dlog(1, FIL__, __LINE__, 1187 928 _("The signature of the configuration file or the file signature database\ncould not be verified. Possible reasons are:\n - gpg binary (%s) not found\n - invalid signature\n - the signature key is not in the private keyring of UID %d,\n - there is no keyring in %s/.gnupg, or\n - the file is not signed - did you move /filename.asc to /filename ?\nTo create a signed file, use (remove old signatures before):\n gpg -a --clearsign --not-dash-escaped FILE\n mv FILE.asc FILE\n"), 1188 #if defined(WITH_GPG)1189 929 DEFAULT_GPG_PATH, 1190 #else1191 DEFAULT_PGP_PATH,1192 #endif1193 930 (int) e_uid, e_home); 1194 931 1195 #if defined(SH_WITH_SERVER) 1196 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETPWNAM_R) 932 #if defined(SH_WITH_SERVER) && defined(USE_GETPWNAM_R) 1197 933 SH_FREE(e_buffer); 1198 934 #endif 1199 #endif1200 935 } 1201 936 1202 937 TPT(((0), FIL__, __LINE__, _("msg=<Status = %d>\n"), status)); 1203 1204 sh_error_handle((-1), FIL__, __LINE__, status, MSG_EXIT_ABORT1, sh.prg_name);1205 aud_exit (FIL__, __LINE__, EXIT_FAILURE);1206 938 1207 939 return (-1); /* make compiler happy */ … … 1223 955 */ 1224 956 fdTmp = open_tmp(); 957 if (SL_ISERROR(fdTmp)) 958 { 959 dlog(1, FIL__, __LINE__, _("Error opening temporary file.\n")); 960 sh_error_handle((-1), FIL__, __LINE__, 0, MSG_E_SUBGEN, 961 _("Error opening temporary file."), 962 _("sh_gpg_extract_signed")); 963 return -1; 964 } 1225 965 1226 966 fin_cp = fdopen(dup(get_the_fd(fd)), "rb"); -
trunk/src/sh_hash.c
r474 r481 20 20 #include "config_xor.h" 21 21 22 /* define this if you want version 1.3 style database file */23 /* #define OLD_BUG */24 25 /* make sure state changes of a file are always reported, even26 * with reportonlyonce=true27 */28 /* #define REPLACE_OLD *//* moved to samhain.h */29 30 22 #include <stdlib.h> 31 23 #include <string.h> … … 48 40 #endif 49 41 42 50 43 #if defined(SH_WITH_CLIENT) || defined(SH_STANDALONE) 51 44 45 #include "samhain.h" 46 #include "sh_utils.h" 47 #include "sh_unix.h" 48 #include "sh_dbIO_int.h" 49 #include "sh_dbIO.h" 52 50 #include "sh_hash.h" 53 #include "sh_utils.h"54 51 #include "sh_error.h" 55 52 #include "sh_tiger.h" … … 61 58 62 59 #if defined(SH_WITH_CLIENT) 63 #include "sh_ forward.h"60 #include "sh_xfer.h" 64 61 #endif 65 62 … … 71 68 #define FIL__ _("sh_hash.c") 72 69 73 SH_MUTEX_STATIC(mutex_hash,PTHREAD_MUTEX_INITIALIZER); 74 75 const char notalink[2] = { '-', '\0' }; 70 SH_MUTEX_INIT(mutex_hash,PTHREAD_MUTEX_INITIALIZER); 76 71 77 72 static char * all_items (file_type * theFile, char * fileHash, int is_new); 78 73 79 #define QUOTE_CHAR '=' 80 81 char * unquote_string (const char * str, size_t len) 82 { 83 int i = 0, t1, t2; 84 char * tmp = NULL; 85 size_t l2, j, k = 0; 86 87 SL_ENTER(_("unquote_string")); 88 89 if (str != NULL) 90 { 91 l2 = len - 2; 92 tmp = SH_ALLOC(len + 1); 93 94 for (j = 0; j <= len; ++j) 95 { 96 if (str[j] != QUOTE_CHAR) 97 { 98 tmp[k] = str[j]; 99 } 100 else if (str[j] == QUOTE_CHAR && j < l2) 101 { 102 t1 = sh_util_hexchar(str[j+1]); 103 t2 = sh_util_hexchar(str[j+2]); 104 if ((t1|t2) >= 0) 105 { 106 i = 16 * t1 + t2; 107 tmp[k] = i; 108 j += 2; 109 } 110 else 111 { 112 tmp[k] = str[j]; 113 } 114 } 115 else 116 tmp[k] = str[j]; 117 ++k; 118 } 119 } 120 SL_RETURN(tmp, _("unquote_string")); 121 } 122 123 124 static char * int2hex (unsigned char i, char * i2h) 125 { 126 static char hexchars[] = "0123456789ABCDEF"; 127 128 i2h[0] = hexchars[(((i) & 0xF0) >> 4)]; /* high */ 129 i2h[1] = hexchars[((i) & 0x0F)]; /* low */ 130 131 return i2h; 132 } 133 134 135 char * quote_string (const char * str, size_t len) 136 { 137 char * tmp; 138 char * tmp2; 139 size_t l2, j, i = 0, k = 0; 140 char i2h[2]; 141 142 SL_ENTER(_("quote_string")); 143 144 if (str == NULL) 145 { 146 SL_RETURN(NULL, _("quote_string")); 147 } 148 149 for (j = 0; j < len; ++j) 150 if (str[j] == '\n' || str[j] == QUOTE_CHAR) ++i; 151 152 l2 = len + 1; 153 if (sl_ok_muls(3, i) && sl_ok_adds(l2, (3*i))) 154 { 155 tmp = SH_ALLOC(len + 1 + 3*i); 156 } 157 else 158 { 159 sh_error_handle((-1), FIL__, __LINE__, -1, MSG_E_SUBGEN, 160 _("integer overflow"), 161 _("quote_string")); 162 SL_RETURN(NULL, _("quote_string")); 163 } 164 165 for (j = 0; j <= len; ++j) 166 { 167 if (str[j] == '\n') 168 { 169 tmp2 = int2hex((unsigned char) '\n', i2h); /* was 'n', fixed in 1.5.4 */ 170 tmp[k] = QUOTE_CHAR; ++k; 171 tmp[k] = tmp2[0]; ++k; 172 tmp[k] = tmp2[1]; 173 } 174 else if (str[j] == QUOTE_CHAR) 175 { 176 tmp2 = int2hex((unsigned char) QUOTE_CHAR, i2h); 177 tmp[k] = QUOTE_CHAR; ++k; 178 tmp[k] = tmp2[0]; ++k; 179 tmp[k] = tmp2[1]; 180 } 181 else 182 { 183 tmp[k] = str[j]; 184 } 185 ++k; 186 } 187 SL_RETURN(tmp, _("quote_string")); 188 } 189 190 static UINT32 * swap_32 (UINT32 * iptr) 191 { 192 #ifdef WORDS_BIGENDIAN 193 unsigned char swap; 194 unsigned char * ii = (unsigned char *) iptr; 195 swap = ii[0]; ii[0] = ii[3]; ii[3] = swap; 196 swap = ii[1]; ii[1] = ii[2]; ii[2] = swap; 197 return iptr; 198 #else 199 return iptr; 200 #endif 201 } 202 203 static UINT64 * swap_64 (UINT64 * iptr) 204 { 205 #ifdef WORDS_BIGENDIAN 206 #ifdef UINT64_IS_32 207 swap_32 ((UINT32*) iptr); 208 #else 209 unsigned char swap; 210 unsigned char * ii = (unsigned char *) iptr; 211 swap = ii[0]; ii[0] = ii[7]; ii[7] = swap; 212 swap = ii[1]; ii[1] = ii[6]; ii[6] = swap; 213 swap = ii[2]; ii[2] = ii[5]; ii[5] = swap; 214 swap = ii[3]; ii[3] = ii[4]; ii[4] = swap; 215 #endif 216 return iptr; 217 #else 218 return iptr; 219 #endif 220 } 221 222 static unsigned short * swap_short (unsigned short * iptr) 223 { 224 #ifdef WORDS_BIGENDIAN 225 if (sizeof(short) == 4) 226 swap_32 ((UINT32*) iptr); 227 else 228 { 229 /* alignment problem */ 230 unsigned char swap; 231 static unsigned short ooop; 232 unsigned char * ii; 233 ooop = *iptr; 234 ii = (unsigned char *) &ooop; 235 /* printf("SWAP0: %hd %d\n", *iptr, sizeof(unsigned short)); */ 236 swap = ii[0]; ii[0] = ii[1]; ii[1] = swap; 237 /* printf("SWAP1: %hd\n", (unsigned short) ooop); */ 238 #ifndef OLD_BUG 239 return &ooop; 240 #endif 241 } 242 return iptr; 243 #else 244 return iptr; 245 #endif 246 } 247 248 249 typedef struct store_info { 250 251 UINT32 mode; 252 UINT32 linkmode; 253 254 UINT64 dev; 255 UINT64 rdev; 256 UINT32 hardlinks; 257 UINT32 ino; 258 UINT64 size; 259 UINT64 atime; 260 UINT64 mtime; 261 UINT64 ctime; 262 UINT32 owner; 263 UINT32 group; 264 265 #ifdef OLD_BUG 266 #if defined(__linux__) 267 UINT32 attributes; 268 char c_attributes[ATTRBUF_SIZE]; 269 #endif 270 #else 271 /* #if defined(__linux__) */ 272 UINT32 attributes; 273 char c_attributes[ATTRBUF_SIZE]; 274 /* endif */ 275 #endif 276 unsigned short mark; 277 char c_owner[USER_MAX+2]; 278 char c_group[GROUP_MAX+2]; 279 char c_mode[CMODE_SIZE]; 280 char checksum[KEY_LEN+1]; 281 } sh_filestore_t; 282 283 typedef struct file_info { 284 sh_filestore_t theFile; 285 char * fullpath; 286 char * linkpath; 287 char * attr_string; 288 int fflags; 289 unsigned long modi_mask; 290 struct file_info * next; 291 } sh_file_t; 292 293 static const char *policy[] = { 294 N_("[]"), 295 N_("[ReadOnly]"), 296 N_("[LogFiles]"), 297 N_("[GrowingLogs]"), 298 N_("[IgnoreNone]"), 299 N_("[IgnoreAll]"), 300 N_("[Attributes]"), 301 N_("[User0]"), 302 N_("[User1]"), 303 N_("[User2]"), 304 N_("[User3]"), 305 N_("[User4]"), 306 N_("[Prelink]"), 307 NULL 308 }; 74 static const char *policy[] = { 75 N_("[]"), 76 N_("[ReadOnly]"), 77 N_("[LogFiles]"), 78 N_("[GrowingLogs]"), 79 N_("[IgnoreNone]"), 80 N_("[IgnoreAll]"), 81 N_("[Attributes]"), 82 N_("[User0]"), 83 N_("[User1]"), 84 N_("[User2]"), 85 N_("[User3]"), 86 N_("[User4]"), 87 N_("[Prelink]"), 88 NULL 89 }; 90 91 static int report_checkflags = S_FALSE; 92 int set_report_checkflags(const char * c) 93 { 94 return sh_util_flagval(c, &report_checkflags); 95 } 96 int get_report_checkflags() 97 { 98 return report_checkflags; 99 } 100 101 309 102 310 103 const char * sh_hash_getpolicy(int class) … … 324 117 #include "sh_hash.h" 325 118 326 /* must fit an int */327 /* #define TABSIZE 2048 */328 #define TABSIZE 65536329 330 /* must fit an unsigned short */331 /* changed for V0.8, as the */332 /* database format has changed */333 334 /* changed again for V0.9 */335 /* #define REC_MAGIC 19 */336 /* changed again for V1.3 */337 #ifdef OLD_BUG338 #define REC_MAGIC 20339 #else340 /* changed again for V1.4 */341 #define REC_MAGIC 21342 #endif343 344 #define REC_FLAGS_ATTR (1<<8)345 #define REC_FLAGS_MASK 0xFF00346 119 347 120 /************************************************************** … … 350 123 * 351 124 **************************************************************/ 352 staticfile_type * sh_hash_create_ft (const sh_file_t * p, char * fileHash)125 file_type * sh_hash_create_ft (const sh_file_t * p, char * fileHash) 353 126 { 354 127 file_type * theFile; … … 391 164 theFile->dev = p->theFile.dev; 392 165 theFile->hardlinks = p->theFile.hardlinks; 166 theFile->check_flags = p->theFile.checkflags; 393 167 394 168 if (p->attr_string) … … 408 182 static int hashsearch_prev (const char * s, struct two_sh_file_t * a, int * index); 409 183 184 185 /************************************************************** 186 * 187 * >>>> The internal database <<< 188 * 189 **************************************************************/ 190 410 191 static sh_file_t * tab[TABSIZE]; 192 193 sh_file_t ** get_default_data_table() 194 { 195 return tab; 196 } 411 197 412 198 /************************************************************** … … 499 285 if (p->linkpath) 500 286 { 501 if (p->linkpath != notalink) 502 SH_FREE(p->linkpath); 287 SH_FREE(p->linkpath); 503 288 p->linkpath = NULL; 504 289 } … … 521 306 char fileHash[KEY_LEN + 1]; 522 307 file_type * theFile; 523 524 308 char * str; 525 526 309 527 310 SL_ENTER(_("hash_unvisited")); … … 552 335 if (((!SH_FFLAG_VISITED_SET(p->fflags)) || SH_FFLAG_CHECKED_SET(p->fflags)) 553 336 && (!SH_FFLAG_REPORTED_SET(p->fflags)) 554 && (!SH_FFLAG_ALLIGNORE_SET(p->fflags)))337 /* && (!SH_FFLAG_ALLIGNORE_SET(p->fflags)) */) 555 338 { 556 339 i = retry_lstat(FIL__, __LINE__, p->fullpath, &buf); … … 565 348 /* If any of the parent directories is under IgnoreAll 566 349 */ 567 if ( 0 != sh_files_is_allignore(ptr))350 if ((0 != sh_files_is_allignore(ptr)) || SH_FFLAG_ALLIGNORE_SET(p->fflags)) 568 351 level = ShDFLevel[SH_LEVEL_ALLIGNORE]; 569 352 SH_FREE(ptr); … … 599 382 (S_TRUE == sh.flag.update && S_TRUE == sh_util_ask_update(p->fullpath))) 600 383 { 601 #ifdef REPLACE_OLD602 384 /* Remove the old entry 603 385 */ … … 610 392 611 393 SL_RET0(_("hash_unvisited")); 612 #else613 SET_SH_FFLAG_REPORTED(p->fflags);614 #endif615 394 } 616 395 } … … 679 458 * 680 459 *********************************************************************/ 681 void sh_hash_remove (const char * path)460 void sh_hash_remove_unconditional (const char * path) 682 461 { 683 462 struct two_sh_file_t entries; 684 463 int index; 685 464 465 SL_ENTER(_("sh_hash_remove_unconditional")); 466 467 SH_MUTEX_LOCK(mutex_hash); 468 if (0 == hashsearch_prev (path, &entries, &index)) 469 { 470 sh_file_t * p = entries.this; 471 472 /* Remove the old entry 473 */ 474 if (entries.prev == p) 475 tab[index] = p->next; 476 else 477 entries.prev->next = p->next; 478 479 delete_db_entry(p); 480 } 481 SH_MUTEX_UNLOCK(mutex_hash); 482 483 SL_RET0(_("sh_hash_remove_unconditional")); 484 } 485 486 void sh_hash_remove (const char * path) 487 { 686 488 SL_ENTER(_("sh_hash_remove")); 687 688 SH_MUTEX_LOCK(mutex_hash);689 489 690 490 if ((sh.flag.reportonce == S_TRUE && sh.flag.update == S_FALSE) || 691 491 (S_TRUE == sh.flag.update && S_TRUE == sh_util_ask_update(path))) 692 492 { 693 if (0 == hashsearch_prev (path, &entries, &index)) 694 { 695 sh_file_t * p = entries.this; 696 #ifdef REPLACE_OLD 697 /* Remove the old entry 698 */ 699 if (entries.prev == p) 700 tab[index] = p->next; 701 else 702 entries.prev->next = p->next; 703 704 delete_db_entry(p); 705 706 goto end; 707 #else 708 SET_SH_FFLAG_REPORTED(p->fflags); 709 #endif 710 } 711 } 712 713 end: 714 ; /* 'label at end of compound statement' */ 715 SH_MUTEX_UNLOCK(mutex_hash); 716 493 sh_hash_remove_unconditional (path); 494 } 717 495 SL_RET0(_("sh_hash_remove")); 718 496 } … … 811 589 if (p->linkpath) 812 590 { 813 if (p->linkpath != notalink) 814 SH_FREE(p->linkpath); 591 SH_FREE(p->linkpath); 815 592 p->linkpath = NULL; 816 593 } … … 856 633 { 857 634 *index = hashfunc(s); 858 859 this = tab[*index]; 860 861 prev = this; 635 this = tab[*index]; 636 prev = this; 862 637 863 638 if (this) 864 639 { 865 640 do { 866 867 641 if ((this->fullpath != NULL) && (0 == strcmp(s, this->fullpath))) 868 642 { 869 643 a->prev = prev; 870 a->this = this; 871 644 a->this = this; 872 645 SL_RETURN( 0, _("hashsearch_prev")); 873 646 } 874 875 647 prev = this; 876 648 this = this->next; 877 878 649 } while(this); 879 650 } … … 888 659 * 889 660 ***********************************************************************/ 890 static void hashinsert (sh_file_t * s)661 void hashinsert (sh_file_t * mtab[TABSIZE], sh_file_t * s) 891 662 { 892 663 sh_file_t * p; … … 898 669 key = hashfunc(s->fullpath); 899 670 900 if ( tab[key] == NULL)901 { 902 tab[key] = s;903 tab[key]->next = NULL;671 if (mtab[key] == NULL) 672 { 673 mtab[key] = s; 674 mtab[key]->next = NULL; 904 675 SL_RET0(_("hashinsert")); 905 676 } 906 677 else 907 678 { 908 p = tab[key];679 p = mtab[key]; 909 680 while (1) 910 681 { 911 if (p && p->fullpath && 912 0 == strcmp(s->fullpath, p->fullpath)) 682 if (p && p->fullpath && 0 == strcmp(s->fullpath, p->fullpath)) 913 683 { 914 684 q = p->next; 915 685 SH_FREE(p->fullpath); 916 if(p->linkpath && p->linkpath != notalink) 917 SH_FREE(p->linkpath); 918 if(p->attr_string) 919 SH_FREE(p->attr_string); 686 if(p->linkpath) SH_FREE(p->linkpath); 687 if(p->attr_string) SH_FREE(p->attr_string); 920 688 memcpy(p, s, sizeof(sh_file_t)); 921 689 p->next = q; 922 SH_FREE(s); 923 s = NULL; 690 SH_FREE(s); s = NULL; 924 691 SL_RET0(_("hashinsert")); 925 692 } … … 940 707 941 708 709 942 710 /****************************************************************** 943 711 * 944 * Get a single line712 * ------- Check functions ------- 945 713 * 946 714 ******************************************************************/ 947 static FILE * sh_fin_fd = NULL; 948 949 static int sh_hash_getline (FILE * fd, char * line, int sizeofline) 950 { 951 register int n = 0; 952 char * res; 953 954 if (sizeofline < 2) { 955 if (sizeofline > 0) line[0] = '\0'; 956 return 0; 957 } 958 res = fgets(line, sizeofline, fd); 959 if (res == NULL) 960 { 961 line[0] = '\0'; 962 return -1; 963 } 964 n = strlen(line); 965 if (n > 0) { 966 --n; 967 line[n] = '\0'; /* remove terminating '\n' */ 968 } 969 return n; 970 } 971 972 static void sh_hash_getline_end (void) 973 { 974 sl_fclose (FIL__, __LINE__, sh_fin_fd); 975 sh_fin_fd = NULL; 715 716 static int IsInit = 0; 717 718 void sh_hash_set_initialized() 719 { 720 IsInit = 1; 976 721 return; 977 722 } 978 723 979 /****************************************************************** 980 * 981 * ------- Check functions ------- 982 * 983 ******************************************************************/ 984 985 static int IsInit = 0; 986 987 988 /****************************************************************** 989 * 990 * Fast forward to start of data 991 * 992 ******************************************************************/ 993 int sh_hash_setdataent (SL_TICKET fd, char * line, int size, const char * file) 994 { 995 long i; 996 extern int get_the_fd (SL_TICKET ticket); 997 998 SL_ENTER(_("sh_hash_setdataent")); 999 1000 sl_rewind (fd); 1001 1002 if (sh_fin_fd != NULL) 1003 { 1004 sl_fclose (FIL__, __LINE__, sh_fin_fd); 1005 sh_fin_fd = NULL; 1006 } 1007 1008 sh_fin_fd = fdopen(dup(get_the_fd(fd)), "rb"); 1009 if (!sh_fin_fd) 1010 { 1011 dlog(1, FIL__, __LINE__, 1012 _("The file signature database: %s is not readable.\n"), 1013 (NULL == file) ? _("(null)") : file); 1014 sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_P_NODATA, 1015 ( (NULL == file) ? _("(null)") : file) 1016 ); 1017 aud_exit (FIL__, __LINE__, EXIT_FAILURE); 1018 } 1019 1020 while (1) 1021 { 1022 i = sh_hash_getline (sh_fin_fd, line, size); 1023 if (i < 0 ) 1024 { 1025 SH_FREE(line); 1026 dlog(1, FIL__, __LINE__, 1027 _("The file signature database: %s does not\ncontain any data, or the start-of-file marker is missing (unlikely,\nunless modified by hand).\n"), 1028 (NULL == file) ? _("(null)") : file); 1029 1030 sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_P_NODATA, 1031 ( (NULL == file) ? _("(null)") : file) 1032 ); 1033 aud_exit (FIL__, __LINE__, EXIT_FAILURE); 1034 } 1035 1036 #if defined(SH_STEALTH) 1037 if (0 == sl_strncmp (line, N_("[SOF]"), 5)) 1038 #else 1039 if (0 == sl_strncmp (line, _("[SOF]"), 5)) 1040 #endif 1041 break; 1042 } 1043 SL_RETURN( 1, _("sh_hash_setdataent")); 1044 } 1045 1046 static int sh_hash_setdataent_old (SL_TICKET fd, char * line, int size, 1047 char * file) 1048 { 1049 long i; 1050 1051 SL_ENTER(_("sh_hash_setdataent_old")); 1052 1053 sl_rewind (fd); 1054 1055 while (1) 1056 { 1057 i = sh_unix_getline (fd, line, size-1); 1058 if (i < 0 ) 1059 { 1060 SH_FREE(line); 1061 dlog(1, FIL__, __LINE__, 1062 _("The file signature database: %s does not\ncontain any data, or the start-of-file marker is missing (unlikely,\nunless modified by hand).\n"), 1063 (NULL == file) ? _("(null)") : file); 1064 1065 sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_P_NODATA, 1066 ( (NULL == file) ? _("(null)") : file) 1067 ); 1068 aud_exit (FIL__, __LINE__, EXIT_FAILURE); 1069 } 1070 1071 #if defined(SH_STEALTH) 1072 if (0 == sl_strncmp (line, N_("[SOF]"), 5)) 1073 #else 1074 if (0 == sl_strncmp (line, _("[SOF]"), 5)) 1075 #endif 1076 break; 1077 } 1078 SL_RETURN( 1, _("sh_hash_setdataent_old")); 1079 } 1080 1081 /****************************************************************** 1082 * 1083 * Read next record 1084 * 1085 ******************************************************************/ 1086 sh_file_t * sh_hash_getdataent (SL_TICKET fd, char * line, int size) 1087 { 1088 sh_file_t * p; 1089 sh_filestore_t ft; 1090 long i; 1091 size_t len; 1092 char * fullpath; 1093 char * linkpath; 1094 char * attr_string = NULL; 1095 char * tmp; 1096 1097 SL_ENTER(_("sh_hash_getdataent")); 1098 1099 (void) fd; 1100 1101 /* Read next record -- Part One 1102 */ 1103 p = SH_ALLOC(sizeof(sh_file_t)); 1104 1105 i = fread (&ft, sizeof(sh_filestore_t), 1, sh_fin_fd); 1106 /* i = sl_read(fd, &ft, sizeof(sh_filestore_t)); */ 1107 /* if ( SL_ISERROR(i) || i == 0) */ 1108 if (i < 1) 1109 { 1110 SH_FREE(p); 1111 SL_RETURN( NULL, _("sh_hash_getdataent")); 1112 } 1113 1114 swap_32(&(ft.mode)); 1115 swap_32(&(ft.linkmode)); 1116 swap_64(&(ft.dev)); 1117 swap_64(&(ft.rdev)); 1118 swap_32(&(ft.hardlinks)); 1119 swap_32(&(ft.ino)); 1120 swap_64(&(ft.size)); 1121 swap_64(&(ft.atime)); 1122 swap_64(&(ft.mtime)); 1123 swap_64(&(ft.ctime)); 1124 swap_32(&(ft.owner)); 1125 swap_32(&(ft.group)); 1126 #if defined(__linux__) || defined(HAVE_STAT_FLAGS) 1127 swap_32(&(ft.attributes)); 1128 #endif 1129 #ifdef OLD_BUG 1130 swap_short(&(ft.mark)); 1131 #else 1132 ft.mark = *(swap_short(&(ft.mark))); 1133 #endif 1134 1135 if ((ft.mark & ~REC_FLAGS_MASK) != REC_MAGIC) 1136 { 1137 SH_FREE(p); 1138 SL_RETURN( NULL, _("sh_hash_getdataent")); 1139 } 1140 1141 /* Read next record -- Part Two -- Fullpath 1142 */ 1143 i = sh_hash_getline (sh_fin_fd, line, size); 1144 if (i <= 0 ) 1145 { 1146 SH_FREE(line); 1147 SH_FREE(p); 1148 dlog(1, FIL__, __LINE__, 1149 _("There is a corrupt record in the file signature database: %s\nThe file path is missing.\n"), 1150 (NULL == file_path('D', 'R'))? _("(null)"):file_path('D', 'R')); 1151 sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_P_NODATA, 1152 ( (NULL == file_path('D', 'R')) ? _("(null)") : 1153 file_path('D', 'R')) 1154 ); 1155 aud_exit (FIL__, __LINE__,EXIT_FAILURE); 1156 } 1157 1158 tmp = unquote_string (line, i); 1159 len = sl_strlen(tmp)+1; 1160 fullpath = SH_ALLOC(len); 1161 (void) sl_strlcpy (fullpath, tmp, len); 1162 if (tmp) 1163 SH_FREE(tmp); 1164 if (fullpath[len-2] == '\n') 1165 fullpath[len-2] = '\0'; 1166 1167 /* Read next record -- Part Three -- Linkpath 1168 */ 1169 i = sh_hash_getline (sh_fin_fd, line, size); 1170 if (i <= 0 ) 1171 { 1172 SH_FREE(line); 1173 SH_FREE(fullpath); 1174 SH_FREE(p); 1175 dlog(1, FIL__, __LINE__, 1176 _("There is a corrupt record in the file signature database: %s\nThe link path (or its placeholder) is missing.\n"), 1177 (NULL == file_path('D', 'R'))? _("(null)"):file_path('D', 'R')); 1178 sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_P_NODATA, 1179 ( (NULL == file_path('D', 'R')) ? _("(null)") : 1180 file_path('D', 'R')) 1181 ); 1182 aud_exit (FIL__, __LINE__,EXIT_FAILURE); 1183 } 1184 1185 tmp = unquote_string (line, i); 1186 1187 if ( tmp && tmp[0] == '-' && 1188 (tmp[1] == '\0' || (tmp[1] == '\n' && tmp[2] == '\0'))) 1189 { 1190 linkpath = (char *)notalink; 1191 } 1192 else 1193 { 1194 len = sl_strlen(tmp); 1195 linkpath = sh_util_strdup_l(tmp, len); 1196 if (len > 0 && linkpath[len-1] == '\n') 1197 linkpath[len-1] = '\0'; 1198 } 1199 1200 if (tmp) 1201 SH_FREE(tmp); 1202 1203 /* Read next record -- Part Four -- attr_string 1204 */ 1205 if ((ft.mark & REC_FLAGS_ATTR) != 0) 1206 { 1207 i = sh_hash_getline (sh_fin_fd, line, size); 1208 if (i <= 0 ) 1209 { 1210 SH_FREE(line); 1211 SH_FREE(fullpath); 1212 if (linkpath != notalink) 1213 SH_FREE(linkpath); 1214 SH_FREE(p); 1215 dlog(1, FIL__, __LINE__, 1216 _("There is a corrupt record in the file signature database: %s\nThe attribute string is missing.\n"), 1217 (NULL == file_path('D', 'R'))? _("(null)"):file_path('D', 'R')); 1218 sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_P_NODATA, 1219 ( (NULL == file_path('D', 'R')) ? _("(null)") : 1220 file_path('D', 'R')) 1221 ); 1222 aud_exit (FIL__, __LINE__,EXIT_FAILURE); 1223 } 1224 1225 tmp = unquote_string (line, i); 1226 1227 len = sl_strlen(tmp)+1; 1228 attr_string = SH_ALLOC(len); 1229 (void) sl_strlcpy (attr_string, tmp, len); 1230 if (tmp) 1231 SH_FREE(tmp); 1232 if (attr_string[len-2] == '\n') 1233 attr_string[len-2] = '\0'; 1234 } 1235 1236 /* Read next record -- Part Four -- Decode 1237 */ 1238 #if defined(SH_STEALTH) 1239 sh_do_decode(fullpath, sl_strlen(fullpath)); 1240 1241 #if defined(__linux__) || defined(HAVE_STAT_FLAGS) 1242 sh_do_decode(ft.c_attributes, sl_strlen(ft.c_attributes)); 1243 #endif 1244 1245 sh_do_decode(ft.c_mode, sl_strlen(ft.c_mode)); 1246 sh_do_decode(ft.c_owner, sl_strlen(ft.c_owner)); 1247 sh_do_decode(ft.c_group, sl_strlen(ft.c_group)); 1248 sh_do_decode(ft.checksum, sl_strlen(ft.checksum)); 1249 1250 /* TXT entries are c_mode[0] != 'l' and do not get decoded 1251 */ 1252 if (ft.c_mode[0] == 'l' && linkpath != notalink) 1253 { 1254 sh_do_decode(linkpath, sl_strlen(linkpath)); 1255 } 1256 1257 if ((ft.mark & REC_FLAGS_ATTR) != 0) 1258 { 1259 sh_do_decode(attr_string, sl_strlen(attr_string)); 1260 } 1261 #endif 1262 1263 memcpy( &(*p).theFile, &ft, sizeof(sh_filestore_t) ); 1264 1265 /* init fflags, such that suid files in 1266 * database are recognized as such 1267 */ 1268 { 1269 mode_t mode = (mode_t) ft.mode; 1270 1271 if (S_ISREG(mode) && 1272 (0 !=(S_ISUID & mode) || 1273 #if defined(HOST_IS_LINUX) 1274 (0 !=(S_ISGID & mode) && 1275 0 !=(S_IXGRP & mode)) 1276 #else 1277 0 !=(S_ISGID & mode) 1278 #endif 1279 ) 1280 ) 1281 p->fflags = SH_FFLAG_SUIDCHK; 1282 1283 else 1284 p->fflags = 0; 1285 } 1286 1287 p->modi_mask = 0L; 1288 p->fullpath = fullpath; 1289 p->linkpath = linkpath; 1290 1291 p->attr_string = attr_string; 1292 1293 /* set to an invalid value 1294 */ 1295 ft.mark = (REC_MAGIC + 5); 1296 1297 SL_RETURN( p, _("sh_hash_getdataent")); 1298 } 724 int sh_hash_get_initialized() 725 { 726 return IsInit; 727 } 728 1299 729 1300 730 /****************************************************************** … … 1305 735 void sh_hash_init () 1306 736 { 1307 1308 #define FGETS_BUF 163841309 1310 sh_file_t * p;1311 SL_TICKET fd;1312 long i;1313 int count = 0;1314 char * line = NULL;1315 1316 #if defined(WITH_GPG) || defined(WITH_PGP)1317 extern int get_the_fd (SL_TICKET ticket);1318 1319 SL_TICKET fdTmp = (-1);1320 #endif1321 char hashbuf[KEYBUF_SIZE];1322 1323 737 volatile int retval = 0; 1324 738 volatile int exitval = EXIT_SUCCESS; … … 1341 755 } 1342 756 1343 fd = (-1);1344 1345 #if defined(SH_WITH_CLIENT)1346 1347 /* Data file from Server1348 */1349 1350 if (fd == (-1) && 0 == sl_strcmp(file_path('D', 'R'), _("REQ_FROM_SERVER")))1351 {1352 sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_D_DSTART);1353 fd = sh_forward_req_file(_("DATA"));1354 if (SL_ISERROR(fd))1355 {1356 dlog(1, FIL__, __LINE__,1357 _("Could not retrieve the file signature database from the server(errnum = %ld).\nPossible reasons include:\n - the server is not running,\n - session key negotiation failed (see the manual for proper setup), or\n - the server cannot access the file.\n"), fd);1358 sh_error_handle ((-1), FIL__, __LINE__, fd, MSG_EXIT_ABORT1,1359 sh.prg_name);1360 retval = 1; exitval = EXIT_FAILURE;1361 goto unlock_and_return;1362 }1363 sl_rewind (fd);1364 1365 sl_strlcpy (sh.data.hash,1366 sh_tiger_hash (file_path('D', 'R'),1367 fd, TIGER_NOLIM, hashbuf, sizeof(hashbuf)),1368 KEY_LEN+1);1369 sl_rewind (fd);1370 }1371 else1372 #endif1373 /* Local data file1374 */1375 1376 if (fd == (-1))1377 {1378 if ( SL_ISERROR(fd = sl_open_read(FIL__, __LINE__,1379 file_path('D', 'R'), SL_YESPRIV)))1380 {1381 TPT(( 0, FIL__, __LINE__, _("msg=<Error opening: %s>\n"),1382 file_path('D', 'R')));1383 dlog(1, FIL__, __LINE__,1384 _("Could not open the local file signature database for reading because\nof the following error: %s (errnum = %ld)\nIf this is a permission problem, you need to change file permissions\nto make the file readable for the effective UID: %d\n"),1385 sl_get_errmsg(), fd, (int) sl_ret_euid());1386 sh_error_handle ((-1), FIL__, __LINE__, fd, MSG_EXIT_ABORT1,1387 sh.prg_name);1388 retval = 1; exitval = EXIT_FAILURE;1389 goto unlock_and_return;1390 }1391 1392 TPT(( 0, FIL__, __LINE__, _("msg=<Opened database: %s>\n"),1393 file_path('D', 'R')));1394 1395 if (0 != sl_strncmp(sh.data.hash,1396 sh_tiger_hash (file_path('D', 'R'), fd, TIGER_NOLIM,1397 hashbuf, sizeof(hashbuf)),1398 KEY_LEN)1399 && sh.flag.checkSum != SH_CHECK_INIT)1400 {1401 dlog(1, FIL__, __LINE__,1402 _("The checksum of the file signature database has changed since startup: %s -> %s\n"),1403 sh.data.hash, sh_tiger_hash (file_path('D', 'R'), fd, TIGER_NOLIM,1404 hashbuf, sizeof(hashbuf)));1405 sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_E_AUTH,1406 ( (NULL == file_path('D', 'R')) ? _("(null)") :1407 file_path('D', 'R') )1408 );1409 retval = 1; exitval = EXIT_FAILURE;1410 goto unlock_and_return;1411 }1412 sl_rewind (fd);1413 1414 } /* new 1.4.8 */1415 1416 if (sig_termfast == 1) /* SIGTERM */1417 {1418 TPT((0, FIL__, __LINE__, _("msg=<Terminate.>\n")));1419 --sig_raised; --sig_urgent;1420 retval = 1; exitval = EXIT_SUCCESS;1421 goto unlock_and_return;1422 }1423 1424 #if defined(WITH_GPG) || defined(WITH_PGP)1425 1426 /* extract the data and copy to temporary file1427 */1428 fdTmp = sh_gpg_extract_signed(fd);1429 1430 if (sig_termfast == 1) /* SIGTERM */1431 {1432 TPT((0, FIL__, __LINE__, _("msg=<Terminate.>\n")));1433 --sig_raised; --sig_urgent;1434 retval = 1; exitval = EXIT_SUCCESS;1435 goto unlock_and_return;1436 }1437 1438 sl_close(fd);1439 fd = fdTmp;1440 1441 /* Validate signature of open file.1442 */1443 if (0 != sh_gpg_check_sign (0, fd, 2))1444 {1445 retval = 1; exitval = EXIT_FAILURE;1446 goto unlock_and_return;1447 }1448 sl_rewind (fd);1449 #endif1450 1451 line = SH_ALLOC(MAX_PATH_STORE+2);1452 1453 /* fast forward to start of data1454 */1455 sh_hash_setdataent(fd, line, MAX_PATH_STORE+1, file_path('D', 'R'));1456 1457 for (i = 0; i < TABSIZE; ++i)1458 tab[i] = NULL;1459 1460 while (1)1461 {1462 if (sig_termfast == 1) /* SIGTERM */1463 {1464 TPT((0, FIL__, __LINE__, _("msg=<Terminate.>\n")));1465 --sig_raised; --sig_urgent;1466 retval = 1; exitval = EXIT_SUCCESS;1467 SH_FREE(line);1468 line = NULL;1469 goto unlock_and_return;1470 }1471 1472 p = sh_hash_getdataent (fd, line, MAX_PATH_STORE+1);1473 if (p != NULL)1474 {1475 hashinsert (p);1476 ++count;1477 }1478 else1479 break;1480 }1481 1482 757 /* Initialization completed. 1483 758 */ 1484 IsInit = 1; 1485 1486 if (line != NULL) 1487 SH_FREE(line); 1488 1489 /* Always keep db in memory, so we have no open file 1490 */ 1491 sl_close (fd); 1492 sh_hash_getline_end(); 1493 /* fd = -1; */ 759 retval = sh_dbIO_load_db(tab); 760 761 if (0 == retval) 762 IsInit = 1; 763 else 764 exitval = EXIT_FAILURE; 1494 765 1495 766 unlock_and_return: … … 1500 771 SL_RET0(_("sh_hash_init")); 1501 772 } 773 sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_EXIT_ABORT1, sh.prg_name); 1502 774 aud_exit (FIL__, __LINE__, exitval); 775 } 776 777 void sh_hash_init_and_checksum() 778 { 779 TPT((0, FIL__, __LINE__, _("msg=<Get checksum of the database.>\n"))) 780 if (sh.flag.checkSum == SH_CHECK_CHECK) 781 { 782 if (0 != sl_strcmp(file_path('D', 'R'), _("REQ_FROM_SERVER"))) 783 { 784 char hashbuf[KEYBUF_SIZE]; 785 (void) sl_strlcpy(sh.data.hash, 786 sh_tiger_hash (file_path('D', 'R'), 787 TIGER_FILE, TIGER_NOLIM, 788 hashbuf, sizeof(hashbuf)), 789 KEY_LEN+1); 790 } 791 792 /* this eventually fetches the file from server to get checksum 793 */ 794 sh_hash_init (); 795 } 796 return; 1503 797 } 1504 798 … … 1536 830 } 1537 831 1538 /******************************************************************1539 *1540 * Insert a file into the database.1541 *1542 ******************************************************************/1543 static int pushdata_isfirst = 1;1544 static SL_TICKET pushdata_fd = -1;1545 1546 static int pushdata_stdout = S_FALSE;1547 1548 static char * sh_db_version_string = NULL;1549 1550 int sh_hash_pushdata_stdout (const char * str)1551 {1552 if (!str)1553 { pushdata_stdout = S_TRUE; return 0; }1554 return -1;1555 }1556 1557 int sh_hash_version_string(const char * str)1558 {1559 if (str)1560 {1561 if (sh_db_version_string != NULL) {1562 SH_FREE(sh_db_version_string);1563 }1564 if (0 == sl_strncmp(str, _("NULL"), 4))1565 {1566 sh_db_version_string = NULL;1567 return 0;1568 }1569 sh_db_version_string = sh_util_strdup(str);1570 return 0;1571 }1572 return -1;1573 }1574 1575 832 static int sh_loosedircheck = S_FALSE; 1576 833 … … 1581 838 1582 839 1583 static void sh_hash_pushdata_int (file_type * buf, char * fileHash)1584 {1585 static long p_count = 0;1586 1587 int status = 0;1588 1589 char * tmp;1590 size_t tmp_len = 0;1591 size_t old_len = 0;1592 size_t path_len = 0;1593 1594 sh_filestore_t p;1595 1596 struct stat sbuf;1597 1598 char * fullpath = NULL;1599 char * linkpath = NULL;1600 char * attr_string = NULL;1601 1602 char * line = NULL;1603 1604 char timestring[81];1605 1606 #if !defined(__linux__) && !defined(HAVE_STAT_FLAGS)1607 int i;1608 #endif1609 1610 SL_ENTER(_("sh_hash_pushdata_int"));1611 1612 fullpath = SH_ALLOC(MAX_PATH_STORE+1);1613 linkpath = SH_ALLOC(MAX_PATH_STORE+1);1614 1615 linkpath[0] = '-';1616 linkpath[1] = '\0';1617 fullpath[0] = '-';1618 fullpath[1] = '\0';1619 1620 if (!buf) {1621 memset(&p, '\0', sizeof(sh_filestore_t));1622 }1623 1624 if ((pushdata_stdout == S_TRUE) && (sh.flag.update == S_TRUE))1625 {1626 dlog(1, FIL__, __LINE__,1627 _("You cannot write the database to stdout when you use update rather than init.\n"));1628 sh_error_handle((-1), FIL__, __LINE__, 0, MSG_EXIT_ABORTS,1629 _("Writing database to stdout with update"),1630 sh.prg_name,1631 _("sh_hash_pushdata_int"));1632 aud_exit(FIL__, __LINE__, EXIT_FAILURE);1633 }1634 1635 if ((pushdata_stdout == S_TRUE) && (sl_is_suid()))1636 {1637 dlog(1, FIL__, __LINE__,1638 _("You cannot write the database to stdout when running with suid privileges.\n"));1639 sh_error_handle((-1), FIL__, __LINE__, 0, MSG_EXIT_ABORTS,1640 _("Writing database to stdout when suid"),1641 sh.prg_name,1642 _("sh_hash_pushdata_int"));1643 aud_exit(FIL__, __LINE__, EXIT_FAILURE);1644 }1645 1646 1647 if ((pushdata_isfirst == 1) && (pushdata_stdout == S_FALSE) &&1648 ( (NULL == file_path('D', 'W')) ||1649 (0 == sl_strcmp(file_path('D', 'W'), _("REQ_FROM_SERVER"))) ))1650 {1651 dlog(1, FIL__, __LINE__,1652 _("You need to configure a local path for initializing the database\nlike ./configure --with-data-file=REQ_FROM_SERVER/some/local/path\n"));1653 sh_error_handle((-1), FIL__, __LINE__, 0, MSG_EXIT_ABORTS,1654 _("No local path for database specified"),1655 sh.prg_name,1656 _("sh_hash_pushdata_int"));1657 aud_exit(FIL__, __LINE__, EXIT_FAILURE);1658 }1659 1660 1661 if ((pushdata_isfirst == 1) && (pushdata_stdout == S_FALSE))1662 {1663 /* Warn that file already exists; file_path != NULL here because1664 * checked above1665 */1666 if (0 == retry_lstat(FIL__, __LINE__, file_path('D', 'W'), &sbuf))1667 {1668 if (sh.flag.update == S_FALSE)1669 {1670 sh_error_handle((-1), FIL__, __LINE__, 0, MSG_FI_DBEX,1671 file_path('D', 'W'));1672 }1673 }1674 }1675 1676 1677 if (sh.flag.update == S_FALSE)1678 {1679 if (pushdata_stdout == S_FALSE && pushdata_fd == -1)1680 {1681 if ( SL_ISERROR(pushdata_fd = sl_open_write(FIL__, __LINE__,1682 file_path('D', 'W'),1683 SL_YESPRIV)))1684 {1685 SH_FREE(fullpath);1686 SH_FREE(linkpath);1687 sh_error_handle((-1), FIL__, __LINE__, pushdata_fd, MSG_E_ACCESS,1688 geteuid(), file_path('D', 'W'));1689 aud_exit(FIL__, __LINE__, EXIT_FAILURE);1690 }1691 1692 if (SL_ISERROR(status = sl_lock (pushdata_fd)))1693 {1694 SH_FREE(fullpath);1695 SH_FREE(linkpath);1696 sh_error_handle((-1), FIL__, __LINE__, status, MSG_E_SUBGPATH,1697 _("Failed to lock baseline database"), _("sh_hash_pushdata_int"),1698 file_path('D', 'W'));1699 aud_exit(FIL__, __LINE__, EXIT_FAILURE);1700 }1701 1702 if ( SL_ISERROR(status = sl_forward(pushdata_fd)))1703 {1704 SH_FREE(fullpath);1705 SH_FREE(linkpath);1706 sh_error_handle((-1), FIL__, __LINE__, status, MSG_E_SUBGPATH,1707 _("Failed to seek to end of baseline database"),1708 _("sh_hash_pushdata_int"),1709 file_path('D', 'W'));1710 aud_exit(FIL__, __LINE__, EXIT_FAILURE);1711 }1712 }1713 }1714 else /* update == TRUE */1715 {1716 if (pushdata_isfirst == 1)1717 {1718 TPT((0, FIL__, __LINE__, _("msg=<Update.>\n")))1719 if ( SL_ISERROR(pushdata_fd = sl_open_rdwr(FIL__, __LINE__,1720 file_path('D', 'W'),1721 SL_YESPRIV))){1722 SH_FREE(fullpath);1723 SH_FREE(linkpath);1724 sh_error_handle((-1), FIL__, __LINE__, pushdata_fd, MSG_E_ACCESS,1725 geteuid(), file_path('D', 'W'));1726 aud_exit(FIL__, __LINE__, EXIT_FAILURE);1727 }1728 1729 if (SL_ISERROR(status = sl_lock (pushdata_fd)))1730 {1731 SH_FREE(fullpath);1732 SH_FREE(linkpath);1733 sh_error_handle((-1), FIL__, __LINE__, status, MSG_E_SUBGPATH,1734 _("Failed to lock baseline database"), _("sh_hash_pushdata_int"),1735 file_path('D', 'W'));1736 aud_exit(FIL__, __LINE__, EXIT_FAILURE);1737 }1738 1739 line = SH_ALLOC(MAX_PATH_STORE+1);1740 if (SL_ISERROR(sh_hash_setdataent_old (pushdata_fd, line,1741 MAX_PATH_STORE,1742 file_path('D', 'W'))))1743 {1744 SH_FREE(fullpath);1745 SH_FREE(linkpath);1746 SH_FREE(line);1747 aud_exit(FIL__, __LINE__, EXIT_FAILURE);1748 }1749 SH_FREE(line);1750 }1751 }1752 1753 if (buf != NULL) {1754 1755 old_len = sl_strlen(buf->fullpath);1756 #if defined(SH_STEALTH)1757 sh_do_encode(buf->fullpath, old_len);1758 #endif1759 tmp = quote_string(buf->fullpath, old_len);1760 tmp_len = sl_strlen(tmp);1761 #if defined(SH_STEALTH)1762 sh_do_decode(buf->fullpath, old_len);1763 #endif1764 1765 if (tmp && tmp_len <= MAX_PATH_STORE)1766 {1767 sl_strlcpy(fullpath, buf->fullpath, MAX_PATH_STORE+1);1768 }1769 else1770 {1771 char hashbuf[KEYBUF_SIZE];1772 1773 sl_strlcpy(fullpath,1774 sh_tiger_hash (buf->fullpath,1775 TIGER_DATA, old_len,1776 hashbuf, sizeof(hashbuf)),1777 KEY_LEN+1);1778 }1779 if (tmp) SH_FREE(tmp);1780 }1781 1782 path_len = sl_strlen(fullpath);1783 #if defined(SH_STEALTH)1784 sh_do_encode(fullpath, path_len);1785 #endif1786 1787 tmp = quote_string(fullpath, path_len);1788 if (tmp) {1789 sl_strlcpy(fullpath, tmp, MAX_PATH_STORE+1);1790 SH_FREE(tmp);1791 }1792 1793 /* NOTE: TXT entries are c_mode[0] != 'l' and do not get decoded1794 */1795 if (buf != NULL /* && buf->c_mode[0] == 'l' */ && buf->link_path != NULL)1796 {1797 1798 old_len = sl_strlen(buf->link_path);1799 #if defined(SH_STEALTH)1800 if (buf->c_mode[0] == 'l')1801 sh_do_encode(buf->link_path, old_len);1802 #endif1803 tmp = quote_string(buf->link_path, old_len);1804 tmp_len = sl_strlen(tmp);1805 #if defined(SH_STEALTH)1806 if (buf->c_mode[0] == 'l')1807 sh_do_decode(buf->link_path, old_len);1808 #endif1809 1810 if (tmp && tmp_len <= MAX_PATH_STORE)1811 {1812 sl_strlcpy(linkpath, buf->link_path, MAX_PATH_STORE+1);1813 }1814 else1815 {1816 char hashbuf[KEYBUF_SIZE];1817 sl_strlcpy(linkpath,1818 sh_tiger_hash (buf->link_path,1819 TIGER_DATA, old_len,1820 hashbuf, sizeof(hashbuf)),1821 KEY_LEN+1);1822 }1823 if (tmp) SH_FREE(tmp);1824 1825 path_len = sl_strlen(linkpath);1826 #if defined(SH_STEALTH)1827 if (buf->c_mode[0] == 'l')1828 sh_do_encode(linkpath, path_len);1829 #endif1830 tmp = quote_string(linkpath, path_len);1831 if (tmp)1832 {1833 sl_strlcpy(linkpath, tmp, MAX_PATH_STORE+1);1834 SH_FREE(tmp);1835 }1836 }1837 1838 if (buf != NULL && buf->attr_string != NULL)1839 {1840 old_len = sl_strlen(buf->attr_string);1841 #if defined(SH_STEALTH)1842 sh_do_encode(buf->attr_string, old_len);1843 #endif1844 tmp = quote_string(buf->attr_string, old_len);1845 if (tmp)1846 {1847 attr_string = tmp;1848 tmp = NULL;1849 }1850 #if defined(SH_STEALTH)1851 sh_do_decode(buf->attr_string, old_len);1852 #endif1853 }1854 1855 1856 if (buf != NULL) {1857 p.mark = REC_MAGIC;1858 if (attr_string)1859 p.mark |= REC_FLAGS_ATTR;1860 sl_strlcpy(p.c_mode, buf->c_mode, CMODE_SIZE);1861 sl_strlcpy(p.c_group, buf->c_group, GROUP_MAX+1);1862 sl_strlcpy(p.c_owner, buf->c_owner, USER_MAX+1);1863 if (fileHash) {1864 sl_strlcpy(p.checksum, fileHash, KEY_LEN+1);1865 }1866 #if defined(__linux__) || defined(HAVE_STAT_FLAGS)1867 sl_strlcpy(p.c_attributes, buf->c_attributes, ATTRBUF_SIZE);1868 #else1869 for (i = 0; i < ATTRBUF_USED; ++i) p.c_attributes[i] = '-';1870 p.c_attributes[ATTRBUF_USED] = '\0';1871 #endif1872 1873 #if defined(SH_STEALTH)1874 sh_do_encode(p.c_mode, sl_strlen(p.c_mode));1875 sh_do_encode(p.c_owner, sl_strlen(p.c_owner));1876 sh_do_encode(p.c_group, sl_strlen(p.c_group));1877 sh_do_encode(p.checksum, sl_strlen(p.checksum));1878 1879 sh_do_encode(p.c_attributes, sl_strlen(p.c_attributes));1880 #endif1881 1882 #if defined(__linux__) || defined(HAVE_STAT_FLAGS)1883 p.attributes = (UINT32) buf->attributes;1884 #else1885 p.attributes = 0;1886 #endif1887 p.linkmode = (UINT32) buf->linkmode;1888 p.hardlinks = (UINT32) buf->hardlinks;1889 p.dev = (UINT64) buf->dev;1890 p.rdev = (UINT64) buf->rdev;1891 p.mode = (UINT32) buf->mode;1892 p.ino = (UINT32) buf->ino;1893 p.size = (UINT64) buf->size;1894 p.mtime = (UINT64) buf->mtime;1895 p.atime = (UINT64) buf->atime;1896 p.ctime = (UINT64) buf->ctime;1897 p.owner = (UINT32) buf->owner;1898 p.group = (UINT32) buf->group;1899 1900 swap_32(&(p.mode));1901 swap_32(&(p.linkmode));1902 swap_64(&(p.dev));1903 swap_64(&(p.rdev));1904 swap_32(&(p.hardlinks));1905 swap_32(&(p.ino));1906 swap_64(&(p.size));1907 swap_64(&(p.atime));1908 swap_64(&(p.mtime));1909 swap_64(&(p.ctime));1910 swap_32(&(p.owner));1911 swap_32(&(p.group));1912 swap_32(&(p.attributes));1913 1914 #ifdef OLD_BUG1915 swap_short(&(p.mark));1916 #else1917 p.mark = *(swap_short(&(p.mark)));1918 #endif1919 }1920 1921 /* write the start marker1922 */1923 if (pushdata_isfirst == 1)1924 {1925 if (sh.flag.update == S_FALSE)1926 {1927 if (sh_db_version_string != NULL)1928 {1929 if (pushdata_stdout == S_FALSE)1930 {1931 sl_write (pushdata_fd, _("\n#Host "), 7);1932 sl_write (pushdata_fd, sh.host.name,1933 sl_strlen(sh.host.name));1934 sl_write (pushdata_fd, _(" Version "), 9);1935 sl_write (pushdata_fd, sh_db_version_string,1936 sl_strlen(sh_db_version_string));1937 sl_write (pushdata_fd, _(" Date "), 6);1938 (void) sh_unix_time(0, timestring, sizeof(timestring));1939 sl_write (pushdata_fd, timestring, strlen(timestring));1940 sl_write (pushdata_fd, "\n", 1);1941 } else {1942 printf ("%s",_("\n#Host "));1943 printf ("%s", sh.host.name);1944 printf ("%s",_(" Version "));1945 printf ("%s", sh_db_version_string);1946 printf ("%s",_(" Date "));1947 (void) sh_unix_time(0, timestring, sizeof(timestring));1948 printf ("%s\n", timestring);1949 }1950 }1951 1952 if (pushdata_stdout == S_FALSE)1953 {1954 #if defined(SH_STEALTH)1955 sl_write (pushdata_fd, "\n", 1);1956 sl_write_line (pushdata_fd, N_("[SOF]"), 5);1957 #else1958 sl_write_line (pushdata_fd, _("\n[SOF]"), 6);1959 #endif1960 }1961 else1962 {1963 #if defined(SH_STEALTH)1964 printf ("\n%s\n", N_("[SOF]"));1965 #else1966 printf ("%s\n", _("\n[SOF]"));1967 #endif1968 }1969 }1970 pushdata_isfirst = 0;1971 }1972 1973 if (pushdata_stdout == S_FALSE)1974 {1975 sl_write (pushdata_fd, &p, sizeof(sh_filestore_t));1976 sl_write_line_fast (pushdata_fd, fullpath, sl_strlen(fullpath));1977 sl_write_line_fast (pushdata_fd, linkpath, sl_strlen(linkpath));1978 if (attr_string)1979 sl_write_line_fast (pushdata_fd, attr_string, sl_strlen(attr_string));1980 } else {1981 if (fwrite (&p, sizeof(sh_filestore_t), 1, stdout))1982 {1983 printf ("%s\n", fullpath);1984 printf ("%s\n", linkpath);1985 if (attr_string)1986 printf ("%s\n", attr_string);1987 }1988 else1989 {1990 perror(_("Error writing database"));1991 aud_exit (FIL__, __LINE__, EXIT_FAILURE);1992 }1993 }1994 1995 ++p_count;1996 1997 if ((sh.flag.update != S_TRUE) && (pushdata_stdout == S_FALSE))1998 {1999 if (sh.flag.checkSum != SH_CHECK_INIT || (buf == NULL && fileHash == NULL))2000 {2001 sl_close (pushdata_fd);2002 pushdata_fd = -1;2003 }2004 }2005 2006 SH_FREE(fullpath);2007 SH_FREE(linkpath);2008 if (attr_string)2009 SH_FREE(attr_string);2010 2011 SL_RET0(_("sh_hash_pushdata_int"));2012 }2013 2014 SH_MUTEX_STATIC(mutex_writeout,PTHREAD_MUTEX_INITIALIZER);2015 2016 void sh_hash_pushdata (file_type * buf, char * fileHash)2017 {2018 SH_MUTEX_LOCK(mutex_writeout);2019 sh_hash_pushdata_int (buf, fileHash);2020 SH_MUTEX_UNLOCK(mutex_writeout);2021 return;2022 }2023 2024 2025 int sh_hash_writeout()2026 {2027 sh_file_t * p;2028 int i;2029 file_type * f;2030 char fileHash[KEY_LEN + 1];2031 2032 SL_ENTER(_("sh_hash_writeout"));2033 2034 if (S_TRUE == file_is_remote())2035 {2036 sh_error_handle((-1), FIL__, __LINE__, S_FALSE, MSG_E_SUBGEN,2037 _("Baseline database is remote"), _("sh_hash_writeout"));2038 SL_RETURN (1, _("sh_hash_writeout"));2039 }2040 2041 SH_MUTEX_LOCK(mutex_writeout);2042 if (!SL_ISERROR(pushdata_fd))2043 {2044 sl_close(pushdata_fd);2045 pushdata_fd = -1;2046 }2047 pushdata_isfirst = 1;2048 2049 2050 SH_MUTEX_LOCK(mutex_hash);2051 for (i = 0; i < TABSIZE; ++i)2052 {2053 for (p = tab[i]; p; p = p->next)2054 {2055 f = sh_hash_create_ft (p, fileHash);2056 sh_hash_pushdata_int (f, fileHash);2057 if (f->attr_string) SH_FREE(f->attr_string);2058 if (f->link_path) SH_FREE(f->link_path);2059 SH_FREE(f);2060 }2061 }2062 SH_MUTEX_UNLOCK(mutex_hash);2063 2064 if (!SL_ISERROR(pushdata_fd))2065 {2066 sl_close(pushdata_fd);2067 pushdata_fd = -1;2068 }2069 pushdata_isfirst = 1;2070 SH_MUTEX_UNLOCK(mutex_writeout);2071 2072 SL_RETURN (0, _("sh_hash_writeout"));2073 }2074 840 2075 841 … … 2378 1144 sl_strlcpy(tmpFile->c_group, _("root"), 5); 2379 1145 1146 tmpFile->check_flags = 0; 1147 2380 1148 if ((str != NULL) && (size < (PATH_MAX/2)-1)) 2381 1149 { … … 2404 1172 2405 1173 if (sh.flag.checkSum == SH_CHECK_INIT) 2406 sh_ hash_pushdata(tmpFile,2407 1174 sh_dbIO_data_write (tmpFile, 1175 (save->checksum[0] == '\0') ? SH_KEY_NULL : save->checksum); 2408 1176 else 2409 1177 sh_hash_pushdata_memory (tmpFile, … … 2524 1292 p.group = (UINT32) buf->group; 2525 1293 1294 p.checkflags = (UINT32) buf->check_flags; 1295 2526 1296 memcpy( &(*fp).theFile, &p, sizeof(sh_filestore_t) ); 2527 1297 fp->fflags = 0; /* init fflags */ … … 2623 1393 msg[0] = '\0'; 2624 1394 1395 if (report_checkflags != S_FALSE) 1396 { 1397 if (is_new) 1398 format = _("checkflags_new=\"0%lo\" "); 1399 else 1400 format = _("checkflags_old=\"0%lo\" "); 1401 sl_snprintf(tmp, SH_MSG_BUF, format, 1402 (unsigned long) theFile->check_flags); 1403 sl_strlcat(msg, tmp, SH_MSG_BUF); 1404 } 2625 1405 2626 1406 #if defined(__linux__) || defined(HAVE_STAT_FLAGS) … … 2790 1570 msg[0] = '\0'; 2791 1571 1572 if (report_checkflags == S_TRUE) 1573 { 1574 if (is_new) 1575 format = _("checkflags_new=<0%lo> "); 1576 else 1577 format = _("checkflags_old=<0%lo> "); 1578 sl_snprintf(tmp, SH_MSG_BUF, format, 1579 (unsigned long) theFile->check_flags); 1580 sl_strlcat(msg, tmp, SH_MSG_BUF); 1581 } 1582 2792 1583 2793 1584 #if defined(__linux__) || defined(HAVE_STAT_FLAGS) … … 2952 1743 { 2953 1744 SH_MUTEX_LOCK(mutex_hash); 2954 hashinsert ( p);2955 p->modi_mask = theFile->check_ mask;1745 hashinsert (tab, p); 1746 p->modi_mask = theFile->check_flags; 2956 1747 SH_MUTEX_UNLOCK(mutex_hash); 2957 1748 } … … 2960 1751 } 2961 1752 1753 int sh_hash_is_null_file(file_type * theFile) 1754 { 1755 if (theFile->hardlinks == SH_DEADFILE && theFile->mode == 0 && 1756 theFile->ino == 0 && theFile->ctime == 0) 1757 { 1758 return S_TRUE; 1759 } 1760 return S_FALSE; 1761 } 1762 1763 int sh_hash_is_null_record(sh_filestore_t * theFile) 1764 { 1765 if (theFile->hardlinks == SH_DEADFILE && theFile->mode == 0 && 1766 theFile->ino == 0 && theFile->ctime == 0) 1767 { 1768 return S_TRUE; 1769 } 1770 return S_FALSE; 1771 } 1772 1773 void sh_hash_insert_null(char * str) 1774 { 1775 file_type theFile = { 0, 0, {'\0'}, 0, 0, 0, 0, 0, 1776 #if defined(__linux__) || defined(HAVE_STAT_FLAGS) 1777 0, {'\0'}, 1778 #endif 1779 {'\0'}, 0, {'\0'}, 0, {'\0'}, 1780 0, 0, 0, 0, 0, 0, 0, NULL, 0, {'\0'}, 0, NULL 1781 }; /* clang compiler bails out on standard conforming init with just {0} */ 1782 char fileHash[KEY_LEN+1]; 1783 char hashbuf[KEYBUF_SIZE]; 1784 1785 sl_strlcpy(fileHash, SH_KEY_NULL, sizeof(fileHash)); 1786 theFile.hardlinks = SH_DEADFILE; 1787 1788 if (sl_strlen(str) < PATH_MAX) 1789 sl_strlcpy(theFile.fullpath, str, PATH_MAX); 1790 else 1791 sl_strlcpy(theFile.fullpath, 1792 sh_tiger_hash(str, TIGER_DATA, sl_strlen(str), 1793 hashbuf, sizeof(hashbuf)), 1794 PATH_MAX); 1795 1796 sh_hash_pushdata_memory(&theFile, fileHash); 1797 return; 1798 } 1799 1800 static int handle_notfound(int log_severity, int class, 1801 file_type * theFile, char * fileHash) 1802 { 1803 sh_file_t * p; 1804 int retval = 0; 1805 1806 if (S_FALSE == sh_ignore_chk_new(theFile->fullpath)) 1807 { 1808 char * tmp = sh_util_safe_name(theFile->fullpath); 1809 char * str; 1810 1811 sh_files_fixup_mask(class, &(theFile->check_flags)); 1812 str = all_items (theFile, fileHash, 1); 1813 1814 sh_error_handle (log_severity, FIL__, __LINE__, 0, 1815 MSG_FI_ADD2, 1816 tmp, str); 1817 ++sh.statistics.files_report; 1818 SH_FREE(str); 1819 SH_FREE(tmp); 1820 } 1821 1822 if (sh.flag.reportonce == S_TRUE) 1823 SET_SH_FFLAG_REPORTED(theFile->file_reported); 1824 1825 if (sh.flag.reportonce == S_TRUE && sh.flag.update == S_FALSE) 1826 { 1827 p = sh_hash_push_int(theFile, fileHash); 1828 if (p) 1829 { 1830 hashinsert (tab, p); 1831 p->modi_mask = theFile->check_flags; 1832 p->theFile.checkflags = p->modi_mask; 1833 } 1834 } 1835 1836 else if (S_TRUE == sh.flag.update) 1837 { 1838 if (S_TRUE == sh_util_ask_update (theFile->fullpath)) 1839 { 1840 p = sh_hash_push_int(theFile, fileHash); 1841 if (p) 1842 { 1843 hashinsert (tab, p); 1844 p->modi_mask = theFile->check_flags; 1845 p->theFile.checkflags = p->modi_mask; 1846 } 1847 } 1848 else 1849 retval = 1; 1850 } 1851 return retval; 1852 } 2962 1853 2963 1854 /***************************************************************** … … 2975 1866 char * tmp_lnk; 2976 1867 char * tmp_lnk_old; 2977 2978 char * str;2979 1868 2980 1869 char timstr1c[32]; … … 2996 1885 volatile int log_severity; 2997 1886 char hashbuf[KEYBUF_SIZE]; 1887 struct { 1888 unsigned long oldflags; 1889 unsigned long newflags; 1890 } cf_report; 2998 1891 2999 1892 int retval; … … 3033 1926 if (p == NULL) 3034 1927 { 3035 if (S_FALSE == sh_ignore_chk_new(theFile->fullpath)) 3036 { 3037 tmp = sh_util_safe_name(theFile->fullpath); 3038 3039 str = all_items (theFile, fileHash, 1); 3040 sh_error_handle (log_severity, FIL__, __LINE__, 0, 3041 MSG_FI_ADD2, 3042 tmp, str); 3043 ++sh.statistics.files_report; 3044 SH_FREE(str); 3045 3046 SH_FREE(tmp); 3047 } 3048 3049 if (sh.flag.reportonce == S_TRUE) 3050 SET_SH_FFLAG_REPORTED(theFile->file_reported); 3051 3052 if (sh.flag.reportonce == S_TRUE && sh.flag.update == S_FALSE) 3053 { 3054 p = sh_hash_push_int(theFile, fileHash); 3055 if (p) 3056 { 3057 hashinsert (p); 3058 p->modi_mask = theFile->check_mask; 3059 } 3060 } 3061 3062 else if (S_TRUE == sh.flag.update) 3063 { 3064 if (S_TRUE == sh_util_ask_update (theFile->fullpath)) 3065 { 3066 p = sh_hash_push_int(theFile, fileHash); 3067 if (p) 3068 { 3069 hashinsert (p); 3070 p->modi_mask = theFile->check_mask; 3071 } 3072 } 3073 else 3074 { 3075 retval = 1; 3076 goto unlock_and_return; 3077 } 3078 } 3079 1928 retval = handle_notfound(log_severity, class, theFile, fileHash); 3080 1929 goto unlock_and_return; 3081 1930 } … … 3086 1935 if (S_TRUE == sh_ignore_chk_mod(theFile->fullpath)) 3087 1936 { 1937 MODI_SET(theFile->check_flags, MODI_NOCHECK); 1938 p->modi_mask = theFile->check_flags; 1939 p->theFile.checkflags = p->modi_mask; 3088 1940 goto unlock_and_return; 3089 1941 } 3090 1942 3091 p->modi_mask = theFile->check_mask; 1943 cf_report.oldflags = p->theFile.checkflags; 1944 cf_report.newflags = theFile->check_flags; 1945 1946 p->modi_mask = theFile->check_flags; 1947 p->theFile.checkflags = p->modi_mask; 3092 1948 3093 1949 /* initialize change_code */ … … 3101 1957 if ( (fileHash != NULL) && 3102 1958 (strncmp (fileHash, p->theFile.checksum, KEY_LEN) != 0) && 3103 (theFile->check_ mask& MODI_CHK) != 0)3104 { 3105 if ((theFile->check_ mask& MODI_SGROW) == 0)1959 (theFile->check_flags & MODI_CHK) != 0) 1960 { 1961 if ((theFile->check_flags & MODI_SGROW) == 0) 3106 1962 { 3107 1963 modi_mask |= MODI_CHK; … … 3114 1970 { 3115 1971 if (S_FALSE == sh_check_rotated_log (theFile->fullpath, (UINT64) p->theFile.size, 3116 (UINT64) p->theFile.ino, p->theFile.checksum)) 1972 (UINT64) p->theFile.ino, p->theFile.checksum, 1973 p->theFile.checkflags)) 3117 1974 { 3118 1975 modi_mask |= MODI_CHK; … … 3139 1996 { 3140 1997 if (!(theFile->link_path) && 3141 (theFile->check_ mask& MODI_LNK) != 0)1998 (theFile->check_flags & MODI_LNK) != 0) 3142 1999 { 3143 2000 linkComp = NULL; … … 3166 2023 3167 2024 if ( sl_strncmp (linkComp, p->linkpath, maxcomp) != 0 && 3168 (theFile->check_ mask& MODI_LNK) != 0)2025 (theFile->check_flags & MODI_LNK) != 0) 3169 2026 { 3170 2027 modi_mask |= MODI_LNK; … … 3179 2036 if ( ( major(theFile->rdev) != major((dev_t)p->theFile.rdev) || 3180 2037 minor(theFile->rdev) != minor((dev_t)p->theFile.rdev) ) && 3181 (theFile->check_ mask& MODI_RDEV) != 0)2038 (theFile->check_flags & MODI_RDEV) != 0) 3182 2039 { 3183 2040 modi_mask |= MODI_RDEV; … … 3190 2047 */ 3191 2048 if ( (UINT32) theFile->ino != (UINT32) p->theFile.ino && 3192 (theFile->check_ mask& MODI_INO) != 0)2049 (theFile->check_flags & MODI_INO) != 0) 3193 2050 { 3194 2051 modi_mask |= MODI_INO; … … 3198 2055 3199 2056 if ( theFile->hardlinks != (nlink_t) p->theFile.hardlinks && 3200 (theFile->check_ mask& MODI_HLN) != 0)2057 (theFile->check_flags & MODI_HLN) != 0) 3201 2058 { 3202 2059 modi_mask |= MODI_HLN; … … 3220 2077 #endif 3221 2078 ) 3222 && (theFile->check_ mask& MODI_MOD) != 0)2079 && (theFile->check_flags & MODI_MOD) != 0) 3223 2080 { 3224 2081 modi_mask |= MODI_MOD; … … 3228 2085 * report link path if switch link/no link 3229 2086 */ 3230 if ((theFile->check_ mask& MODI_LNK) != 0 &&2087 if ((theFile->check_flags & MODI_LNK) != 0 && 3231 2088 (theFile->c_mode[0] != p->theFile.c_mode[0]) && 3232 2089 (theFile->c_mode[0] == 'l' || p->theFile.c_mode[0] == 'l')) … … 3239 2096 3240 2097 if ( theFile->owner != (uid_t) p->theFile.owner && 3241 (theFile->check_ mask& MODI_USR) != 0)2098 (theFile->check_flags & MODI_USR) != 0) 3242 2099 { 3243 2100 modi_mask |= MODI_USR; … … 3247 2104 3248 2105 if ( theFile->group != (gid_t) p->theFile.group && 3249 (theFile->check_ mask& MODI_GRP) != 0)2106 (theFile->check_flags & MODI_GRP) != 0) 3250 2107 { 3251 2108 modi_mask |= MODI_GRP; … … 3256 2113 3257 2114 if ( theFile->mtime != (time_t) p->theFile.mtime && 3258 (theFile->check_ mask& MODI_MTM) != 0)2115 (theFile->check_flags & MODI_MTM) != 0) 3259 2116 { 3260 2117 modi_mask |= MODI_MTM; … … 3263 2120 } 3264 2121 3265 if ( (theFile->check_ mask& MODI_ATM) != 0 &&2122 if ( (theFile->check_flags & MODI_ATM) != 0 && 3266 2123 theFile->atime != (time_t) p->theFile.atime) 3267 2124 { … … 3276 2133 */ 3277 2134 if ( theFile->ctime != (time_t) p->theFile.ctime && 3278 (theFile->check_ mask& MODI_CTM) != 0)2135 (theFile->check_flags & MODI_CTM) != 0) 3279 2136 { 3280 2137 modi_mask |= MODI_CTM; … … 3284 2141 3285 2142 if ( theFile->size != (off_t) p->theFile.size && 3286 (theFile->check_ mask& MODI_SIZ) != 0)3287 { 3288 if ((theFile->check_ mask& MODI_SGROW) == 0 ||2143 (theFile->check_flags & MODI_SIZ) != 0) 2144 { 2145 if ((theFile->check_flags & MODI_SGROW) == 0 || 3289 2146 theFile->size < (off_t) p->theFile.size) 3290 2147 { … … 3309 2166 if (modi_mask != 0 && sh.flag.fulldetail == S_TRUE) 3310 2167 { 3311 if ((theFile->check_ mask& MODI_ATM) == 0)2168 if ((theFile->check_flags & MODI_ATM) == 0) 3312 2169 modi_mask = MASK_READONLY_; 3313 2170 else … … 3322 2179 msg = SH_ALLOC(SH_MSG_BUF); 3323 2180 msg[0] = '\0'; 2181 2182 sh_files_fixup_mask(class, &(cf_report.newflags)); 2183 2184 if ( (report_checkflags != S_FALSE) && (cf_report.oldflags != cf_report.newflags)) 2185 { 2186 sl_snprintf(tmp, SH_MSG_BUF, 2187 #ifdef SH_USE_XML 2188 _("checkflags_old=\"0%lo\" checkflags_new=\"0%lo\" "), 2189 #else 2190 _("checkflags_old=<0%lo>, checkflags_new=<0%lo>, "), 2191 #endif 2192 cf_report.oldflags, cf_report.newflags); 2193 sl_strlcat(msg, tmp, SH_MSG_BUF); 2194 } 3324 2195 3325 2196 if ( ((modi_mask & MODI_MOD) != 0) … … 3374 2245 #endif 3375 2246 3376 #ifdef REPLACE_OLD3377 2247 if ((modi_mask & MODI_MOD) != 0) 3378 2248 { … … 3405 2275 } 3406 2276 } 3407 #endif 2277 3408 2278 } 3409 2279 … … 3419 2289 (unsigned long) theFile->hardlinks); 3420 2290 sl_strlcat(msg, tmp, SH_MSG_BUF); 3421 #ifdef REPLACE_OLD 2291 3422 2292 if (sh.flag.reportonce == S_TRUE && sh.flag.update == S_FALSE) 3423 2293 p->theFile.hardlinks = theFile->hardlinks; 3424 #endif3425 2294 } 3426 2295 … … 3443 2312 ); 3444 2313 sl_strlcat(msg, tmp, SH_MSG_BUF); 3445 #ifdef REPLACE_OLD 2314 3446 2315 if (sh.flag.reportonce == S_TRUE && sh.flag.update == S_FALSE) 3447 2316 p->theFile.rdev = theFile->rdev; 3448 #endif3449 2317 } 3450 2318 … … 3460 2328 (unsigned long) theFile->ino); 3461 2329 sl_strlcat(msg, tmp, SH_MSG_BUF); 3462 #ifdef REPLACE_OLD 2330 3463 2331 if (sh.flag.reportonce == S_TRUE && sh.flag.update == S_FALSE) 3464 2332 { … … 3466 2334 p->theFile.dev = theFile->dev; 3467 2335 } 3468 #endif3469 2336 } 3470 2337 … … 3488 2355 ); 3489 2356 sl_strlcat(msg, tmp, SH_MSG_BUF); 3490 #ifdef REPLACE_OLD 2357 3491 2358 if (sh.flag.reportonce == S_TRUE && sh.flag.update == S_FALSE) 3492 2359 p->theFile.dev = theFile->dev; 3493 #endif3494 2360 } 3495 2361 #endif … … 3512 2378 ); 3513 2379 sl_strlcat(msg, tmp, SH_MSG_BUF); 3514 #ifdef REPLACE_OLD 2380 3515 2381 if ((modi_mask & MODI_USR) != 0) { 3516 2382 if (sh.flag.reportonce == S_TRUE && sh.flag.update == S_FALSE) … … 3520 2386 } 3521 2387 } 3522 #endif3523 2388 } 3524 2389 … … 3542 2407 3543 2408 sl_strlcat(msg, tmp, SH_MSG_BUF); 3544 #ifdef REPLACE_OLD 2409 3545 2410 if ((modi_mask & MODI_GRP) != 0) { 3546 2411 if (sh.flag.reportonce == S_TRUE && sh.flag.update == S_FALSE) … … 3550 2415 } 3551 2416 } 3552 #endif3553 2417 } 3554 2418 … … 3559 2423 (UINT64) theFile->size); 3560 2424 sl_strlcat(msg, tmp, SH_MSG_BUF); 3561 #ifdef REPLACE_OLD 2425 3562 2426 if (sh.flag.reportonce == S_TRUE && sh.flag.update == S_FALSE) 3563 2427 p->theFile.size = theFile->size; 3564 #endif3565 2428 } 3566 2429 … … 3577 2440 #endif 3578 2441 sl_strlcat(msg, tmp, SH_MSG_BUF); 3579 #ifdef REPLACE_OLD 2442 3580 2443 if (sh.flag.reportonce == S_TRUE && sh.flag.update == S_FALSE) 3581 2444 p->theFile.ctime = theFile->ctime; 3582 #endif3583 2445 } 3584 2446 … … 3595 2457 #endif 3596 2458 sl_strlcat(msg, tmp, SH_MSG_BUF); 3597 #ifdef REPLACE_OLD 2459 3598 2460 if (sh.flag.reportonce == S_TRUE && sh.flag.update == S_FALSE) 3599 2461 p->theFile.atime = theFile->atime; 3600 #endif3601 2462 } 3602 2463 … … 3613 2474 #endif 3614 2475 sl_strlcat(msg, tmp, SH_MSG_BUF); 3615 #ifdef REPLACE_OLD 2476 3616 2477 if (sh.flag.reportonce == S_TRUE && sh.flag.update == S_FALSE) 3617 2478 p->theFile.mtime = theFile->mtime; 3618 #endif3619 2479 } 3620 2480 … … 3630 2490 p->theFile.checksum, fileHash); 3631 2491 sl_strlcat(msg, tmp, SH_MSG_BUF); 3632 #ifdef REPLACE_OLD 2492 3633 2493 if (sh.flag.reportonce == S_TRUE && sh.flag.update == S_FALSE) 3634 2494 { 3635 2495 sl_strlcpy(p->theFile.checksum, fileHash, KEY_LEN+1); 3636 if ((theFile->check_ mask& MODI_SGROW) != 0)2496 if ((theFile->check_flags & MODI_SGROW) != 0) 3637 2497 p->theFile.size = theFile->size; 3638 2498 } 3639 #endif 3640 /* FIXME is this correct? */ 2499 2500 3641 2501 if (theFile->c_mode[0] != 'l' && theFile->link_path && 3642 2502 strlen(theFile->link_path) > 2) … … 3665 2525 SH_FREE(tmp_lnk_old); 3666 2526 sl_strlcat(msg, tmp, SH_MSG_BUF); 3667 #ifdef REPLACE_OLD 2527 3668 2528 if (sh.flag.reportonce == S_TRUE && sh.flag.update == S_FALSE) 3669 2529 { 3670 if (p->linkpath != NULL && p->linkpath != notalink)2530 if (p->linkpath != NULL) 3671 2531 SH_FREE(p->linkpath); 3672 if (!(theFile->link_path) || 3673 (theFile->link_path[0] == '-' && theFile->link_path[1] == '\0')) 3674 p->linkpath = (char *)notalink; 2532 if (!(theFile->link_path)) 2533 p->linkpath = sh_util_strdup("-"); 3675 2534 else 3676 2535 p->linkpath = sh_util_strdup(theFile->link_path); 3677 2536 } 3678 #endif 3679 } 3680 3681 if (MODI_AUDIT_ENABLED(theFile->check_mask)) 2537 } 2538 2539 if (MODI_AUDIT_ENABLED(theFile->check_flags)) 3682 2540 { 3683 2541 char result[256]; … … 3701 2559 } 3702 2560 2561 /**************************************************** 2562 * 2563 * REPORT on file change 2564 * 2565 ****************************************************/ 3703 2566 tmp_path = sh_util_safe_name(theFile->fullpath); 3704 2567 sh_error_handle(log_severity, FIL__, __LINE__, … … 3711 2574 SH_FREE(tmp); 3712 2575 SH_FREE(msg); 3713 3714 #ifndef REPLACE_OLD3715 SET_SH_FFLAG_REPORTED(p->fflags);3716 #endif3717 2576 3718 2577 if (S_TRUE == sh.flag.update) … … 3757 2616 if (theFile->link_path) 3758 2617 SH_FREE(theFile->link_path); 3759 if (p->linkpath && p->linkpath != notalink)2618 if (p->linkpath) 3760 2619 theFile->link_path = sh_util_strdup(p->linkpath); 3761 2620 else … … 3815 2674 if (theFile->c_mode[0] == 'l' || theFile->link_path) 3816 2675 { 3817 if (p->linkpath != NULL && p->linkpath != notalink)2676 if (p->linkpath != NULL) 3818 2677 SH_FREE(p->linkpath); 3819 2678 p->linkpath = sh_util_strdup(theFile->link_path); … … 3821 2680 else 3822 2681 { 3823 if (p->linkpath != NULL && p->linkpath != notalink) {2682 if (p->linkpath != NULL) 3824 2683 SH_FREE(p->linkpath); 3825 } 3826 p->linkpath = (char *)notalink; 2684 p->linkpath = sh_util_strdup("-"); 3827 2685 } 3828 2686 … … 3955 2813 { 3956 2814 /* if (0 == strncmp(s, p->fullpath, len_s)) *//* old */ 3957 if (S_TRUE == hash_remove_tree_test(s, p->fullpath, len_s)) 2815 if (S_TRUE == hash_remove_tree_test(s, p->fullpath, len_s)) { 3958 2816 SET_SH_FFLAG_ALLIGNORE(p->fflags); 2817 MODI_SET(p->theFile.checkflags, MODI_ALLIGNORE); 2818 } 3959 2819 } /* if path is not null */ 3960 2820 … … 3984 2844 ListFile = sh_util_strdup(c); 3985 2845 return 0; 2846 } 2847 char * get_list_file() 2848 { 2849 return ListFile; 3986 2850 } 3987 2851 … … 4231 3095 time_t now = time(NULL); 4232 3096 time_t then = (time_t) p->theFile.mtime; 3097 struct tm * time_ptr; 4233 3098 4234 3099 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GMTIME_R) 4235 struct tm * time_ptr;4236 3100 struct tm time_tm; 4237 3101 #endif 3102 3103 if (ListFullDetail != S_FALSE) 3104 { 3105 sh_hash_list_db_entry_full_detail (p); 3106 return; 3107 } 3108 3109 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GMTIME_R) 4238 3110 time_ptr = gmtime_r(&then, &time_tm); 3111 if (!time_ptr) 3112 return; 4239 3113 strftime(thetime, 127, _("%b %d %Y"), time_ptr); 4240 3114 time_ptr = gmtime_r(&now, &time_tm); 3115 if (!time_ptr) 3116 return; 4241 3117 strftime(nowtime, 127, _("%b %d %Y"), time_ptr); 4242 3118 if (0 == strncmp(&nowtime[7], &thetime[7], 4)) 4243 3119 { 4244 3120 time_ptr = gmtime_r(&then, &time_tm); 3121 if (!time_ptr) 3122 return; 4245 3123 strftime(thetime, 127, _("%b %d %H:%M"), time_ptr); 4246 3124 } 4247 3125 #else 4248 strftime(thetime, 127, _("%b %d %Y"), gmtime(&then)); 4249 strftime(nowtime, 127, _("%b %d %Y"), gmtime(&now)); 3126 time_ptr = gmtime(&then); 3127 if (!time_ptr) 3128 return; 3129 strftime(thetime, 127, _("%b %d %Y"), time_ptr); 3130 time_ptr = gmtime(&now); 3131 if (!time_ptr) 3132 return; 3133 strftime(nowtime, 127, _("%b %d %Y"), time_ptr); 4250 3134 if (0 == strncmp(&nowtime[7], &thetime[7], 4)) 4251 strftime(thetime, 127, _("%b %d %H:%M"), gmtime(&then)); 3135 { 3136 time_ptr = gmtime(&then); 3137 if (!time_ptr) 3138 return; 3139 strftime(thetime, 127, _("%b %d %H:%M"), time_ptr); 3140 } 4252 3141 #endif 4253 3142 … … 4327 3216 } 4328 3217 4329 int sh_hash_list_db (const char * db_file)4330 {4331 sh_file_t * p;4332 SL_TICKET fd;4333 char * line;4334 int flag = 0;4335 4336 if (!db_file)4337 {4338 _exit(EXIT_FAILURE);4339 return -1;4340 }4341 if (sl_is_suid())4342 {4343 fprintf(stderr, "%s",_("ERROR: insufficient privilege\n"));4344 _exit (EXIT_FAILURE);4345 return -1; /* for Mac OSX compiler */4346 }4347 if (0 == strcmp(db_file, _("default")))4348 db_file = file_path('D', 'W');4349 if (!db_file)4350 {4351 _exit(EXIT_FAILURE);4352 return -1;4353 }4354 4355 line = SH_ALLOC(MAX_PATH_STORE+2);4356 4357 if ( SL_ISERROR(fd = sl_open_read(FIL__, __LINE__, db_file, SL_YESPRIV)))4358 {4359 fprintf(stderr, _("ERROR: can't open %s for read (errnum = %ld)\n"),4360 db_file, fd);4361 _exit(EXIT_FAILURE);4362 return -1;4363 }4364 4365 /* fast forward to start of data4366 */4367 sh_hash_setdataent(fd, line, MAX_PATH_STORE+1, db_file);4368 4369 while (1)4370 {4371 p = sh_hash_getdataent (fd, line, MAX_PATH_STORE+1);4372 if ((p != NULL) && (p->fullpath[0] == '/'))4373 {4374 if (!ListFile)4375 {4376 flag = 1;4377 if (ListFullDetail == S_FALSE)4378 sh_hash_list_db_entry (p);4379 else4380 sh_hash_list_db_entry_full_detail (p);4381 }4382 else4383 {4384 if (0 != sl_strcmp(ListFile, p->fullpath))4385 {4386 continue;4387 }4388 flag = 1;4389 if ('l' != p->theFile.c_mode[0])4390 {4391 if (sh_hash_printcontent(p->linkpath) < 0)4392 {4393 _exit(EXIT_FAILURE);4394 return -1;4395 }4396 }4397 else4398 {4399 fprintf(stderr, "%s",_("File is a link\n"));4400 _exit(EXIT_FAILURE);4401 return -1;4402 }4403 break;4404 }4405 }4406 else if (p == NULL)4407 {4408 break;4409 }4410 }4411 4412 if (line != NULL)4413 SH_FREE(line);4414 sl_close (fd);4415 4416 fflush(NULL);4417 4418 if (flag == 0)4419 {4420 fprintf(stderr, "%s",_("File not found\n"));4421 _exit(EXIT_FAILURE);4422 }4423 _exit(EXIT_SUCCESS);4424 return 0;4425 }4426 4427 3218 /* if defined(SH_WITH_CLIENT) || defined(SH_STANDALONE) */ 4428 3219 #endif -
trunk/src/sh_html.c
r473 r481 41 41 42 42 #include "samhain.h" 43 #include "sh_ forward.h"43 #include "sh_xfer.h" 44 44 #include "sh_error.h" 45 45 #include "sh_unix.h" … … 159 159 if (time_ptr != NULL) 160 160 strftime (ts1, 80, _("%d-%m-%Y %H:%M:%S"), time_ptr); 161 else 162 sl_strlcpy(ts1, _("01-01-1970 00:00:00"), sizeof(ts1)); 161 163 now = time(NULL); 162 164 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_LOCALTIME_R) … … 167 169 if (time_ptr != NULL) 168 170 strftime (ts2, 80, _("%d-%m-%Y %H:%M:%S"), time_ptr); 171 else 172 sl_strlcpy(ts2, _("01-01-1970 00:00:00"), sizeof(ts2)); 169 173 170 174 sl_snprintf(outline, 1023, … … 193 197 if (time_ptr != NULL) 194 198 strftime (ts1, 80, _("%d-%m-%Y %H:%M:%S"), time_ptr); 199 else 200 sl_strlcpy(ts1, _("01-01-1970 00:00:00"), sizeof(ts1)); 195 201 sl_snprintf(outline, 1023, 196 202 _("<p>Last connection at %s</p>"), … … 416 422 int status; 417 423 int clt_status; 418 int i, n;424 unsigned int i, n; 419 425 420 426 SL_ENTER(_("sh_html_print_one")); -
trunk/src/sh_ignore.c
r438 r481 73 73 SL_ENTER(_("sh_ignore_add")); 74 74 75 if ( (addpath == NULL) || (sl_ok_adds(2, strlen(addpath)) == S L_FALSE) )75 if ( (addpath == NULL) || (sl_ok_adds(2, strlen(addpath)) == S_FALSE) ) 76 76 { 77 77 SL_RETURN(list, _("sh_ignore_add")); -
trunk/src/sh_inotify.c
r474 r481 135 135 int class; 136 136 int rdepth; 137 unsigned long check_ mask;137 unsigned long check_flags; 138 138 char * file; 139 139 } sh_watch; … … 236 236 int ifd = sh_inotify_getfd(); 237 237 238 len = sl_read_timeout_fd (ifd, buffer, count, timeout, S L_FALSE);238 len = sl_read_timeout_fd (ifd, buffer, count, timeout, S_FALSE); 239 239 240 240 return len; … … 364 364 365 365 char * sh_inotify_pop_dormant(sh_watches * watches, 366 int * class, unsigned long * check_ mask,366 int * class, unsigned long * check_flags, 367 367 int * type, int * rdepth) 368 368 { … … 384 384 *type = this->watch->type; 385 385 *rdepth = this->watch->rdepth; 386 *check_ mask = this->watch->check_mask;386 *check_flags = this->watch->check_flags; 387 387 popret = sh_util_strdup_track(this->watch->file, __FILE__, __LINE__); 388 388 … … 424 424 static zAVLKey sh_inotify_getkey(void const *item) 425 425 { 426 return (&(( sh_watch *)item)->watch);426 return (&((const sh_watch *)item)->watch); 427 427 } 428 428 … … 490 490 int sh_inotify_add_watch_later(const char * filename, sh_watches * watches, 491 491 int * errnum, 492 int class, unsigned long check_ mask, int type,492 int class, unsigned long check_flags, int type, 493 493 int rdepth) 494 494 { … … 500 500 item->type = (short) type; 501 501 item->rdepth = (short) rdepth; 502 item->check_ mask = check_mask;502 item->check_flags = check_flags; 503 503 504 504 sh_inotify_add_dormant(watches, item); … … 548 548 549 549 extern void sh_fInotify_report_add(char * path, 550 int class, unsigned long check_ mask);550 int class, unsigned long check_flags); 551 551 552 552 sh_dummy_litem = (void*) &litem; … … 575 575 SH_MUTEX_UNLOCK(mutex_watches); 576 576 577 sh_fInotify_report_add(litem->file, litem->class, litem->check_ mask);577 sh_fInotify_report_add(litem->file, litem->class, litem->check_flags); 578 578 579 579 litem = sh_inotify_list_del_cur(&listcursor, save); … … 592 592 */ 593 593 int sh_inotify_add_watch(char * filename, sh_watches * watches, int * errnum, 594 int class, unsigned long check_ mask, int type, int rdepth)594 int class, unsigned long check_flags, int type, int rdepth) 595 595 { 596 596 volatile int retval = 0; … … 637 637 item->type = type; 638 638 item->rdepth = rdepth; 639 item->check_ mask = check_mask;639 item->check_flags = check_flags; 640 640 641 641 if (NULL == watches->list_of_watches) … … 692 692 693 693 char * sh_inotify_search_item(sh_watches * watches, int watch, 694 int * class, unsigned long * check_ mask,694 int * class, unsigned long * check_flags, 695 695 int * type, int * rdepth) 696 696 { … … 709 709 { 710 710 *class = item->class; 711 *check_ mask = item->check_mask;711 *check_flags = item->check_flags; 712 712 *type = item->type; 713 713 *rdepth = item->rdepth; … … 882 882 883 883 int sh_inotify_add_watch(char * filename, sh_watches * watches, int * errnum, 884 int class, unsigned long check_ mask, int type, int rdepth)884 int class, unsigned long check_flags, int type, int rdepth) 885 885 { 886 886 (void) filename; 887 887 (void) watches; 888 888 (void) class; 889 (void) check_ mask;889 (void) check_flags; 890 890 (void) type; 891 891 (void) rdepth; … … 898 898 int sh_inotify_add_watch_later(const char * filename, sh_watches * watches, 899 899 int * errnum, 900 int class, unsigned long check_ mask, int type, int rdepth)900 int class, unsigned long check_flags, int type, int rdepth) 901 901 { 902 902 (void) filename; 903 903 (void) watches; 904 904 (void) class; 905 (void) check_ mask;905 (void) check_flags; 906 906 (void) type; 907 907 (void) rdepth; … … 927 927 int type; 928 928 int rdepth; 929 unsigned long check_ mask;929 unsigned long check_flags; 930 930 int nrun = 0; 931 931 … … 1022 1022 CuAssertIntEquals(tc, count, 5); 1023 1023 1024 p = sh_inotify_pop_dormant(&twatch, &class, &check_ mask, &type, &rdepth);1024 p = sh_inotify_pop_dormant(&twatch, &class, &check_flags, &type, &rdepth); 1025 1025 CuAssertStrEquals(tc, p, "a5"); 1026 1026 1027 p = sh_inotify_pop_dormant(&twatch, &class, &check_ mask, &type, &rdepth);1027 p = sh_inotify_pop_dormant(&twatch, &class, &check_flags, &type, &rdepth); 1028 1028 CuAssertStrEquals(tc, p, "a3"); 1029 1029 CuAssertIntEquals(tc, class, 3); 1030 1030 1031 p = sh_inotify_pop_dormant(&twatch, &class, &check_ mask, &type, &rdepth);1031 p = sh_inotify_pop_dormant(&twatch, &class, &check_flags, &type, &rdepth); 1032 1032 CuAssertTrue(tc, NULL == p); 1033 1033 CuAssertTrue(tc, NULL == twatch.dormant_watches); -
trunk/src/sh_ipvx.c
r449 r481 165 165 name, name_size, NULL, 0, NI_NUMERICHOST); 166 166 167 168 /* fprintf(stderr, "FIXME: Error %s (%d), name %s (%d)\n",169 gai_strerror(ret), ret, name, name_size); */170 171 167 if (ret != 0 && name_size > 0) 172 168 { … … 343 339 } 344 340 345 static void * sh_dummy_out;341 void * sh_dummy_341_out; 346 342 347 343 char * sh_ipvx_canonical(const char * hostname, char * numeric, size_t nlen) … … 361 357 numeric[0] = '\0'; 362 358 363 sh_dummy_ out = (void *) &out;359 sh_dummy_341_out = (void *) &out; 364 360 365 361 if (sh_ipvx_is_numeric(hostname)) … … 426 422 numeric[0] = '\0'; 427 423 428 sh_dummy_ out = (void *) &out;424 sh_dummy_341_out = (void *) &out; 429 425 430 426 if (sh_ipvx_is_numeric(hostname)) -
trunk/src/sh_log_check.c
r425 r481 143 143 size_t plen = strlen(entry->d_name) + 1; 144 144 145 if (S L_TRUE == sl_ok_adds(plen, dlen))145 if (S_TRUE == sl_ok_adds(plen, dlen)) 146 146 { 147 147 plen += dlen; … … 180 180 plen = strlen(dir); 181 181 182 if (S L_TRUE == sl_ok_adds(plen, 130))182 if (S_TRUE == sl_ok_adds(plen, 130)) 183 183 { 184 184 plen += 130; /* 64 + 64 + 2 */ … … 500 500 * by longjmp' warning. And no, 'volatile' proved insufficient. 501 501 */ 502 static void * sh_dummy_thisfile = NULL;502 void * sh_dummy_502_thisfile = NULL; 503 503 504 504 void sh_check_watches() … … 512 512 * Avoids the 'clobbered by longjmp' warning. 513 513 */ 514 sh_dummy_ thisfile = (void*) &thisfile;514 sh_dummy_502_thisfile = (void*) &thisfile; 515 515 516 516 while (thisfile) -
trunk/src/sh_log_correlate.c
r358 r481 105 105 int sh_keep_comp(const void * a, const void * b) 106 106 { 107 return ( (int)((( struct sh_keep *)a)->last) -108 (int)((( struct sh_keep *)b)->last) );107 return ( (int)(((const struct sh_keep *)a)->last) - 108 (int)(((const struct sh_keep *)b)->last) ); 109 109 } 110 110 -
trunk/src/sh_log_evalrule.c
r383 r481 470 470 } 471 471 472 st atic struct sh_qeval ** dummy_queue;473 static char ** dummy_dstr;472 struct sh_qeval ** sh_dummy_472_queue; 473 char ** sh_dummy_473_dstr; 474 474 475 475 int sh_eval_radd (const char * str) … … 477 477 struct sh_geval * nr; 478 478 struct sh_geval * tmp; 479 struct sh_qeval * queue = NULL;479 struct sh_qeval * queue; 480 480 pcre * rule; 481 481 pcre_extra * rule_extra; … … 506 506 splits = split_array(new, &nfields, ':', lengths); 507 507 508 dummy_queue = &queue; 509 dummy_dstr = &dstr; 508 sh_dummy_472_queue = &queue; 509 sh_dummy_473_dstr = &dstr; 510 511 queue = NULL; 510 512 511 513 if (nfields < 2 || nfields > 3) … … 593 595 pcre_fullinfo(rule, rule_extra, PCRE_INFO_CAPTURECOUNT, &captures); 594 596 595 if (flag_err_debug == S L_TRUE)597 if (flag_err_debug == S_TRUE) 596 598 { 597 599 char * emsg = SH_ALLOC(SH_ERRBUF_SIZE); … … 654 656 if (group_open) 655 657 { 656 if (flag_err_debug == S L_TRUE)658 if (flag_err_debug == S_TRUE) 657 659 { 658 660 char * emsg = SH_ALLOC(SH_ERRBUF_SIZE); … … 826 828 * filled in 827 829 */ 828 st atic struct sh_geval ** dummy1;830 struct sh_geval ** sh_dummy_828_rule; 829 831 830 832 static struct sh_geval * test_rule (struct sh_geval * rule, sh_string *msg, time_t tstamp) … … 834 836 volatile time_t timestamp = tstamp; 835 837 836 dummy1= &rule;838 sh_dummy_828_rule = &rule; 837 839 838 840 if (!rule) … … 844 846 do { 845 847 846 if (flag_err_debug == S L_TRUE)848 if (flag_err_debug == S_TRUE) 847 849 { 848 850 char * emsg = SH_ALLOC(SH_ERRBUF_SIZE); … … 864 866 rule->ovecnum = res; 865 867 866 if (flag_err_debug == S L_TRUE)868 if (flag_err_debug == S_TRUE) 867 869 { 868 870 char * emsg = SH_ALLOC(SH_ERRBUF_SIZE); … … 900 902 } 901 903 902 if (flag_err_debug == S L_TRUE)904 if (flag_err_debug == S_TRUE) 903 905 { 904 906 char * emsg = SH_ALLOC(SH_ERRBUF_SIZE); … … 919 921 DEBUG("debug: no match found\n"); 920 922 /* If there was no match, this is NULL */ 921 dummy1= NULL;923 sh_dummy_828_rule = NULL; 922 924 return rule; 923 925 } … … 926 928 * against msg 927 929 */ 928 st atic struct sh_geval ** dummy2;929 st atic struct sh_geval ** dummy3;930 struct sh_geval ** sh_dummy_928_result; 931 struct sh_geval ** sh_dummy_929_group; 930 932 931 933 static struct sh_geval * test_grules (struct sh_heval * host, … … 936 938 struct sh_geval * group = host->rulegroups; 937 939 938 dummy2= &result;939 dummy3= &group;940 sh_dummy_928_result = &result; 941 sh_dummy_929_group = &group; 940 942 941 943 if (group && sh_string_len(msg) < (size_t)INT_MAX) … … 947 949 /* this is a rule group */ 948 950 949 if (flag_err_debug == S L_TRUE)951 if (flag_err_debug == S_TRUE) 950 952 { 951 953 char * emsg = SH_ALLOC(SH_ERRBUF_SIZE); … … 975 977 */ 976 978 977 if (flag_err_debug == S L_TRUE)979 if (flag_err_debug == S_TRUE) 978 980 { 979 981 char * emsg = SH_ALLOC(SH_ERRBUF_SIZE); … … 995 997 } 996 998 997 dummy2= NULL;998 dummy3= NULL;999 sh_dummy_928_result = NULL; 1000 sh_dummy_929_group = NULL; 999 1001 return result; 1000 1002 } … … 1113 1115 static zAVLKey sh_eval_getkey(void const *item) 1114 1116 { 1115 return (( struct sh_ceval *)item)->hostname->str;1117 return ((const struct sh_ceval *)item)->hostname->str; 1116 1118 } 1117 1119 -
trunk/src/sh_log_mark.c
r363 r481 68 68 static zAVLKey sh_log_mark_getkey(void const *item) 69 69 { 70 return (( struct sh_mark_event *)item)->label->str;70 return ((const struct sh_mark_event *)item)->label->str; 71 71 } 72 72 -
trunk/src/sh_log_parse_apache.c
r362 r481 63 63 * by longjmp' warning. And no, 'volatile' proved insufficient. 64 64 */ 65 static void * sh_dummy_new = NULL;66 static void * sh_dummy_fti = NULL;67 static void * sh_dummy_ftr = NULL;65 void * sh_dummy_65_new = NULL; 66 void * sh_dummy_66_fti = NULL; 67 void * sh_dummy_67_ftr = NULL; 68 68 69 69 void * sh_eval_fileinfo_apache(char * str) … … 88 88 * Avoids the 'clobbered by longjmp' warning. 89 89 */ 90 sh_dummy_ new = (void*) &new;91 sh_dummy_ fti = (void*) &f_time;92 sh_dummy_ ftr = (void*) &result;90 sh_dummy_65_new = (void*) &new; 91 sh_dummy_66_fti = (void*) &f_time; 92 sh_dummy_67_ftr = (void*) &result; 93 93 94 94 if (0 == strncmp("common", str, 6)) … … 109 109 } 110 110 111 if (flag_err_debug == S L_TRUE)111 if (flag_err_debug == S_TRUE) 112 112 { 113 113 SH_MUTEX_LOCK(mutex_thread_nolog); … … 251 251 sh_string_add_from_char(re_string, "$"); 252 252 253 if (flag_err_debug == S L_TRUE)253 if (flag_err_debug == S_TRUE) 254 254 { 255 255 SH_MUTEX_LOCK(mutex_thread_nolog); … … 304 304 char tstr[128]; 305 305 char sstr[128]; 306 c har* hstr;306 const char * hstr; 307 307 int res; 308 308 const char **hstr_addr = (const char **) &hstr; … … 310 310 struct sh_fileinfo_apache * info = (struct sh_fileinfo_apache *) fileinfo; 311 311 312 if (sh_string_len(logline) > 0 && flag_err_debug == S L_TRUE)312 if (sh_string_len(logline) > 0 && flag_err_debug == S_TRUE) 313 313 { 314 314 SH_MUTEX_LOCK(mutex_thread_nolog); … … 409 409 record->pid = PID_INVALID; 410 410 411 pcre_free (hstr);411 pcre_free_substring(hstr); 412 412 return record; 413 413 } -
trunk/src/sh_log_parse_generic.c
r362 r481 46 46 static void default_time (struct sh_logrecord * record) 47 47 { 48 struct tm ts; 48 struct tm ts; 49 struct tm * ts_ptr; 49 50 char tmp[80]; 50 51 size_t len; … … 53 54 54 55 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_LOCALTIME_R) 55 localtime_r (&(record->timestamp), &ts);56 ts_ptr = localtime_r (&(record->timestamp), &ts); 56 57 #else 57 memcpy(&ts, localtime(&(record->timestamp)), sizeof(struct tm)); 58 ts_ptr = localtime(&(record->timestamp)); 59 if (ts_ptr) 60 memcpy(&ts, ts_ptr, sizeof(struct tm)); 58 61 #endif 59 len = strftime(tmp, sizeof(tmp), _("%Y-%m-%dT%H:%M:%S"), &ts); 60 62 if (ts_ptr) 63 len = strftime(tmp, sizeof(tmp), _("%Y-%m-%dT%H:%M:%S"), &ts); 64 else 65 { 66 sl_strlcpy(tmp, _("1970-01-01T00:00:00"), sizeof(tmp)); 67 len = strlen(tmp); 68 } 61 69 record->timestr = sh_string_new_from_lchar(tmp, len); 62 70 -
trunk/src/sh_log_parse_pacct.c
r384 r481 292 292 } 293 293 294 static void * sh_dummy_record = NULL;294 void * sh_dummy_294_record = NULL; 295 295 296 296 struct sh_logrecord * sh_parse_pacct (sh_string * logline, void * fileinfo) … … 303 303 (void) fileinfo; 304 304 305 sh_dummy_ record = (void *) &record;306 307 if (sh_string_len(logline) > 0 && flag_err_debug == S L_TRUE)305 sh_dummy_294_record = (void *) &record; 306 307 if (sh_string_len(logline) > 0 && flag_err_debug == S_TRUE) 308 308 { 309 309 SH_MUTEX_LOCK(mutex_thread_nolog); -
trunk/src/sh_log_parse_syslog.c
r357 r481 78 78 79 79 80 if (flag_err_debug == S L_TRUE && sh_string_len(logline) > 0)80 if (flag_err_debug == S_TRUE && sh_string_len(logline) > 0) 81 81 { 82 82 SH_MUTEX_LOCK(mutex_thread_nolog); -
trunk/src/sh_mail.c
r383 r481 69 69 #undef BAD 70 70 71 static int failedMail = S L_FALSE;71 static int failedMail = S_FALSE; 72 72 73 73 static dnsrep * return_mx (char *domain); … … 337 337 SL_ENTER(_("sh_mail_pushstack")); 338 338 339 if (msg == NULL || failedMail == S L_TRUE /* || sh.srvmail.name[0] == '\0' */)339 if (msg == NULL || failedMail == S_TRUE /* || sh.srvmail.name[0] == '\0' */) 340 340 SL_RETURN((0), (_("sh_mail_pushstack"))); 341 341 … … 550 550 * Return if we cannot mail. 551 551 */ 552 if (failedMail == S L_TRUE)552 if (failedMail == S_TRUE) 553 553 SL_RETURN((-1), _("sh_mail_msg")); 554 554 … … 564 564 sh_mail_emptystack(); 565 565 sh.mailNum.alarm_last = 0; 566 failedMail = S L_TRUE;566 failedMail = S_TRUE; 567 567 SL_RETURN((-1), _("sh_mail_msg")); 568 568 } … … 1259 1259 my_time = time(NULL); 1260 1260 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_LOCALTIME_R) 1261 my_tm 1261 my_tm = localtime_r(&my_time, &time_tm); 1262 1262 #else 1263 my_tm = localtime(&my_time); 1264 #endif 1265 1263 my_tm = localtime(&my_time); 1264 #endif 1265 1266 if (!my_tm) 1267 { 1268 sl_strlcpy(my_tbuf, _("Thu, 01 Jan 1970 00:00:00 +00:00"), sizeof(my_tbuf)); 1269 } 1270 else 1271 { 1266 1272 #if defined(HAVE_STRFTIME_Z) 1267 (void)strftime(my_tbuf, 127, _("%a, %d %b %Y %H:%M:%S %z"), my_tm);1273 (void) strftime(my_tbuf, 127, _("%a, %d %b %Y %H:%M:%S %z"), my_tm); 1268 1274 #else 1269 (void) strftime(my_tbuf, 127, _("%a, %d %b %Y %H:%M:%S %Z"), my_tm); 1270 #endif 1275 (void) strftime(my_tbuf, 127, _("%a, %d %b %Y %H:%M:%S %Z"), my_tm); 1276 #endif 1277 } 1271 1278 1272 1279 TPT(( 0, FIL__, __LINE__, _("msg=<From: <%s>%c%cTo: <%s>%c%cDate: %s>%c%c"), … … 1339 1346 char * tmp; 1340 1347 1341 if (flag_err_debug == S L_TRUE)1348 if (flag_err_debug == S_TRUE) 1342 1349 { 1343 1350 tmp = sh_util_safe_name_keepspace(reply); … … 1382 1389 reply[0] = '\0'; 1383 1390 1384 while (sl_read_timeout_fd (ma_socket, &c, 1, time_wait, S L_FALSE) > 0) {1391 while (sl_read_timeout_fd (ma_socket, &c, 1, time_wait, S_FALSE) > 0) { 1385 1392 1386 1393 if (ireply < (sizeof(reply) - 1)) -
trunk/src/sh_mem.c
r459 r481 112 112 #endif 113 113 114 static memlist_t ** sh_mem_merr_1;114 memlist_t ** sh_dummy_114_merrlist; 115 115 116 116 void sh_mem_stat () … … 121 121 SL_ENTER(_("sh_mem_stat")); 122 122 123 sh_ mem_merr_1= (memlist_t **) &merrlist;123 sh_dummy_114_merrlist = (memlist_t **) &merrlist; 124 124 125 125 if (Alloc_Count == Free_Count) … … 166 166 } 167 167 168 static memlist_t ** sh_mem_merr_2;168 memlist_t ** sh_dummy_168_merrlist; 169 169 170 170 void sh_mem_check () … … 177 177 SL_ENTER(_("sh_mem_check")); 178 178 179 sh_ mem_merr_2= (memlist_t **) &merrlist;179 sh_dummy_168_merrlist = (memlist_t **) &merrlist; 180 180 181 181 sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_MSTAMP, -
trunk/src/sh_modules.c
r372 r481 12 12 #include "sh_mounts.h" 13 13 #include "sh_userfiles.h" 14 #include "sh_kern.h"15 14 #include "sh_suidchk.h" 16 15 #include "sh_processcheck.h" … … 68 67 N_("[UserFiles]"), 69 68 sh_userfiles_table, 70 PTHREAD_MUTEX_INITIALIZER,71 },72 #endif73 74 #ifdef SH_USE_KERN75 {76 N_("KERNEL"),77 -1,78 0,79 sh_kern_init,80 sh_kern_timer,81 sh_kern_check,82 sh_kern_end,83 sh_kern_null,84 85 N_("[Kernel]"),86 sh_kern_table,87 69 PTHREAD_MUTEX_INITIALIZER, 88 70 }, -
trunk/src/sh_nmail.c
r474 r481 329 329 const void * rcv_info) 330 330 { 331 struct alias * rcv = (struct alias *) rcv_info;331 const struct alias * rcv = (const struct alias *) rcv_info; 332 332 333 333 if (!alias || 0 == strcmp(alias, sh_string_str(rcv->recipient))) -
trunk/src/sh_port2proc.c
r384 r481 945 945 continue; 946 946 947 /* fprintf(stderr, "FIXME: %d %d, %d %d, %d %d, %d, %d\n", s->proto, proto,948 s->family, AF_INET,949 sport, ntohs(((struct sockaddr_in *)(&s->laddr))->sin_port),950 (int) xf->xf_uid, (int)xf->xf_pid);951 */952 953 947 if (s->proto != proto) 954 948 continue; … … 970 964 haddr6 = &((struct sockaddr_in6 *)(&s->laddr))->sin6_addr; 971 965 972 973 /* fprintf(stderr, "FIXME: %s\n", inet_ntoa(*haddr)); */974 /* fprintf(stderr, "FIXME: %s\n", inet_ntoa(*saddr)); */975 966 976 967 if ( (s->family == AF_INET && -
trunk/src/sh_portcheck.c
r473 r481 529 529 * by longjmp' warning. And no, 'volatile' proved insufficient. 530 530 */ 531 static void * sh_dummy_pre = NULL;532 static void * sh_dummy_ptr = NULL;531 void * sh_dummy_531_pre = NULL; 532 void * sh_dummy_532_ptr = NULL; 533 533 534 534 /* check the list of open ports for any that are marked as UNKN 535 535 */ 536 static void sh_portchk_check_list (struct sh_portentry ** head, int proto, int report) 536 static void sh_portchk_check_list (struct sh_portentry ** head, 537 int proto, int report) 537 538 { 538 539 struct sh_portentry * ptr = *head; … … 543 544 * Avoids the 'clobbered by longjmp' warning. 544 545 */ 545 sh_dummy_ pre = (void*) ⪯546 sh_dummy_ ptr = (void*) &ptr;546 sh_dummy_531_pre = (void*) ⪯ 547 sh_dummy_532_ptr = (void*) &ptr; 547 548 548 549 while (ptr) … … 616 617 } 617 618 618 sh_dummy_ ptr = NULL;619 sh_dummy_ pre = NULL;619 sh_dummy_532_ptr = NULL; 620 sh_dummy_531_pre = NULL; 620 621 621 622 return; … … 1561 1562 /* Subroutine to add an interface 1562 1563 */ 1563 static void * sh_dummy_str = NULL; /* fix clobbered by.. warning */1564 void * sh_dummy_1564_str = NULL; /* fix clobbered by.. warning */ 1564 1565 1565 1566 static int sh_portchk_add_interface (const char * str) … … 1569 1570 char buf[64]; 1570 1571 1571 sh_dummy_ str = (void*) &str;1572 sh_dummy_1564_str = (void*) &str; 1572 1573 1573 1574 if (iface_initialized == 0) … … 1610 1611 } while (*str); 1611 1612 1612 sh_dummy_ str = NULL;1613 sh_dummy_1564_str = NULL; 1613 1614 return 0; 1614 1615 } -
trunk/src/sh_prelink.c
r379 r481 87 87 return S_FALSE; 88 88 89 status = sl_read_timeout (fd, magic, 4, alert_timeout, S L_FALSE);89 status = sl_read_timeout (fd, magic, 4, alert_timeout, S_FALSE); 90 90 (void) sl_rewind(fd); 91 91 if (status == 4) … … 156 156 /* returns static storage 157 157 */ 158 int sh_prelink_run (char * path, char * file_hash, int alert_timeout )158 int sh_prelink_run (char * path, char * file_hash, int alert_timeout, unsigned long mask) 159 159 { 160 160 static int init = S_FALSE; … … 262 262 char hashbuf[KEYBUF_SIZE]; 263 263 UINT64 length_nolim = TIGER_NOLIM; 264 if (sh.flag.opts == S_TRUE) sh_tiger_set_hashtype_mask(mask); 264 265 sl_strlcpy(file_hash, 265 266 sh_tiger_generic_hash (path, task.pipeTI, &length_nolim, alert_timeout, -
trunk/src/sh_processcheck.c
r399 r481 411 411 * by longjmp' warning. And no, 'volatile' proved insufficient. 412 412 */ 413 static void * sh_dummy_watchlist = NULL;413 void * sh_dummy_413_watchlist = NULL; 414 414 415 415 static void check_watchlist (short * res) … … 422 422 * Avoids the 'clobbered by longjmp' warning. 423 423 */ 424 sh_dummy_ watchlist = (void*) &list;424 sh_dummy_413_watchlist = (void*) &list; 425 425 426 426 while (list) … … 468 468 } 469 469 470 sh_dummy_ watchlist = NULL;470 sh_dummy_413_watchlist = NULL; 471 471 return; 472 472 } … … 625 625 value = (size_t) strtoul(str, &foo, 0); 626 626 627 if (*foo == '\0' && S L_TRUE == sl_ok_adds(value, 1)) {627 if (*foo == '\0' && S_TRUE == sl_ok_adds(value, 1)) { 628 628 sh_prochk_maxpid = value + 1; 629 629 userdef_maxpid = 1; … … 934 934 { 935 935 tstr[pos-1] = '\0'; 936 if (flag_err_debug == S L_TRUE)936 if (flag_err_debug == S_TRUE) 937 937 { 938 938 SH_MUTEX_LOCK(mutex_thread_nolog); -
trunk/src/sh_readconf.c
r432 r481 33 33 #include "sh_unix.h" 34 34 #include "sh_files.h" 35 #include "sh_ forward.h"35 #include "sh_xfer.h" 36 36 #include "sh_gpg.h" 37 37 #include "sh_hash.h" 38 #include "sh_dbIO.h" 38 39 #include "sh_ignore.h" 39 40 #include "sh_database.h" … … 49 50 #include "sh_utils.h" 50 51 #include "sh_restrict.h" 51 52 #include "sh_socket.h" 52 53 53 54 extern int set_reverse_lookup (const char * c); … … 137 138 { 138 139 #ifdef SH_EVAL_SHELL 139 char * tmp = (char*)str;140 char * tmp = sh_util_strdup(str); 140 141 char * out; 142 char * tmp_orig = tmp; 141 143 142 144 while (tmp && isspace((int)*tmp)) ++tmp; … … 150 152 tmp[len-1] = '\0'; 151 153 out = sh_ext_popen_str(&tmp[2]); 154 SH_FREE(tmp_orig); 152 155 return out; 153 156 } 154 157 } 158 SH_FREE(tmp_orig); 155 159 #endif 156 160 return sh_util_strdup(str); … … 384 388 sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_D_START); 385 389 386 fd = sh_ forward_req_file(_("CONF"));390 fd = sh_xfer_request_file(_("CONF")); 387 391 388 392 if (!SL_ISERROR(fd)) … … 392 396 else if (sh.flag.checkSum != SH_CHECK_INIT) 393 397 { 398 sh_error_handle((-1), FIL__, __LINE__, 0, MSG_TCP_FBAD); 394 399 aud_exit (FIL__, __LINE__, EXIT_FAILURE); 395 400 } 396 401 else 397 402 { 403 sh_error_handle(SH_ERR_WARN, FIL__, __LINE__, 0, MSG_TCP_FBAD); 398 404 sh_error_handle ((-1), FIL__, __LINE__, fd, MSG_D_FAIL); 399 405 local_file = 1; … … 490 496 /* Validate signature of open file. 491 497 */ 492 if (0 != sh_gpg_check_sign (fd, 0, 1))498 if (0 != sh_gpg_check_sign (fd, SIG_CONF)) 493 499 { 494 500 SH_FREE(line_in); 501 sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_EXIT_ABORT1, sh.prg_name); 495 502 aud_exit (FIL__, __LINE__, EXIT_FAILURE); 496 503 } … … 830 837 } 831 838 839 840 #if defined (SH_WITH_CLIENT) || defined (SH_STANDALONE) 841 static int sh_readconf_set_delay (const char * c) 842 { 843 unsigned long i = atol (c); 844 845 if (i > INT_MAX) 846 return -i; 847 sh.delayload = (int) i; 848 return 0; 849 } 850 #endif 851 832 852 #ifdef FANCY_LIBCAP 833 853 int sh_readconf_setCaps(const char * c) … … 965 985 sh_files_pushfile_prelink }, 966 986 967 { N_("ignoreadded"), SH_SECTION_MISC, SH_SECTION_NONE,987 { N_("ignoreadded"), SH_SECTION_MISC, SH_SECTION_NONE, 968 988 sh_ignore_add_new }, 969 { N_("ignoremissing"), SH_SECTION_MISC, SH_SECTION_NONE,989 { N_("ignoremissing"), SH_SECTION_MISC, SH_SECTION_NONE, 970 990 sh_ignore_add_del }, 971 { N_("ignoremodified"), SH_SECTION_MISC, SH_SECTION_NONE,991 { N_("ignoremodified"), SH_SECTION_MISC, SH_SECTION_NONE, 972 992 sh_ignore_add_mod }, 973 993 974 { N_("skipchecksum"), SH_SECTION_MISC, SH_SECTION_NONE,994 { N_("skipchecksum"), SH_SECTION_MISC, SH_SECTION_NONE, 975 995 sh_restrict_define }, 976 { N_("filetype"), SH_SECTION_MISC, SH_SECTION_NONE,996 { N_("filetype"), SH_SECTION_MISC, SH_SECTION_NONE, 977 997 sh_restrict_add_ftype }, 978 998 … … 983 1003 sh_set_schedule_two }, 984 1004 985 { N_("usehardlinkcheck"), SH_SECTION_MISC, SH_SECTION_NONE,1005 { N_("usehardlinkcheck"), SH_SECTION_MISC, SH_SECTION_NONE, 986 1006 sh_files_check_hardlinks }, 987 { N_("usersrccheck"), SH_SECTION_MISC, SH_SECTION_NONE,1007 { N_("usersrccheck"), SH_SECTION_MISC, SH_SECTION_NONE, 988 1008 sh_files_use_rsrc }, 989 { N_("hardlinkoffset"), SH_SECTION_MISC, SH_SECTION_NONE,1009 { N_("hardlinkoffset"), SH_SECTION_MISC, SH_SECTION_NONE, 990 1010 sh_files_hle_reg }, 991 1011 #if defined(USE_XATTR) 992 { N_("useselinuxcheck"), SH_SECTION_MISC, SH_SECTION_NONE,1012 { N_("useselinuxcheck"), SH_SECTION_MISC, SH_SECTION_NONE, 993 1013 sh_unix_setcheckselinux }, 994 1014 #endif 995 1015 #if defined(USE_ACL) 996 { N_("useaclcheck"), SH_SECTION_MISC, SH_SECTION_NONE,1016 { N_("useaclcheck"), SH_SECTION_MISC, SH_SECTION_NONE, 997 1017 sh_unix_setcheckacl }, 998 1018 #endif 999 { N_("loosedircheck"), SH_SECTION_MISC, SH_SECTION_NONE,1019 { N_("loosedircheck"), SH_SECTION_MISC, SH_SECTION_NONE, 1000 1020 sh_hash_loosedircheck }, 1001 { N_("addokchars"), SH_SECTION_MISC, SH_SECTION_NONE,1021 { N_("addokchars"), SH_SECTION_MISC, SH_SECTION_NONE, 1002 1022 sh_util_obscure_ok }, 1003 { N_("filenamesareutf8"), SH_SECTION_MISC, SH_SECTION_NONE,1023 { N_("filenamesareutf8"), SH_SECTION_MISC, SH_SECTION_NONE, 1004 1024 sh_util_obscure_utf8 }, 1005 { N_("setrecursionlevel"), SH_SECTION_MISC, SH_SECTION_NONE,1025 { N_("setrecursionlevel"), SH_SECTION_MISC, SH_SECTION_NONE, 1006 1026 sh_files_setrecursion }, 1007 { N_("checksumtest"), SH_SECTION_MISC, SH_SECTION_NONE,1027 { N_("checksumtest"), SH_SECTION_MISC, SH_SECTION_NONE, 1008 1028 sh_util_setchecksum }, 1009 { N_("reportonlyonce"), SH_SECTION_MISC, SH_SECTION_NONE,1029 { N_("reportonlyonce"), SH_SECTION_MISC, SH_SECTION_NONE, 1010 1030 sh_files_reportonce }, 1011 { N_("reportfulldetail"), SH_SECTION_MISC, SH_SECTION_NONE,1031 { N_("reportfulldetail"), SH_SECTION_MISC, SH_SECTION_NONE, 1012 1032 sh_files_fulldetail }, 1013 { N_("uselocaltime"), SH_SECTION_MISC, SH_SECTION_NONE,1033 { N_("uselocaltime"), SH_SECTION_MISC, SH_SECTION_NONE, 1014 1034 sh_unix_uselocaltime }, 1015 1035 1016 { N_("setnicelevel"), SH_SECTION_MISC, SH_SECTION_NONE,1036 { N_("setnicelevel"), SH_SECTION_MISC, SH_SECTION_NONE, 1017 1037 sh_readconf_set_nice }, 1018 1038 1039 { N_("startuploaddelay"), SH_SECTION_MISC, SH_SECTION_NONE, 1040 sh_readconf_set_delay }, 1041 1019 1042 #if defined(FANCY_LIBCAP) 1020 { N_("usecaps"), SH_SECTION_MISC, SH_SECTION_NONE,1043 { N_("usecaps"), SH_SECTION_MISC, SH_SECTION_NONE, 1021 1044 sh_readconf_setCaps }, 1022 1045 #endif 1023 1046 1024 { N_("setdropcache"), SH_SECTION_MISC, SH_SECTION_NONE, 1047 { N_("reportcheckflags"), SH_SECTION_MISC, SH_SECTION_NONE, 1048 set_report_checkflags }, 1049 1050 { N_("setdropcache"), SH_SECTION_MISC, SH_SECTION_NONE, 1025 1051 sl_set_drop_cache }, 1026 1052 1027 { N_("setiolimit"), SH_SECTION_MISC, SH_SECTION_NONE,1053 { N_("setiolimit"), SH_SECTION_MISC, SH_SECTION_NONE, 1028 1054 sh_unix_set_io_limit }, 1029 1055 1030 1056 { N_("versionstring"), SH_SECTION_MISC, SH_SECTION_NONE, 1031 sh_ hash_version_string },1057 sh_dbIO_version_string }, 1032 1058 1033 1059 { N_("digestalgo"), SH_SECTION_MISC, SH_SECTION_NONE, … … 1092 1118 sh_socket_password }, 1093 1119 { N_("setstripdomain"), SH_SECTION_SRV, SH_SECTION_MISC, 1094 sh_ forward_set_strip },1120 sh_xfer_set_strip }, 1095 1121 { N_("useseparatelogs"), SH_SECTION_SRV, SH_SECTION_MISC, 1096 1122 set_flag_sep_log }, … … 1098 1124 sh_unix_set_chroot }, 1099 1125 { N_("setclienttimelimit"), SH_SECTION_SRV, SH_SECTION_MISC, 1100 sh_ forward_set_time_limit },1126 sh_xfer_set_time_limit }, 1101 1127 { N_("setconnectiontimeout"),SH_SECTION_SRV, SH_SECTION_MISC, 1102 sh_ forward_set_timeout },1128 sh_xfer_set_timeout }, 1103 1129 { N_("useclientseverity"), SH_SECTION_SRV, SH_SECTION_MISC, 1104 sh_ forward_use_clt_sev },1130 sh_xfer_use_clt_sev }, 1105 1131 { N_("useclientclass"), SH_SECTION_SRV, SH_SECTION_MISC, 1106 sh_ forward_use_clt_class },1132 sh_xfer_use_clt_class }, 1107 1133 { N_("severitylookup"), SH_SECTION_SRV, SH_SECTION_MISC, 1108 sh_ forward_lookup_level },1134 sh_xfer_lookup_level }, 1109 1135 { N_("setclientfromaccept"), SH_SECTION_SRV, SH_SECTION_MISC, 1110 1136 set_socket_peer }, 1111 1137 { N_("setserverport"), SH_SECTION_SRV, SH_SECTION_MISC, 1112 sh_ forward_set_port },1138 sh_xfer_set_port }, 1113 1139 { N_("setserverinterface"), SH_SECTION_SRV, SH_SECTION_MISC, 1114 sh_ forward_set_interface },1140 sh_xfer_set_interface }, 1115 1141 { N_("client"), SH_SECTION_CLIENTS, SH_SECTION_NONE, 1116 sh_ forward_register_client },1142 sh_xfer_register_client }, 1117 1143 #endif 1118 1144 … … 1124 1150 #if defined(SH_WITH_SERVER) 1125 1151 { N_("setlogserver"), SH_SECTION_SRV, SH_SECTION_MISC, 1126 sh_ forward_setlogserver },1152 sh_xfer_set_logserver }, 1127 1153 #else 1128 1154 { N_("setlogserver"), SH_SECTION_CLT, SH_SECTION_MISC, 1129 sh_ forward_setlogserver },1155 sh_xfer_set_logserver }, 1130 1156 { N_("setthrottle"), SH_SECTION_CLT, SH_SECTION_MISC, 1131 sh_forward_set_throttle_delay}, 1157 sh_xfer_set_throttle_delay}, 1158 { N_("setdeltaretrycount"), SH_SECTION_CLT, SH_SECTION_MISC, 1159 set_delta_retry_count}, 1160 { N_("setdeltaretryinterval"),SH_SECTION_CLT, SH_SECTION_MISC, 1161 set_delta_retry_interval}, 1132 1162 #endif 1133 1163 #endif … … 1274 1304 char * key; 1275 1305 const char * value; 1306 char * value_dup; 1276 1307 char * tmp; 1277 1308 int i; … … 1394 1425 * If !defined(SH_EVAL_SHELL), this will reduce to a strdup. 1395 1426 */ 1396 value = sh_readconf_expand_value(value); 1397 1398 if (!value || (*value) == '\0') 1399 { 1400 TPT(( 0, FIL__, __LINE__, _("msg=<ConfigFile: empty after shell expansion: %s>\n"), 1427 value_dup = sh_readconf_expand_value(value); 1428 1429 if (!value_dup || (*value_dup) == '\0') 1430 { 1431 TPT(( 0, FIL__, __LINE__, 1432 _("msg=<ConfigFile: empty after shell expansion: %s>\n"), 1401 1433 line)); 1402 1434 SL_RETURN(good_opt, _("sh_readconf_line")); 1403 1435 } 1436 1437 value = value_dup; 1404 1438 1405 1439 #if defined (SH_WITH_CLIENT) || defined (SH_STANDALONE) … … 1467 1501 } 1468 1502 1469 SH_FREE( (char*)value);1503 SH_FREE(value_dup); 1470 1504 1471 1505 SL_RETURN(good_opt, _("sh_readconf_line")); 1472 1506 } 1473 1507 1474 1508 -
trunk/src/sh_registry.c
r422 r481 889 889 size_t tlen = sl_strlen(tmp); 890 890 891 if (S L_TRUE == sl_ok_adds(64, tlen))891 if (S_TRUE == sl_ok_adds(64, tlen)) 892 892 { 893 893 char * errbuf; … … 905 905 0, NULL ); 906 906 907 if (elen > 0 && S L_TRUE == sl_ok_adds(elen, tlen))907 if (elen > 0 && S_TRUE == sl_ok_adds(elen, tlen)) 908 908 { 909 909 tlen += elen; … … 978 978 size_t tlen = sl_strlen(tmp); 979 979 980 if (S L_TRUE == sl_ok_adds(64, tlen))980 if (S_TRUE == sl_ok_adds(64, tlen)) 981 981 { 982 982 char * errbuf = SH_ALLOC(64 + tlen); -
trunk/src/sh_schedule.c
r454 r481 55 55 #include "samhain.h" 56 56 #include "sh_mem.h" 57 #include "sh_error_min.h" 57 58 58 59 /* TESTONLY */ … … 143 144 tval = localtime(&now); 144 145 #endif 146 147 if (!tval) 148 { 149 sh_error_handle ((-1), FIL__, __LINE__, errno, MSG_E_SUBGEN, 150 _("localime() failed"), _("test_sched_int") ); 151 return 0; 152 } 153 145 154 count = 0; 146 155 for (i = 0; i < 5; ++i) -
trunk/src/sh_socket.c
r421 r481 33 33 #include <string.h> 34 34 35 #if TIME_WITH_SYS_TIME 36 #include <sys/time.h> 37 #include <time.h> 38 #else 39 #if HAVE_SYS_TIME_H 40 #include <sys/time.h> 41 #else 42 #include <time.h> 43 #endif 44 #endif 45 35 46 #include "samhain.h" 36 47 #include "sh_socket.h" … … 38 49 #include "sh_unix.h" 39 50 #include "sh_calls.h" 51 #include "sh_guid.h" 52 #include "sh_fifo.h" 53 #include "sh_utils.h" 40 54 41 55 #undef FIL__ … … 46 60 #include <signal.h> 47 61 62 typedef struct delta_tofetch { 63 char uuid[SH_UUID_BUF]; 64 time_t last_time; 65 unsigned int count; 66 } SH_DELTA_DB; 67 68 static SH_DELTA_DB * parse_entry(SH_DELTA_DB * db, const char * str) 69 { 70 long last_time; 71 unsigned int count; 72 char buf[SH_UUID_BUF]; 73 int res = sscanf(str, _("%u:%ld:%36s"), &count, &last_time, buf); 74 if (res == 3) 75 { 76 db->count = count; 77 db->last_time = (time_t) last_time; 78 sl_strlcpy(db->uuid, buf, SH_UUID_BUF); 79 return db; 80 } 81 return NULL; 82 } 83 84 static char * unparse_entry(const SH_DELTA_DB * db, char * str, size_t len) 85 { 86 int nbytes = sl_snprintf(str, len, _("%u:%ld:%s"), 87 db->count, (long) db->last_time, db->uuid); 88 if (nbytes < 0 || nbytes >= (int) len) 89 return NULL; 90 return str; 91 } 92 93 static SH_FIFO xfifo = SH_FIFO_INITIALIZER; 94 95 int sh_socket_store_uuid(const char * cmd) 96 { 97 char * p = sh_util_strdup(cmd); 98 char * q = strchr(cmd, ':'); 99 char entry[SH_BUFSIZE]; 100 SH_DELTA_DB db; 101 102 if (!q) { SH_FREE(p); return -1; } 103 104 ++q; 105 106 if (0 != sh_uuid_check(q)) { SH_FREE(p); return -1; } 107 108 db.count = 0; 109 db.last_time = (time_t) 0; 110 sl_strlcpy(db.uuid, q, SH_UUID_BUF); 111 SH_FREE(p); 112 113 if (NULL != unparse_entry(&db, entry, sizeof(entry))) 114 { 115 sh_fifo_push(&xfifo, entry); 116 return 0; 117 } 118 return -1; 119 } 120 121 static unsigned int try_interval = 60; 122 static unsigned int try_max = 2; 123 124 int set_delta_retry_interval(const char * str) 125 { 126 long val = strtol (str, (char **)NULL, 10); 127 128 if (val < 0 || val > INT_MAX) 129 return -1; 130 try_interval = (unsigned int) val; 131 return 0; 132 } 133 int set_delta_retry_count(const char * str) 134 { 135 long val = strtol (str, (char **)NULL, 10); 136 137 if (val < 0 || val > INT_MAX) 138 return -1; 139 try_max = (unsigned int) val; 140 return 0; 141 } 142 143 char * sh_socket_get_uuid(int * errflag, unsigned int * count, time_t * last) 144 { 145 char * entry = sh_fifo_pop(&xfifo); 146 char * uuid = NULL; 147 148 if (entry) 149 { 150 SH_DELTA_DB db; 151 time_t now; 152 153 if (NULL == parse_entry(&db, entry)) 154 { 155 SH_FREE(entry); 156 sh_error_handle(SH_ERR_WARN, FIL__, __LINE__, 0, MSG_E_SUBGEN, 157 _("Bad entry in fifo"), 158 _("sh_socket_get_uuid")); 159 *errflag = -1; 160 return NULL; 161 } 162 163 now = time(NULL); 164 165 if ( (db.count > 0) && ((unsigned long)(now - db.last_time) < try_interval) ) 166 { 167 sh_fifo_push_tail(&xfifo, entry); 168 SH_FREE(entry); 169 *errflag = -1; 170 return NULL; 171 } 172 173 SH_FREE(entry); 174 uuid = sh_util_strdup(db.uuid); 175 *count = db.count; 176 *last = db.last_time; 177 } 178 179 *errflag = 0; 180 return uuid; 181 } 182 183 int sh_socket_return_uuid (const char * uuid, unsigned int count, time_t last) 184 { 185 (void) last; 186 187 if (count < try_max) 188 { 189 char entry[SH_BUFSIZE]; 190 SH_DELTA_DB db; 191 time_t now = time(NULL); 192 193 db.count = count + 1; 194 db.last_time = now; 195 sl_strlcpy(db.uuid, uuid, SH_UUID_BUF); 196 197 if (NULL != unparse_entry(&db, entry, sizeof(entry))) 198 return sh_fifo_push_tail(&xfifo, entry); /* >0 for success */ 199 } 200 return -1; 201 } 202 48 203 void sh_socket_server_cmd(const char * srvcmd) 49 204 { … … 54 209 SL_RET0(_("sh_socket_server_cmd")); 55 210 } 56 if ((srvcmd[0] == 'S') && (srvcmd[1] == 'T') && 57 (srvcmd[2] == 'O') && (srvcmd[3] == 'P'))211 212 if (0 == strncmp(srvcmd, _("STOP"), 4)) 58 213 { 59 214 TPT((0, FIL__, __LINE__, _("msg=<stop command from server>\n"))); … … 65 220 #endif 66 221 } 67 else if ((srvcmd[0] == 'R') && (srvcmd[1] == 'E') && 68 (srvcmd[2] == 'L') && (srvcmd[3] == 'O') && 69 (srvcmd[4] == 'A') && (srvcmd[5] == 'D')) 222 223 else if (0 == strncmp(srvcmd, _("RELOAD"), 6)) 70 224 { 71 225 TPT((0, FIL__, __LINE__, _("msg=<reload command from server>\n"))); … … 77 231 #endif 78 232 } 79 else if ((srvcmd[0] == 'S') && (srvcmd[1] == 'C') && 80 (srvcmd[2] == 'A') && (srvcmd[3] == 'N')) 233 234 else if (0 == strncmp(srvcmd, _("DELTA:"), 6)) 235 { 236 TPT((0, FIL__, __LINE__, _("msg=<delta load command from server>\n"))); 237 238 if (sh_socket_store_uuid(srvcmd) == 0) 239 { 240 ++sh_load_delta_flag; 241 ++sig_raised; 242 } 243 } 244 245 else if (0 == strncmp(srvcmd, _("SCAN"), 4)) 81 246 { 82 247 TPT((0, FIL__, __LINE__, _("msg=<scan command from server>\n"))); 83 if (sh.flag.isdaemon == ON)248 if (sh.flag.isdaemon == S_TRUE) 84 249 { 85 250 #ifdef SIGTTOU … … 96 261 } 97 262 } 263 264 /* Unknown command 265 */ 98 266 else 99 267 { 100 sh_error_handle(SH_ERR_ INFO, FIL__, __LINE__, 0, MSG_E_SUBGEN,268 sh_error_handle(SH_ERR_WARN, FIL__, __LINE__, 0, MSG_E_SUBGEN, 101 269 srvcmd, 102 270 _("sh_socket_server_cmd")); … … 104 272 SL_RET0(_("sh_socket_server_cmd")); 105 273 } 106 /* #if defined (SH_WITH_CLIENT) 107 */ 108 #endif 274 #endif /* #if defined (SH_WITH_CLIENT) */ 109 275 110 276 #if defined(SH_WITH_SERVER) … … 225 391 struct stat buf; 226 392 227 #ifdef SH_DEBUG_SOCKET228 fprintf(stderr, "PROBE\n");229 #endif230 231 393 for (item = (client_t *) zAVLFirst(&avlcursor, all_clients); item; 232 394 item = (client_t *) zAVLNext(&avlcursor)) 233 395 { 234 #ifdef SH_DEBUG_SOCKET235 fprintf(stderr, "%s %d\n", item->hostname, (int)item->status_now);236 #endif237 238 396 if (item->status_now != CLT_INACTIVE) 239 397 { … … 242 400 file = get_client_conf_file (item->hostname, &dummy); 243 401 244 #ifdef SH_DEBUG_SOCKET245 fprintf(stderr, "%s\n", file);246 #endif247 402 if (0 == stat (file, &buf)) 248 403 { … … 250 405 while (new) 251 406 { 252 #ifdef SH_DEBUG_SOCKET253 fprintf(stderr, "%s <> %s\n", new->clt, item->hostname);254 #endif255 407 if (0 == sl_strcmp(new->clt, item->hostname)) 256 408 { 257 409 flag = 1; /* Client is in list already */ 258 410 259 #ifdef SH_DEBUG_SOCKET260 fprintf(stderr, "%lu <> %lu\n",261 (unsigned long) buf.st_mtime,262 (unsigned long)new->cti);263 #endif264 411 if (buf.st_mtime > new->cti) 265 412 { … … 368 515 369 516 #define NEED_PASSWORD_AUTH 370 371 517 #endif 372 518 … … 540 686 SL_RETURN( (0), _("sh_socket_open_int")); 541 687 } 542 /* #if !defined(HAVE_CMSGCRED) || !defined(SO_PEERCRED) */ 543 /* #endif */ 544 545 /* 546 #if !defined(HAVE_GETPEEREID) && !defined(SO_PEERCRED) && !defined(HAVE_STRUCT_CMSGCRED) && !defined(HAVE_STRUCT_FCRED) && !(defined(HAVE_STRUCT_SOCKCRED) && defined(LOCAL_CREDS)) 547 static 548 int sh_socket_read (struct socket_cmd * srvcmd) 549 { 550 srvcmd->cmd[0] = '\0'; 551 srvcmd->clt[0] = '\0'; 552 return 0; 553 } 554 #else 555 */ 688 556 689 557 690 /* … … 582 715 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. 583 716 */ 584 static 585 int sh_socket_read (struct socket_cmd * srvcmd) 586 { 587 struct socket_cmd * list_cmd; 588 char message[SH_MAXMSG]; 589 struct sockaddr_un name; 590 ACCEPT_TYPE_ARG3 size = sizeof(name); 591 717 718 static int receive_message(int talkfd, struct msghdr * msg, size_t message_size) 719 { 720 unsigned int retry = 0; 592 721 int nbytes; 593 int talkfd; 594 int retry = 0; 595 596 char * cmd = NULL; 597 char * clt = NULL; 598 599 int client_uid = -1; 722 char * message = msg->msg_iov->iov_base; 600 723 char errbuf[SH_ERRBUF_SIZE]; 601 724 602 603 struct msghdr msg;604 struct iovec iov;605 606 #if defined(NEED_PASSWORD_AUTH)607 char * eopw = NULL;608 char * goodpassword = NULL;609 #endif610 611 #if defined(HAVE_GETPEEREID)612 uid_t peer_uid;613 gid_t peer_gid;614 #elif defined(SO_PEERCRED)615 struct ucred cr;616 #ifdef HAVE_SOCKLEN_T617 socklen_t cl = sizeof(cr);618 #else619 int cl = sizeof(cr);620 #endif621 622 #elif defined(HAVE_STRUCT_CMSGCRED) || defined(HAVE_STRUCT_FCRED) || (defined(HAVE_STRUCT_SOCKCRED) && defined(LOCAL_CREDS))623 624 #ifdef HAVE_STRUCT_CMSGCRED625 typedef struct cmsgcred Cred;626 #define CRED_UID cmcred_uid627 628 #elif HAVE_STRUCT_FCRED629 typedef struct fcred Cred;630 #define CRED_UID fc_uid631 632 #elif HAVE_STRUCT_SOCKCRED633 typedef struct sockcred Cred;634 #define CRED_UID sc_uid635 636 #endif637 Cred *cred;638 639 /* Compute size without padding */640 char cmsgmem[ALIGN(sizeof(struct cmsghdr)) + ALIGN(sizeof(Cred))];641 /* for NetBSD */642 643 /* Point to start of first structure */644 struct cmsghdr *cmsg = (struct cmsghdr *) cmsgmem;645 #endif646 647 if (pf_unix_fd < 0)648 {649 return 0;650 }651 652 iov.iov_base = (char *) &message;653 iov.iov_len = sizeof(message);654 655 memset (&msg, 0, sizeof (msg));656 msg.msg_iov = &iov;657 msg.msg_iovlen = 1;658 659 #if !defined(SO_PEERCRED) && !defined(HAVE_GETPEEREID)660 #if defined(HAVE_STRUCT_CMSGCRED) || defined(HAVE_STRUCT_FCRED) || (defined(HAVE_STRUCT_SOCKCRED) && defined(LOCAL_CREDS))661 msg.msg_control = (char *) cmsg;662 msg.msg_controllen = sizeof (cmsgmem);663 memset (cmsg, 0, sizeof (cmsgmem));664 #endif665 #endif666 667 /* the socket is non-blocking668 * 'name' is the address of the sender socket669 */670 725 do { 671 talkfd = accept(pf_unix_fd, (struct sockaddr *) &name, &size); 672 } while (talkfd < 0 && errno == EINTR); 673 674 if ((talkfd < 0) && (errno == EAGAIN)) 675 { 676 return 0; 677 } 678 else if (talkfd < 0) 679 { 680 sh_error_handle((-1), FIL__, __LINE__, errno, MSG_E_SUBGEN, 681 sh_error_message (errno, errbuf, sizeof(errbuf)), 682 _("sh_socket_read: accept")); 683 return -1; 684 } 685 686 687 #if defined(LOCAL_CREDS) && !defined(SO_PEERCRED) && !defined(HAVE_GETPEEREID) 688 /* Set the socket to receive credentials on the next message 689 */ 690 { 691 int on = 1; 692 if (setsockopt (talkfd, 0, LOCAL_CREDS, &on, sizeof (on)) < 0) 693 { 694 sh_error_handle((-1), FIL__, __LINE__, errno, MSG_E_SUBGEN, 695 sh_error_message (errno, errbuf, sizeof(errbuf)), 696 _("sh_socket_read: setsockopt")); 697 sl_close_fd(FIL__, __LINE__, talkfd); 698 return -1; 699 } 700 } 701 #endif 702 703 do { 704 nbytes = recvmsg (talkfd, &msg, 0); 726 nbytes = recvmsg (talkfd, msg, 0); 705 727 if ((nbytes < 0) && (errno != EAGAIN)) 706 728 { … … 718 740 } while ((nbytes < 0) && (retry < 3)); 719 741 720 #ifdef SH_DEBUG_SOCKET721 fprintf(stderr, "%d bytes received\n", nbytes);722 #endif723 724 742 /* msg.msg_iov.iov_base, filled by recvmsg 725 743 */ 726 message[ sizeof(message)-1] = '\0';744 message[message_size-1] = '\0'; 727 745 728 746 if (nbytes < 0) … … 731 749 { 732 750 /* no data */ 751 sh_error_handle(SH_ERR_ALL, FIL__, __LINE__, errno, MSG_E_SUBGEN, 752 sh_error_message (errno, errbuf, sizeof(errbuf)), 753 _("sh_socket_read: recvfrom")); 733 754 sl_close_fd(FIL__, __LINE__, talkfd); 734 755 return 0; … … 740 761 return -1; 741 762 } 763 return 0; 764 } 742 765 743 766 #if defined(HAVE_GETPEEREID) 767 768 static int get_peer_uid(int talkfd) 769 { 770 uid_t peer_uid; 771 gid_t peer_gid; 772 char errbuf[SH_ERRBUF_SIZE]; 773 744 774 if (0 != getpeereid(talkfd, &peer_uid, &peer_gid)) 745 775 { … … 750 780 return -1; 751 781 } 752 client_uid = peer_uid; 753 cmd = message; 754 #elif defined(SO_PEERCRED) 782 return peer_uid; 783 } 784 785 #elif defined(SO_PEERCRED) 786 787 static int get_peer_uid(int talkfd) 788 { 789 char errbuf[SH_ERRBUF_SIZE]; 790 struct ucred cr; 791 #ifdef HAVE_SOCKLEN_T 792 socklen_t cl = sizeof(cr); 793 #else 794 int cl = sizeof(cr); 795 #endif 796 755 797 if (0 != getsockopt(talkfd, SOL_SOCKET, SO_PEERCRED, &cr, &cl)) 756 798 { … … 761 803 return -1; 762 804 } 763 client_uid = cr.uid; 764 cmd = message; 765 #elif defined(HAVE_STRUCT_CMSGCRED) || defined(HAVE_STRUCT_FCRED) || (defined(HAVE_STRUCT_SOCKCRED) && defined(LOCAL_CREDS)) 766 if (cmsg->cmsg_len < sizeof (cmsgmem) || cmsg->cmsg_type != SCM_CREDS) 767 { 768 sh_error_handle((-1), FIL__, __LINE__, 0, MSG_E_SUBGEN, 769 _("Message from recvmsg() was not SCM_CREDS"), 770 _("sh_socket_read")); 771 772 /* Check for file descriptors sent using SCM_RIGHTS, and 773 * close them. If MSG_CTRUNC is set, the buffer was too small, 774 * and no fds are duped. 775 */ 776 if (msg.msg_controllen >= sizeof(struct cmsghdr) && 777 (msg.msg_flags & MSG_CTRUNC) == 0) 778 { 779 unsigned int data_size; 780 unsigned int data_i; 781 int fdcount, fdmax; 782 struct cmsghdr * cmptr; 783 int fdsbuf[1 + (sizeof(cmsgmem)/sizeof(int))]; 784 785 for (cmptr = CMSG_FIRSTHDR(&msg); cmptr != NULL; 786 cmptr = CMSG_NXTHDR(&msg, cmptr)) 787 { 788 if (cmptr->cmsg_len > sizeof (cmsgmem) || 789 cmptr->cmsg_level != SOL_SOCKET || 790 cmptr->cmsg_type != SCM_RIGHTS) 791 continue; 792 793 /* Crappy way of finding the data length. 794 * cmptr->cmsg_len includes both header and padding, 795 * how are you supposed to find the data length? 796 * cmptr->cmsg_len - ALIGN(sizeof(struct cmsghdr)) ? 797 */ 798 data_size = 0; 799 800 for (data_i = 0; data_i < cmptr->cmsg_len; ++data_i) 801 { 802 if (CMSG_LEN(data_i) == cmptr->cmsg_len) 803 { 804 data_size = data_i; 805 break; 806 } 807 } 808 memcpy(fdsbuf, CMSG_DATA(cmptr), data_size); 809 fdmax = data_size / sizeof(int); 810 for (fdcount = 0; fdcount < fdmax; ++fdcount) 811 (void) sl_close_fd(FIL__, __LINE__, fdsbuf[fdcount]); 812 } 813 } 814 815 sl_close_fd(FIL__, __LINE__, talkfd); 816 return -1; 817 } 818 cred = (Cred *) CMSG_DATA (cmsg); 819 client_uid = cred->CRED_UID; 820 cmd = message; 821 #elif defined(NEED_PASSWORD_AUTH) 805 return cr.uid; 806 } 807 808 #endif 809 810 #if defined(NEED_PASSWORD_AUTH) 811 char * check_password(char * message, int * client_uid, int talkfd) 812 { 813 char * cmd = NULL; 814 char * eopw = NULL; 815 char * goodpassword = NULL; 816 822 817 goodpassword = sh_get_sockpass(); 823 818 eopw = strchr(message, '@'); … … 830 825 strlen(goodpassword) < (sizeof(message)/2)) 831 826 { 832 client_uid = sh_socket_flaguid;827 *client_uid = sh_socket_flaguid; 833 828 cmd = &message[strlen(goodpassword)+1]; 834 829 sh_set_sockpass(); … … 841 836 sh_set_sockpass(); 842 837 sl_close_fd(FIL__, __LINE__, talkfd); 838 return NULL; 839 } 840 return cmd; 841 } 842 #endif 843 844 static int list_all (int talkfd, char * cmd); 845 static int process_message(int talkfd, char * cmd, struct socket_cmd * srvcmd); 846 847 static 848 int sh_socket_read (struct socket_cmd * srvcmd) 849 { 850 char message[SH_MAXMSG]; 851 struct sockaddr_un name; 852 ACCEPT_TYPE_ARG3 size = sizeof(name); 853 int talkfd; 854 char * cmd = NULL; 855 int client_uid = -1; 856 char errbuf[SH_ERRBUF_SIZE]; 857 struct msghdr msg; 858 struct iovec iov; 859 int status; 860 861 if (pf_unix_fd < 0) 862 return 0; 863 864 iov.iov_base = (char *) &message; 865 iov.iov_len = sizeof(message); 866 867 memset (&msg, 0, sizeof (msg)); 868 msg.msg_iov = &iov; 869 msg.msg_iovlen = 1; 870 871 /* the socket is non-blocking 872 * 'name' is the address of the sender socket 873 */ 874 do { 875 talkfd = accept(pf_unix_fd, (struct sockaddr *) &name, &size); 876 } while (talkfd < 0 && errno == EINTR); 877 878 if ((talkfd < 0) && (errno == EAGAIN)) 879 { 880 return 0; 881 } 882 else if (talkfd < 0) 883 { 884 sh_error_handle((-1), FIL__, __LINE__, errno, MSG_E_SUBGEN, 885 sh_error_message (errno, errbuf, sizeof(errbuf)), 886 _("sh_socket_read: accept")); 843 887 return -1; 844 888 } 889 890 if (receive_message(talkfd, &msg, sizeof(message)) < 0) 891 return -1; 892 893 /* Authenticate request by peer uid or password. 894 */ 895 #if defined(HAVE_GETPEEREID) 896 client_uid = get_peer_uid(talkfd); 897 cmd = message; 898 899 #elif defined(SO_PEERCRED) 900 client_uid = get_peer_uid(talkfd); 901 cmd = message; 902 903 #elif defined(NEED_PASSWORD_AUTH) 904 cmd = check_password(message, &client_uid, talkfd); 905 845 906 #else 846 907 sh_error_handle((-1), FIL__, __LINE__, errno, MSG_E_SUBGEN, … … 851 912 #endif 852 913 853 #ifdef SH_DEBUG_SOCKET854 fprintf(stderr, "Peer uid=%d, required=%d\n",855 client_uid, sh_socket_flaguid);856 #endif857 858 914 if (client_uid != sh_socket_flaguid) 859 915 { … … 865 921 } 866 922 867 868 /* Give a diagnostic message. 869 */ 870 #ifdef SH_DEBUG_SOCKET 871 fprintf (stderr, "Server: got message: %s\n", cmd); 872 #endif 873 874 clt = strchr(cmd, ':'); 923 status = process_message(talkfd, cmd, srvcmd); 924 925 sl_close_fd(FIL__, __LINE__, talkfd); 926 return status; 927 } 928 929 static int check_valid_command(const char * str) 930 { 931 unsigned int i = 0; 932 char * commands[] = { N_("DELTA"), N_("RELOAD"), N_("STOP"), N_("SCAN"), 933 N_("CANCEL"), N_("LISTALL"), N_("LIST"), N_("PROBE"), NULL }; 934 935 while (commands[i]) 936 { 937 if (0 == strcmp(_(commands[i]), str)) 938 { 939 return 0; 940 } 941 ++i; 942 } 943 return -1; 944 } 945 946 static int send_reply (int fd, char * msg) 947 { 948 int nbytes = send (fd, msg, strlen(msg) + 1, 0); 949 950 if (nbytes < 0) 951 { 952 char errbuf[SH_ERRBUF_SIZE]; 953 sh_error_handle((-1), FIL__, __LINE__, errno, MSG_E_SUBGEN, 954 sh_error_message (errno, errbuf, sizeof(errbuf)), 955 _("send_reply")); 956 return -1; 957 } 958 959 return nbytes; 960 } 961 962 static int process_message(int talkfd, char * cmd, struct socket_cmd * srvcmd) 963 { 964 int nbytes; 965 char error_type[SH_ERRBUF_SIZE] = { '\0' }; 966 char * clt = (cmd) ? strchr(cmd, ':') : NULL; 967 968 if (clt && 0 == strncmp(cmd, _("DELTA:"), 6)) 969 { 970 /* DELTA:uuid:hostname 971 */ 972 char * uuid = clt; 973 974 *uuid = '\0'; ++uuid; 975 clt = strchr(uuid, ':'); 976 if (clt) { *clt = '\0'; ++clt; } 977 978 if (sh_uuid_check(uuid) < 0) 979 { 980 sl_strlcpy(error_type, _("!E:uuid-format:"), sizeof(error_type)); 981 sl_strlcat(error_type, uuid, sizeof(error_type)); 982 clt = NULL; 983 } 984 985 --uuid; *uuid = ':'; 986 } 987 else if (clt && *clt == ':') 988 { 989 *clt = '\0'; ++clt; 990 if (check_valid_command(cmd) < 0) 991 { 992 sl_strlcpy(error_type, _("!E:cmd-invalid:"), sizeof(error_type)); 993 sl_strlcat(error_type, cmd, sizeof(error_type)); 994 clt = NULL; 995 } 996 } 997 875 998 if (clt != NULL) 876 999 { 877 *clt = '\0'; ++clt;878 1000 if (sl_strlen(cmd) >= SH_MAXMSGLEN) 879 1001 { 880 #ifdef SH_DEBUG_SOCKET881 fprintf (stderr, "Server: command too long: %s\n", cmd);882 #endif883 1002 sh_error_handle((-1), FIL__, __LINE__, errno, MSG_E_SUBGEN, 884 1003 _("Bad message format: command too long"), 885 1004 _("sh_socket_read")); 886 sl_close_fd(FIL__, __LINE__, talkfd); 1005 sl_strlcpy(error_type, _("!E:cmd-toolong"), sizeof(error_type)); 1006 send_reply(talkfd, error_type); 887 1007 return -1; 888 1008 } 889 1009 else if (sl_strlen(clt) >= SH_MAXMSGLEN) 890 1010 { 891 #ifdef SH_DEBUG_SOCKET892 fprintf (stderr, "Server: hostname too long: %s\n", clt);893 #endif894 1011 sh_error_handle((-1), FIL__, __LINE__, errno, MSG_E_SUBGEN, 895 1012 _("Bad message format: hostname too long"), 896 1013 _("sh_socket_read")); 897 sl_close_fd(FIL__, __LINE__, talkfd); 1014 sl_strlcpy(error_type, _("!E:hostname-toolong"), sizeof(error_type)); 1015 send_reply(talkfd, error_type); 898 1016 return -1; 899 1017 } 900 if (cmd[0] == 'L' && cmd[1] == 'I' && 901 cmd[2] == 'S' && cmd[3] == 'T') 902 { 903 #ifdef SH_DEBUG_SOCKET 904 fprintf (stderr, "Server: list %s\n", clt); 905 #endif 906 goto list_all; 907 } 908 else if (cmd[0] == 'P' && cmd[1] == 'R' && 909 cmd[2] == 'O' && cmd[3] == 'B' && cmd[4] == 'E') 910 { 911 #ifdef SH_DEBUG_SOCKET 912 fprintf (stderr, "Server: probe start %s\n", clt); 913 #endif 1018 1019 if (0 == strncmp(cmd, _("LIST"), 4)) 1020 return list_all(talkfd, cmd); 1021 else if (0 == strncmp(cmd, _("PROBE"), 4)) 1022 { 914 1023 sh_socket_probe4reload(); 915 #ifdef SH_DEBUG_SOCKET 916 fprintf (stderr, "Server: probe done %s\n", clt); 917 #endif 918 cmd[0] = 'L'; cmd[1] = 'I'; cmd[2] = 'S'; cmd[3] = 'T';cmd[4] = '\0'; 919 goto list_all; 920 } 1024 sl_strlcpy(cmd, _("LIST"), 5); 1025 return list_all(talkfd, cmd); 1026 } 1027 921 1028 sl_strlcpy (srvcmd->cmd, cmd, SH_MAXMSGLEN); 922 1029 sl_strlcpy (srvcmd->clt, clt, SH_MAXMSGLEN); … … 925 1032 else 926 1033 { 927 #ifdef SH_DEBUG_SOCKET928 fprintf (stderr, "Server: bad message\n");929 #endif930 1034 sh_error_handle((-1), FIL__, __LINE__, errno, MSG_E_SUBGEN, 931 1035 _("Bad message format"), 932 1036 _("sh_socket_read")); 933 sl_close_fd(FIL__, __LINE__, talkfd); 1037 if (error_type[0] == '\0') 1038 sl_strlcpy(error_type, _("!E:message-format"), sizeof(error_type)); 1039 send_reply(talkfd, error_type); 934 1040 return -1; 935 1041 } 936 1042 937 1043 /* Bounce the message back to the sender. 938 * 'name' is the receiver address; it has been been filled939 * with the sender address in the recvfrom call940 1044 */ 941 #ifdef SH_DEBUG_SOCKET 942 fprintf (stderr, "Server: send message: %s to %s\n", 943 cmd, name.sun_path); 944 #endif 945 /* 946 nbytes = sendto (pf_unix_fd, message, nbytes, 0, 947 (struct sockaddr *) & name, size); 948 */ 949 nbytes = send (talkfd, cmd, strlen(cmd) + 1, 0); 950 sl_close_fd(FIL__, __LINE__, talkfd); 951 if (nbytes < 0) 952 { 953 sh_error_handle((-1), FIL__, __LINE__, errno, MSG_E_SUBGEN, 954 sh_error_message (errno, errbuf, sizeof(errbuf)), 955 _("sh_socket_read: send")); 956 return -1; 957 } 958 #ifdef SH_DEBUG_SOCKET 959 fprintf (stderr, "Server: message is out\n"); 960 #endif 1045 nbytes = send_reply(talkfd, cmd); 1046 961 1047 return nbytes; 962 963 list_all: 964 #ifdef SH_DEBUG_SOCKET 965 fprintf (stderr, "Server: list all\n"); 966 #endif 967 if (cmd[4] == 'A' && cmd[5] == 'L' && cmd[6] == 'L') 1048 } 1049 1050 static int list_all (int talkfd, char * cmd) 1051 { 1052 int nbytes; 1053 struct socket_cmd * list_cmd; 1054 char message[SH_MAXMSG]; 1055 char errbuf[SH_ERRBUF_SIZE]; 1056 1057 if (0 == strncmp(cmd, _("LISTALL"), 7)) 968 1058 { 969 1059 list_cmd = runlist; 970 1060 while (list_cmd) 971 1061 { 972 sl_snprintf(message, sizeof(message), _("SENT % 8s %32s %s"),1062 sl_snprintf(message, sizeof(message), _("SENT %42s %32s %s"), 973 1063 list_cmd->cmd, list_cmd->clt, list_cmd->cti); 974 /* 975 sl_strlcpy(message, _("DONE"), SH_MAXMSG); 976 sl_strlcat(message, " ", SH_MAXMSG); 977 sl_strlcat(message, list_cmd->cmd, SH_MAXMSG); 978 sl_strlcat(message, " ", SH_MAXMSG); 979 sl_strlcat(message, list_cmd->clt, SH_MAXMSG); 980 sl_strlcat(message, " ", SH_MAXMSG); 981 sl_strlcat(message, list_cmd->cti, SH_MAXMSG); 982 */ 1064 983 1065 nbytes = send (talkfd, message, sl_strlen(message) + 1, 0); 984 1066 if (nbytes < 0) … … 987 1069 sh_error_message (errno, errbuf, sizeof(errbuf)), 988 1070 _("sh_socket_read: sendto")); 989 sl_close_fd(FIL__, __LINE__, talkfd);990 1071 return -1; 991 1072 } … … 997 1078 while (list_cmd) 998 1079 { 999 sl_snprintf(message, sizeof(message), _(">>>> % 8s %32s %s"),1080 sl_snprintf(message, sizeof(message), _(">>>> %42s %32s %s"), 1000 1081 list_cmd->cmd, list_cmd->clt, list_cmd->cti); 1001 /* 1002 sl_strlcpy(message, _(">>>>"), SH_MAXMSG); 1003 sl_strlcat(message, " ", SH_MAXMSG); 1004 sl_strlcat(message, list_cmd->cmd, SH_MAXMSG); 1005 sl_strlcat(message, " ", SH_MAXMSG); 1006 sl_strlcat(message, list_cmd->clt, SH_MAXMSG); 1007 sl_strlcat(message, " ", SH_MAXMSG); 1008 sl_strlcat(message, list_cmd->cti, SH_MAXMSG); 1009 */ 1010 /* 1011 nbytes = sendto (pf_unix_fd, message, sl_strlen(message) + 1, 0, 1012 (struct sockaddr *) & name, size); 1013 */ 1082 1014 1083 nbytes = send (talkfd, message, sl_strlen(message) + 1, 0); 1015 1084 if (nbytes < 0) … … 1018 1087 sh_error_message (errno, errbuf, sizeof(errbuf)), 1019 1088 _("sh_socket_read: sendto")); 1020 sl_close_fd(FIL__, __LINE__, talkfd);1021 1089 return -1; 1022 1090 } … … 1024 1092 } 1025 1093 1026 /* 1027 nbytes = sendto (pf_unix_fd, _("END"), 4, 0, 1028 (struct sockaddr *) & name, size); 1029 */ 1030 /* nbytes = *//* never read */ send (talkfd, _("END"), 4, 0); 1031 sl_close_fd(FIL__, __LINE__, talkfd); 1094 send (talkfd, _("END"), 4, 0); 1032 1095 return 0; 1033 1096 } 1034 /* #if !defined(HAVE_CMSGCRED) || !defined(SO_PEERCRED) */1035 /* #endif */1036 1097 1037 1098 static void sh_socket_add2list (struct socket_cmd * in) 1038 1099 { 1039 struct socket_cmd * new; 1040 1041 new = SH_ALLOC(sizeof(struct socket_cmd)); 1042 sl_strlcpy (new->cmd, in->cmd, sizeof(new->cmd)); 1043 sl_strlcpy (new->clt, in->clt, sizeof(new->clt)); 1044 #ifdef SH_DEBUG_SOCKET 1045 fprintf(stderr, "add2list: time set for %s\n", new->clt); 1046 #endif 1047 (void) sh_unix_time(0, new->cti, sizeof(new->cti)); 1048 new->next = cmdlist; 1049 cmdlist = new; 1050 1051 return; 1052 } 1053 1054 static void sh_socket_add2run (struct socket_cmd * in) 1055 { 1056 struct socket_cmd * new = runlist; 1057 char * client_name = in->clt; 1100 struct socket_cmd * new = cmdlist; 1101 struct socket_cmd * last = cmdlist; 1058 1102 1059 1103 while (new) 1060 1104 { 1061 if (0 == sl_strcmp(new->clt, client_name)) 1062 { 1063 sl_strlcpy (new->cmd, in->cmd, sizeof(new->cmd)); 1064 sl_strlcpy (new->clt, in->clt, sizeof(new->clt)); 1065 #ifdef SH_DEBUG_SOCKET 1066 fprintf(stderr, "add2run: time reset for %s\n", new->clt); 1067 #endif 1105 /* Only skip identical commands. 1106 */ 1107 if (0 == sl_strcmp(new->clt, in->clt) && 1108 0 == sl_strcmp(new->cmd, in->cmd)) 1109 { 1068 1110 (void) sh_unix_time(0, new->cti, sizeof(new->cti)); 1069 1111 return; … … 1073 1115 1074 1116 new = SH_ALLOC(sizeof(struct socket_cmd)); 1075 sl_strlcpy (new->cmd, in->cmd, sizeof(new->cmd)); 1076 sl_strlcpy (new->clt, in->clt, sizeof(new->clt)); 1117 sl_strlcpy (new->cmd, in->cmd, sizeof(new->cmd)); 1118 sl_strlcpy (new->clt, in->clt, sizeof(new->clt)); 1119 (void) sh_unix_time(0, new->cti, sizeof(new->cti)); 1120 new->next = NULL; 1121 1122 if (last) 1123 { 1124 while (last->next) { last = last->next; } 1125 last->next = new; 1126 } 1127 else 1128 { 1129 cmdlist = new; 1130 } 1131 return; 1132 } 1133 1134 static void sh_socket_add2run (struct socket_cmd * in) 1135 { 1136 struct socket_cmd * new = runlist; 1137 struct socket_cmd * last = runlist; 1138 1139 while (new) 1140 { 1141 /* Only skip identical commands. First 5 will 1142 * make all 'DELTA' identical. 1143 */ 1144 if (0 == sl_strcmp(new->clt, in->clt) && 1145 0 == sl_strncmp(new->cmd, in->cmd, 5)) 1146 { 1147 sl_strlcpy (new->cmd, in->cmd, sizeof(new->cmd)); 1148 (void) sh_unix_time(0, new->cti, sizeof(new->cti)); 1149 return; 1150 } 1151 new = new->next; 1152 } 1153 1154 new = SH_ALLOC(sizeof(struct socket_cmd)); 1155 sl_strlcpy (new->cmd, in->cmd, sizeof(new->cmd)); 1156 sl_strlcpy (new->clt, in->clt, sizeof(new->clt)); 1077 1157 #ifdef SH_DEBUG_SOCKET 1078 1158 fprintf(stderr, "add2run: time set for %s\n", new->clt); 1079 1159 #endif 1080 1160 (void) sh_unix_time(0, new->cti, sizeof(new->cti)); 1081 new->next = runlist; 1082 runlist = new; 1083 1161 new->next = NULL; 1162 1163 if (last) 1164 { 1165 while (last->next) { last = last->next; } 1166 last->next = new; 1167 } 1168 else 1169 { 1170 runlist = new; 1171 } 1084 1172 return; 1085 1173 } … … 1087 1175 1088 1176 1089 static void sh_socket_rm2list (const char * client_name )1177 static void sh_socket_rm2list (const char * client_name, int remove_all) 1090 1178 { 1091 1179 struct socket_cmd * old = cmdlist; … … 1098 1186 if ((new == cmdlist) && (new->next == NULL)) 1099 1187 { 1188 /* There is only one entry */ 1100 1189 cmdlist = NULL; 1101 1190 SH_FREE(new); … … 1104 1193 else if (new == cmdlist) 1105 1194 { 1195 /* first entry: new = old = cmdlist */ 1106 1196 cmdlist = new->next; 1107 1197 SH_FREE(new); 1108 return; 1198 if (remove_all == S_FALSE) 1199 return; 1200 old = cmdlist; 1201 new = cmdlist; 1202 continue; 1109 1203 } 1110 1204 else … … 1112 1206 old->next = new->next; 1113 1207 SH_FREE(new); 1114 return; 1208 if (remove_all == S_FALSE) 1209 return; 1210 new = old; 1115 1211 } 1116 1212 } … … 1131 1227 1132 1228 if (pf_unix_fd < 0) 1133 { 1134 return 0; 1135 } 1229 return 0; 1136 1230 1137 1231 sl_strlcpy(cancel_cmd, _("CANCEL"), sizeof(cancel_cmd)); … … 1140 1234 { 1141 1235 if (0 == sl_strcmp(cmd.cmd, cancel_cmd)) 1142 { 1143 sh_socket_rm2list (cmd.clt); 1144 } 1236 sh_socket_rm2list (cmd.clt, S_TRUE); 1145 1237 else 1146 { 1147 sh_socket_rm2list (cmd.clt); 1148 sh_socket_add2list (&cmd); 1149 } 1238 sh_socket_add2list (&cmd); 1150 1239 } 1151 1240 return 0; … … 1164 1253 if (0 == sl_strcmp(new->clt, client_name)) 1165 1254 { 1166 sl_strlcpy(out, new->cmd,sizeof(out));1255 sl_strlcpy(out, new->cmd, sizeof(out)); 1167 1256 sh_socket_add2run (new); 1168 sh_socket_rm2list (client_name);1257 sh_socket_rm2list (client_name, S_FALSE); 1169 1258 return out; 1170 1259 } … … 1173 1262 return NULL; 1174 1263 } 1175 1176 1264 /* #if defined (SH_WITH_SERVER) 1177 1265 */ 1178 1266 #endif 1179 1267 1268 1269 #ifdef SH_CUTEST 1270 #include "CuTest.h" 1271 1272 void Test_cmdlist (CuTest *tc) { 1273 1274 #if defined (SH_WITH_SERVER) 1275 struct socket_cmd cmd; 1276 char * p; 1277 1278 sl_strlcpy(cmd.clt, "one", sizeof(cmd.clt)); 1279 sl_strlcpy(cmd.cmd, "RELOAD", sizeof(cmd.cmd)); 1280 1281 sh_socket_add2list (&cmd); 1282 p = sh_socket_check("one"); 1283 CuAssertPtrNotNull(tc, p); 1284 CuAssertStrEquals(tc, "RELOAD", p); 1285 1286 p = sh_socket_check("one"); 1287 CuAssertPtrEquals(tc, NULL, p); 1288 1289 sh_socket_add2list (&cmd); 1290 sl_strlcpy(cmd.cmd, "STOP", sizeof(cmd.cmd)); 1291 sh_socket_add2list (&cmd); 1292 1293 sl_strlcpy(cmd.clt, "two", sizeof(cmd.clt)); 1294 sl_strlcpy(cmd.cmd, "STOP", sizeof(cmd.cmd)); 1295 sh_socket_add2list (&cmd); 1296 sl_strlcpy(cmd.clt, "three", sizeof(cmd.clt)); 1297 sl_strlcpy(cmd.cmd, "STOP", sizeof(cmd.cmd)); 1298 sh_socket_add2list (&cmd); 1299 1300 sl_strlcpy(cmd.clt, "one", sizeof(cmd.clt)); 1301 sl_strlcpy(cmd.cmd, "DELTA", sizeof(cmd.cmd)); 1302 sh_socket_add2list (&cmd); 1303 1304 p = sh_socket_check("one"); 1305 CuAssertPtrNotNull(tc, p); 1306 CuAssertStrEquals(tc, "RELOAD", p); 1307 1308 sl_strlcpy(cmd.clt, "two", sizeof(cmd.clt)); 1309 sl_strlcpy(cmd.cmd, "RELOAD", sizeof(cmd.cmd)); 1310 sh_socket_add2list (&cmd); 1311 sl_strlcpy(cmd.clt, "three", sizeof(cmd.clt)); 1312 sl_strlcpy(cmd.cmd, "RELOAD", sizeof(cmd.cmd)); 1313 sh_socket_add2list (&cmd); 1314 1315 p = sh_socket_check("one"); 1316 CuAssertPtrNotNull(tc, p); 1317 CuAssertStrEquals(tc, "STOP", p); 1318 p = sh_socket_check("one"); 1319 CuAssertPtrNotNull(tc, p); 1320 CuAssertStrEquals(tc, "DELTA", p); 1321 p = sh_socket_check("one"); 1322 CuAssertPtrEquals(tc, NULL, p); 1323 1324 /* Test removal in correct order */ 1325 sl_strlcpy(cmd.clt, "one", sizeof(cmd.clt)); 1326 sl_strlcpy(cmd.cmd, "RELOAD", sizeof(cmd.cmd)); 1327 sh_socket_add2list (&cmd); 1328 sl_strlcpy(cmd.cmd, "STOP", sizeof(cmd.cmd)); 1329 sh_socket_add2list (&cmd); 1330 sl_strlcpy(cmd.cmd, "DELTA", sizeof(cmd.cmd)); 1331 sh_socket_add2list (&cmd); 1332 sl_strlcpy(cmd.cmd, "FOOBAR", sizeof(cmd.cmd)); 1333 sh_socket_add2list (&cmd); 1334 1335 sh_socket_rm2list ("one", S_FALSE); 1336 1337 p = sh_socket_check("one"); 1338 CuAssertPtrNotNull(tc, p); 1339 CuAssertStrEquals(tc, "STOP", p); 1340 1341 sh_socket_rm2list ("one", S_FALSE); 1342 1343 p = sh_socket_check("one"); 1344 CuAssertPtrNotNull(tc, p); 1345 CuAssertStrEquals(tc, "FOOBAR", p); 1346 1347 p = sh_socket_check("one"); 1348 CuAssertPtrEquals(tc, NULL, p); 1349 1350 sl_strlcpy(cmd.clt, "one", sizeof(cmd.clt)); 1351 sl_strlcpy(cmd.cmd, "RELOAD", sizeof(cmd.cmd)); 1352 sh_socket_add2list (&cmd); 1353 sl_strlcpy(cmd.cmd, "STOP", sizeof(cmd.cmd)); 1354 sh_socket_add2list (&cmd); 1355 1356 sl_strlcpy(cmd.clt, "two", sizeof(cmd.clt)); 1357 sl_strlcpy(cmd.cmd, "RELOAD", sizeof(cmd.cmd)); 1358 sh_socket_add2list (&cmd); 1359 sl_strlcpy(cmd.clt, "three", sizeof(cmd.clt)); 1360 sl_strlcpy(cmd.cmd, "RELOAD", sizeof(cmd.cmd)); 1361 sh_socket_add2list (&cmd); 1362 1363 sl_strlcpy(cmd.clt, "one", sizeof(cmd.clt)); 1364 sl_strlcpy(cmd.cmd, "DELTA", sizeof(cmd.cmd)); 1365 sh_socket_add2list (&cmd); 1366 sl_strlcpy(cmd.cmd, "FOOBAR", sizeof(cmd.cmd)); 1367 sh_socket_add2list (&cmd); 1368 1369 sh_socket_rm2list ("one", S_TRUE); 1370 p = sh_socket_check("one"); 1371 CuAssertPtrEquals(tc, NULL, p); 1372 1373 p = sh_socket_check("two"); 1374 CuAssertPtrNotNull(tc, p); 1375 CuAssertStrEquals(tc, "STOP", p); 1376 p = sh_socket_check("two"); 1377 CuAssertPtrNotNull(tc, p); 1378 CuAssertStrEquals(tc, "RELOAD", p); 1379 p = sh_socket_check("two"); 1380 CuAssertPtrEquals(tc, NULL, p); 1381 1382 p = sh_socket_check("three"); 1383 CuAssertPtrNotNull(tc, p); 1384 CuAssertStrEquals(tc, "STOP", p); 1385 p = sh_socket_check("three"); 1386 CuAssertPtrNotNull(tc, p); 1387 CuAssertStrEquals(tc, "RELOAD", p); 1388 p = sh_socket_check("three"); 1389 CuAssertPtrEquals(tc, NULL, p); 1390 1391 p = sh_socket_check("four"); 1392 CuAssertPtrEquals(tc, NULL, p); 1393 #else 1394 (void) tc; 1395 #endif 1396 } 1397 1398 #endif /* #ifdef SH_CUTEST */ 1399 1400 1401 -
trunk/src/sh_static.c
r473 r481 999 999 return -1; 1000 1000 1001 while ((l = data[offset++])) { 1001 while ((l = data[offset])) { 1002 1003 if (offset < INT_MAX) 1004 offset++; 1005 else 1006 return -1; 1002 1007 1003 1008 if ((l & 0xc0) == (0xc0)) { 1004 offset++; 1009 if (offset < INT_MAX) 1010 offset++; 1011 else 1012 return -1; 1005 1013 break; 1006 1014 } 1007 1015 1008 offset += l; 1016 if (offset <= (INT_MAX - l)) 1017 offset += l; 1018 else 1019 return -1; 1009 1020 } 1010 1021 … … 1019 1030 if (i < 0) 1020 1031 return i; 1021 1022 return i + 4; 1032 if (i < (INT_MAX - 4)) 1033 return i + 4; 1034 else 1035 return -1; 1023 1036 } 1024 1037 … … 1036 1049 if (!data) 1037 1050 return -1; 1038 1039 while ((l=data[offset++])) { 1040 if (measure) 1051 while ((l=data[offset])) { 1052 if (offset < INT_MAX) offset++; 1053 else return -1; 1054 if (measure && (total < INT_MAX)) 1041 1055 total++; 1042 1056 if ((l & 0xc0) == (0xc0)) { 1043 if (measure)1057 if (measure && (total < INT_MAX)) 1044 1058 total++; 1045 /* compressed item, redirect */1059 /* compressed item, redirect */ 1046 1060 offset = ((l & 0x3f) << 8) | data[offset]; 1061 if (offset < 0) 1062 return -1; 1047 1063 measure = 0; 1048 1064 continue; 1049 1065 } 1066 1067 if (used >= (INT_MAX - l)) 1068 return -1; 1050 1069 1051 1070 if ((used + l + 1) >= maxlen) 1052 return -1;1071 return -1; 1053 1072 1054 1073 memcpy(dest + used, data + offset, l); 1055 offset += l; 1056 used += l; 1057 if (measure) 1074 1075 if (offset <= (INT_MAX - l)) 1076 offset += l; 1077 else 1078 return -1; 1079 1080 if (used <= (INT_MAX - l)) 1081 used += l; 1082 else 1083 return -1; 1084 if (measure && (total <= (INT_MAX - l))) 1058 1085 total += l; 1059 1086 1087 if (used == INT_MAX) 1088 return -1; 1060 1089 if (data[offset] != 0) 1061 1090 dest[used++] = '.'; … … 1065 1094 1066 1095 /* The null byte must be counted too */ 1067 if (measure ) {1096 if (measure && (total < INT_MAX)) { 1068 1097 total++; 1069 1098 } … … 1078 1107 { 1079 1108 char temp[256]; 1080 int i ;1109 int i = 0; 1081 1110 1082 1111 i = __decode_dotted(message, offset, temp, sizeof(temp)); … … 1084 1113 return i; 1085 1114 1086 message += offset + i; 1115 if (offset <= (INT_MAX - i)) 1116 message += offset + i; 1117 else 1118 return -1; 1087 1119 1088 1120 a->dotted = strdup(temp); … … 1101 1133 DPRINTF("i=%d,rdlength=%d\n", i, a->rdlength); 1102 1134 1103 return i + RRFIXEDSZ + a->rdlength; 1135 if (RRFIXEDSZ <= (INT_MAX - i)) 1136 i += RRFIXEDSZ; 1137 else 1138 return -1; 1139 if (a->rdlength <= (INT_MAX - i)) 1140 return i + a->rdlength; 1141 else 1142 return -1; 1104 1143 } 1105 1144 … … 1148 1187 1149 1188 dest += i; 1189 if (maxlen < i) 1190 return -1; 1150 1191 maxlen -= i; 1151 1192 … … 1158 1199 dest[3] = (q->qclass & 0x00ff) >> 0; 1159 1200 1160 return i + 4; 1201 if (i <= (INT_MAX - 4)) 1202 return i + 4; 1203 else 1204 return -1; 1161 1205 } 1162 1206 -
trunk/src/sh_string.c
r383 r481 13 13 14 14 extern int sl_ok_adds (size_t a, size_t b); 15 #define S L_TRUE 116 #define S L_FALSE 015 #define S_TRUE 1 16 #define S_FALSE 0 17 17 18 18 #include <ctype.h> … … 389 389 sh_string * sh_string_cat_lchar(sh_string * s, const char * str, size_t len) 390 390 { 391 if (sl_ok_adds(len, s->siz) == S L_TRUE)391 if (sl_ok_adds(len, s->siz) == S_TRUE) 392 392 { 393 393 if ((len + 1 + s->len) > s->siz) … … 453 453 size_t len = 0; 454 454 455 if (sl_ok_adds(len1, len2) == S L_TRUE)455 if (sl_ok_adds(len1, len2) == S_TRUE) 456 456 len = len1 + len2; 457 457 else 458 458 return NULL; 459 if (sl_ok_adds( len, len3) == S L_TRUE)459 if (sl_ok_adds( len, len3) == S_TRUE) 460 460 len = len + len3; 461 461 else … … 482 482 increase = SH_STRING_PARCEL; 483 483 484 if (s && sl_ok_adds(s->siz, increase) == S L_TRUE)484 if (s && sl_ok_adds(s->siz, increase) == S_TRUE) 485 485 { 486 486 new = SH_ALLOC(s->siz + increase); -
trunk/src/sh_sub.c
r429 r481 83 83 close (child2parent[0]); 84 84 85 /* fprintf(stderr, "FIXME kill_sub %d\n", (int) sh_child_pid); */86 87 85 /* Let's be rude. */ 88 86 kill(sh_child_pid, SIGKILL); … … 210 208 211 209 sh_child_pid = res; 212 213 /* fprintf(stderr, "FIXME create_sub %d\n", (int) sh_child_pid); */214 210 } 215 211 else … … 252 248 static ssize_t sh_sub_write(int fd, const void *buf, size_t count) 253 249 { 254 c har * mbuf = (char *) buf;250 const char * mbuf = (const char *) buf; 255 251 ssize_t rcount; 256 252 int ttl = 5; /* 0, 1, 9, 81, 729 millisec */ … … 296 292 do { 297 293 298 /* fprintf(stderr, "FIXME wait_com polling..\n"); */299 300 294 do { 301 295 ret = poll(&fds, 1, -1); … … 305 299 { 306 300 ret = sh_sub_read(parent2child[0], &inbuf, sizeof(inbuf)); 307 308 /*309 fprintf(stderr, "FIXME wait_com stat %s (%s)\n",310 inbuf.path, (inbuf.command == SH_COM_LSTAT) ? "lstat" : "stat");311 */312 301 313 302 if (ret == 0) … … 328 317 outbuf.errnum = errno; 329 318 330 /* fprintf(stderr, "FIXME wait_com writing..\n"); */331 332 319 ret = sh_sub_write(child2parent[1], &outbuf, sizeof(outbuf)); 333 320 if (ret < 0) 334 321 { 335 /* fprintf(stderr, "FIXME wait_com return 1\n"); */336 322 return; 337 323 } … … 339 325 else /* sh_sub_read() < 0 */ 340 326 { 341 /* fprintf(stderr, "FIXME wait_com return 2\n"); */342 327 return; 343 328 } 344 329 } 345 346 /* fprintf(stderr, "FIXME wait_com next..\n"); */347 348 330 } while (1 == 1); 349 331 } -
trunk/src/sh_suidchk.c
r474 r481 78 78 #include "sh_suidchk.h" 79 79 #include "sh_hash.h" 80 #include "sh_dbIO.h" 80 81 #include "sh_unix.h" 81 82 #include "sh_files.h" … … 140 141 static int ShSuidchkActive = S_TRUE; 141 142 static time_t ShSuidchkInterval = 7200; 142 static long ShSuidchkFps = 0;143 static unsigned long ShSuidchkFps = 0; 143 144 static int ShSuidchkNosuid = S_FALSE; 144 145 static int ShSuidchkYield = S_FALSE; … … 150 151 static time_t FileLimNow = 0; 151 152 static time_t FileLimStart = 0; 152 static long FileLimNum = 0;153 static long FileLimTotal = 0;153 static unsigned long FileLimNum = 0; 154 static unsigned long FileLimTotal = 0; 154 155 155 156 static sh_schedule_t * ShSuidchkSched = NULL; … … 1134 1135 /* Rate limit (Fps == Files per second) 1135 1136 */ 1136 if ((ShSuidchkFps > 0 && FileLimNum > ShSuidchkFps && FileLimTotal > 0)&&1137 if ((ShSuidchkFps > 0 && FileLimNum > ShSuidchkFps) && 1137 1138 (ShSuidchkYield == S_FALSE)) 1138 1139 { … … 1222 1223 int dummy; 1223 1224 int class; 1224 unsigned long check_ mask= 0;1225 unsigned long check_flags = 0; 1225 1226 1226 1227 theFile = SH_ALLOC(sizeof(file_type)); 1227 1228 1228 1229 (void) sl_strlcpy (theFile->fullpath, tmpcat, PATH_MAX); 1229 theFile->check_ mask= sh_files_maskof(SH_LEVEL_READONLY);1230 theFile->check_flags = sh_files_maskof(SH_LEVEL_READONLY); 1230 1231 CLEAR_SH_FFLAG_REPORTED(theFile->file_reported); 1231 1232 theFile->attr_string = NULL; 1232 1233 theFile->link_path = NULL; 1233 1234 1234 sh_files_search_file(tmpcat, &class, &check_mask, &dummy); 1235 if ((check_mask & MODI_PREL) != 0) 1236 { 1237 theFile->check_mask |= MODI_PREL; 1238 } 1235 sh_files_search_file(tmpcat, &class, &check_flags, &dummy); 1236 if ((check_flags & MODI_PREL) != 0) 1237 MODI_SET(theFile->check_flags, MODI_PREL); 1239 1238 1240 1239 status = sh_unix_getinfo (ShDFLevel[SH_ERR_T_RO], … … 1303 1302 /* Running init. Report on files detected. 1304 1303 */ 1305 sh_ hash_pushdata(theFile, fileHash); /* no call to sh_error_handle */1304 sh_dbIO_data_write (theFile, fileHash); /* no call to sh_error_handle */ 1306 1305 SH_MUTEX_LOCK(mutex_thread_nolog); 1307 1306 sh_error_handle ((-1), FIL__, __LINE__, … … 2215 2214 } 2216 2215 2217 /* This variable is not used anywhere. It only exists2218 * to assign &dirlist to it, which keeps gcc from2219 * putting it into a register, and avoids the 'clobbered2220 * by longjmp' warning. And no, 'volatile' proved insufficient.2221 */2222 static void * sh_dummy_type = NULL;2223 2224 2225 2216 /* Return a newly allocated string naming the type of filesystem that the 2226 2217 file PATH, described by STATP, is on. 2227 2218 RELPATH is the file name relative to the current directory. 2228 2219 Return "unknown" if its filesystem type is unknown. */ 2220 2221 void * sh_dummy_2229_type; 2229 2222 2230 2223 static char * … … 2243 2236 FILE *mfp; 2244 2237 struct mntent *mnt; 2238 2239 /* Take the address to keep gcc from putting it into a register. 2240 * Avoids the 'clobbered by longjmp' warning. 2241 */ 2242 sh_dummy_2229_type = (void *) &type; 2245 2243 2246 2244 if (path == NULL || relpath == NULL) … … 2257 2255 return NULL; 2258 2256 } 2259 2260 /* Take the address to keep gcc from putting it into a register.2261 * Avoids the 'clobbered by longjmp' warning.2262 */2263 sh_dummy_type = (void*) &type;2264 2257 2265 2258 /* Find the entry with the same device number as STATP, and return -
trunk/src/sh_tiger0.c
r444 r481 55 55 #endif 56 56 57 #if defined(__GNUC__) && (__GNUC__ >= 3) 58 #undef SH_GNUC_ALIGN8 59 #define SH_GNUC_ALIGN8 __attribute__((aligned(8))) 60 #else 61 #undef SH_GNUC_ALIGN8 62 #define SH_GNUC_ALIGN8 63 #endif 64 65 57 66 typedef unsigned char sh_byte; 58 67 … … 121 130 char * tmp; 122 131 sh_byte * bptr; 123 sh_byte bbuf[64];132 sh_byte SH_GNUC_ALIGN8 bbuf[64]; 124 133 UINT64 bcount = 0; 125 134 … … 186 195 187 196 #if defined(HAVE_MLOCK) && !defined(HAVE_BROKEN_MLOCK) 188 if (skey->mlock_failed == S L_FALSE)197 if (skey->mlock_failed == S_FALSE) 189 198 { 190 199 if ( (-1) == sh_unix_mlock(FIL__, __LINE__, … … 193 202 { 194 203 SH_MUTEX_LOCK_UNSAFE(mutex_skey); 195 skey->mlock_failed = S L_TRUE;204 skey->mlock_failed = S_TRUE; 196 205 SH_MUTEX_UNLOCK_UNSAFE(mutex_skey); 197 206 } 198 207 } 199 208 #else 200 if (skey->mlock_failed == S L_FALSE)209 if (skey->mlock_failed == S_FALSE) 201 210 { 202 211 SH_MUTEX_LOCK_UNSAFE(mutex_skey); 203 skey->mlock_failed = S L_TRUE;212 skey->mlock_failed = S_TRUE; 204 213 SH_MUTEX_UNLOCK_UNSAFE(mutex_skey); 205 214 } … … 215 224 { 216 225 if (timeout > 0) 217 count = sl_read_timeout (fd, buffer, PRIV_MAX, timeout, S L_TRUE);226 count = sl_read_timeout (fd, buffer, PRIV_MAX, timeout, S_TRUE); 218 227 else 219 228 count = sl_read (fd, buffer, PRIV_MAX); … … 903 912 904 913 n = (off_t) sl_read_timeout (fd, buffer + sum, 905 (size_t) BLOCKSIZE - sum, timeout, S L_FALSE);914 (size_t) BLOCKSIZE - sum, timeout, S_FALSE); 906 915 907 916 if (SL_ISERROR (n)) … … 1450 1459 do { 1451 1460 n = (off_t) sl_read_timeout(fd, buffer + sum, 1452 (size_t) BLOCKSIZE - sum, timeout, S L_FALSE);1461 (size_t) BLOCKSIZE - sum, timeout, S_FALSE); 1453 1462 1454 1463 if (SL_ISERROR (n)) … … 1609 1618 } 1610 1619 1620 void sh_tiger_get_mask_hashtype(unsigned long * mask) 1621 { 1622 if (hash_type == SH_TIGER192) 1623 *mask |= MODI_TIGER192; 1624 else if (hash_type == SH_SHA1) 1625 *mask |= MODI_SHA1; 1626 else if (hash_type == SH_MD5) 1627 *mask |= MODI_MD5; 1628 else if (hash_type == SH_SHA256) 1629 *mask |= MODI_SHA256; 1630 return; 1631 } 1632 1633 void sh_tiger_set_hashtype_mask(unsigned long mask) 1634 { 1635 unsigned long type = mask & MODI_HASHTYPE; 1636 1637 if (type == MODI_TIGER192) 1638 hash_type = SH_TIGER192; 1639 else if (type == MODI_SHA1) 1640 hash_type = SH_SHA1; 1641 else if (type == MODI_MD5) 1642 hash_type = SH_MD5; 1643 else if (type == MODI_SHA256) 1644 hash_type = SH_SHA256; 1645 return; 1646 } 1647 1648 1611 1649 int sh_tiger_hashtype (const char * c) 1612 1650 { -
trunk/src/sh_tiger1_64.c
r474 r481 384 384 void tiger_compress(const word64 *str, word64 state[3]) 385 385 { 386 tiger_compress_macro((( word64*)str), ((word64*)state));386 tiger_compress_macro(((const word64*)str), ((word64*)state)); 387 387 } 388 388 … … 419 419 register word64 i; 420 420 register word64 j = 0; 421 unsigned char temp[64]; 421 union { 422 word64 w64_temp[8]; 423 unsigned char temp[64]; 424 } dd; 422 425 union { 423 426 word64 itmp; … … 435 438 #ifdef BIG_ENDIAN 436 439 for(j=0; j<64; j++) 437 temp[j^7] = ((sh_byte*)str)[j];438 tiger_compress(( (word64*)temp), res);440 dd.temp[j^7] = ((sh_byte*)str)[j]; 441 tiger_compress((dd.w64_temp), res); 439 442 #else 440 443 tiger_compress(str, res); … … 445 448 #ifdef BIG_ENDIAN 446 449 for(j=0; j<i; j++) 447 temp[j^7] = ((sh_byte*)str)[j];448 449 temp[j^7] = 0x01;450 dd.temp[j^7] = ((sh_byte*)str)[j]; 451 452 dd.temp[j^7] = 0x01; 450 453 j++; 451 454 for(; j&7; j++) 452 temp[j^7] = 0;455 dd.temp[j^7] = 0; 453 456 #else 454 457 455 458 #ifndef USE_MEMSET 456 459 for(j=0; j<i; j++) 457 temp[j] = ((sh_byte*)str)[j];458 #else 459 memcpy( temp, str, j=i );460 #endif 461 temp[j++] = 0x01;460 dd.temp[j] = ((const sh_byte*)str)[j]; 461 #else 462 memcpy( dd.temp, str, j=i ); 463 #endif 464 dd.temp[j++] = 0x01; 462 465 for(; j&7; j++) 463 temp[j] = 0;466 dd.temp[j] = 0; 464 467 465 468 #endif … … 469 472 #ifndef USE_MEMSET 470 473 for(; j<64; j++) 471 temp[j] = 0;472 #else 473 memset( temp+j, 0, 64-j);474 #endif 475 tiger_compress(( (word64*)temp), res);474 dd.temp[j] = 0; 475 #else 476 memset( (dd.temp)+j, 0, 64-j); 477 #endif 478 tiger_compress((dd.w64_temp), res); 476 479 j=0; 477 480 } … … 479 482 #ifndef USE_MEMSET 480 483 for(; j<56; j++) 481 temp[j] = 0;482 #else 483 memset( temp+j, 0, 56-j);484 dd.temp[j] = 0; 485 #else 486 memset( (dd.temp)+j, 0, 56-j); 484 487 #endif 485 488 … … 488 491 uu.itmp = ((word64)length)<<3; 489 492 for (j=0; j<8; j++) 490 temp[56+j] = uu.ctmp[j];491 492 tiger_compress(( (word64*)temp), res);493 dd.temp[56+j] = uu.ctmp[j]; 494 495 tiger_compress((dd.w64_temp), res); 493 496 } 494 497 -
trunk/src/sh_tools.c
r472 r481 109 109 p = (_("Key passed is not valid")); 110 110 else if (err_num == BAD_CIPHER_MODE) 111 p = (_("Params struct passed to cipherInit invalid"));111 p = (_("Params struct passed to rijndael_cipherInit invalid")); 112 112 else if (err_num == BAD_CIPHER_STATE) 113 113 p = (_("Cipher in wrong state")); … … 1371 1371 #if defined (SH_WITH_CLIENT) || defined (SH_WITH_SERVER) 1372 1372 1373 #if defined (SH_WITH_CLIENT) 1374 1375 static int probe_done = S_FALSE; 1376 static unsigned char probe_flag = '\0'; 1377 1378 void sh_tools_probe_reset() 1379 { 1380 probe_done = S_FALSE; 1381 probe_flag = '\0'; 1382 return; 1383 } 1384 1385 static int probe_ok(int flag) 1386 { 1387 (void) flag; 1388 if ((probe_flag & SH_PROTO_IVA) != 0) 1389 return S_TRUE; 1390 return S_FALSE; 1391 } 1392 1393 static unsigned char probe_header_set(unsigned char protocol) 1394 { 1395 if (probe_done || (protocol & SH_PROTO_SRP) == 0) 1396 return 0; 1397 1398 return (char) SH_PROTO_IVA; 1399 } 1400 1401 static void probe_header_get(unsigned char protocol) 1402 { 1403 if (probe_done || (protocol & SH_PROTO_SRP) == 0) 1404 return; 1405 1406 /* If the server doesn't know about it, 1407 * it will simply mirror it back. */ 1408 1409 if ((protocol & SH_PROTO_IVA) != 0) 1410 { 1411 /* probe was mirrored */; 1412 } 1413 else 1414 { 1415 /* probe was UNset */ 1416 probe_flag |= SH_PROTO_IVA; 1417 } 1418 probe_done = S_TRUE; 1419 return; 1420 } 1421 1422 #else 1423 static unsigned char probe_header_set(unsigned char protocol) { 1424 (void) protocol; return 0; } 1425 static void probe_header_get(unsigned char protocol) { 1426 (void) protocol; return; } 1427 void sh_tools_probe_reset() { return; } 1428 1429 unsigned char sh_tools_probe_store(unsigned char protocol, int * probe_flag) 1430 { 1431 if ((protocol & SH_PROTO_SRP) == 0) 1432 return protocol; 1433 1434 if ((protocol & SH_PROTO_IVA) != 0) 1435 { 1436 /* probe received */ 1437 *probe_flag |= SH_PROTO_IVA; 1438 protocol &= ~SH_PROTO_IVA; 1439 } 1440 return protocol; 1441 } 1442 1443 static int probe_ok(int flag) 1444 { 1445 if ((flag & SH_PROTO_IVA) != 0) 1446 return S_TRUE; 1447 return S_FALSE; 1448 } 1449 #endif 1450 1451 1373 1452 void get_header (unsigned char * head, unsigned long * bytes, char * u) 1374 1453 { 1375 1454 SL_ENTER(_("get_header")); 1455 1456 probe_header_get(head[0]); 1376 1457 1377 1458 *bytes = … … 1393 1474 #if defined(SH_WITH_CLIENT) || defined(SH_WITH_SERVER) 1394 1475 1395 #ifdef SH_ENCRYPT _21476 #ifdef SH_ENCRYPT 1396 1477 #define TRANS_BYTES 65120 1397 1478 #else … … 1399 1480 #endif 1400 1481 1401 void put_header (unsigned char * head, int protocol,1482 void put_header (unsigned char * head, const int protocol, 1402 1483 unsigned long * length, char * u) 1403 1484 { 1485 unsigned char probe = probe_header_set(protocol); 1404 1486 1405 1487 /* static long transfer_limit = (8 * SH_BUFSIZE); V0.8 */ … … 1408 1490 SL_ENTER(_("put_header")); 1409 1491 1410 head[0] = protocol ;1492 head[0] = protocol|probe; 1411 1493 1412 1494 ASSERT((*length < transfer_limit), _("*length < transfer_limit")) … … 1434 1516 SL_RET0(_("put_header")); 1435 1517 } 1436 #endif1437 1518 1438 1519 /* ------------------------------------------ … … 1453 1534 * only SH_V2_FULLSIZE is used, and only once 1454 1535 */ 1455 #if 0 1456 #ifdef SH_WITH_SERVER 1457 #define SH_V2_FULLSIZE 240 1458 #define SH_V2_PAYLOAD 224 1459 #define SH_V2_MESSAGE 176 1460 #else 1461 #define SH_V2_FULLSIZE 1024 1462 #define SH_V2_PAYLOAD 1008 1463 #define SH_V2_MESSAGE 960 1464 #endif 1465 #endif 1536 1466 1537 #define SH_V2_FULLSIZE 1024 1467 1538 … … 1508 1579 1509 1580 #ifdef SH_ENCRYPT 1581 1510 1582 /* 1511 1583 * #define DEBUG_EN2 … … 1514 1586 * last 4 bytes of outgoing header are set to dummy value 1515 1587 */ 1516 char * sh_tools_makePack (unsigned char * header, 1588 char * sh_tools_makePack (unsigned char * header, int flag, 1517 1589 char * payload, unsigned long payload_size, 1518 1590 keyInstance * keyInstE) 1519 1591 { 1520 UINT32 rpad[3]; 1592 BYTE inBlock[B_SIZ]; 1593 BYTE outBlock[B_SIZ]; 1594 char ivBlock[B_SIZ]; 1595 1596 UINT32 rpad[3]; 1521 1597 unsigned char head[16]; 1522 double epad; 1523 unsigned long i_epad = 0; 1524 unsigned long i_blk = payload_size / 16; 1525 unsigned long i_blkmax = SH_V2_FULLSIZE / 16; 1526 unsigned long pads = 0; 1527 size_t full_size; 1528 char * full_ret; 1529 1530 char * p; 1531 RIJ_BYTE inBlock[B_SIZ]; 1532 RIJ_BYTE outBlock[B_SIZ]; 1533 int j; 1534 cipherInstance cipherInst; 1535 int err_num; 1536 int blkfac; 1537 int oflow = 0; 1598 double epad; 1599 unsigned long i_epad = 0; 1600 unsigned long i_blk = payload_size / 16; 1601 unsigned long i_blkmax = SH_V2_FULLSIZE / 16; 1602 unsigned long pads = 0; 1603 size_t full_size; 1604 char * full_ret; 1605 1606 unsigned char * p; 1607 int j; 1608 cipherInstance cipherInst; 1609 int err_num; 1610 int blkfac; 1611 int oflow = 0; 1612 char expbuf[SH_ERRBUF_SIZE]; 1538 1613 1539 1614 /* … … 1541 1616 */ 1542 1617 if ((i_blk * 16) != payload_size) ++i_blk; 1543 #ifdef DEBUG_EN2 1544 fprintf(stderr, "SEND <%d> blocks <%d>\n", payload_size, i_blk); 1545 #endif 1618 1546 1619 /* random_pad 1547 1620 */ … … 1553 1626 memcpy (&head[8], &rpad[2], 4); 1554 1627 1555 /* protocol1556 */1557 /* memcpy (&head[8], &header[3], 4); */1558 1559 1628 /* size (payload) 1560 1629 */ … … 1566 1635 if (i_blk < i_blkmax) 1567 1636 { 1568 pads = i_blkmax - i_blk; 1569 /* memcpy((char *) &rpad[2], &head[12], 4); */ 1570 epad = taus_get_double (&rpad); 1571 #ifdef DEBUG_EN2 1572 fprintf(stderr, "PAD1 <%d> <%f>\n", pads, epad); 1573 #endif 1637 pads = i_blkmax - i_blk; 1638 epad = taus_get_double (&rpad); 1574 1639 i_epad = (unsigned long) (pads * epad); 1575 #ifdef DEBUG_EN21576 fprintf(stderr, "PAD2 <%d> <%d>\n", i_epad, (i_epad*16));1577 #endif1578 1640 } 1579 1641 … … 1596 1658 1597 1659 full_ret = SH_ALLOC(full_size); 1660 1598 1661 memcpy(full_ret, head, 16); 1599 1662 if (payload != NULL && !oflow) 1600 { 1601 memcpy(&full_ret[16], payload, payload_size); 1602 } 1663 memcpy(&full_ret[16], payload, payload_size); 1664 1603 1665 if ((i_blk*16) > payload_size && !oflow) 1604 1666 { 1605 #ifdef DEBUG_EN21606 fprintf(stderr, "SEN2 <%d>\n", (i_blk*16) - payload_size);1607 #endif1608 1667 memset(&full_ret[16+payload_size], '\0', (i_blk*16) - payload_size); 1609 1668 payload_size = i_blk * 16; 1610 1669 } 1611 1670 memset(&full_ret[16+payload_size], '\0', i_epad*16); 1612 #ifdef DEBUG_EN21613 fprintf(stderr, "SEN3 <%d> <%d>\n", full_size, i_epad*16);1614 #endif1615 1671 1616 1672 /* rewrite header … … 1618 1674 header[1] = (unsigned int)(full_size/256); 1619 1675 header[2] = (unsigned int)(full_size - (256 * header[1])); 1620 /* don't erase protocol from header 1621 memset(&header[3], '\0', 4); 1622 */ 1623 p = full_ret; blkfac = full_size / 16; 1624 1625 err_num = cipherInit (&cipherInst, MODE_CBC, NULL); 1676 1677 p = (unsigned char *) full_ret; 1678 blkfac = full_size / B_SIZ; 1679 1680 err_num = rijndael_cipherInit (&cipherInst, MODE_CBC, NULL); 1626 1681 1627 if (err_num < 0) 1628 { 1629 char expbuf[SH_ERRBUF_SIZE]; 1630 sh_error_handle((-1), FIL__, __LINE__, -1, MSG_E_SUBGEN, 1631 errorExplain(err_num, expbuf, sizeof(expbuf)), 1632 _("sh_tools_makePack: cipherInit")); 1633 } 1634 for (j = 0; j < blkfac; ++j) 1635 { 1682 if (err_num < 0) { 1683 sh_error_handle((-1), FIL__, __LINE__, -1, MSG_E_SUBGEN, 1684 errorExplain(err_num, expbuf, sizeof(expbuf)), 1685 _("sh_tools_makePack: rijndael_cipherInit")); } 1686 1687 if (probe_ok(flag)) { 1688 memcpy(inBlock, p, B_SIZ); 1689 err_num = rijndael_blockEncrypt(&cipherInst, keyInstE, 1690 inBlock, 128, outBlock); 1691 if (err_num >= 0) { 1692 memcpy(p, outBlock, B_SIZ); p += B_SIZ; 1693 memcpy(ivBlock, outBlock, sizeof(ivBlock)); 1694 err_num = rijndael_cipherInit (&cipherInst, MODE_CBC, ivBlock); 1695 if (err_num >= 0) { 1696 err_num = rijndael_blockEncrypt(&cipherInst, keyInstE, 1697 p, 128*(blkfac-1), p); 1698 } 1699 } 1700 } 1701 1702 else { 1703 for (j = 0; j < blkfac; ++j) { 1636 1704 memcpy(inBlock, p, B_SIZ); 1637 err_num = blockEncrypt(&cipherInst, keyInstE,1638 inBlock, 128 * BNUM, outBlock);1639 if (err_num < 0)1640 1641 char expbuf[SH_ERRBUF_SIZE];1642 sh_error_handle((-1), FIL__, __LINE__, -1, MSG_E_SUBGEN,1643 errorExplain(err_num, expbuf, sizeof(expbuf)),1644 _("sh_tools_makePack: blockEncrypt"));1645 } 1705 err_num = rijndael_blockEncrypt(&cipherInst, keyInstE, 1706 inBlock, 128, outBlock); 1707 1708 if (err_num < 0) { 1709 sh_error_handle((-1), FIL__, __LINE__, -1, MSG_E_SUBGEN, 1710 errorExplain(err_num, expbuf, sizeof(expbuf)), 1711 _("sh_tools_makePack: rijndael_blockEncrypt")); 1712 break; } 1713 1646 1714 memcpy(p, outBlock, B_SIZ); 1647 1715 p += B_SIZ; 1648 1716 } 1717 } 1649 1718 1650 1719 return full_ret; … … 1654 1723 * last 4 bytes of incoming header are dummy 1655 1724 */ 1656 char * sh_tools_revertPack (unsigned char * header, char * message,1725 char * sh_tools_revertPack (unsigned char * header, int flag, char * message, 1657 1726 keyInstance * keyInstD, 1658 1727 unsigned long message_size) 1659 1728 { 1729 BYTE inBlock[B_SIZ]; 1730 BYTE outBlock[B_SIZ]; 1731 char ivBlock[B_SIZ]; 1660 1732 unsigned long msg_size; 1661 1733 char * msg_ret; 1662 1734 1663 char * p; 1664 RIJ_BYTE inBlock[B_SIZ]; 1665 RIJ_BYTE outBlock[B_SIZ]; 1735 unsigned char * p; 1666 1736 int j; 1667 1737 cipherInstance cipherInst; … … 1671 1741 1672 1742 msg_size = (256 * (unsigned int)header[1] + (unsigned int)header[2]); 1673 #ifdef DEBUG_EN2 1674 fprintf(stderr, "RECV <%lu>\n", msg_size); 1675 #endif 1676 if (msg_size > message_size) { 1743 if (msg_size > message_size) 1677 1744 msg_size = message_size; 1678 #ifdef DEBUG_EN2 1679 fprintf(stderr, "RECV TRUNC1 <%lu>\n", msg_size); 1680 #endif 1681 } 1682 1683 p = message; blkfac = msg_size / 16; 1684 1685 err_num = cipherInit (&cipherInst, MODE_CBC, NULL); 1745 1746 p = (unsigned char *) message; blkfac = msg_size / 16; 1747 1748 err_num = rijndael_cipherInit (&cipherInst, MODE_CBC, NULL); 1686 1749 1687 1750 if (err_num < 0) … … 1689 1752 sh_error_handle((-1), FIL__, __LINE__, -1, MSG_E_SUBGEN, 1690 1753 errorExplain(err_num, expbuf, sizeof(expbuf)), 1691 _("sh_tools_revertPack: cipherInit")); 1692 } 1693 for (j = 0; j < blkfac; ++j) 1694 { 1754 _("sh_tools_revertPack: rijndael_cipherInit")); 1755 } 1756 1757 if (probe_ok(flag)) { 1758 memcpy(inBlock, p, B_SIZ); 1759 err_num = rijndael_blockDecrypt(&cipherInst, keyInstD, 1760 inBlock, 128, outBlock); 1761 if (err_num >= 0) { 1762 memcpy(p, outBlock, B_SIZ); p += B_SIZ; 1763 memcpy(ivBlock, inBlock, sizeof(ivBlock)); 1764 err_num = rijndael_cipherInit (&cipherInst, MODE_CBC, ivBlock); 1765 if (err_num >= 0) { 1766 err_num = rijndael_blockDecrypt(&cipherInst, keyInstD, 1767 p, 128*(blkfac-1), p); 1768 } 1769 } 1770 } 1771 1772 else { 1773 for (j = 0; j < blkfac; ++j) { 1695 1774 memcpy(inBlock, p, B_SIZ); 1696 err_num = blockDecrypt(&cipherInst, keyInstD, 1697 inBlock, 128 * BNUM, outBlock); 1698 if (err_num < 0) 1699 { 1700 sh_error_handle((-1), FIL__, __LINE__, -1, MSG_E_SUBGEN, 1701 errorExplain(err_num, expbuf, sizeof(expbuf)), 1702 _("sh_tools_revertPack: blockDecrypt")); 1703 } 1775 err_num = rijndael_blockDecrypt(&cipherInst, keyInstD, 1776 inBlock, 128, outBlock); 1777 1778 if (err_num < 0) { 1779 sh_error_handle((-1), FIL__, __LINE__, -1, MSG_E_SUBGEN, 1780 errorExplain(err_num, expbuf, sizeof(expbuf)), 1781 _("sh_tools_revertPack: rijndael_blockDecrypt")); 1782 break; } 1783 1704 1784 memcpy(p, outBlock, B_SIZ); 1705 1785 p += B_SIZ; 1706 1786 } 1707 1787 } 1788 1708 1789 /* rewrite size in header 1709 1790 */ … … 1717 1798 header[1] = (unsigned int)(msg_size/256); 1718 1799 header[2] = (unsigned int)(msg_size - (256 * header[1])); 1719 #ifdef DEBUG_EN2 1720 fprintf(stderr, "RECV TRUNC2 <%lu>\n", msg_size); 1721 #endif 1722 } 1723 #ifdef DEBUG_EN2 1724 fprintf(stderr, "REC2 <%lu>\n", msg_size); 1725 #endif 1726 /* protocol 1727 */ 1728 /* memcpy(&header[3], &message[8], 4); */ 1800 } 1729 1801 1730 1802 /* payload … … 1732 1804 msg_ret = SH_ALLOC(msg_size+1); 1733 1805 if (msg_size > 0) 1734 { 1735 memcpy(msg_ret, &message[16], msg_size); 1736 } 1806 memcpy(msg_ret, &message[16], msg_size); 1737 1807 msg_ret[msg_size] = '\0'; 1738 #ifdef DEBUG_EN2 1739 fprintf(stderr, "REC3 <%lu>\n", msg_size); 1740 #endif 1808 1741 1809 SH_FREE(message); 1742 1743 1810 return msg_ret; 1744 1811 } 1745 #endif 1812 #endif /* #ifdef SH_ENCRYPT */ 1746 1813 1747 1814 int sh_tools_hash_add(char * key, char * buf, int buflen) … … 1781 1848 SL_RETURN((1), _("sh_tools_hash_vfy")); 1782 1849 } 1850 1851 #endif /* defined(SH_WITH_CLIENT) || defined(SH_WITH_SERVER) */ 1852 1783 1853 1784 1854 /* ------------------------------------------ */ … … 1868 1938 #if defined (SH_WITH_SERVER) 1869 1939 1870 char * get_client_conf_file (c har * peer, unsigned long * length)1940 char * get_client_conf_file (const char * peer, unsigned long * length) 1871 1941 { 1872 1942 char * ret; … … 1874 1944 struct stat buf; 1875 1945 char * base; 1876 size_t size;1877 1946 1878 1947 SL_ENTER(_("get_client_conf_file")); 1879 1948 1880 1949 base = sh_util_strdup(DEFAULT_DATAROOT); 1881 1882 size = sl_strlen(base); 1883 if (sl_ok_adds(size, sl_strlen(peer))) 1884 size += sl_strlen(peer); 1885 if (sl_ok_adds(size, 6)) 1886 size += 6; 1887 1888 ret = SH_ALLOC(size); 1889 sl_strlcpy(ret, base, size); 1890 sl_strlcat(ret, _("/rc."), size); 1891 sl_strlcat(ret, peer, size); 1892 1950 ret = sh_util_strconcat(base, _("/rc."), peer, NULL); 1951 if (!ret) 1952 { SH_FREE(base); *length = 0; SL_RETURN(NULL, _("get_client_conf_file")); } 1953 1893 1954 status = retry_stat (FIL__, __LINE__, ret, &buf); 1894 1895 1955 if (status == 0) 1896 1956 goto lab_end; … … 1899 1959 (long) sh.effective.uid, ret); 1900 1960 1901 sl_strlcpy(ret, base, size); 1902 sl_strlcat(ret, "/rc", size); 1961 SH_FREE(ret); ret = sh_util_strconcat(base, _("/rc"), NULL); 1962 if (!ret) 1963 { SH_FREE(base); *length = 0; SL_RETURN(NULL, _("get_client_conf_file")); } 1903 1964 1904 1965 status = retry_stat (FIL__, __LINE__, ret, &buf); 1905 1906 1966 if (status == 0) 1907 1967 goto lab_end; … … 1910 1970 (long) sh.effective.uid, ret); 1911 1971 1912 SH_FREE(base); 1913 SH_FREE(ret); 1914 *length=0; 1972 SH_FREE(base); SH_FREE(ret); *length=0; 1915 1973 SL_RETURN(NULL, _("get_client_conf_file")); 1916 1974 … … 1920 1978 sh_error_handle(SH_ERR_ERR, FIL__, __LINE__, status, MSG_E_SUBGEN, 1921 1979 _("File too large"), _("get_client_conf_file")); 1922 SH_FREE(base); 1980 SH_FREE(base); SH_FREE(ret); *length = 0; 1923 1981 SL_RETURN(NULL, _("get_client_conf_file")); 1924 1982 } 1925 *length = (unsigned long) buf.st_size; 1926 SH_FREE(base); 1983 1984 SH_FREE(base); *length = (unsigned long) buf.st_size; 1927 1985 SL_RETURN(ret, _("get_client_conf_file")); 1928 1986 } 1929 1987 1930 char * get_client_data_file (c har * peer, unsigned long * length)1988 char * get_client_data_file (const char * peer, unsigned long * length) 1931 1989 { 1932 1990 char * ret; 1933 1991 int status; 1934 1992 struct stat buf; 1935 1936 1993 char * base; 1937 size_t size;1938 1994 1939 1995 SL_ENTER(_("get_client_data_file")); 1940 1996 1941 1997 base = sh_util_strdup(DEFAULT_DATAROOT); 1942 1943 size = sl_strlen(base); 1944 if (sl_ok_adds(size, sl_strlen(peer))) 1945 size += sl_strlen(peer); 1946 if (sl_ok_adds(size, 8)) 1947 size += 8; 1948 1949 ret = SH_ALLOC(size); 1950 sl_strlcpy(ret, base, size); 1951 sl_strlcat(ret, _("/file."), size); 1952 sl_strlcat(ret, peer, size); 1953 1998 ret = sh_util_strconcat(base, _("/file."), peer, NULL); 1999 if (!ret) 2000 { SH_FREE(base); *length = 0; SL_RETURN(NULL, _("get_client_data_file")); } 2001 1954 2002 status = retry_stat (FIL__, __LINE__, ret, &buf); 1955 1956 2003 if (status == 0) 1957 2004 goto lab1_end; … … 1960 2007 (long) sh.effective.uid, ret); 1961 2008 1962 1963 sl_strlcpy(ret, base, size); 1964 sl_strlcat(ret, _("/file"), size); 1965 2009 SH_FREE(ret); 2010 ret = sh_util_strconcat(base, _("/file"), NULL); 2011 if (!ret) 2012 { SH_FREE(base); *length = 0; SL_RETURN(NULL, _("get_client_data_file")); } 2013 1966 2014 status = retry_stat (FIL__, __LINE__, ret, &buf); 1967 1968 2015 if (status == 0) 1969 2016 goto lab1_end; … … 1972 2019 (long) sh.effective.uid, ret); 1973 2020 1974 1975 *length = 0; 1976 SH_FREE(base); 1977 SH_FREE(ret); 2021 *length = 0; SH_FREE(base); SH_FREE(ret); 1978 2022 SL_RETURN(NULL, _("get_client_data_file")); 1979 2023 … … 1983 2027 sh_error_handle(SH_ERR_ERR, FIL__, __LINE__, status, MSG_E_SUBGEN, 1984 2028 _("File too large"), _("get_client_data_file")); 1985 SH_FREE(base); 2029 SH_FREE(base); SH_FREE(ret); *length = 0; 1986 2030 SL_RETURN(NULL, _("get_client_data_file")); 1987 2031 } 2032 2033 *length = (unsigned long) buf.st_size; SH_FREE(base); 2034 SL_RETURN(ret, _("get_client_data_file")); 2035 } 2036 2037 char * get_client_uuid_file (const char * peer, unsigned long * length, const char * uuid) 2038 { 2039 char * ret; 2040 int status; 2041 struct stat buf; 2042 char * base; 2043 2044 SL_ENTER(_("get_client_uuid_file")); 2045 2046 base = sh_util_strdup(DEFAULT_DATAROOT); 2047 ret = sh_util_strconcat(base, _("/file."), peer, ".", uuid, NULL); 2048 SH_FREE(base); 2049 if (!ret) 2050 { *length = 0; SL_RETURN(NULL, _("get_client_uuid_file")); } 2051 2052 status = retry_stat (FIL__, __LINE__, ret, &buf); 2053 if (status != 0) 2054 { 2055 sh_error_handle(SH_ERR_ERR, FIL__, __LINE__, status, MSG_E_ACCESS, 2056 (long) sh.effective.uid, ret); 2057 SH_FREE(ret); *length = 0; 2058 SL_RETURN(NULL, _("get_client_uuid_file")); 2059 } 2060 else if (buf.st_size > 0x7fffffff) 2061 { 2062 sh_error_handle(SH_ERR_ERR, FIL__, __LINE__, status, MSG_E_SUBGEN, 2063 _("File too large"), _("get_client_uuid_file")); 2064 SH_FREE(ret); *length = 0; 2065 SL_RETURN(NULL, _("get_client_data_file")); 2066 } 2067 1988 2068 *length = (unsigned long) buf.st_size; 1989 SH_FREE(base); 1990 SL_RETURN(ret, _("get_client_data_file")); 1991 1992 } 2069 SL_RETURN(ret, _("get_client_uuid_file")); 2070 } 2071 1993 2072 #endif 1994 2073 … … 2091 2170 if (SL_ISERROR(fd)) 2092 2171 { 2093 sh_error_handle( SH_ERR_ALL, FIL__, __LINE__, fd, MSG_E_SUBGEN,2172 sh_error_handle((-1), FIL__, __LINE__, fd, MSG_E_SUBGEN, 2094 2173 _("Error opening temporary file"), _("open_tmp")); 2095 2174 TPT(( 0, FIL__, __LINE__, _("msg=<Error %d temporary file %s>\n"), 2096 2175 fd, file)); 2097 2176 } 2098 2099 2177 2100 2178 SH_FREE (file); -
trunk/src/sh_unix.c
r474 r481 103 103 #include "sh_prelink.h" 104 104 #include "sh_pthread.h" 105 #include "sh_sem.h" 105 106 106 107 /* moved here from far below … … 482 483 sl_strlcat(msg, details, 128); 483 484 (void) safe_logger (thesignal, method, msg); 485 486 close_ipc (); 484 487 raise(SIGKILL); 485 488 } … … 526 529 } while (val_return < 0 && errno == EINTR); 527 530 531 close_ipc (); 528 532 safe_logger (mysignal, 0, NULL); 529 533 } … … 594 598 if (skey != NULL) 595 599 memset (skey, '\0', sizeof(sh_key_t)); 596 #ifdef WITH_MESSAGE_QUEUE597 600 close_ipc (); 598 #endif599 601 safe_logger (mysignal, 0, NULL); 600 602 do { … … 636 638 if (skey != NULL) 637 639 memset (skey, '\0', sizeof(sh_key_t)); 638 #ifdef WITH_MESSAGE_QUEUE639 640 close_ipc (); 640 #endif641 641 642 642 do { … … 669 669 #endif 670 670 #ifdef SIGTTOU 671 if (mysignal == SIGTTOU) 672 sig_force_check = 1; 671 if (mysignal == SIGTTOU) { 672 sig_force_check = 1; sh_sem_trylock(); } 673 673 #endif 674 674 #ifdef SIGTTIN … … 682 682 #ifdef SIGQUIT 683 683 if (mysignal == SIGQUIT) 684 { 685 sig_terminate = 1; 686 ++sig_urgent; 687 } 684 sig_terminate = 1; 688 685 #endif 689 686 #ifdef SIGTERM … … 1042 1039 if ((status == ERANGE) && (w == NULL)) 1043 1040 { 1044 if (S L_TRUE == sl_ok_adds( gbufsize, SH_GRBUF_SIZE ))1041 if (S_TRUE == sl_ok_adds( gbufsize, SH_GRBUF_SIZE )) 1045 1042 { 1046 1043 SH_FREE(buffer); … … 1722 1719 struct utsname buf; 1723 1720 int i; 1724 intddot;1721 unsigned int ddot; 1725 1722 int len; 1726 1723 char * p; … … 1892 1889 */ 1893 1890 #if defined(HAVE_MLOCK) && !defined(HAVE_BROKEN_MLOCK) 1894 if (skey->mlock_failed == S L_FALSE)1891 if (skey->mlock_failed == S_FALSE) 1895 1892 { 1896 1893 if ( (-1) == sh_unix_mlock( FIL__, __LINE__, … … 1898 1895 { 1899 1896 SH_MUTEX_LOCK_UNSAFE(mutex_skey); 1900 skey->mlock_failed = S L_TRUE;1897 skey->mlock_failed = S_TRUE; 1901 1898 SH_MUTEX_UNLOCK_UNSAFE(mutex_skey); 1902 1899 } 1903 1900 } 1904 1901 #else 1905 if (skey->mlock_failed == S L_FALSE)1902 if (skey->mlock_failed == S_FALSE) 1906 1903 { 1907 1904 SH_MUTEX_LOCK_UNSAFE(mutex_skey); 1908 skey->mlock_failed = S L_TRUE;1905 skey->mlock_failed = S_TRUE; 1909 1906 SH_MUTEX_UNLOCK_UNSAFE(mutex_skey); 1910 1907 } … … 1980 1977 1981 1978 if (dummy == NULL) 1982 sh.flag.isdaemon = ON;1979 sh.flag.isdaemon = S_TRUE; 1983 1980 else 1984 1981 res = sh_util_flagval (dummy, &sh.flag.isdaemon); … … 2003 2000 2004 2001 if (dummy == NULL) 2005 sh.flag.isdaemon = OFF;2002 sh.flag.isdaemon = S_FALSE; 2006 2003 else 2007 2004 res = sh_util_flagval (dummy, &sh.flag.isdaemon); … … 2221 2218 char * tz = sh_util_strdup(getenv("TZ")); /* flawfinder: ignore */ 2222 2219 size_t tzlen = strlen(tz); 2223 if (S L_TRUE == sl_ok_adds (4, tzlen)) {2220 if (S_TRUE == sl_ok_adds (4, tzlen)) { 2224 2221 env[3] = SH_ALLOC(4+tzlen); 2225 2222 sl_strlcpy(env[3], "TZ=", 4); … … 2244 2241 memset(skey, 0, sizeof(sh_key_t)); 2245 2242 (void) umask(S_IRGRP|S_IWGRP|S_IXGRP|S_IROTH|S_IWOTH|S_IXOTH); 2246 sh_unix_closeall (3, -1, S L_TRUE); /* in child process */2243 sh_unix_closeall (3, -1, S_TRUE); /* in child process */ 2247 2244 execve(path, arg, env); 2248 2245 _exit(EXIT_FAILURE); … … 2284 2281 struct tm bb; 2285 2282 2283 struct tm * aptr; 2284 struct tm * bptr; 2285 2286 2286 int sign = 0; 2287 2287 int diff = 0; … … 2292 2292 2293 2293 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GMTIME_R) 2294 gmtime_r (xx, &aa);2294 aptr = gmtime_r (xx, &aa); 2295 2295 #else 2296 memcpy (&aa, gmtime(xx), sizeof(struct tm)); 2296 aptr = gmtime(xx); 2297 if (aptr) 2298 memcpy (&aa, aptr, sizeof(struct tm)); 2297 2299 #endif 2298 2300 2299 2301 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_LOCALTIME_R) 2300 localtime_r (xx, &bb);2302 bptr = localtime_r (xx, &bb); 2301 2303 #else 2302 memcpy (&bb, localtime(xx), sizeof(struct tm)); 2303 #endif 2304 2305 /* Check for datum wrap-around. 2306 */ 2307 if (aa.tm_year < bb.tm_year) 2308 sign = (-1); 2309 else if (aa.tm_mon < bb.tm_mon) 2310 sign = (-1); 2311 else if (aa.tm_mday < bb.tm_mday) 2312 sign = (-1); 2313 else if (bb.tm_year < aa.tm_year) 2314 sign = ( 1); 2315 else if (bb.tm_mon < aa.tm_mon) 2316 sign = ( 1); 2317 else if (bb.tm_mday < aa.tm_mday) 2318 sign = ( 1); 2319 2320 diff = aa.tm_hour * 60 + aa.tm_min; 2321 diff = (bb.tm_hour * 60 + bb.tm_min) - diff; 2322 diff = diff - (sign * 24 * 60); /* datum wrap-around correction */ 2323 hh = diff / 60; 2324 mm = diff - (hh * 60); 2325 sprintf (tz, _("%+03d%02d"), hh, mm); /* known to fit */ 2326 2304 bptr = localtime(xx); 2305 if (bptr) 2306 memcpy (&bb, bptr, sizeof(struct tm)); 2307 #endif 2308 2309 if (bptr && aptr) 2310 { 2311 /* Check for datum wrap-around. 2312 */ 2313 if (aa.tm_year < bb.tm_year) 2314 sign = (-1); 2315 else if (aa.tm_mon < bb.tm_mon) 2316 sign = (-1); 2317 else if (aa.tm_mday < bb.tm_mday) 2318 sign = (-1); 2319 else if (bb.tm_year < aa.tm_year) 2320 sign = ( 1); 2321 else if (bb.tm_mon < aa.tm_mon) 2322 sign = ( 1); 2323 else if (bb.tm_mday < aa.tm_mday) 2324 sign = ( 1); 2325 2326 diff = aa.tm_hour * 60 + aa.tm_min; 2327 diff = (bb.tm_hour * 60 + bb.tm_min) - diff; 2328 diff = diff - (sign * 24 * 60); /* datum wrap-around correction */ 2329 hh = diff / 60; 2330 mm = diff - (hh * 60); 2331 sprintf (tz, _("%+03d%02d"), hh, mm); /* known to fit */ 2332 } 2333 else 2334 { 2335 sprintf (tz, _("%+03d%02d"), 0, 0); 2336 } 2327 2337 SL_RETURN(tz, _("t_zone")); 2328 2338 } … … 2560 2570 static int sh_unix_use_localtime = S_FALSE; 2561 2571 2562 /* whether to use localtime for file times atams in logs2572 /* whether to use localtime for file timestamps in logs 2563 2573 */ 2564 2574 int sh_unix_uselocaltime (const char * c) … … 3485 3495 3486 3496 int sh_unix_checksum_size (char * filename, off_t size, int is_max_size, 3487 char * fileHash, int alert_timeout, SL_TICKET fd )3497 char * fileHash, int alert_timeout, SL_TICKET fd, unsigned long mask) 3488 3498 { 3489 3499 file_type * tmpFile; … … 3517 3527 char hashbuf[KEYBUF_SIZE]; 3518 3528 UINT64 local_length = (UINT64) (tmpFile->size < 0 ? 0 : tmpFile->size); 3529 if (sh.flag.opts == S_TRUE) sh_tiger_set_hashtype_mask(mask); 3519 3530 sl_strlcpy(fileHash, 3520 3531 sh_tiger_generic_hash (filename, fd, &(local_length), … … 3541 3552 3542 3553 int sh_check_rotated_log (const char * path, 3543 UINT64 old_size, UINT64 old_inode, const char * old_hash )3554 UINT64 old_size, UINT64 old_inode, const char * old_hash, unsigned long mask) 3544 3555 { 3545 3556 struct stat obuf; … … 3560 3571 if (!SL_ISERROR(fd)) 3561 3572 { 3562 sh_unix_checksum_size (rotated_file, old_size, S_FALSE, hashbuf, 120 /* alert_timeout */, fd); 3573 sh_unix_checksum_size (rotated_file, old_size, S_FALSE, 3574 hashbuf, 120 /* alert_timeout */, fd, mask); 3563 3575 3564 3576 sl_close(fd); … … 3814 3826 SL_ENTER(_("sh_unix_getinfo")); 3815 3827 3816 if (!MODI_INITIALIZED(theFile->check_ mask))3828 if (!MODI_INITIALIZED(theFile->check_flags)) 3817 3829 { 3818 3830 tmp2 = sh_util_safe_name (theFile->fullpath); … … 3823 3835 SH_MUTEX_UNLOCK(mutex_thread_nolog); 3824 3836 SH_FREE(tmp2); 3837 SL_RETURN((-1),_("sh_unix_getinfo")); 3825 3838 } 3826 3839 … … 3989 4002 if (fileHash != NULL) 3990 4003 { 3991 if ((theFile->check_ mask& MODI_CHK) == 0 ||4004 if ((theFile->check_flags & MODI_CHK) == 0 || 3992 4005 sh_restrict_this(theFile->fullpath, (UINT64) fbuf.st_size, 3993 4006 (UINT64) fbuf.st_mode, rval_open)) … … 3995 4008 sl_strlcpy(fileHash, SH_KEY_NULL, KEY_LEN+1); 3996 4009 } 3997 else if ((theFile->check_ mask& MODI_PREL) != 0 &&4010 else if ((theFile->check_flags & MODI_PREL) != 0 && 3998 4011 S_TRUE == sh_prelink_iself(rval_open, fbuf.st_size, 3999 4012 alert_timeout, theFile->fullpath)) 4000 4013 { 4001 4014 if (0 != sh_prelink_run (theFile->fullpath, 4002 fileHash, alert_timeout ))4015 fileHash, alert_timeout, theFile->check_flags)) 4003 4016 sl_strlcpy(fileHash, SH_KEY_NULL, KEY_LEN+1); 4004 4017 } … … 4008 4021 UINT64 length_current = TIGER_NOLIM; 4009 4022 4010 if (MODI_TXT_ENABLED(theFile->check_ mask) && fbuf.st_size < (10 * SH_TXT_MAX))4023 if (MODI_TXT_ENABLED(theFile->check_flags) && fbuf.st_size < (10 * SH_TXT_MAX)) 4011 4024 { 4012 4025 sl_init_content (rval_open, fbuf.st_size); 4013 4026 } 4014 4027 4028 if (sh.flag.opts == S_TRUE) sh_tiger_set_hashtype_mask(theFile->check_flags); 4015 4029 sl_strlcpy(fileHash, 4016 4030 sh_tiger_generic_hash (theFile->fullpath, … … 4023 4037 content = sh_string_copy(content); 4024 4038 4025 if ((theFile->check_ mask& MODI_SGROW) != 0)4039 if ((theFile->check_flags & MODI_SGROW) != 0) 4026 4040 { 4027 4041 /* Update size so it matches the one for which the checksum … … 4032 4046 sh_unix_checksum_size (theFile->fullpath, length_current, S_TRUE, 4033 4047 &fileHash[KEY_LEN + 1], 4034 alert_timeout, rval_open );4048 alert_timeout, rval_open, theFile->check_flags); 4035 4049 } 4036 4050 } … … 4046 4060 if (fileHash != NULL) 4047 4061 { 4048 if ((theFile->check_ mask& MODI_CHK) == 0 ||4062 if ((theFile->check_flags & MODI_CHK) == 0 || 4049 4063 sh_restrict_this(theFile->fullpath, (UINT64) fbuf.st_size, 4050 4064 (UINT64) fbuf.st_mode, rval_open)) … … 4057 4071 { 4058 4072 if (0 != sh_prelink_run (theFile->fullpath, 4059 fileHash, alert_timeout ))4073 fileHash, alert_timeout, theFile->check_flags)) 4060 4074 sl_strlcpy(fileHash, SH_KEY_NULL, KEY_LEN+1); 4061 4075 } … … 4065 4079 UINT64 length_current = TIGER_NOLIM; 4066 4080 4067 if (MODI_TXT_ENABLED(theFile->check_ mask) && fbuf.st_size < (10 * SH_TXT_MAX))4081 if (MODI_TXT_ENABLED(theFile->check_flags) && fbuf.st_size < (10 * SH_TXT_MAX)) 4068 4082 { 4069 4083 sl_init_content (rval_open, fbuf.st_size); 4070 4084 } 4071 4085 4086 if (sh.flag.opts == S_TRUE) sh_tiger_set_hashtype_mask(theFile->check_flags); 4072 4087 sl_strlcpy(fileHash, 4073 4088 sh_tiger_generic_hash (theFile->fullpath, rval_open, … … 4080 4095 content = sh_string_copy(content); 4081 4096 4082 if ((theFile->check_ mask& MODI_SGROW) != 0)4097 if ((theFile->check_flags & MODI_SGROW) != 0) 4083 4098 { 4084 4099 /* Update size so it matches the one for which the checksum … … 4089 4104 sh_unix_checksum_size (theFile->fullpath, length_current, S_TRUE, 4090 4105 &fileHash[KEY_LEN + 1], 4091 alert_timeout, rval_open );4106 alert_timeout, rval_open, theFile->check_flags); 4092 4107 } 4093 4108 } … … 4105 4120 sl_strlcpy(fileHash, SH_KEY_NULL, KEY_LEN+1); 4106 4121 4107 if ((theFile->check_ mask& MODI_CHK) != 0)4122 if ((theFile->check_flags & MODI_CHK) != 0) 4108 4123 { 4109 4124 tmp2 = sh_util_safe_name (theFile->fullpath); … … 4276 4291 /* --- Output the file. --- 4277 4292 */ 4278 if (flag_err_debug == S L_TRUE)4293 if (flag_err_debug == S_TRUE) 4279 4294 { 4280 4295 tmp2 = sh_util_safe_name ((filename == NULL) ? … … 5294 5309 int sh_unix_count_mlock() 5295 5310 { 5296 int i = 0;5311 unsigned int i = 0; 5297 5312 char str[32][64]; 5298 5313 sh_page_l * page_list; … … 5325 5340 #ifdef WITH_TPT 5326 5341 { 5327 int j = 0;5342 unsigned int j = 0; 5328 5343 while (j < i && j < 32) 5329 5344 { 5330 sh_error_handle(SH_ERR_ INFO, FIL__, __LINE__, j, MSG_E_SUBGEN,5345 sh_error_handle(SH_ERR_ALL, FIL__, __LINE__, j, MSG_E_SUBGEN, 5331 5346 str[j], _("sh_unix_count_mlock")); 5332 5347 ++j; … … 5336 5351 5337 5352 sl_snprintf(str[0], 64, _("%d pages locked"), i); 5338 sh_error_handle(SH_ERR_ INFO, FIL__, __LINE__, i, MSG_E_SUBGEN,5353 sh_error_handle(SH_ERR_ALL, FIL__, __LINE__, i, MSG_E_SUBGEN, 5339 5354 str[0], _("sh_unix_count_mlock")); 5340 5355 SL_RETURN((i), _("sh_unix_count_mlock")); … … 5515 5530 this_line = 0; 5516 5531 c = '\0'; 5517 while (c != '\n' && num > 0 &&this_line < (sizeof(theline)-1))5532 while (c != '\n' && this_line < (sizeof(theline)-1)) 5518 5533 { 5519 5534 do { -
trunk/src/sh_utils.c
r473 r481 309 309 } 310 310 } 311 out[rem] = ','; ++rem; 312 while (p[1] == '\n') ++p; /* scan over consecutive newlines */311 out[rem] = ','; ++rem; /* <-- ensures (rem > 0) is true */ 312 while (p[1] == '\n') ++p; /* scan over consecutive newlines */ 313 313 state = 0; 314 314 if (p[1] == '\0') { 315 if (rem > 0) out[rem-1] = '\0';315 out[rem-1] = '\0'; /* rem > 0 because of 4 lines above */ 316 316 break; 317 317 } … … 782 782 char hashbuf[KEYBUF_SIZE]; 783 783 784 784 int result; 785 785 size_t i; 786 786 787 787 SL_ENTER(_("sh_util_hmac_tiger")); 788 ASSERT((KEY_BLOCK <= (KEY_LEN/2)), _("KEY_BLOCK <= (KEY_LEN/2)")) 789 790 if (KEY_BLOCK > (KEY_LEN/2)) 791 { 792 (void) sh_tiger_hash (NULL, TIGER_DATA, 0, hashbuf, sizeof(hashbuf)); 793 sl_strlcpy(res, hashbuf, len); 794 SL_RETURN(res, _("sh_util_hmac_tiger")); 795 } 788 789 ASSERT((KEY_BLOCK <= (KEY_LEN/2)), _("KEY_BLOCK <= (KEY_LEN/2)")); 796 790 797 791 memcpy (K, zap, KEY_BLOCK); 798 792 799 if (sh_util_hextobinary (K, hexkey, KEY_LEN) < 0) 800 { 801 (void) sh_tiger_hash (NULL, TIGER_DATA, 0, hashbuf, sizeof(hashbuf)); 802 sl_strlcpy(res, hashbuf, len); 803 SL_RETURN(res, _("sh_util_hmac_tiger")); 804 } 805 806 if (sl_ok_adds(textlen, KEY_BLOCK)) 793 result = sh_util_hextobinary (K, hexkey, KEY_LEN); 794 795 ASSERT((result >= 0), _("result >= 0")); 796 797 if ((result >= 0) && sl_ok_adds(textlen, KEY_BLOCK)) 807 798 { 808 799 inner = (char *) SH_ALLOC (textlen + KEY_BLOCK); … … 830 821 /* now compute the hash 831 822 */ 832 h1 = sh_tiger_hash_uint32 ( outer, 833 TIGER_DATA, 834 KEY_BLOCK, 823 h1 = sh_tiger_hash_uint32 ( outer, TIGER_DATA, KEY_BLOCK, 835 824 kbuf, KEY_BYT/sizeof(UINT32)); 836 825 for (i = 0; i < (KEY_LEN/8); ++i) 837 { 838 /* cc[i] = h1[i]; */ 839 copy_four ( (unsigned char *) &(cc[i]), h1[i]); 840 } 841 842 h2 = sh_tiger_hash_uint32 ( inner, 843 TIGER_DATA, 826 copy_four ( (unsigned char *) &(cc[i]), h1[i]); 827 828 h2 = sh_tiger_hash_uint32 ( inner, TIGER_DATA, 844 829 (unsigned long) KEY_BLOCK+textlen, 845 830 kbuf, KEY_BYT/sizeof(UINT32)); 846 831 for (i = KEY_LEN/8; i < (KEY_LEN/4); ++i) 847 { 848 copy_four ( (unsigned char *) &(cc[i]), h2[i - (KEY_LEN/8)]); 849 /* cc[i] = h2[i - (KEY_LEN/8)]; */ 850 } 832 copy_four ( (unsigned char *) &(cc[i]), h2[i - (KEY_LEN/8)]); 833 851 834 SH_FREE(inner); 852 835 … … 1033 1016 1034 1017 1035 /* interval [0, 429496729 6]1018 /* interval [0, 4294967295] 1036 1019 */ 1037 1020 static UINT32 taus_get_long (void *vstate) … … 1160 1143 char bufx[9 * sizeof(UINT32) + 1]; 1161 1144 int status; 1162 static unsigned long seed_time = 0; 1145 static unsigned long seed_time = 0; 1146 static unsigned long seed_counter = 3000; 1163 1147 unsigned long gtime; 1164 1148 … … 1167 1151 if (skey->rngI == GOOD) 1168 1152 { 1169 if ( (sh_unix_longtime () - seed_time) < 7200) 1153 ++seed_counter; 1154 1155 if ( ((sh_unix_longtime () - seed_time) < 1800) && 1156 ( seed_counter < 3000)) 1170 1157 SL_RETURN( (0), _("taus_seed")); 1171 1158 } 1172 1159 1173 seed_time = sh_unix_longtime (); 1160 seed_time = sh_unix_longtime (); 1161 seed_counter = 0; 1174 1162 1175 1163 status = sh_entropy (24, bufx); … … 1834 1822 int sh_util_obscurename (ShErrLevel level, const char * name_orig, int flag) 1835 1823 { 1836 const unsigned char * name = ( unsigned char *) name_orig;1824 const unsigned char * name = (const unsigned char *) name_orig; 1837 1825 char * safe; 1838 1826 unsigned int i; … … 2308 2296 unsigned char b; 2309 2297 size_t lout = 0; 2310 intw = 0;2298 unsigned int w = 0; 2311 2299 2312 2300 if (out && in) -
trunk/src/sh_utmp.c
r474 r481 848 848 * by longjmp' warning. And no, 'volatile' proved insufficient. 849 849 */ 850 static void * sh_dummy_userold = NULL;851 static void * sh_dummy_user = NULL;850 void * sh_dummy_850_userold = NULL; 851 void * sh_dummy_851_user = NULL; 852 852 853 853 … … 883 883 * Avoids the 'clobbered by longjmp' warning. 884 884 */ 885 sh_dummy_ userold = (void*) &userold;886 sh_dummy_ user = (void*) &user;885 sh_dummy_850_userold = (void*) &userold; 886 sh_dummy_851_user = (void*) &user; 887 887 888 888 /* ------- find user -------- … … 1133 1133 1134 1134 out: 1135 sh_dummy_ user = NULL;1136 sh_dummy_ userold = NULL;1135 sh_dummy_851_user = NULL; 1136 sh_dummy_850_userold = NULL; 1137 1137 1138 1138 SL_RET0(_("sh_utmp_addlogin")); -
trunk/src/slib.c
r476 r481 587 587 588 588 589 #if !defined (VA_COPY) 590 #if defined (__GNUC__) && defined (__PPC__) && (defined (_CALL_SYSV) || defined (_WIN32)) 591 #define VA_COPY(ap1, ap2) (*(ap1) = *(ap2)) 592 #elif defined (VA_COPY_AS_ARRAY) 593 #define VA_COPY(ap1, ap2) memmove ((ap1), (ap2), sizeof (va_list)) 594 #else /* va_list is a pointer */ 595 #define VA_COPY(ap1, ap2) ((ap1) = (ap2)) 596 #endif 597 #endif 598 589 599 #if !defined(HAVE_VSNPRINTF) || defined(HAVE_BROKEN_VSNPRINTF) 590 600 static … … 774 784 str[n-1] = '\0'; 775 785 #else 776 va_copy(vl2, vl);/* save the argument list */786 VA_COPY (vl2, vl); /* save the argument list */ 777 787 total = sl_printf_count (format, vl); 778 788 len = (int) total; … … 820 830 str[n-1] = '\0'; 821 831 #else 822 va_copy(vl2, vl);/* save the argument list */832 VA_COPY (vl2, vl); /* save the argument list */ 823 833 total = sl_printf_count (format, vl); 824 834 if (total < n) … … 1141 1151 static gid_t rgid_orig; 1142 1152 1143 static int uids_are_stored = S L_FALSE;1144 static int suid_is_set = S L_TRUE;1153 static int uids_are_stored = S_FALSE; 1154 static int suid_is_set = S_TRUE; 1145 1155 1146 1156 #ifdef HAVE_SETRESUID … … 1156 1166 int sl_is_suid() 1157 1167 { 1158 if (uids_are_stored == S L_FALSE)1168 if (uids_are_stored == S_FALSE) 1159 1169 { 1160 1170 if (getuid() == geteuid() && getgid() == getegid()) … … 1179 1189 { 1180 1190 SL_ENTER(_("sl_get_euid")); 1181 /* SL_REQUIRE(uids_are_stored == S L_TRUE, _("uids_are_stored == SL_TRUE"));*/1182 if (uids_are_stored == S L_TRUE)1191 /* SL_REQUIRE(uids_are_stored == S_TRUE, _("uids_are_stored == S_TRUE"));*/ 1192 if (uids_are_stored == S_TRUE) 1183 1193 *ret = euid; 1184 1194 else … … 1189 1199 uid_t sl_ret_euid() 1190 1200 { 1191 /* SL_REQUIRE(uids_are_stored == S L_TRUE, _("uids_are_stored == SL_TRUE"));*/1192 if (uids_are_stored == S L_TRUE)1201 /* SL_REQUIRE(uids_are_stored == S_TRUE, _("uids_are_stored == S_TRUE"));*/ 1202 if (uids_are_stored == S_TRUE) 1193 1203 return (euid); 1194 1204 else … … 1203 1213 { 1204 1214 SL_ENTER(_("sl_get_egid")); 1205 /* SL_REQUIRE(uids_are_stored == S L_TRUE, _("uids_are_stored == SL_TRUE"));*/1206 if (uids_are_stored == S L_TRUE)1215 /* SL_REQUIRE(uids_are_stored == S_TRUE, _("uids_are_stored == S_TRUE"));*/ 1216 if (uids_are_stored == S_TRUE) 1207 1217 *ret = egid; 1208 1218 else … … 1218 1228 { 1219 1229 SL_ENTER(_("sl_get_ruid")); 1220 /* SL_REQUIRE(uids_are_stored == S L_TRUE, _("uids_are_stored == SL_TRUE"));*/1221 if (uids_are_stored == S L_TRUE)1230 /* SL_REQUIRE(uids_are_stored == S_TRUE, _("uids_are_stored == S_TRUE"));*/ 1231 if (uids_are_stored == S_TRUE) 1222 1232 *ret = ruid; 1223 1233 else … … 1233 1243 { 1234 1244 SL_ENTER(_("sl_get_rgid")); 1235 /* SL_REQUIRE(uids_are_stored == S L_TRUE, _("uids_are_stored == SL_TRUE"));*/1236 if (uids_are_stored == S L_TRUE)1245 /* SL_REQUIRE(uids_are_stored == S_TRUE, _("uids_are_stored == S_TRUE"));*/ 1246 if (uids_are_stored == S_TRUE) 1237 1247 *ret = rgid; 1238 1248 else … … 1248 1258 { 1249 1259 SL_ENTER(_("sl_get_ruid_orig")); 1250 /* SL_REQUIRE(uids_are_stored == S L_TRUE, _("uids_are_stored == SL_TRUE"));*/1251 if (uids_are_stored == S L_TRUE)1260 /* SL_REQUIRE(uids_are_stored == S_TRUE, _("uids_are_stored == S_TRUE"));*/ 1261 if (uids_are_stored == S_TRUE) 1252 1262 *ret = ruid_orig; 1253 1263 else … … 1263 1273 { 1264 1274 SL_ENTER(_("sl_get_rgid_orig")); 1265 /* SL_REQUIRE(uids_are_stored == S L_TRUE, _("uids_are_stored == SL_TRUE"));*/1266 if (uids_are_stored == S L_TRUE)1275 /* SL_REQUIRE(uids_are_stored == S_TRUE, _("uids_are_stored == S_TRUE"));*/ 1276 if (uids_are_stored == S_TRUE) 1267 1277 *ret = rgid_orig; 1268 1278 else … … 1289 1299 SL_ENTER(_("sl_set_suid")); 1290 1300 1291 if (uids_are_stored == S L_FALSE)1301 if (uids_are_stored == S_FALSE) 1292 1302 { 1293 1303 SL_IRETURN(SL_ENONE, _("sl_set_suid")); 1294 1304 } 1295 1305 1296 SL_REQUIRE(uids_are_stored == S L_TRUE, _("uids_are_stored == SL_TRUE"));1306 SL_REQUIRE(uids_are_stored == S_TRUE, _("uids_are_stored == S_TRUE")); 1297 1307 1298 1308 if (ruid == euid && rgid == egid) 1299 1309 { 1300 suid_is_set = S L_TRUE;1310 suid_is_set = S_TRUE; 1301 1311 SL_IRETURN(SL_ENONE, _("sl_set_suid")); 1302 1312 } 1303 SL_REQUIRE(suid_is_set == S L_FALSE, _("suid_is_set == SL_FALSE"));1313 SL_REQUIRE(suid_is_set == S_FALSE, _("suid_is_set == S_FALSE")); 1304 1314 1305 1315 #if defined(HAVE_SETRESUID) … … 1330 1340 1331 1341 SL_REQUIRE(retval == 0, _("retval == 0")); 1332 suid_is_set = S L_TRUE;1342 suid_is_set = S_TRUE; 1333 1343 SL_IRETURN(SL_ENONE, _("sl_set_suid")); 1334 1344 } … … 1344 1354 SL_ENTER(_("sl_unset_suid")); 1345 1355 1346 if (uids_are_stored == S L_FALSE)1356 if (uids_are_stored == S_FALSE) 1347 1357 { 1348 1358 SL_IRETURN(SL_ENONE, _("sl_unset_suid")); 1349 1359 } 1350 1360 1351 SL_REQUIRE(uids_are_stored == S L_TRUE, _("uids_are_stored == SL_TRUE"));1361 SL_REQUIRE(uids_are_stored == S_TRUE, _("uids_are_stored == S_TRUE")); 1352 1362 1353 1363 if (ruid == euid && rgid == egid) 1354 1364 { 1355 suid_is_set = S L_FALSE;1365 suid_is_set = S_FALSE; 1356 1366 SL_IRETURN(SL_ENONE, _("sl_unset_suid")); 1357 1367 } 1358 SL_REQUIRE(suid_is_set == S L_TRUE, _("suid_is_set == SL_TRUE"));1368 SL_REQUIRE(suid_is_set == S_TRUE, _("suid_is_set == S_TRUE")); 1359 1369 1360 1370 #if defined(HAVE_SETRESUID) … … 1384 1394 1385 1395 SL_REQUIRE(retval == 0, _("retval == 0")); 1386 suid_is_set = S L_FALSE;1396 suid_is_set = S_FALSE; 1387 1397 SL_IRETURN(SL_ENONE, _("sl_unset_suid")); 1388 1398 } … … 1395 1405 { 1396 1406 SL_ENTER(_("sl_save_uids")); 1397 if (uids_are_stored == S L_TRUE)1407 if (uids_are_stored == S_TRUE) 1398 1408 SL_IRETURN(SL_EREPEAT, _("sl_save_uids")); 1399 1409 … … 1404 1414 ruid = ruid_orig; 1405 1415 rgid = rgid_orig; 1406 uids_are_stored = S L_TRUE;1416 uids_are_stored = S_TRUE; 1407 1417 1408 1418 SL_IRETURN(SL_ENONE, _("sl_save_uids")); … … 1417 1427 { 1418 1428 SL_ENTER(_("sl_drop_privileges")); 1419 SL_REQUIRE(uids_are_stored == S L_TRUE, _("uids_are_stored == SL_TRUE"));1429 SL_REQUIRE(uids_are_stored == S_TRUE, _("uids_are_stored == S_TRUE")); 1420 1430 1421 1431 SL_REQUIRE(setgid(rgid_orig) == 0, _("setgid(rgid_orig) == 0")); … … 1442 1452 { 1443 1453 SL_ENTER(_("sl_policy_get_root")); 1444 SL_REQUIRE(uids_are_stored == S L_FALSE, _("uids_are_stored == SL_FALSE"));1454 SL_REQUIRE(uids_are_stored == S_FALSE, _("uids_are_stored == S_FALSE")); 1445 1455 1446 1456 SL_REQUIRE (sl_save_uids() == SL_ENONE, _("sl_save_uids() == SL_ENONE")); … … 1455 1465 rgid = egid; 1456 1466 } 1457 suid_is_set = S L_TRUE;1467 suid_is_set = S_TRUE; 1458 1468 if (euid == 0) 1459 1469 { … … 1474 1484 { 1475 1485 SL_ENTER(_("sl_policy_get_real")); 1476 SL_REQUIRE(uids_are_stored == S L_FALSE, _("uids_are_stored == SL_FALSE"));1486 SL_REQUIRE(uids_are_stored == S_FALSE, _("uids_are_stored == S_FALSE")); 1477 1487 SL_REQUIRE (sl_save_uids() == SL_ENONE, _("sl_save_uids() == SL_ENONE")); 1478 1488 … … 1507 1517 _("sl_drop_privileges() == SL_ENONE")); 1508 1518 1509 suid_is_set = S L_TRUE;1519 suid_is_set = S_TRUE; 1510 1520 SL_IRETURN(SL_ENONE, _("sl_policy_get_real")); 1511 1521 } … … 1522 1532 1523 1533 SL_REQUIRE(user != NULL, _("user != NULL")); 1524 SL_REQUIRE(uids_are_stored == S L_FALSE, _("uids_are_stored == SL_FALSE"));1534 SL_REQUIRE(uids_are_stored == S_FALSE, _("uids_are_stored == S_FALSE")); 1525 1535 SL_REQUIRE (sl_save_uids() == SL_ENONE, _("sl_save_uids() == SL_ENONE")); 1526 1536 … … 1778 1788 ofiles[fd]->content = NULL; 1779 1789 ofiles[fd]->stream = stream; 1780 ofiles[fd]->flush = S L_FALSE;1790 ofiles[fd]->flush = S_FALSE; 1781 1791 1782 1792 sl_strlcpy(ofiles[fd]->ofile, ofile, SL_OFILE_SIZE); … … 2058 2068 ofiles[fd]->content = NULL; 2059 2069 ofiles[fd]->stream = NULL; 2060 ofiles[fd]->flush = S L_FALSE;2070 ofiles[fd]->flush = S_FALSE; 2061 2071 2062 2072 sl_strlcpy(ofiles[fd]->ofile, ofile, SL_OFILE_SIZE); … … 2182 2192 #endif 2183 2193 2184 static int sl_drop_cache = S L_FALSE;2194 static int sl_drop_cache = S_FALSE; 2185 2195 2186 2196 int sl_set_drop_cache(const char * str) … … 2203 2213 #if defined(HAVE_POSIX_FADVISE) && defined(HAVE_MINCORE) && defined(POSIX_FADV_DONTNEED) 2204 2214 2205 if (S L_FALSE != sl_drop_cache && !SL_ISERROR(status))2215 if (S_FALSE != sl_drop_cache && !SL_ISERROR(status)) 2206 2216 { 2207 2217 int fd = get_the_fd(status); … … 2209 2219 { 2210 2220 if (0 == sl_check_mincore(fd)) 2211 ofiles[fd]->flush = S L_TRUE;2221 ofiles[fd]->flush = S_TRUE; 2212 2222 } 2213 2223 } … … 2345 2355 { 2346 2356 #if defined(HAVE_POSIX_FADVISE) && defined(HAVE_MINCORE) && defined(POSIX_FADV_DONTNEED) 2347 if (ofiles[fd]->flush == S L_TRUE)2357 if (ofiles[fd]->flush == S_TRUE) 2348 2358 { 2349 2359 posix_fadvise(fd, 0, 0, POSIX_FADV_DONTNEED); … … 2569 2579 extern volatile int sig_termfast; 2570 2580 2571 if (is_nonblocking == S L_FALSE)2581 if (is_nonblocking == S_FALSE) 2572 2582 { 2573 2583 /* set to non-blocking mode … … 2620 2630 { 2621 2631 error = errno; 2622 if (is_nonblocking == S L_FALSE)2632 if (is_nonblocking == S_FALSE) 2623 2633 retry_fcntl(FIL__, __LINE__, fd, F_SETFL, sflags); 2624 2634 TPT(( 0, FIL__, __LINE__, _("msg=<read error>"))); … … 2637 2647 else if (retval == 0) 2638 2648 { 2639 if (is_nonblocking == S L_FALSE)2649 if (is_nonblocking == S_FALSE) 2640 2650 retry_fcntl(FIL__, __LINE__, fd, F_SETFL, sflags); 2641 2651 TPT(( 0, FIL__, __LINE__, _("msg=<timeout>"))); … … 2648 2658 { 2649 2659 error = errno; 2650 if (is_nonblocking == S L_FALSE)2660 if (is_nonblocking == S_FALSE) 2651 2661 retry_fcntl(FIL__, __LINE__, fd, F_SETFL, sflags); 2652 2662 TPT(( 0, FIL__, __LINE__, _("msg=<timeout>"))); … … 2657 2667 if (sig_termfast == 1) 2658 2668 { 2659 if (is_nonblocking == S L_FALSE)2669 if (is_nonblocking == S_FALSE) 2660 2670 retry_fcntl(FIL__, __LINE__, fd, F_SETFL, sflags); 2661 2671 TPT(( 0, FIL__, __LINE__, _("msg=<terminated>"))); … … 2669 2679 if (tdiff > timeout) 2670 2680 { 2671 if (is_nonblocking == S L_FALSE)2681 if (is_nonblocking == S_FALSE) 2672 2682 retry_fcntl(FIL__, __LINE__, fd, F_SETFL, sflags); 2673 2683 TPT(( 0, FIL__, __LINE__, _("msg=<timeout>"))); … … 2679 2689 } 2680 2690 2681 if (is_nonblocking == S L_FALSE)2691 if (is_nonblocking == S_FALSE) 2682 2692 retry_fcntl(FIL__, __LINE__, fd, F_SETFL, sflags); 2683 2693 return ((int) bytes); … … 2888 2898 2889 2899 extern uid_t rootonly[]; 2890 extern int EUIDSLOT;2891 extern int ORIG_EUIDSLOT;2900 extern unsigned int EUIDSLOT; 2901 extern unsigned int ORIG_EUIDSLOT; 2892 2902 2893 2903 extern char tf_path[MAXFILENAME]; /* Error path for trust function. */ … … 2998 3008 int sl_trust_purge_user (void) 2999 3009 { 3000 int i;3010 unsigned int i; 3001 3011 3002 3012 EUIDSLOT = ORIG_EUIDSLOT; … … 3074 3084 { 3075 3085 long status; 3076 static time_t old = 0;3077 static time_t now;3086 static size_t old = 0; 3087 static size_t now; 3078 3088 3079 3089 SL_ENTER(_("sl_trustfile_euid")); … … 3084 3094 3085 3095 now = time(NULL); 3096 3086 3097 if (now < (old + 300)) 3087 3098 { … … 3119 3130 { 3120 3131 if ((b == 0) || (a >= (INT_MIN / b) && a <= (INT_MAX / b))) 3121 return S L_TRUE; /* no overflow */3122 return S L_FALSE;3132 return S_TRUE; /* no overflow */ 3133 return S_FALSE; 3123 3134 } 3124 3135 … … 3126 3137 { 3127 3138 if ((b == 0) || (a <= (SIZE_MAX / b))) 3128 return S L_TRUE; /* no overflow */3129 return S L_FALSE;3139 return S_TRUE; /* no overflow */ 3140 return S_FALSE; 3130 3141 } 3131 3142 … … 3134 3145 (void) a; 3135 3146 if (b != 0) 3136 return S L_TRUE; /* no overflow */3137 return S L_FALSE;3147 return S_TRUE; /* no overflow */ 3148 return S_FALSE; 3138 3149 } 3139 3150 … … 3143 3154 { 3144 3155 if (a <= (INT_MAX - b)) 3145 return S L_TRUE; /* no overflow */3156 return S_TRUE; /* no overflow */ 3146 3157 else 3147 return S L_FALSE;3158 return S_FALSE; 3148 3159 } 3149 3160 else if (a < 0 && b < 0) 3150 3161 { 3151 3162 if (a >= (INT_MIN - b)) 3152 return S L_TRUE; /* no overflow */3163 return S_TRUE; /* no overflow */ 3153 3164 else 3154 return S L_FALSE;3155 } 3156 return S L_TRUE;3165 return S_FALSE; 3166 } 3167 return S_TRUE; 3157 3168 } 3158 3169 … … 3160 3171 { 3161 3172 if (a <= (SIZE_MAX - b)) 3162 return S L_TRUE; /* no overflow */3173 return S_TRUE; /* no overflow */ 3163 3174 else 3164 return S L_FALSE;3175 return S_FALSE; 3165 3176 } 3166 3177 … … 3170 3181 { 3171 3182 if (a <= (INT_MAX + b)) 3172 return S L_TRUE; /* no overflow */3183 return S_TRUE; /* no overflow */ 3173 3184 else 3174 return S L_FALSE;3185 return S_FALSE; 3175 3186 } 3176 3187 else if (a < 0 && b >= 0) 3177 3188 { 3178 3189 if (a >= (INT_MIN + b)) 3179 return S L_TRUE; /* no overflow */3190 return S_TRUE; /* no overflow */ 3180 3191 else 3181 return S L_FALSE;3182 } 3183 return S L_TRUE;3184 } 3192 return S_FALSE; 3193 } 3194 return S_TRUE; 3195 } -
trunk/src/t-test1.c
r454 r481 230 230 if(m->size > 0) free(m->ptr); 231 231 m->ptr = (unsigned char *)memalign(sizeof(int) << r, size); 232 /* fprintf(stderr, "FIXME memalign %p\n", m->ptr); */233 232 ++n_memalign; 234 233 } else if(r < 20) { /* calloc */ … … 246 245 #endif 247 246 ++n_calloc; 248 /* fprintf(stderr, "FIXME calloc %p\n", m->ptr); */249 247 } else if(r < 100 && m->size < REALLOC_MAX) { /* realloc */ 250 248 if(m->size == 0) m->ptr = NULL; 251 249 m->ptr = realloc(m->ptr, size); 252 /* fprintf(stderr, "FIXME realloc %p\n", m->ptr); */253 250 ++n_realloc; 254 251 } else { /* plain malloc */ 255 252 if(m->size > 0) free(m->ptr); 256 253 m->ptr = (unsigned char *)malloc(size); 257 /* fprintf(stderr, "FIXME malloc %p\n", m->ptr); */258 254 ++n_malloc; 259 255 } -
trunk/src/trustfile.c
r474 r481 102 102 103 103 104 #if ndef TRUST_MAIN104 #if !defined(TRUST_MAIN) 105 105 106 106 #include "slib.h" … … 121 121 122 122 #define TRUST_DEBUG 123 #define S L_FALSE 0124 #define S L_TRUE 1123 #define S_FALSE 0 124 #define S_TRUE 1 125 125 #define SL_ENTER(string) 126 126 #define SL_IRETURN(a, b) return a … … 222 222 223 223 uid_t tf_euid = tf_uid_neg; 224 int EUIDSLOT = sizeof(test_rootonly)/sizeof(uid_t);225 int ORIG_EUIDSLOT = sizeof(test_rootonly)/sizeof(uid_t);224 unsigned int EUIDSLOT = sizeof(test_rootonly)/sizeof(uid_t); 225 unsigned int ORIG_EUIDSLOT = sizeof(test_rootonly)/sizeof(uid_t); 226 226 227 227 char tf_path[MAXFILENAME]; /* error path for trust function */ … … 381 381 SL_ENTER(_("isin")); 382 382 if (list == NULL) 383 SL_IRETURN(S L_FALSE, _("isin"));383 SL_IRETURN(S_FALSE, _("isin")); 384 384 385 385 while(*list != tf_uid_neg && *list != n) … … 400 400 (UID_CAST) n); 401 401 #endif 402 SL_IRETURN(S L_FALSE, _("isin"));402 SL_IRETURN(S_FALSE, _("isin")); 403 403 } 404 404 … … 408 408 (UID_CAST)n, (UID_CAST)*list); 409 409 #endif 410 SL_IRETURN(S L_TRUE, _("isin"));410 SL_IRETURN(S_TRUE, _("isin")); 411 411 } 412 412 … … 506 506 if (pbuffer) free(pbuffer); 507 507 #endif 508 SL_IRETURN(S L_FALSE, _("isingrp"));508 SL_IRETURN(S_FALSE, _("isingrp")); 509 509 510 510 end_true: … … 513 513 if (pbuffer) free(pbuffer); 514 514 #endif 515 SL_IRETURN(S L_TRUE, _("isingrp"));515 SL_IRETURN(S_TRUE, _("isingrp")); 516 516 } 517 517 … … 537 537 #endif 538 538 539 int retval = S L_FALSE;539 int retval = S_FALSE; 540 540 541 541 SL_ENTER(_("onlytrustedingrp")); … … 567 567 (UID_CAST)grp); 568 568 #endif 569 retval = S L_FALSE;569 retval = S_FALSE; 570 570 goto end_retval; 571 571 } … … 574 574 575 575 if(g->gr_mem == NULL || g->gr_mem[0] == NULL ) 576 SL_IRETURN(S L_TRUE, _("onlytrustedingrp") );576 SL_IRETURN(S_TRUE, _("onlytrustedingrp") ); 577 577 */ 578 578 … … 640 640 #endif 641 641 tf_baduid = w->pw_uid; 642 retval = S L_FALSE;642 retval = S_FALSE; 643 643 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETGRGID_R) 644 644 if (pbuffer) free(pbuffer); … … 698 698 #endif 699 699 tf_baduid = w->pw_uid; 700 retval = S L_FALSE;700 retval = S_FALSE; 701 701 goto out; 702 /* SL_IRETURN(S L_FALSE, _("onlytrustedingrp")); */703 } 704 } 705 } 706 retval = S L_TRUE;702 /* SL_IRETURN(S_FALSE, _("onlytrustedingrp")); */ 703 } 704 } 705 } 706 retval = S_TRUE; 707 707 708 708 out: … … 720 720 721 721 #ifdef TRUST_DEBUG 722 if (retval == S L_TRUE)722 if (retval == S_TRUE) 723 723 fprintf(stderr, 724 724 "trustfile: group %ld: all members are trusted users --> OK\n", … … 849 849 char * csym; /* contents of symlink file */ 850 850 char * full; /* "full" name of symlink */ 851 register char *b, *t; /* used to copy stuff around */ 852 register int lsym; /* num chars in symlink ref */ 853 register int i; /* trustworthy or not? */ 851 char *b; /* used to copy stuff around */ 852 const char *t; /* used to copy stuff around */ 853 int lsym; /* num chars in symlink ref */ 854 int i; /* trustworthy or not? */ 854 855 const char * t_const; 855 856 char *end; … … 915 916 /* smack on the /../ 916 917 */ 917 t_const = "/../"; t = (c har *)t_const;918 t_const = "/../"; t = (const char *)t_const; 918 919 while(*t && b < end) 919 920 *b++ = *t++; … … 997 998 * file regardless of permissions, so bomb 998 999 */ 999 if (((okusers != NULL && S L_FALSE == isin((uid_t)stbuf.st_uid,okusers))||1000 (badusers != NULL && S L_TRUE == isin((uid_t)stbuf.st_uid,badusers))))1000 if (((okusers != NULL && S_FALSE == isin((uid_t)stbuf.st_uid,okusers))|| 1001 (badusers != NULL && S_TRUE == isin((uid_t)stbuf.st_uid,badusers)))) 1001 1002 { 1002 1003 #ifdef TRUST_DEBUG -
trunk/src/yulectl.c
r454 r481 24 24 #include <stdlib.h> 25 25 #include <string.h> 26 #include <ctype.h> 26 27 #include <errno.h> 27 28 … … 41 42 #define SH_MAXMSG 209 42 43 44 #if !defined(HAVE_GETPEEREID) && !defined(SO_PEERCRED) && \ 45 !defined(HAVE_STRUCT_CMSGCRED) && !defined(HAVE_STRUCT_FCRED) && \ 46 !(defined(HAVE_STRUCT_SOCKCRED) && defined(LOCAL_CREDS)) 47 #define SH_REQ_PASSWORD 1 48 #endif 49 43 50 static int sock = -1; 44 static char * sockname = NULL;45 46 51 static char password[15] = ""; 47 48 52 static int verbose = 0; 49 53 … … 86 90 87 91 88 int89 make_named_socket (char * sockname)92 static int 93 create_unix_socket () 90 94 { 91 95 int sock; 92 93 #if 094 struct sockaddr_un name;95 size_t size;96 #else97 (void) sockname;98 #endif99 96 100 97 /* Create the socket. */ … … 107 104 } 108 105 109 #if 0110 /* Bind a name to the socket. */111 name.sun_family = AF_FILE;112 strcpy (name.sun_path, sockname);113 114 /* The size of the address is115 the offset of the start of the filename,116 plus its length,117 plus one for the terminating null byte. */118 size = (offsetof (struct sockaddr_un, sun_path)119 + strlen (name.sun_path) + 1);120 121 if (bind (sock, (struct sockaddr *) &name, size) < 0)122 {123 perror (_("ERROR: bind"));124 return -1;125 }126 #endif127 128 106 return sock; 129 107 } 130 108 131 void109 static void 132 110 termination_handler (int signum) 133 111 { … … 138 116 fprintf(stdout, _("# Terminated on signal %d\n"), signum); 139 117 } 140 #if 0 141 if (sockname != NULL) unlink (sockname); 142 #endif 143 if (sock >= 0 ) close (sock); 144 118 if (sock >= 0 ) 119 close (sock); 145 120 return; 146 121 } 147 122 148 149 int send_to_server (char * serversock, char * message) 123 static char * safe_copy(char * to, const char * from, size_t size) 124 { 125 if (to && from) 126 { 127 strncpy (to, from, size); 128 if (size > 0) 129 to[size-1] = '\0'; 130 else 131 *to = '\0'; 132 } 133 return to; 134 } 135 136 137 static int send_to_server (char * serversock, char * message) 150 138 { 151 139 struct sockaddr_un name; 152 /* size_t size; */153 140 int size; 154 141 int nbytes; … … 168 155 } 169 156 170 /* Send the datagram. 171 nbytes = sendto (sock, message, strlen (message) + 1, 0, 172 (struct sockaddr *) & name, size); 157 /* Send the data. 173 158 */ 174 159 nbytes = send (sock, message, strlen (message) + 1, 0); 175 176 160 if (nbytes < 0) 177 161 { … … 205 189 } 206 190 207 int recv_from_server (char * message)191 static int recv_from_server (char * message) 208 192 { 209 193 int nbytes = 0; … … 211 195 int num = 0; 212 196 int good = -1; 213 int islist = 0;214 197 char * p; 215 198 216 199 if (password[0] == '\0') 217 { 218 if (message[0] == 'L' && message[1] == 'I' && 219 message[2] == 'S' && message[3] == 'T') 220 { 221 islist = 1; 222 } 223 if (message[0] == 'P' && message[1] == 'R' && 224 message[2] == 'O' && message[3] == 'B' && message[4] == 'E' ) 225 { 226 islist = 1; 227 } 228 } 200 p = message; 229 201 else 230 { 231 p = &message[strlen(password)+1]; 232 if (p[0] == 'L' && p[1] == 'I' && 233 p[2] == 'S' && p[3] == 'T') 234 { 235 islist = 1; 236 } 237 if (p[0] == 'P' && p[1] == 'R' && 238 p[2] == 'O' && p[3] == 'B' && p[4] == 'E' ) 239 { 240 islist = 1; 241 } 242 } 243 244 if (islist == 1) 202 p = &message[strlen(password)+1]; 203 204 if (0 == strncmp(p, _("PROBE"), 5) || 205 0 == strncmp(p, _("LIST"), 4)) 245 206 { 246 207 do { 247 /*248 nbytes = recvfrom (sock, recvmsg, SH_MAXMSG, 0, NULL, 0);249 */250 208 nbytes = getline_from_server (sock, recvmsg, SH_MAXMSG); 251 209 if (nbytes < 0) 252 210 { 253 211 if (errno == EAGAIN) 254 { 255 return 0; 256 } 212 return 0; 257 213 else 258 214 { … … 262 218 } 263 219 else if (nbytes == 0) 264 { 265 return 0; 266 } 220 return 0; 221 267 222 if (recvmsg[0] == 'E' && recvmsg[1] == 'N' && recvmsg[2] == 'D') 268 223 { … … 277 232 else 278 233 { 279 /*280 nbytes = recvfrom (sock, recvmsg, SH_MAXMSG, 0, NULL, 0);281 */282 234 nbytes = recv (sock, recvmsg, SH_MAXMSG, 0); 283 235 if (nbytes < 0) … … 290 242 /* Print a diagnostic message. */ 291 243 if (password[0] == '\0') 292 { 293 good = strcmp (message, recvmsg); 294 } 244 good = strcmp (message, recvmsg); 295 245 else 296 { 297 good = strcmp (&message[strlen(password)+1], recvmsg); 298 } 246 good = strcmp (&message[strlen(password)+1], recvmsg); 299 247 300 248 if (0 != good) 301 249 { 302 fprintf (stderr, "%s", _("ERROR: Bounced message != original message (possible reason: superfluous password).\n")); 250 if (0 == strncmp(recvmsg, _("!E:"), 3)) 251 { 252 fputs(recvmsg, stderr); 253 fputc('\n', stderr); 254 } 255 else 256 { 257 fputs (_("ERROR: Bounced message != original message.\n"), stderr); 258 } 303 259 return -1; 304 260 } … … 312 268 } 313 269 314 void usage(char * name) 270 static int check_uuid(const char * in) 271 { 272 int i; 273 const char *cp; 274 275 if (!in || strlen(in) != 36) 276 return -1; 277 for (i=0, cp = in; i <= 36; i++,cp++) { 278 if ((i == 8) || (i == 13) || (i == 18) || 279 (i == 23)) { 280 if (*cp == '-') 281 continue; 282 else 283 return -1; 284 } 285 if (i== 36) 286 if (*cp == 0) 287 continue; 288 if (!isxdigit(*cp)) 289 return -1; 290 } 291 return 0; 292 } 293 294 static int check_command(const char * str) 295 { 296 unsigned int i = 0; 297 char * commands[] = { N_("DELTA:"), N_("RELOAD"), N_("STOP"), N_("SCAN"), 298 N_("CANCEL"), N_("LISTALL"), N_("LIST"), N_("PROBE"), NULL }; 299 300 while (commands[i]) 301 { 302 size_t len = strlen(_(commands[i])); 303 304 if (0 == strncmp(_(commands[i]), str, len)) 305 { 306 if (i == 0) 307 { 308 char * p = strchr(str, ':'); ++p; 309 if ( 0 == check_uuid(p) ) 310 return 0; 311 } 312 else 313 { 314 if (len == strlen(str)) 315 return 0; 316 } 317 } 318 ++i; 319 } 320 321 fprintf (stderr, _("ERROR: invalid command <%s>\n\n"), str); 322 return -1; 323 } 324 325 static void print_usage_and_exit(char * name, int exit_status) 315 326 { 316 327 printf(_("\nUsage : %s [-v][-s server_socket] -c command <client_hostname>\n\n"), … … 325 336 printf("%s", _(" variable YULECTL_PASSWORD (not recommended).\n\n")); 326 337 327 printf("%s", _("Commands: RELOAD <reload configuration>\n")); 328 printf("%s", _(" STOP <terminate>\n")); 329 printf("%s", _(" SCAN <initiate file system check\n")); 330 printf("%s", _(" CANCEL <cancel previous command>\n")); 331 printf("%s", _(" LIST <list queued commands>\n")); 332 printf("%s", _(" LISTALL <list queued and last sent commands>\n")); 333 printf("%s", _(" PROBE <probe all clients for necessity of reload>\n")); 334 return; 338 printf("%s", _("Commands: RELOAD reload configuration\n")); 339 printf("%s", _(" DELTA:<uuid> load delta database with given uuid\n")); 340 printf("%s", _(" STOP terminate\n")); 341 printf("%s", _(" SCAN initiate file system check\n")); 342 printf("%s", _(" CANCEL cancel pending command(s)\n")); 343 printf("%s", _(" LIST list queued commands\n")); 344 printf("%s", _(" LISTALL list queued and last sent commands\n")); 345 printf("%s", _(" PROBE probe all clients for necessity of reload\n")); 346 exit(exit_status); 335 347 } 336 348 … … 339 351 size_t len; 340 352 341 if (!str) 342 return str; 353 if (!str) return str; 343 354 344 355 len = strlen(str); … … 351 362 break; 352 363 } 353 354 364 return str; 355 365 } 356 366 357 void fixup_message (char * message) 358 { 359 char message2[SH_MAXMSG]; 360 char home[4096]; 361 FILE * fp; 367 static int get_home(char * home, size_t size) 368 { 362 369 struct passwd * pwent; 363 char * pw; 364 365 pw = getenv(_("YULECTL_PASSWORD")); 366 if (pw && strlen(pw) < 15) 367 { 368 strcpy(password, pw); 369 strcpy(message2, password); 370 goto do_msg; 371 } 372 370 373 371 pwent = getpwuid(geteuid()); 374 372 if ((pwent == 0) || (pwent->pw_dir == NULL)) … … 379 377 if (NULL != getenv(_("HOME"))) 380 378 { 381 strncpy(home, getenv(_("HOME")), 4096); 382 home[4095] = '\0'; 379 safe_copy(home, getenv(_("HOME")), size); 383 380 } 384 381 else 385 382 { 386 383 fprintf (stderr, _("ERROR: no home directory for euid %ld (tried $HOME and password database).\n"), (long) geteuid()); 387 exit(EXIT_FAILURE);384 return -1; 388 385 } 389 386 } 390 387 else 391 388 { 392 strncpy(home, pwent->pw_dir, 4096); 393 home[4095] = '\0'; 394 } 389 safe_copy(home, pwent->pw_dir, size); 390 } 391 return 0; 392 } 393 394 static int get_passwd(char * message2, size_t size) 395 { 396 char home[4096]; 397 FILE * fp; 398 char * pw; 399 400 /* 1) Password from environment 401 */ 402 pw = getenv(_("YULECTL_PASSWORD")); 403 if (pw && strlen(pw) < 15) 404 { 405 strcpy(password, pw); 406 strcpy(message2, password); 407 return 0; 408 } 409 410 /* 2) Password from $HOME/.yule_cred 411 */ 412 if (get_home(home, sizeof(home)) < 0) 413 return -1; 395 414 396 415 if ( (strlen(home) + strlen(_("/.yulectl_cred")) + 1) > 4096) 397 416 { 398 417 fprintf (stderr, "%s", _("ERROR: path for $HOME is too long.\n")); 399 exit(EXIT_FAILURE);418 return -1; 400 419 } 401 420 strcat(home, _("/.yulectl_cred")); 402 421 fp = fopen(home, "r"); 403 422 404 #if !defined(HAVE_GETPEEREID) && !defined(SO_PEERCRED) && !defined(HAVE_STRUCT_CMSGCRED) && !defined(HAVE_STRUCT_FCRED) && !(defined(HAVE_STRUCT_SOCKCRED) && defined(LOCAL_CREDS))423 #if defined(SH_REQ_PASSWORD) 405 424 if (fp == NULL) 406 425 { … … 415 434 home, (long)geteuid(), (long)getuid()); 416 435 } 417 exit(EXIT_FAILURE);436 return -1; 418 437 } 419 438 #else 420 439 if (fp == NULL) 421 return ;440 return 0; 422 441 #endif 423 442 424 if (NULL == fgets(message2, size of(message2), fp))443 if (NULL == fgets(message2, size, fp)) 425 444 { 426 445 fprintf (stderr, 427 446 _("ERROR: empty or unreadable password file (%s).\n"), 428 447 home); 429 exit(EXIT_FAILURE);448 return -1; 430 449 } 431 450 … … 436 455 fprintf (stderr, "%s", 437 456 _("ERROR: Password too long (max. 14 characters).\n")); 438 exit(EXIT_FAILURE); 439 } 440 457 return -1; 458 } 441 459 strcpy(password, message2); 442 460 fclose(fp); 443 461 444 do_msg: 445 strcat(message2, "@"); 446 447 strncat(message2, message, SH_MAXMSG - strlen(message2) -1); 448 message2[SH_MAXMSG-1] = '\0'; 449 strcpy(message, message2); 462 return 0; 463 } 464 465 static int fixup_message (char * message) 466 { 467 char message_fixed[SH_MAXMSG] = { 0 }; 468 469 if (get_passwd(message_fixed, sizeof(message_fixed)) < 0) 470 return -1; 471 472 if (strlen(message_fixed) > 0) 473 { 474 strcat(message_fixed, "@"); 475 476 strncat(message_fixed, message, SH_MAXMSG - strlen(message_fixed) -1); 477 message_fixed[SH_MAXMSG-1] = '\0'; 478 strcpy(message, message_fixed); 479 } 480 return 0; 481 } 482 483 static int fill_serversock(char * serversock, size_t size) 484 { 485 int status; 486 487 #ifdef HAVE_VSNPRINTF 488 status = snprintf(serversock, size, _("%s/%s.sock"), 489 DEFAULT_PIDDIR, SH_INSTALL_NAME); 490 #else 491 if ((strlen(DEFAULT_PIDDIR) + strlen(SH_INSTALL_NAME) + 1 + 6) > size) 492 status = -1; 493 else 494 status = sprintf (serversock, _("%s/%s.sock"), 495 DEFAULT_PIDDIR, SH_INSTALL_NAME); 496 #endif 497 498 if ((status < 0) || (status > (int)(size-1))) 499 { 500 fprintf(stderr, _("ERROR: Path too long (maximum %d): %s/%s.sock\n"), 501 (int) (size-1), DEFAULT_PIDDIR, SH_INSTALL_NAME); 502 return -1; 503 } 504 return 0; 505 } 506 507 static void checklen(char * command, char * str, size_t maxlen) 508 { 509 if (strlen(str) > maxlen) 510 { 511 fprintf(stderr, _("ERROR: String too long (max %d): %s\n\n"), 512 (int) maxlen, str); 513 print_usage_and_exit (command, EXIT_FAILURE); 514 } 450 515 return; 451 516 } 452 517 518 static void checknull(char * command, char * str) 519 { 520 if (str == NULL || str[0] == '\0') { 521 fprintf(stderr, "%s", _("ERROR: option with missing argument\n\n")); 522 print_usage_and_exit(command, EXIT_FAILURE); 523 } 524 return; 525 } 453 526 454 527 int … … 457 530 458 531 char message[SH_MAXMSG] = ""; 459 char clientcd[1024];460 532 char serversock[256]; 461 int status , size;533 int status; 462 534 int num = 1; 463 535 int flag = 0; 464 465 #ifdef HAVE_VSNPRINTF 466 status = snprintf(serversock, 256, _("%s/%s.sock"), 467 DEFAULT_PIDDIR, SH_INSTALL_NAME); 468 #else 469 if ((strlen(DEFAULT_PIDDIR) + strlen(SH_INSTALL_NAME) + 1 + 6) > 256) 470 { 471 status = -1; 472 } 473 else 474 { 475 status = sprintf (serversock, _("%s/%s.sock"), 476 DEFAULT_PIDDIR, SH_INSTALL_NAME); 477 } 478 #endif 479 480 if ((status < 0) || (status > 255)) 481 { 482 fprintf(stderr, _("ERROR: Path too long (maximum 255): %s/%s.sock\n"), 483 DEFAULT_PIDDIR, SH_INSTALL_NAME); 484 return (EXIT_FAILURE); 485 } 536 537 if (fill_serversock(serversock, sizeof(serversock)) < 0) 538 return (EXIT_FAILURE); 539 486 540 487 541 while (argc > 1 && argv[num][0] == '-') … … 490 544 { 491 545 case 'h': 492 usage(argv[0]); 493 return (EXIT_SUCCESS); 494 546 print_usage_and_exit(argv[0], EXIT_SUCCESS); 547 break; 495 548 case 'v': 496 549 ++verbose; 497 550 break; 498 499 551 case 's': 500 552 --argc; ++num; 501 if (argv[num] == NULL || argv[num][0] == '\0') { 502 usage(argv[0]); 503 fprintf(stderr, "%s", _("ERROR: -s: argument missing\n")); 504 return (EXIT_FAILURE); 505 } else { 506 if (strlen(argv[num]) > 255) 507 { 508 fprintf(stderr, _("ERROR: Path too long: %s\n"), argv[num]); 509 return (EXIT_FAILURE); 510 } 511 strncpy (serversock, argv[num], 256); 512 serversock[255] = '\0'; 513 } 553 checknull(argv[0], argv[num]); 554 checklen(argv[0], argv[num], sizeof(serversock)-1); 555 safe_copy (serversock, argv[num], sizeof(serversock)); 514 556 break; 515 516 557 case 'c': 517 558 --argc; ++num; 518 if (argv[num] == NULL || argv[num][0] == '\0') { 519 usage(argv[0]); 520 fprintf(stderr, "%s", _("ERROR: -c: argument missing\n")); 521 return (EXIT_FAILURE); 522 } else { 523 if (strlen(argv[num]) >= SH_MAXMSG) 524 { 525 fprintf(stderr, _("ERROR: Command too long: %s\n"), 526 argv[num]); 527 return (EXIT_FAILURE); 528 } 529 strncpy (message, argv[num], SH_MAXMSG); 530 message[SH_MAXMSG-1] = '\0'; 531 strncat(message, ":", SH_MAXMSG-strlen(message)-1); 532 message[SH_MAXMSG-1] = '\0'; 533 flag = 1; 534 } 559 checknull(argv[0], argv[num]); 560 checklen(argv[0], argv[num], SH_MAXMSG-1); 561 if (0 != check_command(argv[num])) 562 print_usage_and_exit(argv[0], EXIT_FAILURE); 563 safe_copy(message, argv[num], SH_MAXMSG); 564 strncat(message, ":", SH_MAXMSG-strlen(message)-1); 565 message[SH_MAXMSG-1] = '\0'; 566 flag = 1; 535 567 break; 536 537 568 default: 538 usage(argv[0]);539 fprintf(stderr, _("ERROR: unknown option -%c\n"), argv[num][1]);540 return (EXIT_FAILURE);569 fprintf(stderr, _("ERROR: unknown option -%c\n\n"), argv[num][1]); 570 print_usage_and_exit(argv[0], EXIT_FAILURE); 571 break; 541 572 } 542 573 --argc; ++num; … … 544 575 545 576 if (flag == 0) /* no command given */ 546 { 547 usage(argv[0]); 548 return (EXIT_FAILURE); 549 } 577 print_usage_and_exit(argv[0], EXIT_FAILURE); 550 578 551 579 if (argc > 1) 552 580 { 553 if (strlen(argv[num]) > (SH_MAXMSG - strlen(message) -1)) 554 { 555 fprintf(stderr, _("ERROR: Hostname too long: %s\n"), argv[num]); 556 return (EXIT_FAILURE); 557 } 558 strncat (message, argv[num], SH_MAXMSG -strlen(message) - 1); 581 checklen(argv[0], argv[num], SH_MAXMSG - strlen(message) - 1); 582 strncat (message, argv[num], SH_MAXMSG - strlen(message) - 1); 559 583 message[SH_MAXMSG-1] = '\0'; 560 584 } 561 585 else 562 586 { 563 if ( message[0] == 'P' && message[1] == 'R' &&564 message[2] == 'O' && message[3] == 'B' && message[4] == 'E')587 if (0 == strncmp(message, _("PROBE"), 5) || 588 0 == strncmp(message, _("LIST"), 4)) 565 589 { 566 590 strncat (message, _("dummy"), SH_MAXMSG -strlen(message) - 1); 567 591 message[SH_MAXMSG-1] = '\0'; 568 592 } 569 else if (message[0] == 'L' && message[1] == 'I' &&570 message[2] == 'S' && message[3] == 'T')571 {572 strncat (message, _("dummy"), SH_MAXMSG -strlen(message) - 1);573 message[SH_MAXMSG-1] = '\0';574 }575 593 else 576 594 { 577 595 fprintf(stderr, "%s", _("ERROR: this command requires a hostname\n")); 578 usage(argv[0]); 579 return (EXIT_FAILURE); 580 } 581 } 582 583 fixup_message(message); 584 585 /* OpenBSD wants >= 1024 586 */ 587 if (NULL == getcwd(clientcd, 1024)) 588 { 589 perror(_("ERROR: getcwd")); 590 return (EXIT_FAILURE); 591 } 592 size = strlen(clientcd) + 1 + strlen(CLIENT) + 6; 593 sockname = calloc(1,size); 594 if (!sockname) 595 { 596 perror(_("ERROR: main: malloc")); 597 return (EXIT_FAILURE); 598 } 599 #ifdef HAVE_VSNPRINTF 600 snprintf(sockname, size, _("%s/%s.sock"), clientcd, CLIENT); 601 #else 602 sprintf(sockname, _("%s/%s.sock"), clientcd, CLIENT); 603 #endif 596 print_usage_and_exit(argv[0], EXIT_FAILURE); 597 } 598 } 599 600 if (fixup_message(message) < 0) 601 return (EXIT_FAILURE); 604 602 605 603 /* Make the socket. 606 604 */ 607 sock = make_named_socket (sockname);605 sock = create_unix_socket (); 608 606 if (sock < 0) 609 { 610 return (EXIT_FAILURE); 611 } 607 return (EXIT_FAILURE); 612 608 613 609 /* Set up termination handler. … … 630 626 /* Wait for a reply. 631 627 */ 632 if (message[0] == 'L' && message[1] == 'I' && 633 message[2] == 'S' && message[3] == 'T') 634 { 635 if (verbose) 628 if (verbose) 629 { 630 if (0 == strncmp(message, "LIST", 4)) 636 631 fprintf(stdout, "%s", _("# Waiting for listing.\n")); 637 } 638 else 639 { 640 if (verbose) 632 else 641 633 fprintf(stdout, "%s", _("# Waiting for confirmation.\n")); 642 634 } 635 643 636 status = recv_from_server (message); 644 637 645 638 if (status < 0) 646 639 { 647 fp rintf(stderr, "%s", _("ERROR: receiving data from server failed.\n"));640 fputs(_("ERROR: unexpected or no reply from server.\n"), stderr); 648 641 (void) termination_handler(0); 649 642 return (EXIT_FAILURE); -
trunk/src/zAVLTree.c
r474 r481 40 40 } 41 41 42 staticchar * dummy_zfree_string;42 char * dummy_zfree_string; 43 43 #ifdef __clang__ 44 staticchar * dummy_zfree_str;44 char * dummy_zfree_str; 45 45 #endif 46 46 … … 145 145 if (tree->keytype == zAVL_KEY_STRING) 146 146 { 147 return (strcmp((c har*)a, (char *)b));147 return (strcmp((const char*)a, (const char *)b)); 148 148 } 149 149 else /* zAVL_KEY_INT */ 150 150 { 151 int x = *((int *)a);152 int y = *((int *)b);151 const int x = *((const int *)a); 152 const int y = *((const int *)b); 153 153 154 154 if (x > y) return 1; -
trunk/test/test.sh
r235 r481 151 151 echo " ${S}test.sh 9${E} -- Process check" 152 152 echo " ${S}test.sh 10${E} -- Port check" 153 echo " ${S}test.sh 11${E} -- CL verify option" 154 echo " ${S}test.sh 12${E} -- CL create DeltaDB" 155 echo " ${S}test.sh 13${E} -- CL create/verify partial DB" 153 156 154 157 echo " ${S}test.sh 20${E} -- Test c/s init/check (testrc_2.in)" … … 157 160 echo " ${S}test.sh 23${E} -- Test full c/s w/mysql (testrc_2.in)" 158 161 echo " ${S}test.sh 24${E} -- Test full c/s w/postgres (testrc_2.in)" 162 echo " ${S}test.sh 25${E} -- Test server w/yulectl (testrc_2.in)" 163 echo " ${S}test.sh 26${E} -- Test c/s case one (testrc_2.in)" 164 echo " ${S}test.sh 27${E} -- Test c/s case two (testrc_2.in)" 159 165 echo " ${S}test.sh all${E} -- All tests" 160 166 } … … 164 170 echo " (1) testcompile.sh (2) testhash.sh (3) testrun_1.sh (4) testrun_1a.sh" 165 171 echo " (5) testext.sh (6) testtimesrv.sh (7) testrun_1b.sh (8) testrun_1c.sh" 166 echo " (9) testrun_1d.sh (10) testrun_1e.sh" 172 echo " (9) testrun_1d.sh (10) testrun_1e.sh (11) testrun_1f.sh (12) testrun_1g.sh" 173 echo " (13) testrun_1h.sh" 167 174 echo " (20) testrun_2.sh (21) testrun_2a.sh (22) testrun_2b.sh (23) testrun_2c.sh" 168 echo " (24) testrun_2d.sh "175 echo " (24) testrun_2d.sh (25) testrun_2e.sh (26) testrun_2f.sh (27) testrun_2g.sh" 169 176 } 170 177 … … 434 441 rm -f testrc_1ext 435 442 rm -f ./.samhain_file 443 rm -f file.*.*-*-*-*-* 436 444 rm -f ./.samhain_log* 437 445 rm -f ./.samhain_lock* … … 446 454 rm -f yule.html2 447 455 rm -f test_dnmalloc 456 rm -f tmp_list_file 457 rm -f test_filter.txt 448 458 } 449 459 … … 626 636 exit $? 627 637 fi 638 if test x$1 = x11; then 639 . ${SCRIPTDIR}/testrun_1.sh 640 . ${SCRIPTDIR}/testrun_1f.sh 641 testrun1f 642 print_summary 643 exit $? 644 fi 645 if test x$1 = x12; then 646 . ${SCRIPTDIR}/testrun_1.sh 647 . ${SCRIPTDIR}/testrun_1g.sh 648 testrun1g 649 print_summary 650 exit $? 651 fi 652 if test x$1 = x13; then 653 . ${SCRIPTDIR}/testrun_1.sh 654 . ${SCRIPTDIR}/testrun_1h.sh 655 testrun1h 656 print_summary 657 exit $? 658 fi 628 659 if test x$1 = x20; then 629 660 . ${SCRIPTDIR}/testrun_2.sh … … 659 690 exit $? 660 691 fi 692 if test x$1 = x25; then 693 . ${SCRIPTDIR}/testrun_2e.sh 694 testrun2e $hostname 695 print_summary 696 exit $? 697 fi 698 if test x$1 = x26; then 699 . ${SCRIPTDIR}/testrun_2f.sh 700 testrun2f $hostname 701 print_summary 702 exit $? 703 fi 704 if test x$1 = x27; then 705 . ${SCRIPTDIR}/testrun_2g.sh 706 testrun2g $hostname 707 print_summary 708 exit $? 709 fi 661 710 if test x$1 = xall; then 662 711 TEST_MAX=0 … … 681 730 . ${SCRIPTDIR}/testrun_1e.sh 682 731 let "TEST_MAX = TEST_MAX + MAXTEST" >/dev/null 732 . ${SCRIPTDIR}/testrun_1f.sh 733 let "TEST_MAX = TEST_MAX + MAXTEST" >/dev/null 734 . ${SCRIPTDIR}/testrun_1g.sh 735 let "TEST_MAX = TEST_MAX + MAXTEST" >/dev/null 736 . ${SCRIPTDIR}/testrun_1h.sh 737 let "TEST_MAX = TEST_MAX + MAXTEST" >/dev/null 683 738 . ${SCRIPTDIR}/testrun_2.sh 684 739 let "TEST_MAX = TEST_MAX + MAXTEST" >/dev/null … … 690 745 let "TEST_MAX = TEST_MAX + MAXTEST" >/dev/null 691 746 . ${SCRIPTDIR}/testrun_2d.sh 747 let "TEST_MAX = TEST_MAX + MAXTEST" >/dev/null 748 . ${SCRIPTDIR}/testrun_2e.sh 749 let "TEST_MAX = TEST_MAX + MAXTEST" >/dev/null 750 . ${SCRIPTDIR}/testrun_2f.sh 751 let "TEST_MAX = TEST_MAX + MAXTEST" >/dev/null 752 . ${SCRIPTDIR}/testrun_2g.sh 692 753 let "TEST_MAX = TEST_MAX + MAXTEST" >/dev/null 693 754 # … … 734 795 testrun1e 735 796 # 797 . ${SCRIPTDIR}/testrun_1.sh 798 . ${SCRIPTDIR}/testrun_1f.sh 799 MAXTEST=${TEST_MAX}; export MAXTEST 800 testrun1f 801 # 802 . ${SCRIPTDIR}/testrun_1.sh 803 . ${SCRIPTDIR}/testrun_1g.sh 804 MAXTEST=${TEST_MAX}; export MAXTEST 805 testrun1g 806 # 807 . ${SCRIPTDIR}/testrun_1.sh 808 . ${SCRIPTDIR}/testrun_1h.sh 809 MAXTEST=${TEST_MAX}; export MAXTEST 810 testrun1h 811 # 736 812 . ${SCRIPTDIR}/testrun_2.sh 737 813 MAXTEST=${TEST_MAX}; export MAXTEST … … 753 829 MAXTEST=${TEST_MAX}; export MAXTEST 754 830 testrun2d $hostname 831 # 832 . ${SCRIPTDIR}/testrun_2e.sh 833 MAXTEST=${TEST_MAX}; export MAXTEST 834 testrun2e $hostname 835 # 836 . ${SCRIPTDIR}/testrun_2f.sh 837 MAXTEST=${TEST_MAX}; export MAXTEST 838 testrun2f $hostname 839 # 840 . ${SCRIPTDIR}/testrun_2g.sh 841 MAXTEST=${TEST_MAX}; export MAXTEST 842 testrun2g $hostname 755 843 # 756 844 print_summary … … 768 856 769 857 __ARCHIVE_FOLLOWS__ 770 £ÉúDíÏoãDÇœ UbN\'€8*Û:IÓJpãÔ-ŠùÑBU!o2M771 þz&éf/#§šgGâßa%7U$ÄHšU{àÚš 772 ã$M¶Ûª.¬4Ù 773 Ï÷Þ×3!39΀§dän2;3ã.ïÕ]ýzïÕëóq.~Æ7ëqû\³ 774 môž< 775 äo'q²È&)+:2¯êL| 776 aùp×a!(-aDÀø²p% 777 R°×dŒ3ãK 858 p{Uí=lÛFÇé©Å!sÑ-diD&%r 859 #QŽÖ 860 ÙQ0ÒbÍ€d+Kеk¢@75kå¡l}!KaDÔ:µC=öÐÕ 861 ¥ØRA 862 8MûÄñþw÷ã;Ùñ(Å#ÛêR 1ìÜ[2?=^º0þ@bŒ~ËÒ^ÆÇR4ãcXôåž3IÑvd 863 BÊUY¯î÷ºöÿ)7]n 864 bD11QBpIH&yQ6EÙÎ/Àä"ÏÉtBž&ع² 865 pÍ,B¡,bL KÈRseèäUêȶe6xDZÔ{EÙ §jENkÐ0 866 h!YÓÊP3·ÉŸqG(kºi;P)Êl8î 867 Ø:ÚQml¹JÔTÂî1³6²JjÙcR 868 Û¯ëŠÅ. %d8Iä:ì7ÁÙ× 869 ¶@sü9!1RÉÙeC+OªgMªÞŸÔQ 870 ÓBi Iýb±Šõç5Û-ã\ 871 MÇ}.TËæT#g+÷c4l`g6Á¬jgxŒÏ 872 Ñ 873 e[Óbz±p£9ÀÆjg6AHFºiànxVÇõ+Gª#ñÒ®@¢e«ŠÅ4QÓ, 874 ;±4H i9ᢊ 875 778 876 779 "ÒZ'å 780 JÍÃO,ÔJAIÏF$H 781 CŠ²dGÁPCËi Ø1ûYðØVTäF$ ÀÛP74¬ªyši§ ¿iG(« LgeSÖzGLÀŠd{éEgÀËi:K9%ðiúkIÑ9€8r&ù-pþ782 xŸ\ãŠS«º·'4nœÈöo 783 ËiÝ0QØÐÑžýâc]Ö_PUÿlêCs?$ýT÷Ð(*&ö+ú¶1Že:ý`&³VdE=o¥ãušyhèÇÈcuÄÖë1×6WÜ¢4C§ÝhTâäÜAÉ/Ö 784 ù]nÞ1ÆP2kbÅÐCÔêwõ!ÃÈô:Íò 2I³ª*"B~ºF@Àñ³ÚÝ®ü=§Î 785 ®.npÉ 786 Ö±Áâ]GœhósM¹§Œð]))zöÁ{ (âž]787 NâUi×òÂKîœùÔ'|ÄÇp4çÑøûá{Þ¹ð¯GCºV}Ñt E4w¬ðáXÄ÷0êÐ788 Š)Xöÿ¶DU÷ ÅËÒû¯n 789 ËÚÝú>sþ[:®ÙÿÝ^Þ{ŸÿÏxœ^gÿ÷¹ÙþÿBx1ûÿO¿üÐùý¯œ:à 790 œ_y>¬^ýËïOE§,>/G)ÀÑö7žîÑÑÙ³ú.µ>>é>ý£[p.®|Cèðýã³'à.(|u¹;ô.§&žý;ýú[?öÓÿîøXù\9Žýfr 791 ݧ 792 nÁ¹žNZÊõÃÃfѶËõR§]Žª¥b»Ø²Ú 793 ë°T¬5:õF±TkÚ]ÈÙÿíèôìôQÉ79îëšÇŸ(øhŒ|®šÏÑš(»\Ž¬b«}xPjV«õZµa7êµJŲJr»b[Tfë VªÖ+TßÎN®Ñ$Ñu?ì×OÊߟ³àŒp¥&ÚïhjØ 794 «ÒŽ«õN˲[Z³U/µ*õ]?,µ*öA£ZîXV¥n7;Ã:=îþùëcg®úrR ZþÅS\%c§ž7{¢äâI`nÝ+ 795 ©D@ÌMûBgÝéœEa-^ú|7¢EgædFü8(íFdLOñÉ 796 ûâ 797 Á`0 798 Á`0 799 Á`0 800 F¿ès((877 ># èÚ±z 878 §+nhÔÝÁåð&SN0ZIŒ8Œ«h8ÛÂZb<^~$J+³QÕ(î| 879 Ý 880 ëvzYüÖËüô¢w;ÁÖü§tÂ|:}OºãÒŽ^_âJÅto ,ÑR"ž÷( 881 € £«|# 882 àr"zè 883 Š¹÷_ÿþÇõ<Nm¹ÿÇ%]ÃüÏŸ:ÿ³¬ÿ,ÿ3vó?KûIþŒüÿëo?õc¢ 884 `Þ{Òïñ;C]ÁeTÿª^^qËçNãTÆpëPÃÃÓÆ7]= 885 <ûkPqjï 886 Á£?Ô/O 887 PÔãӧà&š|9=¬üþðÉêÆÌš 888 üöþ0k!ÏDù/ÂúqªúMeð¬2šžÕît·[ýÝf³ßkµúµn£Õì4v[ûÝ~³ÛÚoWö:m¬7÷zZ 889 ¿zõ"¬ 890 Œ&žñ墣úw_Snùhÿ8uiÁõ«ûµN£±Ûk÷;j»ßݯï 891 tkœfµW7v»Õ^§^ëvêõÇ»œNïåàNÏzäÆ÷·Ÿ-5OA_ 892 óÚj¿çÊVüâæ(¯ ¢Éó$Ûﮢì 893 » 894 ž^HM 895 øb[Œy'ñ 896 ëhIæŒëw5o2 897 ÒÐb!f|81œ|·o 898 @ @ @ ð.ò7<Ì( -
trunk/test/testcompile.sh
r474 r481 157 157 if [ $? -eq 0 ]; then 158 158 isLinux=1 159 sed --in-place 's/-Wall/-Wall -Werror /' Makefile159 sed --in-place 's/-Wall/-Wall -Werror -Wpointer-arith -Wcast-qual/' Makefile 160 160 fi 161 161 # -
trunk/test/testhash.sh
r378 r481 63 63 fi 64 64 # 65 ${TOP_SRCDIR}/configure --enable-debug=gdb --quiet $TRUST --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$RCFILE --with-log-file=$LOGFILE --with-pid-file=$PW_DIR/.samhain_lock --with-data-file=$PW_DIR/.samhain_file --enable-db-reload '--enable-login-watch' '--enable-mounts-check' ${C_LOGFILE} '--enable-port-check' '--enable-suidcheck' '-- with-rnd=unix'65 ${TOP_SRCDIR}/configure --enable-debug=gdb --quiet $TRUST --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$RCFILE --with-log-file=$LOGFILE --with-pid-file=$PW_DIR/.samhain_lock --with-data-file=$PW_DIR/.samhain_file --enable-db-reload '--enable-login-watch' '--enable-mounts-check' ${C_LOGFILE} '--enable-port-check' '--enable-suidcheck' '--enable-message-queue' 66 66 # 67 67 fail=0 -
trunk/test/testrun_1.sh
r371 r481 42 42 43 43 MAXTEST=15; export MAXTEST 44 MAXTEST_3=15; export MAXTEST_3 44 45 45 46 test_dirs () { … … 1144 1145 } 1145 1146 1147 echo "${BASE}" > ./tmp_list_file 1148 1146 1149 for ff in $TDIRS; do 1147 1150 mkdir "${BASE}/${ff}" || { … … 1149 1152 return 1; 1150 1153 } 1154 echo "${BASE}/${ff}" >> ./tmp_list_file 1151 1155 chmod 0755 "${BASE}/${ff}" 1152 1156 for gg in $TFILES; do 1153 1157 echo "1 This is a test file" > "${BASE}/${ff}/${gg}" 1154 1158 chmod 0644 "${BASE}/${ff}/${gg}" 1159 echo "${BASE}/${ff}/${gg}" >> ./tmp_list_file 1155 1160 ln -s "${BASE}/${ff}/${gg}" "${BASE}/${ff}/l_${gg}" 1161 echo "${BASE}/${ff}/l_${gg}" >> ./tmp_list_file 1156 1162 done 1157 1163 echo "2 This is a test file" >> "${BASE}/${ff}/y" … … 1207 1213 POLICY=`eval echo '"$'"TESTPOLICY_$tcount"'"'` 1208 1214 1209 until [ -z "$POLICY"]1215 until [ ${tcount} -gt ${MAXTEST_3} ] 1210 1216 do 1211 1217 prep_init -
trunk/test/testrun_1a.sh
r155 r481 27 27 testrun_stealth () 28 28 { 29 tcount=1 429 tcount=1 30 30 31 31 if test -r "Makefile"; then -
trunk/test/testrun_2a.sh
r472 r481 23 23 RCFILE="$PW_DIR/testrc_2"; export RCFILE 24 24 25 SERVER_BUILDOPTS="--quiet $TRUST --enable-network=server --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=REQ_FROM_SERVER$PW_DIR/testrc_2 --with-data-file=REQ_FROM_SERVER$PW_DIR/.samhain_file --with-logserver=${SH_LOCALHOST} --with-log-file=$PW_DIR/.samhain_log --with-pid-file=$PW_DIR/.samhain_lock "; export SERVER_BUILDOPTS26 27 CLIENT_BUILDOPTS="--quiet $TRUST --enable-network=client --enable-srp --prefix=$PW_DIR --with-tmp-dir=$PW_DIR --localstatedir=$PW_DIR --with-config-file=REQ_FROM_SERVER$RCFILE --with-data-file=REQ_FROM_SERVER$PW_DIR/.samhain_file --with-log-file=$LOGFILE --with-pid-file=$PW_DIR/.samhain_lock --enable-suidcheck "; export CLIENT_BUILDOPTS25 SERVER_BUILDOPTS="--quiet $TRUST --enable-network=server --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=REQ_FROM_SERVER$PW_DIR/testrc_2 --with-data-file=REQ_FROM_SERVER$PW_DIR/.samhain_file --with-logserver=${SH_LOCALHOST} --with-log-file=$PW_DIR/.samhain_log --with-pid-file=$PW_DIR/.samhain_lock --enable-debug=gdb"; export SERVER_BUILDOPTS 26 27 CLIENT_BUILDOPTS="--quiet $TRUST --enable-network=client --enable-srp --prefix=$PW_DIR --with-tmp-dir=$PW_DIR --localstatedir=$PW_DIR --with-config-file=REQ_FROM_SERVER$RCFILE --with-data-file=REQ_FROM_SERVER$PW_DIR/.samhain_file --with-log-file=$LOGFILE --with-pid-file=$PW_DIR/.samhain_lock --enable-suidcheck --enable-debug"; export CLIENT_BUILDOPTS 28 28 29 29 do_test_1_a () { … … 233 233 } 234 234 235 MAXTEST= 6; export MAXTEST235 MAXTEST=4; export MAXTEST 236 236 237 237 testrun2a () … … 280 280 fi 281 281 # 282 SERVER_BUILDOPTS="${SERVER_BUILDOPTS_ORIG} -- enable-encrypt=1"; export SERVER_BUILDOPTS283 CLIENT_BUILDOPTS="${CLIENT_BUILDOPTS_ORIG} -- enable-encrypt=1"; export CLIENT_BUILDOPTS282 SERVER_BUILDOPTS="${SERVER_BUILDOPTS_ORIG} --disable-ipv6"; export SERVER_BUILDOPTS 283 CLIENT_BUILDOPTS="${CLIENT_BUILDOPTS_ORIG} --disable-ipv6"; export CLIENT_BUILDOPTS 284 284 # 285 285 testrun2a_internal 286 286 do_test_1_a 287 287 if [ $? -eq 0 ]; then 288 [ -z "$quiet" ] && log_ok 4 ${MAXTEST} " Encryption (v1)";288 [ -z "$quiet" ] && log_ok 4 ${MAXTEST} "IPv6 disabled"; 289 289 else 290 [ -z "$quiet" ] && log_fail 4 ${MAXTEST} "Encryption (v1)"; 291 fi 292 # 293 SERVER_BUILDOPTS="${SERVER_BUILDOPTS_ORIG}"; export SERVER_BUILDOPTS 294 CLIENT_BUILDOPTS="${CLIENT_BUILDOPTS_ORIG} --enable-encrypt=1"; export CLIENT_BUILDOPTS 295 # 296 testrun2a_internal 297 do_test_1_a 298 if [ $? -eq 0 ]; then 299 [ -z "$quiet" ] && log_ok 5 ${MAXTEST} "Encryption backward compat"; 300 else 301 [ -z "$quiet" ] && log_fail 5 ${MAXTEST} "Encryption backward compat"; 302 fi 303 # 304 SERVER_BUILDOPTS="${SERVER_BUILDOPTS_ORIG} --disable-ipv6"; export SERVER_BUILDOPTS 305 CLIENT_BUILDOPTS="${CLIENT_BUILDOPTS_ORIG} --disable-ipv6"; export CLIENT_BUILDOPTS 306 # 307 testrun2a_internal 308 do_test_1_a 309 if [ $? -eq 0 ]; then 310 [ -z "$quiet" ] && log_ok 6 ${MAXTEST} "IPv6 disabled"; 311 else 312 [ -z "$quiet" ] && log_fail 6 ${MAXTEST} "IPv6 disabled"; 290 [ -z "$quiet" ] && log_fail 4 ${MAXTEST} "IPv6 disabled"; 313 291 fi 314 292 # -
trunk/test/testrun_2d.sh
r207 r481 101 101 testrun2a_internal 102 102 # 103 for ff in ./rc.*; do 104 ORIGINAL="SetUdpActive=no" 105 REPLACEMENT="ReportCheckflags=yes" 106 ex -s rc.morrigan.localdomain <<EOF 107 %s/$ORIGINAL/$REPLACEMENT/g 108 wq 109 EOF 110 done 111 # 103 112 ORIGINAL="DatabaseSeverity=none" 104 113 REPLACEMENT="DatabaseSeverity=info"
Note:
See TracChangeset
for help on using the changeset viewer.