Test Post

Date: 2021-09-19

modDate: 2022-04-17

tags: test

This is a test post for mod date.

Testing image in sub-directory.

And an inline image following this:

You Shall Not Pass

nixos nfs

Date: 2022-05-10

modDate: 2022-05-10

tags: nixos nfs openbsd

I migrated from FreeBSD to NixOS for my nas. Apparently I never tested/used NFS on the new OS. When I went to mount my music share from my OpenBSD client I received the following error.

NFS Portmap: RPC: Program not registered

I followed this guide to add NFS to the NixOS config.

NixOS NFS WIki

That partially worked. I could use the local client in the example to connect and an Arch Linux client could connect. But my OpenBSD client would not connect.

After some (ok a lot) of searching I stumbled upon this guide, which suggested to run the below rpcinfo commands.

https://misc.openbsd.narkive.com/WSgxZV17/nfs-protocol-not-supported-when-mounting-from-a-linux-machine

rpcinfo -t hostname mountd
rpcinfo -u hostname mountd
rpcinfo -t hostname nfs
rpcinfo -u hostname nfs

When I got to this one it became obvious what was really going on.

rpcinfo -u nas nfs
rpcinfo: RPC: Program not registered
program 100003 is not available

It turns out that OpenBSD defaults to using UDP for NFS and Linux defaults to TCP. When I had ran my rpcinfo command I didn’t notice that there was a UDP entry missing for the NFS service.

rpcinfo -p nas
   program vers proto   port
    100000    4   tcp    111  portmapper
    100000    3   tcp    111  portmapper
    100000    2   tcp    111  portmapper
    100000    4   udp    111  portmapper
    100000    3   udp    111  portmapper
    100000    2   udp    111  portmapper
    100024    1   udp   4000  status
    100024    1   tcp   4000  status
    100005    1   udp   4002  mountd
    100005    1   tcp   4002  mountd
    100005    2   udp   4002  mountd
    100005    2   tcp   4002  mountd
    100005    3   udp   4002  mountd
    100005    3   tcp   4002  mountd
    100003    3   tcp   2049  nfs
    100003    4   tcp   2049  nfs
    100227    3   tcp   2049
    100021    1   udp   4001  nlockmgr
    100021    3   udp   4001  nlockmgr
    100021    4   udp   4001  nlockmgr
    100021    1   tcp   4001  nlockmgr
    100021    3   tcp   4001  nlockmgr
    100021    4   tcp   4001  nlockmgr

showmount -e nas
Exports list on nas:
export                            192.168.88.0/24
export/music                      192.168.88.0/24

I tried mount_nfs with the -T option to specify using TCP and it worked!

mount_nfs -T nas:/export/music /mnt/nas-media

I then hunted around for the flag for NixOS to add a UDP service for NFS. You need to add udp=y. The below is the NFS config for my NixOS.

services = {
  nfs = {
    server.enable = true;
    server.exports = ''
      /export          192.168.88.0/24(rw,fsid=0,no_subtree_check)
      /export/music    192.168.88.0/24(rw,nohide,insecure,no_subtree_check)
    '';
    # for nvsv3
    # fixed rpc.statd port; for firewall
    server.statdPort  = 4000;
    server.lockdPort  = 4001;
    server.mountdPort = 4002;
    server.extraNfsdConfig = ''udp=y'';
  }:
}:

# Open ports in the firewall.
networking.firewall.enable = true;
networking.firewall.allowedTCPPorts = [ 111 2049 4000 4001 4002 20048 ];
networking.firewall.allowedUDPPorts = [ 111 2049 4000 4001 4002 20048 ];

Now rpcinfo shows:

rpcinfo -p nas
   program vers proto   port
    100000    4   tcp    111  portmapper
    100000    3   tcp    111  portmapper
    100000    2   tcp    111  portmapper
    100000    4   udp    111  portmapper
    100000    3   udp    111  portmapper
    100000    2   udp    111  portmapper
    100005    1   udp   4002  mountd
    100005    1   tcp   4002  mountd
    100005    2   udp   4002  mountd
    100005    2   tcp   4002  mountd
    100005    3   udp   4002  mountd
    100005    3   tcp   4002  mountd
    100024    1   udp   4000  status
    100024    1   tcp   4000  status
    100003    3   tcp   2049  nfs
    100003    4   tcp   2049  nfs
    100227    3   tcp   2049
    100003    3   udp   2049  nfs
    100227    3   udp   2049
    100021    1   udp   4001  nlockmgr
    100021    3   udp   4001  nlockmgr
    100021    4   udp   4001  nlockmgr
    100021    1   tcp   4001  nlockmgr
    100021    3   tcp   4001  nlockmgr
    100021    4   tcp   4001  nlockmgr

