void-linux / void-linux/void-packages
gpsd: User/group/permission issues, does not work on USB serial GPS sources without manual chmod
Nobody has claimed this yet.
- Dominant language
- Shell
- Stars
- 3.4k
- Forks
- 2.8k
- Avg merge
- 2d 5h
- Merged PRs (30d)
- 299
Description
Is this a new report?
Yes
System Info
Void 5.19.17_1 x86_64 GenuineIntel uptodate rFFFFFFFFFFF
Package(s) Affected
gpsd-3.24_2
Does a report exist for this bug with the project's home (upstream) and/or another distro?
No response
Expected behaviour
- Plug in USB GPS source (mine is a u-blox 7)
- Verify it works and has a GPS lock using gpsmon as root. This tool directly talks to the GPS device rather than needing gpsd to be working.
# gpsmon /dev/ttyACM0
-
Stop gpsmon
-
Start gpsd daemon in one terminal (as root, with verbose debugging flags like this)
# gpsd -N -F /run/gpsd.sock -D5 /dev/ttyACM0
- Run cgps (or any other gps client) in another terminal. This will talk to gpsd and (if everything is working) give you similar output to what gpsmon did.
$ cgps
Actual behaviour
cgps fails to see any data and gpsd spits the following errors:
gpsd:PROG: CORE: gpsd_open(/dev/ttyACM0) fd -1
gpsd:PROG: SER: gpsd_serial_open(/dev/ttyACM0) sourcetype 12 fd -1
gpsd:INFO: SER: opening GPS data source type 12 at '/dev/ttyACM0'
gpsd:ERROR: SER: device open of /dev/ttyACM0 failed: Permission denied(13) - retrying read-only
gpsd:ERROR: SER: read-only device open of /dev/ttyACM0 failed: Permission denied(13)
gpsd:ERROR: /dev/ttyACM0: device activation failed, freeing device.
Looking at the running process list reveals that the gpsd process has changed to the 'gpsd' user.
Permissions for the serial device:
$ ls -lh /dev/ttyACM0
crw-rw---- 1 root dialout 166, 0 Nov 30 22:38 /dev/ttyACM0
Adding the gpsd user to the dialout group does NOT fix the problem.
Allowing anyone rw access to the serial device DOES fix the problem temporarily
# chmod a+x /dev/ttyACM0
According to the gpsd manpage:
Before doing any processing of GPS data, it tries to drop root privileges by setting its UID to "nobody" (or another configured userid) and its group ID to the group of the initial GPS passed on the command line — or, if that device doesn’t exist, to the group of /dev/ttyS0.
I do not understand how processes can have group ids, but regardless this feature does not seem to be working as intended.
The srcpkg template has this line in it, not sure if it is related to this problem or not:
make_build_args="dbus_export=0 gpsd_user=gpsd gpsd_group=gpsd
Steps to reproduce
See above.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the gpsd privilege-drop behavior described in the manpage and the srcpkg template's make_build_args. Reproduce the issue with gpsmon, gpsd, and cgps, then compare the daemon's resulting user and groups with the /dev/ttyACM0 dialout permissions. Done means gpsd can open the USB serial device without manual chmod while still dropping privileges.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- linux
- Domain
- operating-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100