Search code examples
linuxgoserial-portpostfix-mta

/dev/ttyACM0 File does not exist while Postfix pipe


When I run script as regular user manually, everything is OK. But if an email is received and piped into Go script, I can not open serial port because file does not exist.

postfix   1239  1025  0 13:20 ? 00:00:00 pipe -n watchParadox -t unix flags=F user=watch argv=/usr/local/bin/watch -paradox
watch     1240  1239  0 13:20 ? 00:00:00 /usr/local/bin/watch -paradox

Script is running under watch user who has been added to dialout group, postfix user, just to be sure, is in dialout also.

In my script I ran ls -la command to find out which files do truly exist:

drwxr-xr-x   6 root root  380 Feb 25 13:19 .
dr-xr-xr-x. 18 root root 4096 Feb 22 17:53 ..
lrwxrwxrwx   1 root root   11 Feb 25 13:19 core -> /proc/kcore
lrwxrwxrwx   1 root root   13 Feb 25 13:19 fd -> /proc/self/fd
crw-rw-rw-   1 root root 1, 7 Feb 25 13:19 full
drwxr-xr-x   2 root root    0 Feb 25 13:19 hugepages
lrwxrwxrwx   1 root root   28 Feb 25 13:19 log -> /run/systemd/journal/dev-log
drwxrwxrwt   2 root root   40 Feb 25 13:19 mqueue
crw-rw-rw-   1 root root 1, 3 Feb 25 13:19 null
lrwxrwxrwx   1 root root    8 Feb 25 13:19 ptmx -> pts/ptmx
drwxr-xr-x   2 root root    0 Feb 25 13:19 pts
crw-rw-rw-   1 root root 1, 8 Feb 25 13:19 random
drwxrwxrwt   2 root root   40 Feb 25 13:19 shm
lrwxrwxrwx   1 root root   15 Feb 25 13:19 stderr -> /proc/self/fd/2
lrwxrwxrwx   1 root root   15 Feb 25 13:19 stdin -> /proc/self/fd/0
lrwxrwxrwx   1 root root   15 Feb 25 13:19 stdout -> /proc/self/fd/1
crw-rw-rw-   1 root root 5, 0 Feb 25 13:19 tty
crw-rw-rw-   1 root root 1, 9 Feb 25 13:19 urandom 

I am certain following file exists but is not shown when postfix pipe is executed.

crw-rw---- 1 root dialout 166, 0 25. úno 13.19 ttyACM0

I tried chmod 777 on the file but no luck in that department. Opening file via https://github.com/tarm/serial library which uses Go function:

os.OpenFile("ttyACM0", syscall.O_RDWR|syscall.O_NOCTTY|syscall.O_NONBLOCK, 0666)

results with

ttyACM0: no such file or directory

The problem is not the path because I tried relative (using chdir) and absolute with same exact outcome.

I even disabled SELinux which is not what I want to do but in search of solution I try anything.

Code is OK because manual execution of the script passes through properly. I think there is something wrong with Linux settings.


Solution

  • It seems like it was truly Linux problem and some underlying fabrics of it which I do not understand. I was running Fedora25 but the problem does not occur on Debian8.