Also NixOS supports NFS versions 3 through 4.2 and OpenBSD supports versions 2 and 3. However both OSs do successfully negotiate to use version 3.

offlineimap nametrans

Date: 2022-04-03

modDate: 2022-04-04

tags: offlineimap notmuch emacs neomutt

I wanted to add a second email provider and have it integrated into my current Maildir folder so I didn’t have to jump through hoops configuring notmuch, emacs, and neomutt to use different Maildir directories.

The offlineimap nametrans doc hints at that but at least for me wasn’t clear enough on how to set that up.

In a new local repository section I added:

nametrans = lambda foldername: re.sub('\.gandi$', '', foldername)

And in a new remote repository section I added:

nametrans = lambda foldername: re.sub('(^INBOX|^Sent)', foldername + '.gandi', foldername)

folderfilter = lambda foldername: re.search('^INBOX$', foldername) \ or re.search('^Sent$', foldername)

The remote nametrans adds a suffix to my INBOX and Sent folders so they won’t collide with my other mail provider. The local one removes the suffix so it can be mapped back to my new provider.

The folderfilter restricts my download email to just those two folders.

Then in my first mail provider’s local repository section I added the below so offlineimap won’t try and sync the second providers folders to it:

folderfilter = lambda foldername: not re.search('\.gandi$', foldername)

You can find the scripts here

emacs/notmuch helper scripts part II

Date: 2021-10-02

modDate: 2021-10-02

tags: emacs notmuch

How to delete and move email - Part II

Part I

One of the ugly parts of doing a move this way was the helper shell script was hard coded and quite ugly. Each folder you wanted to support had to have an entry similar to the following:

notmuch search --format=text0 --output=files tag:move:inbox | xargs -n1 -0 -r -t ~/bin/my_mv.sh ~/Maildir/INBOX/cur/.
notmuch tag -move:inbox -flagged tag:move:inbox

I wrote a few elisp functions that pattern match your typed input with what folders exist in your Maildir directory and also allow for tab completion.

;; functions to move mail
;; in message move mail
(defun my-move-dir-msg-execute (&optional new-tags)
  (notmuch-show-tag-message (concat "+move:" new-tags))
  ;;(rename-file (notmuch-show-get-filename) (concat "~/Maildir/" new-tags "/cur/"))
  (notmuch-poll-and-refresh-this-buffer)
  )

