X-Git-Url: https://ruderich.org/simon/gitweb/?a=blobdiff_plain;f=mail%2Fmutt%2Fcrypto-autoencrypt.pl;fp=mail%2Fmutt%2Fcrypto-autoencrypt.pl;h=08cf146bff5e94304c6d20a82c636dfb40540760;hb=214dc48c13fb068452efcb832809bddf6c5601a5;hp=0000000000000000000000000000000000000000;hpb=7944bc5ce0d42f27738cc087ece4edbba02d0747;p=config%2Fdotfiles.git diff --git a/mail/mutt/crypto-autoencrypt.pl b/mail/mutt/crypto-autoencrypt.pl new file mode 100755 index 0000000..08cf146 --- /dev/null +++ b/mail/mutt/crypto-autoencrypt.pl @@ -0,0 +1,38 @@ +#!/usr/bin/perl + +# Helper script for mutt to create a list of send-hooks which enable +# crypt_autoencrypt for known GnuPG keys. + +# Copyright (C) 2009-2013 Simon Ruderich +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + + +use strict; +use warnings; + +open my $gpg, '-|', 'gpg --list-keys --with-colons --fixed-list-mode' or die $!; +while (<$gpg>) { + next if not /^uid:/; + + # We don't skip invalid, deleted, revoked, expired and not-trusted UIDs to + # prevent sending an unencrypted mail when e.g. a key is revoked or + # expired; GnuPG will warn if we use any of them. If you really want to + # skip those UIDs (not recommended), uncomment the next line. + #next if /^uid:[idren]:/; + + next if not /<(.+?@.+?)>:/; + print "send-hook '~t $1' 'set crypt_autoencrypt=yes'\n"; +} +close $gpg or die $!;