On Unix systems, serial ports usually are represented by device files. The serial port device files are e.g.:
/dev/ttyS?
starting with /dev/ttyS0
/dev/cuaa?
starting with /dev/cuaa0
If you have a serial port reserved for the camera, you can just use chown, chgrp, chmod on its device file to provide a certain user or group or everybody with access to it.
You can use the
gphoto2
command to check whether you have permissions to access a
certain device:
--list-ports
alice@host:~$
gphoto2 --list-ports
Devices found: 2 Path Description -------------------------------------------------------------- serial:/dev/ttyS0 Serial Port 0 usb: Universal Serial Bus
alice@host:~$
This shows that user alice (who seems to be running the
command) has access to the serial device
/dev/ttyS0
.
Let's make a few examples with the first serial port
on a Linux system, called
/dev/ttyS0
.
You start with having a look at the device file:
host:~#
ls -l
/dev/ttyS0
crw-rw---- 1 root dialout 4, 64 Jul 5 12:05 /dev/ttyS0
host:~#
OK, so user root and all users of the group dialout can access the device /dev/ttyS0. You now have a few choices of what to do.
Example 4.1. Exclusive access to a serial camera for one user
You want to give user alice exclusive access to the first serial port on your Linux machine:
host:~#
# give alice exclusive access to the device file (you must be root)host:~#
chown alice /dev/ttyS0
host:~#
chmod 0600 /dev/ttyS0
host:~#
ls -l /dev/ttyS0
crw------- 1 alice dialout 4, 64 Jul 5 12:05 /dev/ttyS0
host:~#
Test for access by running
gphoto2
as the respective user. Look for
--list-ports
/dev/ttyS0
in the output.
Example 4.2. Access to serial camera for a group of users
You could just add user alice to the group dialout, but this will almost certainly cause confusion between dialing and using the camera. So you'd better create a group named "camera", add alice to that group and give the group access to the camera:
host:~#
# give users in group "camera" access to this device (you must be root)host:~#
groupadd camera
host:~#
chgrp camera /dev/ttyS0
host:~#
chmod 0060 /dev/ttyS0
host:~#
ls -l /dev/ttyS0
c---rw---- 1 root camera 4, 64 Jul 5 12:05 /dev/ttyS0
host:~#
Test for access by running
gphoto2
as the respective user. Look for
--list-ports
/dev/ttyS0
in the output.
BTW, it makes sense to also set the permissions for USB camera devices to allow the "camera" group access. Then any user in the "camera" group will have access to any camera.
Example 4.3. Access to serial camera for anybody
Allowing anybody access to something is considered bad security. However, for quick testing or for non-networked single-user systems, this can also make sense:
host:~#
# give anybody access to this device (you must be root)host:~#
chmod a+rw /dev/ttyS0
host:~#
ls -l /dev/ttyS0
crw-rw-rw- 1 root dialout 4, 64 Jul 5 12:05 /dev/ttyS0
host:~#
Test for access by running
gphoto2
as the respective user. Look for
--list-ports
/dev/ttyS0
in the output.