(defun my-move-dir-msg (&optional kill)
  (interactive "P")
  (let ((dirs (directory-files "~/Maildir" nil ))
        (prompt (if kill "Copy DIR to kill ring: " "Browse DIR: "))
        (fn (if kill #'kill-new 'my-move-dir-msg-execute)))
    (if dirs
        (funcall fn (completing-read prompt dirs nil nil nil nil (car dirs)))
      (message "No DIRs found."))))

;; map for message
(define-key notmuch-show-mode-map "M" #'my-move-dir-msg)

;; in search view move message
(defun my-move-dir-search-execute (&optional new-tags)
  ;;(message "selected dir: %s" new-tags)
  ;;(message "move: %s" (concat "+move:" new-tags))
  (notmuch-search-tag (list (concat "+move:" new-tags)))
  (notmuch-poll-and-refresh-this-buffer)
  )

(defun my-move-dir-search (&optional kill)
  (interactive "P")
  (let ((dirs (directory-files "~/Maildir" nil ))
        (prompt (if kill "Copy DIR to kill ring: " "Browse DIR: "))
        (fn (if kill #'kill-new 'my-move-dir-search-execute)))
    (if dirs
        (funcall fn (completing-read prompt dirs nil nil nil nil (car dirs)))
      (message "No DIRs found."))))

Then I added the below snippet to my move shell script:

notmuch search tag:/move:.*/ | while read -r i
do
        thread=`echo $i | cut -c1-23`
        #dir=`echo $i | cut -c72- | cut -d':' -f2 | cut -d' ' -f1 | cut -d')' -f1`
        dir=`echo $i | sed -e's/.*(.*move://' -e's/ .*)$//' -e's/)$//'`
        echo 'thread: ' $thread 'dir: ' $dir
        notmuch search --format=text0 --output=files tag:move:$dir | xargs -n1 -0 -r -t ~/bin/my_mv.sh ~/Maildir/$dir/cur/.
        notmuch new >/dev/null 2>&1
        notmuch tag -move:$dir -flagged -unread -- $thread
done

Now the move script has no hard coded folder names.

You can find the scripts here

FreeBSD ZFS umask issue

Date: 2020-11-29

modDate: 2020-11-29

tags: freebsd umask zfs

How to resolve not readable files

I am not sure how this started, but I assume I clicked some option on FreeNAS that set the ACL flag. Then I migrated to FreeBSD.

Unfortunately I set this flag on only a few directories and since I also had a hardware problem I didn’t notice right away or correlate it with other actions.

When I did discover it I was setting up a new NFS client to my NAS and thought it was an NFS issue.

Setting the ZFS ACL flag results in allowing you to create a file yet not being able to read it.

For example:

$ ls -l

total 1

---------- 1 jjf jjf 0 Nov 29 14:25 t

One way to tell if you have an ACL set is by the plus sign after the permissions.

drwxrwxr-x+ 14 jjf jjf 15 Nov 28 05:21 music

By running the following command you can recursively clear all ACLs that you may have set.

setfacl -Rb *

emacs/notmuch sent mail

Date: 2020-10-28

modDate: 2020-10-28

tags: emacs notmuch

How to copy an email to a sent folder

I have been puzzling over how to add my sent email to my Maildir/Sent folder. Clearly in FCC/BCC they describe the variable “notmuch-fcc-dirs” as a directory and in Maildir format.

However I could not get it to work. Since my mail provider handles plus addressing I decided to use that instead. I added a Bcc field to my header with my sent folder as a bcc in my init.el file.

(setq message-default-mail-headers "Bcc: mailID+Sent@mail.com")

Then after my Maildir sync program runs my Sent folder is copied down to my Maildir/Sent/cur directory.

emacs/notmuch helper scripts

Date: 2020-10-28

modDate: 2021-11-03

tags: emacs notmuch

How to delete and move email

Notmuch only indexes emails. They don’t modify any of your email in your Maildir folders.

This is mostly copied from other sites. However I am using OpenBSD and don’t have the GNU mv command with the -t flag to make life easy with the xargs command.

Edit: When I implemented emacs/notmuch helper scripts part II I had removed the “deleted” tag, since I wasn’t using it. By default notmuch will ignore any messages with this flag in a search. One thing I didn’t realize was this flag helps you visualize which messages are deleted in a thread with a lot of messages. I was just relying on the message residing in the Trash folder.

My emacs script now looks like:

(define-key notmuch-show-mode-map "d"
  (lambda ()
    "toggle deleted tag for message"
    (interactive)
    (if (member "move:trash" (notmuch-show-get-tags))
        (notmuch-show-tag (list "-move:trash" "-deleted"))
      (notmuch-show-tag (list "+move:trash" "+deleted" "-inbox" "-unread")))))

(define-key notmuch-search-mode-map "d"
  (lambda ()
    "toggle deleted tag for message"
    (interactive)
    (if (member "move:trash" (notmuch-search-get-tags))
        (notmuch-search-tag (list "-move:trash" "-deleted"))
      (notmuch-search-tag (list "+move:trash" "+deleted" "-inbox" "-unread")))))

My shell scripts look like:

notmuch_delete.sh:

/usr/local/bin/notmuch search --format=text0 --output=files "tag:deleted and not folder:Trash" | xargs -n1 -0 -r -t ~/bin/my_mv.sh ~/Maildir/Trash/cur/.

/usr/local/bin/notmuch new

my_mv.sh:

mv "$2" "$1"

Then after my Maildir sync program runs the message will be removed from the folder.

This can also be adopted to moving a message from one folder to another.

callerID

Date: 2020-07-19

modDate: 2020-07-19

tags: python

Finally cleaned up my caller ID blocker enough to publish it to git.

It uses a USRobotics USB modem to get the caller ID from a Plain Old telephone Service (POTS) line. It also announces the callers name from the address book via the connected speaker.

The repository is callerID

rssFeed

Date: 2020-07-17

modDate: 2020-07-17

tags: python

Finally cleaned up my news aggregator enough to publish it to git.

It will email you each story found in the news feeds. The repository is rssFeed

Welcome to my blog

Date: 2020-05-03

modDate: 2020-05-03

tags: smallblog

This is a filler post. I hope to post about technical projects I am working on. These include IoT and general programming.