[chrony-users] Regarding socket permissions

[ Thread Index | Date Index | More chrony.tuxfamily.org/chrony-users Archives ]


Hi,

Hopefully this isn't appropriate for this channel, I have had a hard time finding an answer externally.

I have a C++ application which would like to send timing information to `chrony`, the goal is sync between an MCU and a linux machine. I think I need to input this as a REFCLOCK.

I see in the chrony code (I'm using v3.5 on ubuntu 20) that after creating the socket it attempts to set the permissions to 666 (R/WR for all) while the owner is root. My problem is that trying to access this socket from the C++ script continuously returns error (13) permission denied.

Current the chrony config is
refclock SOCK /var/run/chrony.ttyACM0.sock
Very basic just to start with. I thought perhaps I could change this to a less restricted location, like
refclock SOCK /tmp/chrony.ttyACM0.sock
Which then results in 
chronyd[3550180]: Fatal error : bind(/tmp/chrony.ttyACM0.sock) failed : Permission denied

The connection function is
// acquire a connection to an existing Unix-domain socket
socket_t netlib_localsocket(const char * sockfile, int socktype)
{
int sock;

if ((sock = socket(AF_UNIX, socktype, 0)) < 0) {
return -1;
} else {
struct sockaddr_un saddr;

memset(&saddr, 0, sizeof(struct sockaddr_un));
saddr.sun_family = AF_UNIX;
(void)strlcpy(saddr.sun_path, sockfile, sizeof(saddr.sun_path));

if (connect(sock, (struct sockaddr *)&saddr, SUN_LEN(&saddr)) < 0) {
(void)close(sock);
return -2;
}

return sock;
}
}

My C++ application is based off of GPSD, which I can't use directly because I'm not strictly using GPS or NMEA messages and I can't give 100% control of the serial port to any external program. The same application works with SHM, I was attempting with sockets instead as I understand there should be some advantages regarding latency with polling vs interrupt based communications.

Curious if any of you had an idea of what could be wrong..

Best regards,
Morten


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/