Changeset 214 for trunk


Ignore:
Timestamp:
Feb 17, 2009, 10:54:26 PM (16 years ago)
Author:
katerina
Message:

Rewrite mail subsystem for more flexibility (closes ticket #141).

Location:
trunk
Files:
18 edited

Legend:

Unmodified
Added
Removed
  • trunk/Makefile.in

    r209 r214  
    110110
    111111HEADERS = samhain.h sh_unix.h sh_utils.h sh_error.h sh_error_min.h sh_files.h \
    112         sh_getopt.h sh_readconf.h sh_tiger.h sh_hash.h sh_mail.h \
     112        sh_getopt.h sh_readconf.h sh_tiger.h sh_hash.h \
     113        sh_mail.h sh_mail_int.h sh_nmail.h \
    113114        sh_mem.h sh_entropy.h sh_forward.h sh_modules.h sh_utmp.h \
    114115        sh_kern.h sh_suidchk.h sh_srp.h sh_fifo.h sh_html.h sh_tools.h \
     
    128129        $(srcsrc)/sh_tiger1.c $(srcsrc)/sh_tiger2.c \
    129130        $(srcsrc)/sh_tiger1_64.c $(srcsrc)/sh_tiger2_64.c \
    130         $(srcsrc)/sh_hash.c $(srcsrc)/sh_mail.c \
     131        $(srcsrc)/sh_hash.c $(srcsrc)/sh_mail.c $(srcsrc)/sh_nmail.c \
    131132        $(srcsrc)/sh_mem.c $(srcsrc)/sh_entropy.c \
    132133        $(srcsrc)/sh_forward.c $(srcsrc)/sh_modules.c \
     
    163164        samhain.o sh_unix.o sh_utils.o sh_error.o \
    164165        sh_getopt.o sh_readconf.o \
    165         sh_hash.o sh_mail.o sh_mem.o \
     166        sh_hash.o sh_mail.o sh_nmail.o sh_mem.o \
    166167        sh_entropy.o sh_forward.o sh_modules.o sh_utmp.o sh_kern.o \
    167168        sh_suidchk.o sh_srp.o sh_fifo.o sh_tools.o sh_html.o sh_gpg.o \
     
    16521653
    16531654
    1654 samhain.o: $(srcsrc)/samhain.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_pthread.h $(srcinc)/sh_files.h $(srcinc)/sh_utils.h $(srcinc)/sh_error.h $(srcinc)/sh_unix.h $(srcinc)/sh_getopt.h $(srcinc)/sh_readconf.h $(srcinc)/sh_hash.h $(srcinc)/sh_mail.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.h
     1655samhain.o: $(srcsrc)/samhain.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_pthread.h $(srcinc)/sh_files.h $(srcinc)/sh_utils.h $(srcinc)/sh_error.h $(srcinc)/sh_unix.h $(srcinc)/sh_getopt.h $(srcinc)/sh_readconf.h $(srcinc)/sh_hash.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.h
    16551656sh_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_tiger.h $(srcinc)/sh_prelink.h $(srcinc)/sh_pthread.h $(srcinc)/sh_static.h $(srcinc)/sh_prelude.h $(srcinc)/sh_ignore.h
    16561657sh_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
    1657 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_mail.h $(srcinc)/sh_forward.h $(srcinc)/sh_prelude.h $(srcinc)/sh_pthread.h $(srcinc)/sh_tools.h $(srcinc)/sh_extern.h
     1658sh_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
    16581659sh_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)/zAVLTree.h
    16591660sh_getopt.o: $(srcsrc)/sh_getopt.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_error.h $(srcinc)/sh_getopt.h $(srcinc)/sh_files.h $(srcinc)/sh_utils.h $(srcinc)/sh_mail.h $(srcinc)/sh_forward.h $(srcinc)/sh_hash.h $(srcinc)/sh_extern.h
    1660 sh_readconf.o: $(srcsrc)/sh_readconf.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_error.h $(srcinc)/sh_database.h $(srcinc)/sh_unix.h $(srcinc)/sh_utils.h $(srcinc)/sh_files.h $(srcinc)/sh_mail.h $(srcinc)/sh_calls.h $(srcinc)/sh_tiger.h $(srcinc)/sh_forward.h $(srcinc)/sh_modules.h $(srcinc)/sh_gpg.h $(srcinc)/sh_hash.h $(srcinc)/sh_ignore.h $(srcinc)/sh_prelink.h $(srcinc)/sh_extern.h $(srcinc)/sh_tools.h $(srcinc)/sh_database.h $(srcinc)/sh_prelude.h
     1661sh_readconf.o: $(srcsrc)/sh_readconf.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_error.h $(srcinc)/sh_database.h $(srcinc)/sh_unix.h $(srcinc)/sh_utils.h $(srcinc)/sh_files.h $(srcinc)/sh_mail.h $(srcinc)/sh_nmail.h $(srcinc)/sh_calls.h $(srcinc)/sh_tiger.h $(srcinc)/sh_forward.h $(srcinc)/sh_modules.h $(srcinc)/sh_gpg.h $(srcinc)/sh_hash.h $(srcinc)/sh_ignore.h $(srcinc)/sh_prelink.h $(srcinc)/sh_extern.h $(srcinc)/sh_tools.h $(srcinc)/sh_database.h $(srcinc)/sh_prelude.h
    16611662sh_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
    16621663sh_tiger1.o: $(srcsrc)/sh_tiger1.c Makefile config_xor.h
     
    16651666sh_tiger2_64.o: $(srcsrc)/sh_tiger2_64.c Makefile config_xor.h
    16661667sh_hash.o: $(srcsrc)/sh_hash.c Makefile config_xor.h $(srcinc)/sh_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
    1667 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_static.h $(srcinc)/sh_tools.h
     1668sh_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_mail_int.h $(srcinc)/sh_nmail.h $(srcinc)/sh_static.h $(srcinc)/sh_tools.h
    16681669sh_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
    16691670sh_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
    1670 sh_forward.o: $(srcsrc)/sh_forward.c Makefile config_xor.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_mail.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
     1671sh_forward.o: $(srcsrc)/sh_forward.c Makefile config_xor.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
    16711672sh_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
    16721673sh_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
     
    16741675sh_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
    16751676sh_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
    1676 sh_fifo.o: $(srcsrc)/sh_fifo.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_mem.h $(srcinc)/sh_unix.h
     1677sh_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
    16771678sh_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)/rijndael-api-fst.h $(srcinc)/rijndael-api-fst.h
    16781679sh_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.h
     
    17241725sh_log_check.o: $(srcsrc)/sh_log_check.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_pthread.h $(srcinc)/sh_utils.h $(srcinc)/sh_string.h $(srcinc)/sh_log_check.h $(srcinc)/sh_log_evalrule.h $(srcinc)/sh_modules.h
    17251726sh_log_parse_samba.o: $(srcsrc)/sh_log_parse_samba.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_pthread.h $(srcinc)/sh_log_check.h $(srcinc)/sh_string.h
     1727sh_nmail.o: $(srcsrc)/sh_nmail.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_pthread.h $(srcinc)/sh_mem.h $(srcinc)/sh_mail.h $(srcinc)/sh_tiger.h $(srcinc)/sh_string.h $(srcinc)/sh_utils.h $(srcinc)/sh_fifo.h $(srcinc)/sh_mail_int.h $(srcinc)/zAVLTree.h
  • trunk/depend.dep

    r197 r214  
    11
    22# DO NOT DELETE THIS LINE
    3 samhain.o: $(srcsrc)/samhain.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_pthread.h $(srcinc)/sh_files.h $(srcinc)/sh_utils.h $(srcinc)/sh_error.h $(srcinc)/sh_unix.h $(srcinc)/sh_getopt.h $(srcinc)/sh_readconf.h $(srcinc)/sh_hash.h $(srcinc)/sh_mail.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.h
     3samhain.o: $(srcsrc)/samhain.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_pthread.h $(srcinc)/sh_files.h $(srcinc)/sh_utils.h $(srcinc)/sh_error.h $(srcinc)/sh_unix.h $(srcinc)/sh_getopt.h $(srcinc)/sh_readconf.h $(srcinc)/sh_hash.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.h
    44sh_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_tiger.h $(srcinc)/sh_prelink.h $(srcinc)/sh_pthread.h $(srcinc)/sh_static.h $(srcinc)/sh_prelude.h $(srcinc)/sh_ignore.h
    55sh_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_mail.h $(srcinc)/sh_forward.h $(srcinc)/sh_prelude.h $(srcinc)/sh_pthread.h $(srcinc)/sh_tools.h $(srcinc)/sh_extern.h
     6sh_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
    77sh_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)/zAVLTree.h
    88sh_getopt.o: $(srcsrc)/sh_getopt.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_error.h $(srcinc)/sh_getopt.h $(srcinc)/sh_files.h $(srcinc)/sh_utils.h $(srcinc)/sh_mail.h $(srcinc)/sh_forward.h $(srcinc)/sh_hash.h $(srcinc)/sh_extern.h
    9 sh_readconf.o: $(srcsrc)/sh_readconf.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_error.h $(srcinc)/sh_database.h $(srcinc)/sh_unix.h $(srcinc)/sh_utils.h $(srcinc)/sh_files.h $(srcinc)/sh_mail.h $(srcinc)/sh_calls.h $(srcinc)/sh_tiger.h $(srcinc)/sh_forward.h $(srcinc)/sh_modules.h $(srcinc)/sh_gpg.h $(srcinc)/sh_hash.h $(srcinc)/sh_ignore.h $(srcinc)/sh_prelink.h $(srcinc)/sh_extern.h $(srcinc)/sh_tools.h $(srcinc)/sh_database.h $(srcinc)/sh_prelude.h
     9sh_readconf.o: $(srcsrc)/sh_readconf.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_error.h $(srcinc)/sh_database.h $(srcinc)/sh_unix.h $(srcinc)/sh_utils.h $(srcinc)/sh_files.h $(srcinc)/sh_mail.h $(srcinc)/sh_nmail.h $(srcinc)/sh_calls.h $(srcinc)/sh_tiger.h $(srcinc)/sh_forward.h $(srcinc)/sh_modules.h $(srcinc)/sh_gpg.h $(srcinc)/sh_hash.h $(srcinc)/sh_ignore.h $(srcinc)/sh_prelink.h $(srcinc)/sh_extern.h $(srcinc)/sh_tools.h $(srcinc)/sh_database.h $(srcinc)/sh_prelude.h
    1010sh_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
    1111sh_tiger1.o: $(srcsrc)/sh_tiger1.c Makefile config_xor.h
     
    1414sh_tiger2_64.o: $(srcsrc)/sh_tiger2_64.c Makefile config_xor.h
    1515sh_hash.o: $(srcsrc)/sh_hash.c Makefile config_xor.h $(srcinc)/sh_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
    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_static.h $(srcinc)/sh_tools.h
     16sh_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_mail_int.h $(srcinc)/sh_nmail.h $(srcinc)/sh_static.h $(srcinc)/sh_tools.h
    1717sh_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
    1818sh_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 sh_forward.o: $(srcsrc)/sh_forward.c Makefile config_xor.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_mail.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
     19sh_forward.o: $(srcsrc)/sh_forward.c Makefile config_xor.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
    2020sh_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
    2121sh_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
     
    2323sh_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
    2424sh_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
    25 sh_fifo.o: $(srcsrc)/sh_fifo.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_mem.h $(srcinc)/sh_unix.h
     25sh_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
    2626sh_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)/rijndael-api-fst.h $(srcinc)/rijndael-api-fst.h
    2727sh_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.h
     
    7575sh_log_check.o: $(srcsrc)/sh_log_check.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_pthread.h $(srcinc)/sh_utils.h $(srcinc)/sh_string.h $(srcinc)/sh_log_check.h $(srcinc)/sh_log_evalrule.h $(srcinc)/sh_modules.h
    7676sh_log_parse_samba.o: $(srcsrc)/sh_log_parse_samba.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_pthread.h $(srcinc)/sh_log_check.h $(srcinc)/sh_string.h
     77sh_nmail.o: $(srcsrc)/sh_nmail.c Makefile config_xor.h $(srcinc)/samhain.h $(srcinc)/sh_pthread.h $(srcinc)/sh_mem.h $(srcinc)/sh_mail.h $(srcinc)/sh_tiger.h $(srcinc)/sh_string.h $(srcinc)/sh_utils.h $(srcinc)/sh_fifo.h $(srcinc)/sh_mail_int.h $(srcinc)/zAVLTree.h
  • trunk/depend.sum

    r197 r214  
    1 3645502766
     11874099800
  • trunk/docs/Changelog

    r212 r214  
    112.5.3:
     2        * rewrite mail subsystem to allow individual filtering
     3          for recipients
    24        * allow shell expansion for values of config file options
    35        * allow list as value for option PortCheckInterface
  • trunk/include/sh_fifo.h

    r1 r214  
    1010 *****************************************************/
    1111
    12 #define SH_FIFO_MAX 128
     12#define SH_FIFO_MAX 16384
    1313
    1414/*****************************************************
     
    2121  struct dlist * next;
    2222  char         * data;
     23  char         * s_xtra;
     24  int            i_xtra;
     25  int            transact;
    2326  struct dlist * prev;
    2427};
     
    4750 * Returns: -1 if the list is full, 0 on success
    4851 */
    49 int push_list (SH_FIFO * fifo, char * indat);
     52int push_list (SH_FIFO * fifo, char * indat, int in_i, const char * in_str);
    5053
    5154/* Push an item on the tail of the list.
     
    5356 * Returns: -1 if the list is full, 0 on success
    5457 */
    55 int push_tail_list (SH_FIFO * fifo, char * indat);
     58int push_tail_list (SH_FIFO * fifo, char * indat, int in_i, const char * in_str);
    5659
    5760/* pop an item from the tail of the list
     
    6265char * pop_list (SH_FIFO * fifo);
    6366
     67
     68sh_string * tag_list (SH_FIFO * fifo, char * tag,
     69                      int(*check)(int, const char*, const char*, const void*),
     70                      const void * info);
     71void rollback_list (SH_FIFO * fifo);
     72void mark_list (SH_FIFO * fifo);
     73void reset_list (SH_FIFO * fifo);
     74int commit_list (SH_FIFO * fifo);
     75
    6476#endif
  • trunk/include/sh_mail.h

    r22 r214  
    5252/* call if not urgent
    5353 */
    54 int sh_mail_pushstack (/*@null@*/char * msg);
    55 
    56 /* call if mail immediate
    57  */
    58 int sh_mail_msg (/*@null@*/char * message);
     54int sh_mail_pushstack (int severity, const char * msg, const char * alias);
    5955
    6056/* set sender of mail
  • trunk/include/sh_pthread.h

    r170 r214  
    3030
    3131#define SH_MUTEX_LOCK_UNSAFE(M) pthread_mutex_lock(&(M))
     32#define SH_MUTEX_TRYLOCK_UNSAFE(M) pthread_mutex_trylock(&(M))
    3233#define SH_MUTEX_UNLOCK_UNSAFE(M) pthread_mutex_unlock(&(M))
    3334
     
    140141#define SH_MUTEX_UNLOCK(M)                      ((void)0)
    141142#define SH_MUTEX_LOCK_UNSAFE(M)                 ((void)0)
     143#define SH_MUTEX_TRYLOCK_UNSAFE(M)              (0)
    142144#define SH_MUTEX_UNLOCK_UNSAFE(M)               ((void)0)
    143145
  • trunk/include/sh_utils.h

    r185 r214  
    4040  unsigned long   data_ulong;
    4141  long            data_long;
    42   /*@null@*/char *data_str;
     42  char          *data_str;
    4343} st_format;
    4444
     
    131131/* a simple compressor
    132132 */
    133 long sh_util_compress (char * dest, char * src, size_t dest_size);
     133size_t sh_util_compress (char * dest, char * src, size_t dest_size);
    134134
    135135/* an even simpler en-/decoder
  • trunk/include/slib.h

    r212 r214  
    203203   * strstr
    204204   */
    205   const char * sl_strstr (const char * haystack, const char * needle);
     205  char * sl_strstr (const char * haystack, const char * needle);
    206206
    207207  /*
  • trunk/src/samhain.c

    r207 r214  
    7272#include "sh_hash.h"
    7373
    74 #include "sh_mail.h"
     74#include "sh_nmail.h"
    7575
    7676#include "sh_tiger.h"
     
    521521   */
    522522#if defined(SH_WITH_MAIL)
    523   if (0 == strcmp (DEFAULT_MAILADDRESS, _("NULL")))
     523  if (0 != strcmp (DEFAULT_MAILADDRESS, _("NULL")))
    524524    {
    525525#if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_STRTOK_R)
     
    529529      if (p)
    530530        {
    531           (void) sh_mail_setaddress_int (p);
     531          (void) sh_nmail_add_compiled_recipient (p);
    532532          while (NULL != (p = strtok_r (NULL, ", \t", &saveptr)))
    533             (void) sh_mail_setaddress_int (p);
     533            (void) sh_nmail_add_compiled_recipient (p);
    534534        }
    535535#else
     
    538538      if (p)
    539539        {
    540           (void) sh_mail_setaddress_int (p);
     540          (void) sh_nmail_add_compiled_recipient (p);
    541541          while (NULL != (p = strtok (NULL, ", \t")))
    542             (void) sh_mail_setaddress_int (p);
     542            (void) sh_nmail_add_compiled_recipient (p);
    543543        }
    544544#endif
     
    725725  if (sh.mailNum.alarm_last > 0)
    726726    {
    727       (void) sh_mail_msg (NULL);
     727      (void) sh_nmail_flush ();
    728728    }
    729729#endif
     
    17771777#endif
    17781778
    1779 #if defined(SH_WITH_MAIL)
    1780               reset_count_dev_mail();
    1781 #endif
    17821779              reset_count_dev_console();
    17831780              reset_count_dev_time();
     
    20572054#if defined(SH_WITH_MAIL)
    20582055          TPT((0, FIL__, __LINE__, _("msg=<Flush mail queue.>\n")))
    2059           (void) sh_mail_msg (NULL);
     2056          (void) sh_nmail_flush ();
    20602057#endif
    20612058        }
     
    21082105        {
    21092106          TPT((0, FIL__, __LINE__, _("msg=<Flush mail queue.>\n")))
    2110           (void) sh_mail_msg (NULL);
     2107          (void) sh_nmail_flush ();
    21112108          sh.mailTime.alarm_last = time (NULL);
    21122109        }
     
    21572154#if defined(SH_WITH_MAIL)
    21582155  if (sh.mailNum.alarm_last > 0)
    2159     (void)sh_mail_msg (NULL);
     2156    (void)sh_nmail_flush ();
    21602157#endif
    21612158
  • trunk/src/sh_error.c

    r181 r214  
    5858#include "sh_unix.h"
    5959#include "sh_tiger.h"
    60 #include "sh_mail.h"
     60#include "sh_nmail.h"
    6161#include "sh_forward.h"
    6262#include "sh_prelude.h"
     
    12271227              mail_block = 1;
    12281228
    1229               BREAKEXIT(sh_mail_msg);
     1229              BREAKEXIT(sh_nmail_msg);
    12301230              if ( (severity & SH_ERR_FATAL) == 0)
    1231                 retval = sh_mail_pushstack (lmsg->msg);
     1231                retval = sh_nmail_pushstack (severity, lmsg->msg, NULL);
    12321232              else
    1233                 retval = sh_mail_msg (lmsg->msg);
     1233                retval = sh_nmail_msg (severity, lmsg->msg, NULL);
    12341234
    12351235              mail_block = 0;
  • trunk/src/sh_extern.c

    r212 r214  
    13801380
    13811381      for (i = 0; i < task->fand_c; ++i)
    1382         if (NULL != sl_strstr(message, task->fand_v[i]))
    1383           ++j;
    1384 
    1385       if (j != task->fand_c)
    1386         {
    1387           SL_RETURN ((-1), _("sh_ext_filter"));
     1382        {
     1383          if (NULL == sl_strstr(message, task->fand_v[i]))
     1384            {
     1385              SL_RETURN ((-1), _("sh_ext_filter"));
     1386            }
    13881387        }
    13891388
  • trunk/src/sh_fifo.c

    r22 r214  
    3232#include "sh_mem.h"
    3333#include "sh_unix.h"
     34#include "sh_utils.h"
     35#include "sh_string.h"
     36#include "sh_fifo.h"
    3437
    3538#if defined(HAVE_MLOCK) && !defined(HAVE_BROKEN_MLOCK)
     
    3740#endif
    3841
    39 #define SH_FIFO_MAX 128
    40 
    41 struct dlist {
    42   /*@null@*//*@dependent@*/ struct dlist * next;
    43   char         * data;
    44   /*@null@*//*@dependent@*/ struct dlist * prev;
    45 };
    46 
    47 typedef struct fifo_str {
    48   /*@null@*//*@dependent@*/ struct dlist * head_ptr;
    49   /*@null@*//*@dependent@*/ struct dlist * tail_ptr;
    50   int            fifo_cts;
    51 } SH_FIFO;
    52 
    53 
     42#define SH_FIFO_TAGGED 1
     43#define SH_FIFO_M_FAIL 2
     44#define SH_FIFO_MARKED 4
     45
     46/* Prepare an email message and return it.
     47 */
     48sh_string * tag_list (SH_FIFO * fifo, char * tag,
     49                      int(*valid)(int, const char*, const char*, const void*),
     50                      const void * info)
     51{
     52  struct dlist * item;
     53  sh_string * result = NULL;
     54
     55  if (fifo && fifo->fifo_cts > 0)
     56    {
     57      item = fifo->head_ptr;
     58
     59      while (item)
     60        {
     61          if ( (tag && item->s_xtra && 0 == strcmp(item->s_xtra, tag)) ||
     62               !(item->s_xtra) )
     63            {
     64              if (valid == NULL)
     65                {
     66                  item->transact |= SH_FIFO_TAGGED;
     67                }
     68              else
     69                {
     70                  if (!valid(item->i_xtra, item->data, tag, info))
     71                    goto skipped;
     72                  item->transact |= SH_FIFO_TAGGED;
     73                }
     74              if (!result)
     75                {
     76                  result = sh_string_new_from_lchar(item->data, strlen(item->data));
     77                }
     78              else
     79                {
     80                  result = sh_string_cat_lchar(result, "\r\n", 2);
     81                  result = sh_string_add_from_char(result, item->data);
     82                }
     83            }
     84        skipped:
     85          item = item->next;
     86        }
     87    }
     88  return result;
     89}
     90
     91void rollback_list (SH_FIFO * fifo)
     92{
     93  struct dlist * item;
     94
     95  if (fifo && fifo->fifo_cts > 0)
     96    {
     97      item = fifo->head_ptr;
     98
     99      while (item && 0 != (item->transact & SH_FIFO_TAGGED))
     100        {
     101          item->transact |= SH_FIFO_M_FAIL;
     102          item = item->next;
     103        }
     104    }
     105}
     106
     107void mark_list (SH_FIFO * fifo)
     108{
     109  struct dlist * item;
     110
     111  if (fifo && fifo->fifo_cts > 0)
     112    {
     113      item = fifo->head_ptr;
     114
     115      while (item && 0 != (item->transact & SH_FIFO_TAGGED))
     116        {
     117          item->transact |= SH_FIFO_MARKED;
     118          item = item->next;
     119        }
     120    }
     121}
     122
     123void reset_list (SH_FIFO * fifo)
     124{
     125  struct dlist * item;
     126
     127  if (fifo && fifo->fifo_cts > 0)
     128    {
     129      item = fifo->head_ptr;
     130
     131      while (item)
     132        {
     133          item->transact = 0;
     134          item = item->next;
     135        }
     136    }
     137}
     138
     139int commit_list (SH_FIFO * fifo)
     140{
     141  struct dlist * item;
     142  struct dlist * getit;
     143  int    retval = 0;
     144
     145  if (fifo && fifo->fifo_cts > 0)
     146    {
     147      item = fifo->head_ptr;
     148
     149      while (item)
     150        {
     151          getit = NULL;
     152
     153          if ( 0 != (item->transact & SH_FIFO_MARKED) && /* sent              */
     154               0 == (item->transact & SH_FIFO_M_FAIL) )  /* no recipient fail */
     155            {
     156              if (item == fifo->head_ptr)
     157                fifo->head_ptr   = item->next;
     158              if (item == fifo->tail_ptr)
     159                fifo->tail_ptr   = item->prev;
     160              if (item->prev)
     161                item->prev->next = item->next;
     162              if (item->next)
     163                item->next->prev = item->prev;
     164              --(fifo->fifo_cts);
     165              getit = item;
     166            }
     167          item  = item->next;
     168
     169          /* Delete it
     170           */
     171          if (getit)
     172            {
     173              size_t len = sl_strlen(getit->data);
     174              memset(getit->data, 0, len);
     175              if (NULL != sl_strstr (getit->data, _("LOGKEY")))
     176                {
     177                  MUNLOCK(getit->data, (len+1));
     178                  ;
     179                }
     180              if (getit->s_xtra)
     181                SH_FREE(getit->s_xtra);
     182              SH_FREE(getit->data);
     183              SH_FREE(getit);
     184              ++retval;
     185            }
     186        }
     187    }
     188  return retval;
     189}
    54190
    55191/* push an item on the head of the list
    56192 */
    57 int push_list (SH_FIFO * fifo, char * indat)
     193int push_list (SH_FIFO * fifo, char * indat, int in_i, const char * in_str)
    58194{
    59195  struct dlist * item;
     
    79215    }
    80216  item            = SH_ALLOC(sizeof(struct dlist));
    81   /*@i@*/ item->data      = SH_ALLOC(len+1);
     217  item->data      = SH_ALLOC(len+1);
    82218 
    83219  if (NULL != sl_strstr (indat, _("LOGKEY")))
     
    90226  item->data[len] = '\0';
    91227
     228  item->i_xtra = in_i;
     229  if (in_str)
     230    item->s_xtra = sh_util_strdup(in_str);
     231  else
     232    item->s_xtra = NULL;
     233  item->transact = 0;
     234
    92235  if (fifo->tail_ptr == NULL)
    93236    {
     
    97240  else
    98241    {
    99       /*@i@*/ fifo->head_ptr->prev = item;
     242      fifo->head_ptr->prev = item;
    100243      item->prev           = NULL;
    101244    }
     
    111254/* push an item on the tail of the list
    112255 */
    113 int push_tail_list (SH_FIFO * fifo, char * indat)
     256int push_tail_list (SH_FIFO * fifo, char * indat, int in_i, const char * in_str)
    114257{
    115258  struct dlist * item;
     
    135278
    136279  item            = SH_ALLOC(sizeof(struct dlist));
    137   /*@i@*/item->data      = SH_ALLOC(len+1);
     280  item->data      = SH_ALLOC(len+1);
    138281
    139282  if (NULL != sl_strstr (indat, _("LOGKEY")))
     
    145288  sl_strlcpy (item->data, indat, len+1);
    146289  item->data[len] = '\0';
     290
     291  item->i_xtra = in_i;
     292  if (in_str)
     293    item->s_xtra = sh_util_strdup(in_str);
     294  else
     295    item->s_xtra = NULL;
     296  item->transact = 0;
    147297
    148298  if (fifo->head_ptr == NULL)
     
    205355    }
    206356
     357  if (getit->s_xtra)
     358    SH_FREE(getit->s_xtra);
    207359  SH_FREE(getit->data);
    208360  SH_FREE(getit);
  • trunk/src/sh_forward.c

    r210 r214  
    131131#include "sh_entropy.h"
    132132#include "sh_html.h"
    133 #include "sh_mail.h"
     133#include "sh_nmail.h"
    134134#include "sh_socket.h"
    135135#define SH_NEED_GETHOSTBYXXX
     
    791791      if (status != 0)
    792792        {
    793           (void) push_tail_list (fifo, popmsg);
     793          (void) push_tail_list (fifo, popmsg, 0, NULL);
    794794          SH_FREE(popmsg);
    795           if (SH_FIFO_MAX == push_list (fifo, errmsg))
     795          if (SH_FIFO_MAX == push_list (fifo, errmsg, 0,NULL))
    796796            {
    797797              SL_RETURN (-2, _("sh_forward"));
     
    812812                         sh.srvexport.name);
    813813      failed = BAD;
    814       if (SH_FIFO_MAX == push_list (fifo, errmsg))    /* push message on stack */
     814      if (SH_FIFO_MAX == push_list (fifo, errmsg, 0, NULL))/* push on stack */
    815815        {
    816816          SL_RETURN (-2, _("sh_forward"));
     
    50625062            sh_forward_mark_dead ();
    50635063
    5064 #if defined(SH_WITH_MAIL)
    5065             reset_count_dev_mail();
    5066 #endif
    50675064            reset_count_dev_console();
    50685065            reset_count_dev_time();
     
    52845281        {
    52855282          TPT((0, FIL__, __LINE__, _("msg=<Flush mail queue.>\n")))
    5286           (void) sh_mail_msg (NULL);
     5283          (void) sh_nmail_flush ();
    52875284          sh.mailTime.alarm_last = tcurrent;
    52885285        }
  • trunk/src/sh_mail.c

    r210 r214  
    5959#include "sh_tools.h"
    6060#include "sh_pthread.h"
     61#include "sh_mail_int.h"
     62#include "sh_nmail.h"
    6163
    6264#undef  FIL__
     
    6769static int failedMail = SL_FALSE;
    6870
    69 /* MX Resolver Struct
    70  */
    71 typedef struct mx_ {
    72   int    pref;
    73   char * address;
    74 } mx;
    75 
    76 typedef struct dnsrep_ {
    77   int    count;
    78   mx   * reply;
    79 } dnsrep;
    80 
    81 static int free_mx (dnsrep * answers);
    8271static dnsrep * return_mx (char *domain);
    8372
     
    258247}
    259248
    260 #define SH_FILT_NUM 32
    261 #define SH_FILT_OR  0
    262 #define SH_FILT_AND 1
    263 #define SH_FILT_NOT 2
    264 #define SH_FILT_INIT { 0, { NULL }, 0, { NULL }, 0, { NULL }}
    265 
    266 typedef struct _sh_filter_type
    267 {
    268   int      for_c;
    269   char   * for_v[SH_FILT_NUM];
    270   int      fand_c;
    271   char   * fand_v[SH_FILT_NUM];
    272   int      fnot_c;
    273   char   * fnot_v[SH_FILT_NUM];
    274 
    275 } sh_filter_type;
    276 
    277 static
     249void sh_filter_filterfree (sh_filter_type * filter)
     250{
     251  int i;
     252
     253  if (filter)
     254    {
     255      for (i = 0; i < filter->for_c; ++i) {
     256        if (filter->for_v[i])
     257          SH_FREE(filter->for_v[i]);
     258        filter->for_v[i] = NULL;
     259      }
     260      filter->for_c = 0;
     261      for (i = 0; i < filter->fand_c; ++i) {
     262        if (filter->fand_v[i])
     263          SH_FREE(filter->fand_v[i]);
     264        filter->fand_v[i] = NULL;
     265      }
     266      filter->fand_c = 0;
     267      for (i = 0; i < filter->fnot_c; ++i) {
     268        if (filter->fnot_v[i])
     269          SH_FREE(filter->fnot_v[i]);
     270        filter->fnot_v[i] = NULL;
     271      }
     272      filter->fnot_c = 0;
     273    }
     274}
     275
    278276int sh_filter_filteradd (const char * argstring,
    279277                         sh_filter_type * filter, int ftype)
     
    375373
    376374/*
    377  * -- check filters
    378  */
    379 static
     375 * -- Check filters. Returns 0 if message passes.
     376 */
    380377int sh_filter_filter (const char * message, sh_filter_type * filter)
    381378{
    382379  int i;
    383   int j = 0;
    384 
    385   SL_ENTER(_("sh_mail_filter"));
    386 
    387   /* Presence of any of these keywords prevents execution.
    388    */
    389   if (filter->fnot_c > 0)
    390     {
    391       for (i = 0; i < filter->fnot_c; ++i)
    392         {
    393           if (NULL != sl_strstr(message, filter->fnot_v[i]))
     380
     381  SL_ENTER(_("sh_filter_filter"));
     382
     383  if (filter)
     384    {
     385
     386      /* Presence of any of these keywords prevents execution.
     387       */
     388      if (filter->fnot_c > 0)
     389        {
     390          for (i = 0; i < filter->fnot_c; ++i)
    394391            {
    395               SL_RETURN ((-1), _("sh_filter_filter"));
     392              if (NULL != sl_strstr(message, filter->fnot_v[i]))
     393                {
     394                  SL_RETURN ((-1), _("sh_filter_filter"));
     395                }
    396396            }
    397397        }
    398     }
    399 
    400   /* Presence of all of these keywords is required for execution.
    401    */
    402   if (filter->fand_c > 0)
    403     {
    404       j = 0;
    405 
    406       for (i = 0; i < filter->fand_c; ++i)
    407         if (NULL != sl_strstr(message, filter->fand_v[i]))
    408           ++j;
    409 
    410       if (j != filter->fand_c)
    411         {
     398     
     399      /* Presence of all of these keywords is required for execution.
     400       */
     401      if (filter->fand_c > 0)
     402        {
     403          for (i = 0; i < filter->fand_c; ++i)
     404            {
     405              if (NULL == sl_strstr(message, filter->fand_v[i]))
     406                {
     407                  SL_RETURN ((-1), _("sh_filter_filter"));
     408                }
     409            }
     410        }
     411     
     412      /* Presence of at least one of these keywords is required for execution.
     413       */
     414      if (filter->for_c > 0)
     415        {
     416          for (i = 0; i < filter->for_c; ++i)
     417            {
     418              if (NULL != sl_strstr(message, filter->for_v[i]))
     419                {
     420                  goto isok;
     421                }
     422            }
    412423          SL_RETURN ((-1), _("sh_filter_filter"));
    413424        }
    414     }
    415 
    416   /* Presence of at least one of these keywords is required for execution.
    417    */
    418   if (filter->for_c > 0)
    419     {
    420       for (i = 0; i < filter->for_c; ++i)
    421         {
    422           if (NULL != sl_strstr(message, filter->for_v[i]))
    423             {
    424               goto isok;
    425             }
    426         }
    427       SL_RETURN ((-1), _("sh_filter_filter"));
    428425    }
    429426
    430427 isok:
    431428  SL_RETURN ((0), _("sh_filter_filter"));
    432 }
    433 
    434 
    435 static sh_filter_type mail_filter = SH_FILT_INIT;
    436 
    437 /*
    438  * -- add keywords to the OR filter
    439  */
    440 int sh_mail_add_or (const char * str)
    441 {
    442   return (sh_filter_filteradd (str, &(mail_filter), SH_FILT_OR));
    443 }
    444 
    445 /*
    446  * -- add keywords to the AND filter
    447  */
    448 int sh_mail_add_and (const char * str)
    449 {
    450   return (sh_filter_filteradd (str, &(mail_filter), SH_FILT_AND));
    451 }
    452 
    453 /*
    454  * -- add keywords to the NOT filter
    455  */
    456 int sh_mail_add_not (const char * str)
    457 {
    458   return (sh_filter_filteradd (str, &(mail_filter), SH_FILT_NOT));
    459 }
    460 
    461 
    462 static char * address_list[8] = {
    463   NULL, NULL, NULL, NULL,
    464   NULL, NULL, NULL, NULL
    465 };
    466 
    467 static   int   address_num = 0;
    468 static   int   address_num_compiled = 0;
    469 static   int   setaddress_compiled = S_FALSE;
    470 
    471 void reset_count_dev_mail(void)
    472 {
    473   /* if not, then we still have the compiled-in address (if any), so we
    474    * don' touch them
    475    */
    476   if (address_num_compiled == -99)
    477     address_num = 0;
    478   return;
    479 }
    480 
    481 int sh_mail_setaddress (const char * address)
    482 {
    483   char     *     p;
    484 
    485   SL_ENTER(_("sh_mail_setaddress"));
    486  
    487   if (0 == strcmp(address, _("NULL")))
    488     SL_RETURN ( (0), _("sh_mail_setaddress"));
    489    
    490   if (address != NULL && address_num < (2 * SH_PATHBUF / 64 ))
    491     {
    492       if (address_num < (SH_PATHBUF / 64 ))
    493         p = &sh.srvmail.name[address_num*64];
    494       else
    495         p = &sh.srvmail.alt[address_num*64];
    496 
    497       (void) sl_strlcpy (p, address, 64);
    498      
    499       if ((p == NULL) || ( sl_strlen(address) != sl_strlen(p)))
    500         {
    501           memset(p, (int)'\0', 64);
    502           SL_RETURN ( (-1), _("sh_mail_setaddress"));
    503         }
    504       address_list[address_num] = p;
    505 #if 0
    506       if (!sl_is_suid())
    507         {
    508           TPT(( 0, FIL__, __LINE__, _("msg=<address_list[%d] = %s>\n"),
    509                 address_num, address_list[address_num]));
    510         }
    511 #endif
    512       if (setaddress_compiled == S_TRUE)
    513         {
    514           ++address_num;
    515           ++address_num_compiled;
    516         }
    517       else
    518         {
    519           if (address_num == address_num_compiled)
    520             {
    521               address_num = 0;
    522               address_num_compiled = -99;
    523             }
    524           ++address_num;
    525         }
    526       SL_RETURN ( (0), _("sh_mail_setaddress"));
    527     }
    528   SL_RETURN ( (-1), _("sh_mail_setaddress"));
    529 }
    530 
    531 int sh_mail_setaddress_int (const char * address)
    532 {
    533   int i;
    534   SL_ENTER(_("sh_mail_setaddress_int"));
    535   setaddress_compiled = S_TRUE;
    536   i = sh_mail_setaddress(address);
    537   setaddress_compiled = S_FALSE;
    538   SL_RETURN(i, _("sh_mail_setaddress_int"));
    539429}
    540430
     
    553443
    554444
    555 static int all_in_one = S_FALSE;
     445int sh_mail_all_in_one = S_FALSE;
    556446
    557447int sh_mail_setFlag (const char * str)
     
    559449  int i;
    560450  SL_ENTER(_("sh_mail_setFlag"));
    561   i = sh_util_flagval(str, &all_in_one);
     451  i = sh_util_flagval(str, &sh_mail_all_in_one);
    562452  SL_RETURN(i, _("sh_mail_setFlag"));
    563453}
     
    584474}
    585475
    586 
    587 static SH_FIFO * fifo_mail = NULL;
     476SH_MUTEX_INIT(mutex_fifo_mail, PTHREAD_MUTEX_INITIALIZER);
     477
     478SH_FIFO * fifo_mail = NULL;
    588479
    589480static
     
    598489    SL_RET0(_("sh_mail_emptystack"));
    599490
     491  SH_MUTEX_LOCK(mutex_fifo_mail);
    600492  while (NULL != (msg = pop_list(fifo_mail)))
    601493    {
     
    604496      SH_FREE(msg);
    605497    }
     498  SH_MUTEX_UNLOCK(mutex_fifo_mail);
    606499
    607500  SL_RET0(_("sh_mail_emptystack"));
     
    610503/* insert "\r\n" after each 998 char
    611504 */
    612 static char * split_string(char * str);
    613 
    614 int sh_mail_pushstack (/*@null@*/char * msg)
     505static char * split_string(const char * str);
     506
     507/* fixes warning: variable ‘p’ might be clobbered by ‘longjmp’ or ‘vfork’*/
     508static char ** p_dummy;
     509
     510int sh_mail_pushstack (int severity, const char * msg, const char * alias)
    615511{
    616512  char * p;
    617   int    retval = 0;
     513  volatile int    retval = 0;
    618514  int    status;
    619515
    620516  SL_ENTER(_("sh_mail_pushstack"));
    621517
    622   if (msg == NULL || failedMail == SL_TRUE || sh.srvmail.name[0] == '\0')
     518  if (msg == NULL || failedMail == SL_TRUE /* || sh.srvmail.name[0] == '\0' */)
    623519    SL_RETURN((0), (_("sh_mail_pushstack")));
    624520
    625   if (0 != sh_filter_filter(msg, &mail_filter))
    626     SL_RETURN((0), (_("sh_mail_pushstack")));
    627 
    628 #if 0
    629   if (msg != NULL && sl_strlen(msg) > 998)  /* RFC 2822 */
    630     msg[998] = '\0';
    631 #endif
    632 
    633521  p = split_string(msg);
     522  /* fixes "variable ‘p’ might be clobbered by ‘longjmp’ or ‘vfork’" */
     523  p_dummy = &p;
     524
     525  SH_MUTEX_LOCK(mutex_fifo_mail);
    634526
    635527  if (fifo_mail == NULL)
     
    638530      fifo_init(fifo_mail);
    639531    }
    640 
    641   status = push_list (fifo_mail, p);
     532  status = push_list (fifo_mail, p, severity, alias);
     533  SH_MUTEX_UNLOCK(mutex_fifo_mail);
     534
    642535  if (status >= 0)
    643536    ++sh.mailNum.alarm_last;
     
    647540  if (sh.mailNum.alarm_last >= sh.mailNum.alarm_interval)
    648541    {
    649       BREAKEXIT(sh_mail_msg);
    650       retval = sh_mail_msg (NULL);
     542      BREAKEXIT(sh_nmail_flush);
     543      retval = sh_nmail_flush ();
    651544    }
    652545
     
    660553 */
    661554static int sh_mail_end_conn (FILE * connfile, int fd);
    662 static FILE * sh_mail_start_conn (int aFlag, int * fd);
     555static FILE * sh_mail_start_conn (struct alias * address, int * fd, int * anum);
    663556
    664557static
    665 void sh_mail_get_subject(char * message,
     558void sh_mail_get_subject(const char * message,
    666559                         char * mheader, size_t len)
    667560{
     
    677570  char * mptr;
    678571  char   sev[8];
     572  char * msg;
    679573
    680574  SL_ENTER(_("sh_mail_get_subject"));
     
    693587  /* fast forward to the important part
    694588   */
    695   mptr = (char*)sl_strstr(message, _("msg="));
     589  msg  = sh_util_strdup(message);
     590
     591  mptr = sl_strstr(msg, _("msg="));
    696592  if (mptr)
    697593    {
     
    700596    }
    701597  else
    702     rep_serv_tab[2].data_str   = message;
    703 
    704   mptr = (char*)sl_strstr(message, _("sev="));
     598    rep_serv_tab[2].data_str   = msg;
     599
     600  mptr = sl_strstr(msg, _("sev="));
    705601  if (mptr)
    706602    {
     
    714610  else
    715611    {
    716       mptr = message;
     612      mptr = msg;
    717613      sev[0] = *mptr; ++mptr;
    718614      sev[1] = *mptr; ++mptr;
     
    737633  (void) sl_strlcat(mheader, p, len);
    738634  SH_FREE(p);
     635  SH_FREE(msg);
    739636  SL_RET0(_("sh_mail_get_subject"));
    740637}
    741638
    742 
    743 #if defined(HAVE_MLOCK) && !defined(HAVE_BROKEN_MLOCK)
    744 #include <sys/mman.h>
    745 #endif
    746 
    747 static char * sh_mail_realloc (char * inbuf, size_t * insize, size_t increase)
    748 {
    749   size_t newsize;
    750   char * outbuf = inbuf;
    751 
    752   SL_ENTER(_("sh_mail_realloc"));
    753 
    754   if (sl_ok_adds((*insize), 1))
    755     {
    756       newsize = (*insize) + 1;
    757 
    758       if (sl_ok_adds(newsize, increase))
    759         {
    760           newsize += increase;
    761 
    762           outbuf = SH_ALLOC(newsize);
    763           MLOCK(outbuf, newsize);
    764           (void) sl_strlcpy(outbuf, inbuf, newsize);
    765 
    766           memset (inbuf, 0, (*insize));
    767           MUNLOCK(inbuf, (*insize));
    768           SH_FREE(inbuf);
    769 
    770           *insize = newsize;
    771         }
    772     }
    773 
    774   SL_RETURN( (outbuf), _("sh_mail_realloc"));
    775 }
    776 
    777 int sh_mail_msg (/*@null@*/char * message)
     639void sh_mail_signature_block (sh_string  * sigMsg, char * recipient,
     640                              char * bufcompress)
     641{
     642  time_t         id_audit;
     643  char         * theSig;
     644  char ibuf[80];
     645  unsigned int count;
     646
     647  /* ------ signature block ------------------------------------ */
     648 
     649  sigMsg = sh_string_add_from_char(sigMsg,
     650                                   _("-----BEGIN SIGNATURE-----\r\n"));
     651 
     652  count  = sh_nmail_get_mailkey (recipient, skey->mailkey_new, KEY_LEN+1,
     653                                 &id_audit);
     654 
     655  if (count != 0)
     656    {
     657      char sigbuf[KEYBUF_SIZE];
     658     
     659      /* Sign the message with the signature key.
     660       */
     661      theSig = sh_util_siggen (skey->mailkey_new,
     662                               bufcompress, sl_strlen(bufcompress),
     663                               sigbuf, sizeof(sigbuf));
     664      sigMsg = sh_string_add_from_char(sigMsg, theSig);
     665    }
     666  else
     667    {
     668       /* reveal first signature key
     669       */
     670      /* flawfinder: ignore */
     671      (void) sl_strlcpy(skey->crypt, skey->mailkey_new, KEY_LEN+1);
     672     
     673      BREAKEXIT(sh_util_encode);
     674      /* flawfinder: ignore */
     675      sh_util_encode(skey->crypt, bufcompress, 0, 'A');
     676     
     677      /* flawfinder: ignore */
     678      sigMsg     = sh_string_add_from_char(sigMsg, skey->crypt);
     679     
     680      /* flawfinder: ignore */
     681      memset (skey->crypt, 0, KEY_LEN);
     682    }
     683
     684    sigMsg     = sh_string_add_from_char(sigMsg, "\r\n");
     685
     686    sl_snprintf(ibuf, sizeof(ibuf), _("%06u %010lu::%s\r\n"),
     687                count, (unsigned long) id_audit, sh.host.name);
     688
     689    sigMsg     = sh_string_add_from_char(sigMsg, ibuf);
     690    sigMsg     = sh_string_add_from_char(sigMsg, _("-----END MESSAGE-----"));
     691
     692    return;
     693}
     694
     695int sh_mail_msg (const char * message)
    778696{
    779697    char         subject[32+32+SH_MINIBUF+2+3+SH_PATHBUF];
    780698    char         mheader[32+32+SH_MINIBUF+2+3];
    781699
    782     char       * mailMsg;
    783     char       * popMsg;
    784     int          status = 0, errcount;
     700    sh_string  * mailMsg;
     701    sh_string  * compMsg;
     702    int          status = 0;
     703    volatile int errcount;
    785704    size_t       wrlen;
    786     int          i;
    787     int          num_popped = 0;
    788     int          retval = -1; 
     705    volatile int retval = -1; 
    789706
    790707    char       * bufcompress;
     708    size_t       compressed;
     709
    791710    static int   failcount = 0;
    792     static int   isfirst   = 1;
    793     static int   mailcount = 0;
    794711    FILE       * connfile  = NULL;
    795712
     
    797714    struct  sigaction  new_act;
    798715
    799     static  time_t id_audit  = 0;
    800716    static  time_t fail_time = 0;
    801717    static  time_t success_time = 0;
    802718
    803     static  int ma_block = 0;
    804 
    805719    int       ma_socket = -1;
    806720
    807     SH_FIFO * fifo_temp = NULL;
    808 
    809     char    * theSig;
    810     char    * theMsg = NULL;
     721    int            address_num = 0;
     722    sh_string    * theMsg = NULL;
    811723
    812724    /* #define SH_MAILBUF (256)    */
    813 #define SH_MAILBUF (8*4096)
    814 
    815     size_t    msgbufsize = SH_MAILBUF;
    816     size_t    combufsize = SH_MAILBUF;
     725#define SH_MAILBUF 4096
     726
    817727    char      timebuf[81];
    818     char hashbuf[KEYBUF_SIZE];
    819728
    820729    SL_ENTER(_("sh_mail_msg"));
    821730
    822     if (ma_block == 1)
    823       SL_RETURN( (0), _("sh_mail_msg"));
    824 
    825     /* Return if we cannot mail.
     731    /*
     732     * Return if we cannot mail.
    826733     */
    827734    if (failedMail == SL_TRUE)
    828735      SL_RETURN((-1), _("sh_mail_msg"));
    829736
    830     if (failedMail == SL_FALSE && address_list[0] == NULL)
    831       {
    832         TPT((0, FIL__, __LINE__,
    833              _("msg=<Mail error: no recipient address.>\n")));
    834         failedMail = SL_TRUE;
    835         SL_RETURN((-1), _("sh_mail_msg"));
    836       }
    837 
     737    /*
     738     * Final failure, can't mail for SH_MAX_FAIL hours.
     739     */
    838740    if ( (success_time > 0) && (fail_time > 0) &&
    839741         (time(NULL) - success_time) > 3600*SH_MAX_FAIL)
    840742      {
    841         ma_block = 1;
    842743        sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_SRV_FAIL,
    843                          _("mail"), address_list[0]);
    844         ma_block = 0;
     744                         _("mail"),
     745                         sh_string_str(all_recipients->recipient));
    845746        sh_mail_emptystack();
    846747        sh.mailNum.alarm_last = 0;
     
    849750      }
    850751
    851     /* Try at most each hour.
     752    /*
     753     * Try at most every three seconds to mail if there was a failure.
    852754     */
    853755    if ((fail_time > 0) && (time(NULL) - fail_time) < 3/*600*/)
     
    855757        if (failcount > 3)
    856758          {
    857             /* -- Save for later. --
     759            /* -- Save for later. Changed: done by caller. --
     760             *      sh_nmail_pushstack (severity, message, alias);
    858761             */
    859             sh_mail_pushstack (message);
    860762            ++failcount;
    861763           
     
    873775    fail_time = 0;
    874776
    875     /* -- Polling, empty queue. --
    876      */
    877     if (message == NULL && sh.mailNum.alarm_last == 0)
    878       SL_RETURN((-1), _("sh_mail_msg"));
    879 
    880     /* -- Filtered. --
    881      */
    882     if (message != NULL && 0 != sh_filter_filter(message, &mail_filter))
    883       SL_RETURN((-1), (_("sh_mail_msg")));
    884 
    885 
    886777
    887778    /* ---------  Build complete message. ------------------------ */
    888779
    889     theMsg = split_string(message);
     780    /* Don't flush the queue here, because tag_list doesn't know
     781     * how to filter messages. */
     782
     783    theMsg = sh_string_new_from_lchar(message, strlen(message));
    890784
    891785    /* ---------- Header  ---------------------------------------- */
     
    894788      {
    895789        (void) sl_strlcpy(mheader, _("Subject: "),       sizeof(mheader)-5);
    896         (void) sl_strlcat(mheader, sh_unix_time (0, timebuf, sizeof(timebuf)),
     790        (void) sl_strlcat(mheader,
     791                          sh_unix_time (0, timebuf, sizeof(timebuf)),
    897792                          sizeof(mheader)-5);
    898793        (void) sl_strlcat(mheader, " ",                  sizeof(mheader)-5);
     
    901796    else
    902797      {
    903        
    904         if (message == NULL)
    905           {
    906             theMsg  = pop_list(fifo_mail);
    907             message = theMsg;
    908             if (message)
    909               --sh.mailNum.alarm_last;
    910           }
    911798       
    912799        if (message)
     
    917804          {
    918805            (void) sl_strlcpy(mheader, _("Subject: "),     sizeof(mheader)-5);
    919             (void) sl_strlcat(mheader, sh_unix_time (0, timebuf, sizeof(timebuf)),
     806            (void) sl_strlcat(mheader,
     807                              sh_unix_time (0, timebuf, sizeof(timebuf)),
    920808                              sizeof(mheader)-5);
    921809            (void) sl_strlcat(mheader, " ",                sizeof(mheader)-5);
     
    937825
    938826
    939     mailMsg     = (char *) SH_ALLOC (msgbufsize);
    940     bufcompress = (char *) SH_ALLOC (combufsize);
    941 
    942     MLOCK(mailMsg     , msgbufsize);
    943     MLOCK(bufcompress , combufsize);
    944 
    945     (void) sl_strlcpy(mailMsg, mheader, msgbufsize);
     827    mailMsg     = sh_string_new (SH_MAILBUF);
     828    compMsg     = sh_string_new (SH_MAILBUF);
     829
     830    mailMsg     = sh_string_add_from_char(mailMsg, mheader);
     831    mailMsg     = sh_string_add_from_char(mailMsg,
     832                                          _("-----BEGIN MESSAGE-----\r\n"));
     833
     834    mailMsg     = sh_string_add_from_char(mailMsg, subject);
     835    mailMsg     = sh_string_add          (mailMsg, theMsg);
     836    mailMsg     = sh_string_add_from_char(mailMsg, "\r\n");
     837
     838    /* ---------- Compressed Message  ---------------------------- */
     839
     840    compMsg     = sh_string_add_from_char(compMsg, subject);
     841    compMsg     = sh_string_add          (compMsg, theMsg);
     842    compMsg     = sh_string_add_from_char(compMsg, "\r\n");
     843
     844    bufcompress = SH_ALLOC(sh_string_len(compMsg) + KEY_LEN + 1);
    946845    bufcompress[0] = '\0';
    947846
    948     (void) sl_strlcat(mailMsg, _("-----BEGIN MESSAGE-----\r\n"), msgbufsize);
    949     (void) sl_strlcat(mailMsg, subject, msgbufsize);
    950     (void) sh_util_compress (bufcompress, subject,
    951                              (combufsize - KEY_LEN - 1));
    952     if (message != NULL)
    953       {
    954         if ((sl_strlen(theMsg) + sl_strlen(mailMsg) + 1) >
    955             (msgbufsize-(4*KEY_LEN)))
    956           {
    957             mailMsg     = sh_mail_realloc(mailMsg,     
    958                                           &msgbufsize, sl_strlen(theMsg)+2);
    959             bufcompress = sh_mail_realloc(bufcompress,
    960                                           &combufsize, sl_strlen(theMsg));
    961           }
    962         (void) sl_strlcat(mailMsg,  theMsg, msgbufsize-(4*KEY_LEN));
    963         (void) sl_strlcat(mailMsg,  "\r\n", msgbufsize-(4*KEY_LEN));
    964 
    965         (void) sh_util_compress (bufcompress,  theMsg, combufsize-KEY_LEN-1);
    966       }
    967 
    968     if (sh.mailNum.alarm_last > 0)
    969       {
    970         fifo_temp = SH_ALLOC (sizeof(SH_FIFO));
    971         fifo_init (fifo_temp);
    972 
    973         while ( NULL != (popMsg = pop_list(fifo_mail)) )
    974           {
    975             (void) push_list (fifo_temp, popMsg);
    976 
    977             if ((sl_strlen(popMsg) + sl_strlen(mailMsg) + 1) >
    978                 (msgbufsize-(4*KEY_LEN)))
    979               {
    980                 mailMsg     = sh_mail_realloc(mailMsg,     
    981                                               &msgbufsize,
    982                                               sl_strlen(popMsg)+2);
    983                 bufcompress = sh_mail_realloc(bufcompress,
    984                                               &combufsize,
    985                                               sl_strlen(popMsg));
    986               }
    987 
    988             (void) sl_strlcat(mailMsg, popMsg, msgbufsize-(4*KEY_LEN));
    989             (void) sl_strlcat(mailMsg, "\r\n", msgbufsize-(4*KEY_LEN));
    990             (void) sh_util_compress(bufcompress, popMsg, combufsize-KEY_LEN-1);
    991             SH_FREE(popMsg);
    992             --sh.mailNum.alarm_last;
    993             ++num_popped;
    994           }
    995       }
    996 
    997     /* ------ signature block ------------------------------------ */
    998    
    999     (void) sl_strlcat(mailMsg, _("-----BEGIN SIGNATURE-----\r\n"), msgbufsize);
    1000 
    1001     /* Generate new signature key.
    1002      */
    1003     if (isfirst == 1)
    1004       {
    1005         BREAKEXIT(sh_util_keyinit);
    1006         (void) sh_util_keyinit (skey->mailkey_old, KEY_LEN+1);
    1007       }
    1008 
    1009     /* iterate the key
    1010      */
    1011     (void) sl_strlcpy(skey->mailkey_new,
    1012                       sh_tiger_hash (skey->mailkey_old, TIGER_DATA, KEY_LEN,
    1013                                      hashbuf, sizeof(hashbuf)),
    1014                       KEY_LEN+1);
    1015 
    1016     if (isfirst == 0)
    1017       {
    1018         char sigbuf[KEYBUF_SIZE];
    1019 
    1020         /* Sign the message with the signature key.
    1021          */
    1022         theSig = sh_util_siggen (skey->mailkey_new,
    1023                                  bufcompress, sl_strlen(bufcompress),
    1024                                  sigbuf, sizeof(sigbuf));
    1025         (void) sl_strlcat (mailMsg,
    1026                            theSig,
    1027                            msgbufsize);
    1028       }
    1029     else
    1030       {
    1031         id_audit = time (NULL);
    1032 
    1033         /* reveal first signature key
    1034          */
    1035         /* flawfinder: ignore */
    1036         (void) sl_strlcpy(skey->crypt, skey->mailkey_new, KEY_LEN+1);
    1037 
    1038         BREAKEXIT(sh_util_encode);
    1039         /* flawfinder: ignore */
    1040         sh_util_encode(skey->crypt, bufcompress, 0, 'A');
    1041 
    1042         /* flawfinder: ignore */
    1043         (void) sl_strlcat (mailMsg, skey->crypt, msgbufsize);
    1044         /* flawfinder: ignore */
    1045         memset (skey->crypt, 0, KEY_LEN);
    1046         isfirst = 0;
    1047       }
    1048     (void) sl_strlcat (mailMsg, "\r\n", msgbufsize);
    1049 
    1050     /* X(n) -> X(n-1)
    1051      */
    1052     (void) sl_strlcpy (skey->mailkey_old, skey->mailkey_new, KEY_LEN+1);
    1053 
    1054     sl_snprintf(subject, sizeof(subject), _("%06d %010ld::%s\r\n"),
    1055                 mailcount, (long) id_audit, sh.host.name);
    1056 
    1057     (void) sl_strlcat (mailMsg, subject, msgbufsize);
    1058     ++mailcount;
    1059 
    1060     (void) sl_strlcat (mailMsg, _("-----END MESSAGE-----"), msgbufsize);
    1061 
    1062 
     847    compressed = sh_util_compress (bufcompress,
     848                                   sh_string_str(compMsg),
     849                                   sh_string_len(compMsg) + 1);
    1063850
    1064851    /* ---------- Connect ---------------------------------------- */
    1065 
    1066 
    1067852
    1068853    /* -- Catch (ignore) 'broken pipe'.
     
    1074859    (void) sigaction (SIGPIPE, &new_act, &old_act);
    1075860
    1076     i        = 0;
    1077861    errcount = 0;
    1078862
    1079     if (all_in_one == S_FALSE)
     863    if (sh_mail_all_in_one == S_FALSE)
    1080864      {
    1081         while (address_list[i] != NULL && i < address_num)
     865        struct alias * address_list;
     866
     867        address_list = all_recipients;
     868
     869        while (address_list)
    1082870          {
    1083             connfile = sh_mail_start_conn (i, &ma_socket);
     871            if (address_list->send_mail == 1)
     872              {
     873                connfile = sh_mail_start_conn (address_list,
     874                                               &ma_socket, &address_num);
    1084875           
    1085             if (NULL != connfile)
    1086               {
    1087                 wrlen = fwrite (mailMsg, 1, sl_strlen(mailMsg),
    1088                                  connfile);
    1089                 wrlen -= sl_strlen(mailMsg);
    1090                 if (wrlen == 0)
    1091                   status = sh_mail_end_conn (connfile, ma_socket);
     876                if (NULL != connfile)
     877                  {
     878                    wrlen = fwrite (sh_string_str(mailMsg), 1,
     879                                    sh_string_len(mailMsg), connfile);
     880                    wrlen -= sh_string_len(mailMsg);
     881
     882                    if (wrlen == 0)
     883                      {
     884                        sh_string  * sigMsg  = sh_string_new (0);
     885
     886                        sh_mail_signature_block (sigMsg,
     887                                                 sh_string_str(address_list->recipient),
     888                                                 bufcompress);
     889
     890                        wrlen = fwrite (sh_string_str(sigMsg), 1,
     891                                        sh_string_len(sigMsg), connfile);
     892                        wrlen -= sh_string_len(sigMsg);
     893
     894                        sh_string_destroy(&sigMsg);
     895                      }
     896
     897                    if (wrlen == 0)
     898                      status = sh_mail_end_conn (connfile, ma_socket);
     899                    else
     900                      status = -1;
     901                  }
     902                if (NULL == connfile ||  status != 0)
     903                  {
     904                    sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_SRV_FAIL,
     905                                     _("mail"),
     906                                     sh_string_str(address_list->recipient));
     907                    ++errcount;
     908                    ++sh.statistics.mail_failed;
     909                  }
    1092910                else
    1093                   status = -1;
     911                  {
     912                    ++sh.statistics.mail_success;
     913                  }
     914               
     915                if (connfile != NULL)
     916                  {
     917                    (void) fclose (connfile);
     918                    connfile = NULL;
     919                  }
    1094920              }
    1095             if (NULL == connfile ||  status != 0)
    1096               {
    1097                 ma_block = 1;
    1098                 sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_SRV_FAIL,
    1099                                  _("mail"), address_list[i]);
    1100                 ma_block = 0;
    1101                 ++errcount;
    1102                 ++sh.statistics.mail_failed;
    1103               }
    1104             else
    1105               {
    1106                 ++sh.statistics.mail_success;
    1107               }
    1108 
    1109             if (connfile != NULL)
    1110               {
    1111                 (void) fclose (connfile);
    1112                 connfile = NULL;
    1113               }
    1114             ++i;
     921            address_list = address_list->all_next;
    1115922          }
    1116923      }
    1117924    else
    1118925      {
    1119         connfile = sh_mail_start_conn ( -9 , &ma_socket);
    1120        
     926        connfile = sh_mail_start_conn (NULL, &ma_socket, &address_num);
     927
    1121928        if (NULL != connfile)
    1122929          {
    1123             wrlen = fwrite (mailMsg, 1, sl_strlen(mailMsg), connfile);
    1124             wrlen -= sl_strlen(mailMsg);
     930            wrlen = fwrite (sh_string_str(mailMsg), 1,
     931                            sh_string_len(mailMsg), connfile);
     932            wrlen -= sh_string_len(mailMsg);
     933
     934            if (wrlen == 0)
     935              {
     936                sh_string  * sigMsg  = sh_string_new (0);
     937               
     938                sh_mail_signature_block (sigMsg,
     939                                         NULL,
     940                                         bufcompress);
     941               
     942                wrlen = fwrite (sh_string_str(sigMsg), 1,
     943                                sh_string_len(sigMsg), connfile);
     944                wrlen -= sh_string_len(sigMsg);
     945               
     946                sh_string_destroy(&sigMsg);
     947              }
     948
    1125949            if (wrlen == 0)
    1126950              status = sh_mail_end_conn (connfile, ma_socket);
     
    1128952              status = -1;
    1129953          }
    1130         if (NULL == connfile ||  status != 0)
     954
     955        if (NULL == connfile || status != 0)
    1131956          {
    1132             ma_block = 1;
     957            struct alias* ma_address = all_recipients;
     958
     959            while (ma_address)
     960              {
     961                if (ma_address->send_mail == 1)
     962                  break;
     963                ma_address = ma_address->all_next;
     964              }
     965
    1133966            sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_SRV_FAIL,
    1134                              _("mail"), address_list[0]);
    1135             ma_block = 0;
     967                             _("mail"), sh_string_str(ma_address->recipient));
    1136968            errcount = address_num;
    1137969            ++sh.statistics.mail_failed;
     
    1148980          }
    1149981      }
    1150 
    1151982   
    1152     memset (bufcompress, 0, combufsize);
    1153     MUNLOCK(bufcompress , combufsize);
     983    memset (bufcompress, 0, compressed);
    1154984    SH_FREE(bufcompress);
    1155985
    1156     memset (mailMsg, 0, msgbufsize);
    1157     MUNLOCK(mailMsg , msgbufsize);
    1158     SH_FREE(mailMsg);
     986    memset (sh_string_str(mailMsg), 0, sh_string_len(mailMsg));
     987    memset (sh_string_str(compMsg), 0, sh_string_len(compMsg));
     988    memset (sh_string_str(theMsg),  0, sh_string_len(theMsg));
     989
     990    sh_string_destroy(&mailMsg);
     991    sh_string_destroy(&compMsg);
     992    sh_string_destroy(&theMsg);
    1159993
    1160994    /* --- Stay responsible for delivery in case of failure --- */
    1161995
    1162     if (errcount == address_num && fifo_temp != NULL)
     996    if (errcount == address_num)
    1163997      {
    1164         while ( (NULL != (popMsg = pop_list(fifo_temp))) )
    1165           {
    1166             if (push_list (fifo_mail, popMsg) >= 0)
    1167               ++sh.mailNum.alarm_last;
    1168             SH_FREE(popMsg);
    1169           }
    1170         if (message != NULL)
    1171           {
    1172             if (fifo_mail == NULL)
    1173               {
    1174                 fifo_mail = SH_ALLOC(sizeof(SH_FIFO));
    1175                 fifo_init(fifo_mail);
    1176               }
    1177             retval = push_list (fifo_mail,  theMsg);
    1178             if (retval >= 0)
    1179               ++sh.mailNum.alarm_last;
    1180             if (retval == SH_FIFO_MAX)
    1181               retval = -2;
    1182             else
    1183               retval = -1;
    1184           }
     998        rollback_list(fifo_mail);
     999        retval = -1;
    11851000      }
    1186     else if (fifo_temp != NULL)
     1001    else
    11871002      {
    1188         while ( (NULL != (popMsg = pop_list(fifo_temp))) )
    1189           {
    1190             SH_FREE(popMsg);
    1191           }
     1003        mark_list(fifo_mail);
    11921004      }
    1193     if (fifo_temp != NULL)
    1194       SH_FREE(fifo_temp);
    1195 
    1196     /*
    1197     if (connfile != NULL)
    1198       fclose (connfile);
    1199     */
    1200 
    1201     if (theMsg != NULL)
    1202       SH_FREE(theMsg);
    12031005
    12041006    /* --- Reset signal. ---
     
    12111013        SL_RETURN((retval), _("sh_mail_msg"));
    12121014      }
     1015
    12131016    success_time = time(NULL);
    12141017    failcount = 0;
     
    12981101 *
    12991102 * start connection
    1300  * for details on SMTP, see RFC 821
     1103 * for details on SMTP, see RFC 821
     1104 *
     1105 * If ma_address == NULL, will send to all marked with
     1106 * send_mail=1 in recipient list, else to ma_address.   
    13011107 */
    13021108
    13031109static time_t time_wait = 300;
    13041110
    1305 static FILE * sh_mail_start_conn (int aFlag, int * ma_socket)
     1111static FILE * sh_mail_start_conn (struct alias * ma_address,
     1112                                  int * ma_socket, int * anum)
    13061113{
    13071114  char       * address;
     1115  int          aFlag = 0;
    13081116
    13091117  int          ecount;
     
    13341142  time_wait  = 300;
    13351143
    1336   if (aFlag >= 0)
    1337     address = address_list[aFlag];
    1338   else
    1339     address = address_list[0];
    1340 
    1341   TPT(( 0, FIL__, __LINE__, _("msg=<aFlag %d address %s>\n"),
    1342         aFlag, address));
    1343 
    1344   /* -------   split adress ------------------  */
    1345 
    1346   if (0 == strcmp(address, _("NULL")))
     1144  if (ma_address == NULL)
     1145    {
     1146      aFlag = 1;
     1147      ma_address = all_recipients;
     1148
     1149      while (ma_address)
     1150        {
     1151          if (ma_address->send_mail == 1)
     1152            break;
     1153          ma_address = ma_address->all_next;
     1154        }
     1155    }
     1156
     1157  if (!ma_address)
    13471158    {
    13481159      SL_RETURN( NULL, _("sh_mail_start_conn"));
    13491160    }
    1350    
     1161
     1162  address = sh_string_str(ma_address->recipient);
     1163
     1164  TPT(( 0, FIL__, __LINE__, _("msg=<address %s>\n"),
     1165        address));
     1166
     1167  /* -------   split adress ------------------  */
     1168
    13511169  if (strchr (address, '@') == NULL) {
    13521170    (void) sl_strlcpy(ma_user,    address,     256);
     
    13581176      ++i;
    13591177    }
    1360 
     1178   
    13611179    /* adress[i] = '@'
    13621180     */
     
    13851203  else
    13861204    {
    1387       answers = return_mx (ma_machine);
     1205      answers = ma_address->mx_list;
     1206      if (!answers)
     1207        {
     1208          answers = return_mx (ma_machine);
     1209          ma_address->mx_list = answers;
     1210        }
     1211
    13881212      if (answers)
    13891213        {
     
    14021226                break;
    14031227            }
    1404           (void) free_mx(answers);
    14051228        }
    14061229      else
     
    15111334  /* tell them who to send mail to
    15121335   */
    1513   if (aFlag >= 0)
     1336  if (aFlag == 0)
    15141337    {
    15151338      TPT(( 0, FIL__, __LINE__,  _("msg=<RCPT TO:<%s>>%c%c"),
     
    15291352          SL_RETURN( NULL, _("sh_mail_start_conn"));
    15301353        }
     1354      *anum = 1;
    15311355    }
    15321356  else
    15331357    {
    1534       ecount = 0;
    1535       for (i = 0; i < address_num; ++i)
    1536         {
    1537           if (address_list[i] == NULL)  /* paranoia */
    1538             break;
     1358      int address_num = 0;
     1359      ecount      = 0;
     1360
     1361      ma_address = all_recipients;
     1362
     1363      while (ma_address)
     1364        {
     1365          if (ma_address->send_mail != 1)
     1366            {
     1367              ma_address = ma_address->next;
     1368              continue;
     1369            }
     1370
     1371          ++address_num;
     1372
    15391373          TPT(( 0, FIL__, __LINE__,  _("msg=<RCPT TO:<%s>>%c%c"),
    1540                 address_list[i], 13, 10));
     1374                sh_string_str(ma_address->recipient), 13, 10));
    15411375         
    15421376          (void) fflush(connFile);
    1543           fprintf(connFile, _("RCPT TO:<%s>%c%c"), address_list[i], 13, 10);
     1377          fprintf(connFile, _("RCPT TO:<%s>%c%c"),
     1378                  sh_string_str(ma_address->recipient), 13, 10);
    15441379          (void) fflush(connFile);
    15451380         
     
    15481383              sh_error_handle((-1), FIL__, __LINE__, 0, MSG_E_NET,
    15491384                              _("RCPT TO failed"), _("sh_mail_start_conn"),
    1550                               _("mail"), address_list[i]);
     1385                              _("mail"), sh_string_str(ma_address->recipient));
    15511386
    15521387              TPT(( 0, FIL__, __LINE__, _("msg=<Timeout.>\n")));
    15531388              ++ecount;
    15541389            }
    1555         }
     1390          ma_address = ma_address->next;
     1391        }
     1392
     1393      *anum += address_num;
     1394
    15561395      if (ecount == address_num)
    15571396        {
     
    17711610#define SPLIT_AT 998
    17721611
    1773 static char * split_string(char * str)
     1612static char * split_string(const char * str)
    17741613{
    17751614  size_t size;
     
    17781617
    17791618  char * p, * p0;
    1780   char * q;
     1619  const char * q;
    17811620
    17821621  if (!str)
     
    22052044}
    22062045
    2207 static int free_mx (dnsrep * answers)
     2046int free_mx (dnsrep * answers)
    22082047{
    22092048  mx     * result;
  • trunk/src/sh_readconf.c

    r211 r214  
    3434#include "sh_files.h"
    3535#include "sh_mail.h"
     36#include "sh_nmail.h"
    3637#include "sh_calls.h"
    3738#include "sh_tiger.h"
     
    10981099  { N_("setmailnum"),        SH_SECTION_MAIL,  SH_SECTION_MISC,
    10991100    sh_mail_setNum },
    1100   { N_("setmailaddress"),    SH_SECTION_MAIL,  SH_SECTION_MISC,
    1101     sh_mail_setaddress },
    11021101  { N_("setmailrelay"),      SH_SECTION_MAIL,  SH_SECTION_MISC,
    11031102    sh_mail_set_relay },
     
    11081107  { N_("setmailsender"),     SH_SECTION_MAIL,  SH_SECTION_MISC,
    11091108    sh_mail_set_sender },
     1109  { N_("setmailaddress"),    SH_SECTION_MAIL,  SH_SECTION_MISC,
     1110    sh_nmail_add_recipient },
     1111  { N_("closeaddress"),      SH_SECTION_MAIL,  SH_SECTION_MISC,
     1112    sh_nmail_close_recipient },
     1113  { N_("setaddrseverity"),   SH_SECTION_MAIL,  SH_SECTION_MISC,
     1114    sh_nmail_set_severity },
    11101115  { N_("setmailfilternot"),  SH_SECTION_MAIL,  SH_SECTION_MISC,
    1111     sh_mail_add_not },
     1116    sh_nmail_add_not },
    11121117  { N_("setmailfilterand"),  SH_SECTION_MAIL,  SH_SECTION_MISC,
    1113     sh_mail_add_and },
     1118    sh_nmail_add_and },
    11141119  { N_("setmailfilteror"),   SH_SECTION_MAIL,  SH_SECTION_MISC,
    1115     sh_mail_add_or },
     1120    sh_nmail_add_or },
    11161121#endif
    11171122  { N_("setbindaddress"),    SH_SECTION_MISC,  SH_SECTION_NONE,
     
    12141219  static const char  *closing[] = {
    12151220    N_("closecommand"),
     1221    N_("closeaddress"),
    12161222    N_("logmonendgroup"),
    12171223    N_("logmonendhost"),
  • trunk/src/sh_utils.c

    r210 r214  
    816816/* a simple compressor
    817817 */
    818 long sh_util_compress (char * dest, char * src, size_t dest_size)
     818size_t sh_util_compress (char * dest, char * src, size_t dest_size)
    819819{
    820820  char * add;
     
    857857
    858858  dest[dest_size-1] = '\0'; /* paranoia       */
    859   SL_RETURN(((long)count), _("sh_util_compress")); /* no of chars copied */   
     859  SL_RETURN((count), _("sh_util_compress")); /* no of chars copied */   
    860860}
    861861
  • trunk/src/slib.c

    r212 r214  
    10911091 */
    10921092
    1093 const char * sl_strstr (const char * haystack, const char * needle)
     1093char * sl_strstr (const char * haystack, const char * needle)
    10941094{
    10951095#ifndef HAVE_STRSTR
     
    26942694    {
    26952695    case SL_EBOGUS:
    2696       return _("Bogus file. Modified during access");
     2696      return _("Bogus file, modified during access");
    26972697    case SL_EWRITE:
    26982698      return _("Write error");
Note: See TracChangeset for help on using the changeset viewer.