Skip to content

Instantly share code, notes, and snippets.

@trantor
Last active October 21, 2017 20:53
Show Gist options
  • Save trantor/0581892b26ae29c884a85ffd0e288665 to your computer and use it in GitHub Desktop.
Save trantor/0581892b26ae29c884a85ffd0e288665 to your computer and use it in GitHub Desktop.
Sample dgsh script with problems
** Contents of the script **
** Input lines of the argument files embedded as annotation **
#!/usr/local/bin/dgsh
MITTENTE=$1
shift
# invoked as match-dgsh messages@mailagenziaentrate40.top filename
# contents of "filename" below
#Oct 13 14:11:17 mx1 postfix/smtpd[27128]: 011F0120045: client=mailagenziaentrate40.top[82.202.248.170]
#Oct 13 14:11:17 mx1 postfix/cleanup[17224]: 011F0120045: message-id=<B24801BDDD092784585D14AAAEF48E02@mailagenziaentrate40.top>
#Oct 13 14:11:17 mx1 postfix/cleanup[17224]: 011F0120045: info: header Subject: Lettera di Sollecito from mailagenziaentrate40.top[82.202.248.170]; from=<messages@mailagenziaentrate40.top> to=<test@example.com> proto=ESMTP helo=<mailagenziaentrate40.top>
#Oct 13 14:11:17 mx1 postfix/qmgr[15544]: 011F0120045: from=<messages@mailagenziaentrate40.top>, size=97531, nrcpt=1 (queue active)
#Oct 13 14:11:23 mx1 postfix/smtp[15939]: 011F0120045: to=<test@example.com>, relay=127.0.0.1[127.0.0.1]:10024, delay=8.2, delays=1.7/0/0/6.5, dsn=2.0.0, status=sent (250 2.0.0 from MTA(smtp:[127.0.0.1]:10025): 250 2.0.0 Ok: queued as CA65A120044)
#Oct 13 14:11:23 mx1 postfix/qmgr[15544]: 011F0120045: removed
#Oct 13 14:12:17 mx1 postfix/smtpd[27128]: 123FF324567: client=mailagenziaentrate40.top[82.202.248.170]
#Oct 13 14:12:17 mx1 postfix/cleanup[17224]: 123FF324567: message-id=<B24801BDDD092784585D14F12312@mailagenziaentrate40.top>
#Oct 13 14:12:17 mx1 postfix/cleanup[17224]: 123FF324567: info: header Subject: Lettera di Sollecito from mailagenziaentrate40.top[82.202.248.170]; from=<messages@mailagenziaentrate40.top> to=<sample@prrrr.to> proto=ESMTP helo=<mailagenziaentrate40.top>
#Oct 13 14:12:17 mx1 postfix/qmgr[15544]: 123FF324567: from=<messages@mailagenziaentrate40.top>, size=97531, nrcpt=1 (queue active)
#Oct 13 14:12:23 mx1 postfix/smtp[15939]: 123FF324567: to=<sample@prrrr.to>, relay=127.0.0.1[127.0.0.1]:10024, delay=8.2, delays=1.7/0/0/6.5, dsn=2.0.0, status=sent (250 2.0.0 from MTA(smtp:[127.0.0.1]:10025): 250 2.0.0 Ok: queued as CA65A120044)
#Oct 13 14:12:23 mx1 postfix/qmgr[15544]: 123FF324567: removed
xzcat -f "$@" |
{{
grep -E 'Subject:.*from=<'"${MITTENTE}" |
#Oct 13 14:11:17 mx1 postfix/cleanup[17224]: 011F0120045: info: header Subject: Lettera di Sollecito from mailagenziaentrate40.top[82.202.248.170]; from=<messages@mailagenziaentrate40.top> to=<test@example.com> proto=ESMTP helo=<mailagenziaentrate40.top>
#Oct 13 14:12:17 mx1 postfix/cleanup[17224]: 123FF324567: info: header Subject: Lettera di Sollecito from mailagenziaentrate40.top[82.202.248.170]; from=<messages@mailagenziaentrate40.top> to=<sample@prrrr.to> proto=ESMTP helo=<mailagenziaentrate40.top>
grep -oP '[[:xdigit:]]+(?=: info: header Subject:)' |
#011F0120045
#123FF324567
sort -u &
#011F0120045
#123FF324567
cat &
}} |
grep -F --matching-lines --file=- |
#Oct 13 14:11:17 mx1 postfix/smtpd[27128]: 011F0120045: client=mailagenziaentrate40.top[82.202.248.170]
#Oct 13 14:11:17 mx1 postfix/cleanup[17224]: 011F0120045: message-id=<B24801BDDD092784585D14AAAEF48E02@mailagenziaentrate40.top>
#Oct 13 14:11:17 mx1 postfix/cleanup[17224]: 011F0120045: info: header Subject: Lettera di Sollecito from mailagenziaentrate40.top[82.202.248.170]; from=<messages@mailagenziaentrate40.top> to=<test@example.com> proto=ESMTP helo=<mailagenziaentrate40.top>
#Oct 13 14:11:17 mx1 postfix/qmgr[15544]: 011F0120045: from=<messages@mailagenziaentrate40.top>, size=97531, nrcpt=1 (queue active)
#Oct 13 14:11:23 mx1 postfix/smtp[15939]: 011F0120045: to=<test@example.com>, relay=127.0.0.1[127.0.0.1]:10024, delay=8.2, delays=1.7/0/0/6.5, dsn=2.0.0, status=sent (250 2.0.0 from MTA(smtp:[127.0.0.1]:10025): 250 2.0.0 Ok: queued as CA65A120044)
#Oct 13 14:11:23 mx1 postfix/qmgr[15544]: 011F0120045: removed
#Oct 13 14:12:17 mx1 postfix/smtpd[27128]: 123FF324567: client=mailagenziaentrate40.top[82.202.248.170]
#Oct 13 14:12:17 mx1 postfix/cleanup[17224]: 123FF324567: message-id=<B24801BDDD092784585D14F12312@mailagenziaentrate40.top>
#Oct 13 14:12:17 mx1 postfix/cleanup[17224]: 123FF324567: info: header Subject: Lettera di Sollecito from mailagenziaentrate40.top[82.202.248.170]; from=<messages@mailagenziaentrate40.top> to=<sample@prrrr.to> proto=ESMTP helo=<mailagenziaentrate40.top>
#Oct 13 14:12:17 mx1 postfix/qmgr[15544]: 123FF324567: from=<messages@mailagenziaentrate40.top>, size=97531, nrcpt=1 (queue active)
#Oct 13 14:12:23 mx1 postfix/smtp[15939]: 123FF324567: to=<sample@prrrr.to>, relay=127.0.0.1[127.0.0.1]:10024, delay=8.2, delays=1.7/0/0/6.5, dsn=2.0.0, status=sent (250 2.0.0 from MTA(smtp:[127.0.0.1]:10025): 250 2.0.0 Ok: queued as CA65A120044)
#Oct 13 14:12:23 mx1 postfix/qmgr[15544]: 123FF324567: removed
grep -oP '(?<=: to=<)[^>]+'
#test@example.com
#sample@prrrr.to
*** Output ***
dgsh -x match.dgsh messages@mailagenziaentrate40.top logfile
+ MITTENTE=messages@mailagenziaentrate40.top
+ shift
+ dgsh-wrap xzcat -f logfile
+ grep -F --matching-lines --file=-
+ grep -oP '(?<=: to=<)[^>]+'
+ dgsh-conc -o 2
+ dgsh-conc -i 2
+ grep -E 'Subject:.*from=<messages@mailagenziaentrate40.top'
+ grep -oP '[[:xdigit:]]+(?=: info: header Subject:)'
+ wait
+ sort -u
+ cat
ERROR: More than one edges are flexible. Cannot compute solution. Exiting.
dgsh: No solution was found to satisfy the I/O requirements of the following 0 participating processes:
*** Error in `dgsh-wrap': free(): invalid pointer: 0x00007ffc5e3e2ae4 ***
======= Backtrace: =========
/lib/x86_64-linux-gnu/libc.so.6(+0x777e5)[0x7f42fce417e5]
/lib/x86_64-linux-gnu/libc.so.6(+0x8037a)[0x7f42fce4a37a]
/lib/x86_64-linux-gnu/libc.so.6(cfree+0x4c)[0x7f42fce4e53c]
dgsh-wrap[0x4058e2]
dgsh-wrap[0x406208]
dgsh-wrap[0x40ac5f]
dgsh-wrap[0x402483]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0)[0x7f42fcdea830]
dgsh-wrap[0x401439]
======= Memory map: ========
00400000-0040f000 r-xp 00000000 08:11 8535587 /usr/local/libexec/dgsh/dgsh-wrap
0060f000-00610000 r-xp 0000f000 08:11 8535587 /usr/local/libexec/dgsh/dgsh-wrap
00610000-00611000 rwxp 00010000 08:11 8535587 /usr/local/libexec/dgsh/dgsh-wrap
013bb000-013dc000 rwxp 00000000 00:00 0 [heap]
7f42f8000000-7f42f8021000 rwxp 00000000 00:00 0
7f42f8021000-7f42fc000000 ---p 00000000 00:00 0
7f42fcbb4000-7f42fcbca000 r-xp 00000000 08:11 6817824 /lib/x86_64-linux-gnu/libgcc_s.so.1
7f42fcbca000-7f42fcdc9000 ---p 00016000 08:11 6817824 /lib/x86_64-linux-gnu/libgcc_s.so.1
7f42fcdc9000-7f42fcdca000 rwxp 00015000 08:11 6817824 /lib/x86_64-linux-gnu/libgcc_s.so.1
7f42fcdca000-7f42fcf8a000 r-xp 00000000 08:11 6828166 /lib/x86_64-linux-gnu/libc-2.23.so
7f42fcf8a000-7f42fd18a000 ---p 001c0000 08:11 6828166 /lib/x86_64-linux-gnu/libc-2.23.so
7f42fd18a000-7f42fd18e000 r-xp 001c0000 08:11 6828166 /lib/x86_64-linux-gnu/libc-2.23.so
7f42fd18e000-7f42fd190000 rwxp 001c4000 08:11 6828166 /lib/x86_64-linux-gnu/libc-2.23.so
7f42fd190000-7f42fd194000 rwxp 00000000 00:00 0
7f42fd194000-7f42fd1ba000 r-xp 00000000 08:11 6815831 /lib/x86_64-linux-gnu/ld-2.23.so
7f42fd384000-7f42fd387000 rwxp 00000000 00:00 0
7f42fd3b6000-7f42fd3b9000 rwxp 00000000 00:00 0
7f42fd3b9000-7f42fd3ba000 r-xp 00025000 08:11 6815831 /lib/x86_64-linux-gnu/ld-2.23.so
7f42fd3ba000-7f42fd3bb000 rwxp 00026000 08:11 6815831 /lib/x86_64-linux-gnu/ld-2.23.so
7f42fd3bb000-7f42fd3bc000 rwxp 00000000 00:00 0
7ffc5e3c3000-7ffc5e3e4000 rwxp 00000000 00:00 0 [stack]
7ffc5e3f7000-7ffc5e3f9000 r--p 00000000 00:00 0 [vvar]
7ffc5e3f9000-7ffc5e3fb000 r-xp 00000000 00:00 0 [vdso]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0 [vsyscall]
9320 dgsh: timeout for negotiation. Exit.
9321 dgsh: timeout for negotiation. Exit.
9319 dgsh: timeout for negotiation. Exit.
9318 dgsh: timeout for negotiation. Exit.
9323 dgsh: timeout for negotiation. Exit.
9324 dgsh: timeout for negotiation. Exit.
9322 dgsh: timeout for negotiation. Exit.
9325 dgsh: timeout for negotiation. Exit.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment