Access to tty port by non-root user

This forum is for topics specific to the Raspberry Pi and Arch Linux ARM

Access to tty port by non-root user

Postby Passiday » Fri May 22, 2015 8:22 pm

I have installed ArchLinux ARM on Raspberry Pi (Model B Revision 2.0).

The solution I am working on requires a Python script to send data over tty serial port /dev/ttyAMA0. This script should run automatically upon start-up without user interruption. The plan is to configure the start-up so that a special non-privileged user is logged-in automatically, and then a user start-up script is automatically executed.

However, I have problems with accessing the tty port.
The ownership of /dev/ttyAMA0 port is root:tty.
The special non-privileged user is enlisted in the tty group.
The problem is that the /dev/ttyAMA0 permissions by default are rw--w---- (620)
Without the read access to the port, the Python script can not initialize the port and the script fails.
The problem is easily fixed by executing
$ sudo chmod g+r /dev/ttyAMA0
But, this required user to enter the password, so this is not a solution for user-interruption-free auto-executed start-up script.

Please suggest some way how to fix this situation.
Passiday
 
Posts: 5
Joined: Fri May 22, 2015 8:18 pm

Re: Access to tty port by non-root user

Postby WarheadsSE » Fri May 22, 2015 8:44 pm

tmpdfiles.d
Core Developer
Remember: Arch Linux ARM is entirely community donation supported!
WarheadsSE
Developer
 
Posts: 6807
Joined: Mon Oct 18, 2010 2:12 pm

Re: Access to tty port by non-root user

Postby Passiday » Fri May 22, 2015 9:24 pm

I created a file /etc/tmpfiles.d/solution.conf

And wrote there one line:

F /dev/ttyAMA0 0660 root tty

However, after reboot the permissions of the /dev/ttyAMA0 file are still 620

What am I doing wrong?
Passiday
 
Posts: 5
Joined: Fri May 22, 2015 8:18 pm

Re: Access to tty port by non-root user

Postby Passiday » Sat May 23, 2015 6:16 pm

Ok, the problem was with the fact that ttyAMA0 on Raspberry Pi is used for serial console, and the serial console init takes place after all the tty files initialization, overriding anything that is set up at /usr/lib/udev/rules.d/ config files.

Removing any references to ttyAMA0 in /boot/cmdline.txt and rebooting fixed the /dev/ttyAMA0 permissions without any extra configuration needed.
Passiday
 
Posts: 5
Joined: Fri May 22, 2015 8:18 pm


Return to Raspberry Pi

Who is online

Users browsing this forum: No registered users and 2 guests

cron