Postfix管道中不存在/ dev / ttyACM0文件

时间:2017-02-25 12:55:39

标签: linux go serial-port postfix

当我手动以普通用户身份运行脚本时,一切正常。但是如果接收到电子邮件并将其传送到Go脚本,我就无法打开串口,因为文件不存在。

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

脚本在已添加到拨出组,后缀用户的手表用户下运行,只是为了确保,还在拨出中。

在我的脚本中,我运行了ls -la命令来找出确实存在的文件:

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 

我确定以下文件存在,但在执行postfix管道时不显示。

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

我在文件上尝试了chmod 777但在该部门没有运气。通过使用Go功能的https://github.com/tarm/serial库打开文件:

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

的结果

  

ttyACM0:没有这样的文件或目录

问题不在于路径,因为我尝试了相对(使用chdir)和绝对具有相同的确切结果。

我甚至禁用了SELinux,这不是我想做的,但在寻找解决方案的时候,我尝试了一切。

代码正常,因为脚本的手动执行正确通过。我认为Linux设置有问题。

2 个答案:

答案 0 :(得分:0)

ttyACM0的正确路径是/ dev / ttyACM0。您可以定义udev规则,以便在附加文件时设置文件模式。

如果程序无法访问,那么您的程序可能会运行chrooted()。

答案 1 :(得分:0)

它似乎是真正的Linux问题和它的一些底层结构,我不明白。我在运行Fedora25,但Debian8上没有出现这个问题。

相关问题