From bb3dacc60498a096eda2dbd32cbbf65d0482fe99 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Mon, 23 May 2022 17:09:21 +0000 Subject: [PATCH 01/19] blaze822: don't try to open /dev/stdin Use the same check is blaze822() as in blaze822_file() to ensure that we don't try to open /dev/stdin, which is non-POSIX. Message-Id: <20220523170921.2623516-1-hi@alyssa.is> --- blaze822.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/blaze822.c b/blaze822.c index 9262f6f..47f03a2 100644 --- a/blaze822.c +++ b/blaze822.c @@ -443,7 +443,10 @@ blaze822(char *file) if (!mesg) return 0; - fd = open(file, O_RDONLY); + if (strcmp(file, "/dev/stdin") == 0) + fd = dup(0); + else + fd = open(file, O_RDONLY); if (fd < 0) { free(mesg); return 0; From bbc754e2a164cebb1a67a1a12bd3ab338cb0beba Mon Sep 17 00:00:00 2001 From: jgart <47760695+jgarte@users.noreply.github.com> Date: Fri, 13 May 2022 15:02:27 -0500 Subject: [PATCH 02/19] List commands ~respectively Closes: #228 [via git-merge-pr] --- man/mcom.1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/man/mcom.1 b/man/mcom.1 index 36fd6f3..957c322 100644 --- a/man/mcom.1 +++ b/man/mcom.1 @@ -6,7 +6,7 @@ .Nm mfwd , .Nm mbnc , .Nm mrep -.Nd compose, reply, forward, bounce, send messages +.Nd compose, forward, bounce, reply, send messages .Sh SYNOPSIS .Nm mcom .Op Fl Ar header Ar values\ ... From 877569a6f3810a3ef8672bd9c056f313e77d2ea1 Mon Sep 17 00:00:00 2001 From: gco Date: Fri, 10 Jun 2022 20:08:40 -0700 Subject: [PATCH 03/19] if -fstack-protector-strong is used, it needs to be specified for both compiling and linking Closes: #229 [via git-merge-pr] --- GNUmakefile | 1 + 1 file changed, 1 insertion(+) diff --git a/GNUmakefile b/GNUmakefile index 07a0b1a..c90e938 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -1,5 +1,6 @@ CFLAGS?=-g -O2 -fstack-protector-strong -D_FORTIFY_SOURCE=2 override CFLAGS:=-Wall -Wno-switch -Wextra $(CFLAGS) +LDFLAGS?=-fstack-protector-strong LDLIBS=-lrt OS := $(shell uname) From e6813fd07cb102f5e0826bf33560d4cfa255073a Mon Sep 17 00:00:00 2001 From: gco Date: Fri, 10 Jun 2022 20:11:53 -0700 Subject: [PATCH 04/19] solaris needs termios.h and __EXTENSIONS__ for TIOCGWINSZ and winsize --- mflow.c | 5 +++++ mscan.c | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/mflow.c b/mflow.c index 9bed19d..5ba925e 100644 --- a/mflow.c +++ b/mflow.c @@ -1,3 +1,7 @@ +#ifdef __sun +#define __EXTENSIONS__ /* to get TIOCGWINSZ */ +#endif + #include #include @@ -9,6 +13,7 @@ #include #include #include +#include #include "blaze822.h" #include "xpledge.h" diff --git a/mscan.c b/mscan.c index 52ba9a4..0494409 100644 --- a/mscan.c +++ b/mscan.c @@ -1,6 +1,9 @@ #ifndef _XOPEN_SOURCE #define _XOPEN_SOURCE 700 #endif +#ifdef __sun +#define __EXTENSIONS__ /* to get TIOCGWINSZ */ +#endif #include "xpledge.h" @@ -19,6 +22,7 @@ #include #include #include +#include #include "blaze822.h" #include "u8decode.h" From 9d66764434f640f8c36bbbf93a30d8f5d44ee6c9 Mon Sep 17 00:00:00 2001 From: Omar Polo Date: Fri, 26 Aug 2022 11:18:06 +0200 Subject: [PATCH 05/19] mrefile/mdeliver: -M needs the `fattr' pledge promise for utimes(2) Message-Id: <2Z5ISO2SNIGZU.2E8B1F41F84RV@venera> --- mdeliver.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mdeliver.c b/mdeliver.c index c9e00c5..5269929 100644 --- a/mdeliver.c +++ b/mdeliver.c @@ -355,7 +355,11 @@ usage2: if (argc != optind+1) goto usage2; - xpledge("stdio rpath wpath cpath", ""); + xpledge("stdio rpath wpath cpath fattr", ""); + if (!preserve_mtime && !Mflag) { + /* drop fattr */ + xpledge("stdio rpath wpath cpath", ""); + } targetdir = argv[optind]; From 8d543fdb2115341ce7d2e3c2e866f2663fbe08c8 Mon Sep 17 00:00:00 2001 From: codesoap Date: Wed, 9 Nov 2022 22:55:18 +0100 Subject: [PATCH 06/19] mcom: allow spaces in sequence for mbnc and mrep Closes: #231 [via git-merge-pr] --- mcom | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mcom b/mcom index d60070e..fb48401 100755 --- a/mcom +++ b/mcom @@ -321,7 +321,10 @@ fi ) fi ;; *mbnc*) + old_ifs="$IFS" + IFS=$NL set -- $(mseq -- "$@") + IFS="$old_ifs" if [ "$#" -ne 1 ]; then printf 'mbnc: needs exactly one mail to bounce\n' 1>&2 exit 1 @@ -344,7 +347,10 @@ fi ) ;; *mrep*) + old_ifs="$IFS" + IFS=$NL set -- $(mseq -- "$@") + IFS="$old_ifs" if [ "$#" -ne 1 ]; then printf 'mrep: needs exactly one mail to reply to\n' 1>&2 exit 1 From 1babebc12c3ea8d3395f00c9607e863866c190fc Mon Sep 17 00:00:00 2001 From: Michael Forney Date: Wed, 7 Dec 2022 13:11:58 -0800 Subject: [PATCH 07/19] mlist: use fixed-width integer types for struct linux_dirent64 d_ino and d_off --- mlist.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mlist.c b/mlist.c index 5debf99..20061d9 100644 --- a/mlist.c +++ b/mlist.c @@ -111,8 +111,8 @@ list(char *prefix, char *file) #include struct linux_dirent64 { - ino64_t d_ino; /* 64-bit inode number */ - off64_t d_off; /* 64-bit offset to next structure */ + uint64_t d_ino; /* 64-bit inode number */ + int64_t d_off; /* 64-bit offset to next structure */ unsigned short d_reclen; /* Size of this dirent */ unsigned char d_type; /* File type */ char d_name[]; /* Filename (null-terminated) */ From 74e77845c3fb259a73e598ac2176cc1b88133401 Mon Sep 17 00:00:00 2001 From: Michael Forney Date: Wed, 7 Dec 2022 13:34:37 -0800 Subject: [PATCH 08/19] mmime: include strings.h for strncasecmp --- mmime.c | 1 + 1 file changed, 1 insertion(+) diff --git a/mmime.c b/mmime.c index ab5bcf4..6334569 100644 --- a/mmime.c +++ b/mmime.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include From 2365f48f06a05e8c9ffbb2430ee994c0b43ea82a Mon Sep 17 00:00:00 2001 From: Leah Neukirchen Date: Fri, 9 Dec 2022 19:53:53 +0100 Subject: [PATCH 09/19] mcolor: print out form-feed --- mcolor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mcolor b/mcolor index d3a402a..ba2c42c 100755 --- a/mcolor +++ b/mcolor @@ -7,7 +7,7 @@ function so(s) { return sprintf("\033[1m%s\033[0m", s) } BEGIN { hdr = 1; if ("NO_COLOR" in ENVIRON || match(ENVIRON["TERM"], "^(dumb|network|9term)")) no_color = 1 } no_color { print; next } /\r$/ { sub(/\r$/, "") } -/^\014$/ { nextmail = 1; next } +/^\014$/ { nextmail = 1; print(fg(co("FF",232), $0)); next } /^$/ { hdr = 0 } /^-- $/ { ftr = 1 } /^--- .* ---/ { print fg(co("SEP",242), $0); ftr = 0; sig = 0; next } From cccf01cb9aa45769e2e9d41c1e8e98a6502a98e0 Mon Sep 17 00:00:00 2001 From: Leah Neukirchen Date: Sun, 18 Dec 2022 21:08:28 +0100 Subject: [PATCH 10/19] mrep/mbnc: use mseq -r as leading whitespace is now significant. Reported by lhynes. --- mcom | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mcom b/mcom index fb48401..397cb5f 100755 --- a/mcom +++ b/mcom @@ -323,7 +323,7 @@ fi *mbnc*) old_ifs="$IFS" IFS=$NL - set -- $(mseq -- "$@") + set -- $(mseq -r -- "$@") IFS="$old_ifs" if [ "$#" -ne 1 ]; then printf 'mbnc: needs exactly one mail to bounce\n' 1>&2 @@ -343,13 +343,13 @@ fi printf 'Resent-Date: %s\n' "$(mdate)" ( IFS=$NL - cat $(mseq -- "$@") + cat $(mseq -r -- "$@") ) ;; *mrep*) old_ifs="$IFS" IFS=$NL - set -- $(mseq -- "$@") + set -- $(mseq -r -- "$@") IFS="$old_ifs" if [ "$#" -ne 1 ]; then printf 'mrep: needs exactly one mail to reply to\n' 1>&2 From 1838158ef19d489e554b3460059fba47d26ba145 Mon Sep 17 00:00:00 2001 From: Leah Neukirchen Date: Thu, 16 Mar 2023 19:54:46 +0100 Subject: [PATCH 11/19] blaze822_priv.h: use proper lc/uc Mail headers may contain characters where the simple definition breaks, which results in wrong formatting on output. Fixes #235. --- blaze822_priv.h | 6 +++--- rfc2047.c | 3 ++- t/1100-mhdr.t | 26 ++++++++++++++++++++++++++ 3 files changed, 31 insertions(+), 4 deletions(-) create mode 100755 t/1100-mhdr.t diff --git a/blaze822_priv.h b/blaze822_priv.h index a84c963..e5f4a09 100644 --- a/blaze822_priv.h +++ b/blaze822_priv.h @@ -12,9 +12,9 @@ struct message { #define isfws(c) (((unsigned char)(c) == ' ' || (unsigned char)(c) == '\t' || (unsigned char)(c) == '\n' || (unsigned char)(c) == '\r')) -// ASCII lowercase/uppercase without alpha check (wrong for "@[\]^_") -#define lc(c) ((c) | 0x20) -#define uc(c) ((c) & 0xdf) +// 7bit-ASCII only lowercase/uppercase +#define lc(c) (((unsigned)(c)-'A') < 26 ? ((c) | 0x20) : (c)) +#define uc(c) (((unsigned)(c)-'a') < 26 ? ((c) & 0xdf) : (c)) // dirent type that can be a mail/dir (following symlinks) #if defined(DT_REG) && defined(DT_LNK) && defined(DT_UNKNOWN) diff --git a/rfc2047.c b/rfc2047.c index 3074b4d..5aec546 100644 --- a/rfc2047.c +++ b/rfc2047.c @@ -201,7 +201,8 @@ blaze822_decode_rfc2047(char *dst, char *src, size_t dlen, char *tgtenc) if (ic == (iconv_t)-1) goto nocode; - char enc = lc(*e++); + char enc = lc(*e); + e++; if (*e++ != '?') goto nocode; char *start = e; diff --git a/t/1100-mhdr.t b/t/1100-mhdr.t new file mode 100755 index 0000000..9937041 --- /dev/null +++ b/t/1100-mhdr.t @@ -0,0 +1,26 @@ +#!/bin/sh -e +cd ${0%/*} +. ./lib.sh + +plan 9 + +cat <tmp +Header: foo +Header2: bar +Header-Three: quux +Header_Four: ding + +Body +EOF + +check_same 'Header' 'mhdr -h Header ./tmp' 'echo foo' +check_same 'Header2' 'mhdr -h Header2 ./tmp' 'echo bar' +check_same 'Header-Three' 'mhdr -h Header-Three ./tmp' 'echo quux' +check_same 'Header_Four' 'mhdr -h Header_Four ./tmp' 'echo ding' + +check_same 'header' 'mhdr -h header ./tmp' 'echo foo' +check_same 'header2' 'mhdr -h header2 ./tmp' 'echo bar' +check_same 'header-Three' 'mhdr -h header-Three ./tmp' 'echo quux' +check_same 'header_Four' 'mhdr -h header_Four ./tmp' 'echo ding' + +check 'issue 235' 'mhdr ./tmp |grep -i header_four' From 786238551a692a8073d02d4f4aea89f3212391c9 Mon Sep 17 00:00:00 2001 From: Mark Hills Date: Thu, 30 Mar 2023 15:07:05 +0100 Subject: [PATCH 12/19] Document a reasonable practice for deleting mails Discussed in #236. --- man/mblaze.7 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/man/mblaze.7 b/man/mblaze.7 index 328bcef..da2aebf 100644 --- a/man/mblaze.7 +++ b/man/mblaze.7 @@ -163,6 +163,9 @@ thread it and look at it interactively: Or you could list the attachments of the 20 largest messages in your INBOX: .Dl mlist ~/Maildir/INBOX | msort -S | tail -20 | mshow -t .Pp +Or delete messages beyond a certain age: +.Dl mlist ~/Maildir/INBOX | mpick -t 'mtime < \&"-365d\&"' | xargs rm +.Pp Or apply the patches from the current message: .Dl mshow -O . '*.diff' | patch .Pp From ce435c8f6fd4987db36747156ddce811ebf6fd67 Mon Sep 17 00:00:00 2001 From: Johannes Thyssen Tishman Date: Thu, 22 Jun 2023 19:26:39 +0200 Subject: [PATCH 13/19] Add Drafts profile key Allow the user to set a Drafts key in profile to store draft messages and sent messages separately if Outbox is set. --- man/mblaze-profile.5 | 7 +++++-- mcom | 14 ++++++++------ 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/man/mblaze-profile.5 b/man/mblaze-profile.5 index 65d1b3d..fe58309 100644 --- a/man/mblaze-profile.5 +++ b/man/mblaze-profile.5 @@ -52,8 +52,11 @@ generation in .It Li Outbox\&: If set, .Xr mcom 1 -will create draft messages in this maildir, -and save messages there after sending. +will save messages in this maildir after sending. +.It Li Drafts\&: +If set, +.Xr mcom 1 +will create draft messages in this maildir (defaults to Outbox). .It Li Reply-From\&: A comma-separated list of display name and mail address pairs, formatted like this: .Dl Li Primary Name , Name v.2 , \[dq]Name, My Third\[dq] , ... diff --git a/mcom b/mcom index 397cb5f..2cc4df5 100755 --- a/mcom +++ b/mcom @@ -236,7 +236,9 @@ esac hdrs="$(printf '%s\n' "${hdrs#$NL}" | mhdr -)" outbox=$(mhdr -h outbox "$MBLAZE/profile" | sed "s:^~/:$HOME/:") -if [ -z "$outbox" ]; then +draftbox=$(mhdr -h drafts "$MBLAZE/profile" | sed "s:^~/:$HOME/:") +draftbox="${draftbox:-$outbox}" +if [ -z "$draftbox" ]; then if [ -z "$resume" ]; then i=0 while [ -f "snd.$i" ]; do @@ -249,13 +251,13 @@ if [ -z "$outbox" ]; then draftmime="$draft.mime" else if [ -z "$resume" ]; then - draft="$(true | mdeliver -v -c -XD "$outbox")" + draft="$(true | mdeliver -v -c -XD "$draftbox")" if [ -z "$draft" ]; then - printf '%s\n' "$0: failed to create draft in outbox $outbox." 1>&2 + printf '%s\n' "$0: failed to create draft in outbox $draftbox." 1>&2 exit 1 fi elif [ -z "$draft" ]; then - draft=$(mlist -D "$outbox" | msort -r -M | sed 1q) + draft=$(mlist -D "$draftbox" | msort -r -M | sed 1q) fi draftmime="$(printf '%s\n' "$draft" | sed 's,\(.*\)/cur/,\1/tmp/mime-,')" fi @@ -446,7 +448,7 @@ while :; do if $sendmail <"$draftmime"; then if [ "$outbox" ]; then mv "$draftmime" "$draft" - mflag -d -S "$draft" + mrefile $(mflag -d -S "$draft") "$outbox" else rm "$draft" "$draftmime" fi @@ -464,7 +466,7 @@ while :; do stampdate "$draft" if $sendmail <"$draft"; then if [ "$outbox" ]; then - mflag -d -S "$draft" + mrefile $(mflag -d -S "$draft") "$outbox" else rm "$draft" fi From 23a9e7022ea375aafc06ee28fd8466fccd0e5ded Mon Sep 17 00:00:00 2001 From: Johannes Thyssen Tishman Date: Fri, 23 Jun 2023 09:56:14 +0200 Subject: [PATCH 14/19] Quote command expansion to prevent word splitting This is necessary to support maildir paths that contain spaces. Closes: #242 [via git-merge-pr] --- mcom | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mcom b/mcom index 2cc4df5..4e834c6 100755 --- a/mcom +++ b/mcom @@ -448,7 +448,7 @@ while :; do if $sendmail <"$draftmime"; then if [ "$outbox" ]; then mv "$draftmime" "$draft" - mrefile $(mflag -d -S "$draft") "$outbox" + mrefile "$(mflag -d -S "$draft")" "$outbox" else rm "$draft" "$draftmime" fi @@ -466,7 +466,7 @@ while :; do stampdate "$draft" if $sendmail <"$draft"; then if [ "$outbox" ]; then - mrefile $(mflag -d -S "$draft") "$outbox" + mrefile "$(mflag -d -S "$draft")" "$outbox" else rm "$draft" fi From 43f2cb8b491d95eb79b6b6d404865135971fe642 Mon Sep 17 00:00:00 2001 From: Leah Neukirchen Date: Tue, 18 Jul 2023 14:02:52 +0200 Subject: [PATCH 15/19] mscan: only spawn pager when stdout is a tty We still get the terminal size for when users manually page, e.g. mscan | less This is consistent with how mshow already works. Fixes #243. --- mscan.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/mscan.c b/mscan.c index 0494409..4052f1f 100644 --- a/mscan.c +++ b/mscan.c @@ -575,9 +575,13 @@ main(int argc, char *argv[]) struct winsize w; int ttyfd = open("/dev/tty", O_RDONLY | O_NOCTTY); - if (ttyfd >= 0 && ioctl(ttyfd, TIOCGWINSZ, &w) == 0) { - cols = w.ws_col; + if (ttyfd >= 0) { + if (ioctl(ttyfd, TIOCGWINSZ, &w) == 0) + cols = w.ws_col; + close(ttyfd); + } + if (isatty(1)) { char *pg; pg = getenv("MBLAZE_PAGER"); if (!pg) @@ -590,8 +594,6 @@ main(int argc, char *argv[]) pg, strerror(errno)); } } - if (ttyfd >= 0) - close(ttyfd); xpledge("stdio rpath", ""); From 75de7d47da797b5cf6e7a859a1bff030f7b571a3 Mon Sep 17 00:00:00 2001 From: Meudwy Date: Tue, 25 Jul 2023 11:55:26 +0100 Subject: [PATCH 16/19] minc: read directory names from stdin This matches `mlist` where it can take directories as arguments or via stdin. Closes: #244 [via git-merge-pr] --- GNUmakefile | 4 ++-- man/minc.1 | 3 +++ minc.c | 13 ++++++++----- t/9000-minc.t | 8 +++++++- 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/GNUmakefile b/GNUmakefile index c90e938..89cb779 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -28,8 +28,8 @@ all: $(ALL) museragent $(ALL) : % : %.o maddr magrep mdeliver mexport mflag mflow mgenmid mhdr mpick mscan msed mshow \ msort mthread : blaze822.o mymemmem.o mytimegm.o -maddr magrep mdeliver mexport mflag mgenmid mhdr mlist mpick mscan msed mseq \ - mshow msort mthread : seq.o slurp.o mystrverscmp.o +maddr magrep mdeliver mexport mflag mgenmid mhdr minc mlist mpick mscan msed \ + mseq mshow msort mthread : seq.o slurp.o mystrverscmp.o maddr magrep mflow mhdr mpick mscan mshow : rfc2047.o magrep mflow mhdr mshow : rfc2045.o mshow : filter.o safe_u8putstr.o rfc2231.o pipeto.o diff --git a/man/minc.1 b/man/minc.1 index cb71c85..6b7f96c 100644 --- a/man/minc.1 +++ b/man/minc.1 @@ -17,6 +17,9 @@ by moving them from to .Pa cur , and adjusting the filenames. +If used non-interactively with no specified folders, +.Nm +reads directory names from the standard input. .Pp By default, the new filenames are printed, separated by newlines. diff --git a/minc.c b/minc.c index c1d28fd..2811646 100644 --- a/minc.c +++ b/minc.c @@ -74,14 +74,17 @@ usage: exit(1); } - if (optind == argc) - goto usage; - xpledge("stdio rpath cpath", ""); status = 0; - for (i = optind; i < argc; i++) - inc(argv[i]); + if (optind == argc) { + if (isatty(0)) + goto usage; + blaze822_loop(0, 0, inc); + } else { + for (i = optind; i < argc; i++) + inc(argv[i]); + } return status; } diff --git a/t/9000-minc.t b/t/9000-minc.t index 3d5b789..9b29194 100644 --- a/t/9000-minc.t +++ b/t/9000-minc.t @@ -1,7 +1,7 @@ #!/bin/sh -e cd ${0%/*} . ./lib.sh -plan 1 +plan 2 rm -rf test.dir mkdir test.dir @@ -16,4 +16,10 @@ inbox/new/2 check_test 'minc' -eq 2 'minc inbox | wc -l' +while read f; do touch "$f"; done < Date: Tue, 25 Jul 2023 14:28:09 +0100 Subject: [PATCH 17/19] mdirs: add Maildir profile key When `mdirs` is executed without any arguments, look for the `Maildir` key in the profile and use that instead (if set). Closes: #245 [via git-merge-pr] --- GNUmakefile | 8 ++++---- man/mblaze-profile.5 | 4 ++++ man/mdirs.1 | 22 ++++++++++++++++++++-- mdirs.c | 41 ++++++++++++++++++++++++++++++++++++++--- 4 files changed, 66 insertions(+), 9 deletions(-) diff --git a/GNUmakefile b/GNUmakefile index 89cb779..d3c081e 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -26,10 +26,10 @@ SCRIPT = mcolor mcom mless mmkdir mquote museragent all: $(ALL) museragent $(ALL) : % : %.o -maddr magrep mdeliver mexport mflag mflow mgenmid mhdr mpick mscan msed mshow \ - msort mthread : blaze822.o mymemmem.o mytimegm.o -maddr magrep mdeliver mexport mflag mgenmid mhdr minc mlist mpick mscan msed \ - mseq mshow msort mthread : seq.o slurp.o mystrverscmp.o +maddr magrep mdeliver mdirs mexport mflag mflow mgenmid mhdr mpick mscan msed \ + mshow msort mthread : blaze822.o mymemmem.o mytimegm.o +maddr magrep mdeliver mdirs mexport mflag mgenmid mhdr minc mlist mpick mscan \ + msed mseq mshow msort mthread : seq.o slurp.o mystrverscmp.o maddr magrep mflow mhdr mpick mscan mshow : rfc2047.o magrep mflow mhdr mshow : rfc2045.o mshow : filter.o safe_u8putstr.o rfc2231.o pipeto.o diff --git a/man/mblaze-profile.5 b/man/mblaze-profile.5 index fe58309..d9aaad5 100644 --- a/man/mblaze-profile.5 +++ b/man/mblaze-profile.5 @@ -49,6 +49,10 @@ The fully qualified domain name used for .Li Message\&-Id\&: generation in .Xr mgenmid 1 . +.It Li Maildir\&: +If set, +.Xr mdirs 1 +will use this maildir when no directories are supplied. .It Li Outbox\&: If set, .Xr mcom 1 diff --git a/man/mdirs.1 b/man/mdirs.1 index 44ffae4..f564803 100644 --- a/man/mdirs.1 +++ b/man/mdirs.1 @@ -1,4 +1,4 @@ -.Dd January 22, 2020 +.Dd July 25, 2023 .Dt MDIRS 1 .Os .Sh NAME @@ -17,6 +17,14 @@ for maildir folders and prints them, separated by newlines. .Pp +If +.Ar dirs +is not present then use +.Sq Li Maildir\&: +from +.Pa "${MBLAZE:-$HOME/.mblaze}/profile" +.Pq if set . +.Pp To .Nm , a maildir folder is a directory containing @@ -36,10 +44,20 @@ Print folders separated by a NUL character. .It Fl a Traverse into all subfolders, without considering the maildir++ name conventions. .El +.Sh ENVIRONMENT +.Bl -tag -width Ds +.It Ev MBLAZE +Directory containing mblaze configuration. +.Po +Default: +.Pa $HOME/.mblaze +.Pc +.El .Sh EXIT STATUS .Ex -std .Sh SEE ALSO -.Xr find 1 +.Xr find 1 , +.Xr mblaze-profile 5 .Sh AUTHORS .An Leah Neukirchen Aq Mt leah@vuxu.org .Sh LICENSE diff --git a/mdirs.c b/mdirs.c index 5f49906..89ebab5 100644 --- a/mdirs.c +++ b/mdirs.c @@ -3,8 +3,10 @@ #include #include +#include #include #include +#include #include #include "blaze822.h" @@ -72,6 +74,33 @@ mdirs(char *fpath) closedir(dir); } +char * +profile_maildir() +{ + char *f = blaze822_home_file("profile"); + struct message *config = blaze822(f); + char *maildir; + static char path[PATH_MAX]; + + if (!config) + return 0; + + if (!(maildir = blaze822_hdr(config, "maildir"))) + return 0; + + if (strncmp(maildir, "~/", 2) == 0) { + const char *home = getenv("HOME"); + if (!home) { + struct passwd *pw = getpwuid(getuid()); + home = pw ? pw->pw_dir : "/dev/null/homeless"; + } + snprintf(path, sizeof path, "%s/%s", home, maildir+2); + maildir = path; + } + + return maildir; +} + int main(int argc, char *argv[]) { @@ -86,11 +115,17 @@ usage: exit(1); } - if (argc == optind) - goto usage; - xpledge("stdio rpath", ""); + if (argc == optind) { + char *maildir = profile_maildir(); + if (maildir) { + mdirs(maildir); + return 0; + } + goto usage; + } + char toplevel[PATH_MAX]; if (!getcwd(toplevel, sizeof toplevel)) { perror("mdirs: getcwd"); From 59ee2e0ab9f6721ffb6e0b686582d1d121b7a6cf Mon Sep 17 00:00:00 2001 From: Leah Neukirchen Date: Mon, 31 Jul 2023 21:12:38 +0200 Subject: [PATCH 18/19] mgpg: use quiet to only print errors Else it can happen that gpg output is prepended to the message we want to decode, and recursive decoding fails. --- contrib/mgpg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/mgpg b/contrib/mgpg index 4a46701..4190501 100755 --- a/contrib/mgpg +++ b/contrib/mgpg @@ -20,7 +20,7 @@ n=$(mshow -t "$tmp" | awk -F: ' /: application\/octet-stream/ {if (supported) print $1}') if [ "$n" ]; then - mshow -O "$tmp" "$n" | $GPG -d 2>&1 || exit 0 + mshow -O "$tmp" "$n" | $GPG --quiet -d 2>&1 || exit 0 exit 64 fi exit 63 From 5310c4ea38a99e99c2c6c944e651bbc8e72a3d92 Mon Sep 17 00:00:00 2001 From: Johannes Thyssen Tishman Date: Thu, 5 Oct 2023 15:39:46 +0200 Subject: [PATCH 19/19] mcolor: Add coloring support for diffs Closes: #249 [via git-merge-pr] --- mcolor | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mcolor b/mcolor index ba2c42c..6e3417f 100755 --- a/mcolor +++ b/mcolor @@ -8,14 +8,18 @@ BEGIN { hdr = 1; if ("NO_COLOR" in ENVIRON || match(ENVIRON["TERM"], "^(dumb|net no_color { print; next } /\r$/ { sub(/\r$/, "") } /^\014$/ { nextmail = 1; print(fg(co("FF",232), $0)); next } -/^$/ { hdr = 0 } +/^$/ { hdr = 0; diff = 0 } /^-- $/ { ftr = 1 } +/^diff -/ { diff = 1 } /^--- .* ---/ { print fg(co("SEP",242), $0); ftr = 0; sig = 0; next } /^-----BEGIN .* SIGNATURE-----/ { sig = 1 } nextmail && /^From:/ { hdr = 1 } hdr && /^From:/ { print so(fg(co("FROM",119), $0)); next } hdr { print fg(co("HEADER",120), $0); next } ftr { print fg(co("FOOTER",244), $0); next } +diff && /^-/ { print fg(co("DIFF_D",160), $0); next } +diff && /^\+/ { print fg(co("DIFF_I",40), $0); next } +diff && /^@/ { print fg(co("DIFF_R",226), $0); next } /^-----BEGIN .* MESSAGE-----/ || /^-----END .* SIGNATURE-----/ { print fg(co("SIG",244), $0); sig = 0; next } sig { print fg(co("SIG",244), $0); next }