To not require pmc and phc2sys to run under the same user as ptp4l, change the ownership of their socket to the server socket, so it can send a response to their socket.
Signed-off-by: Miroslav Lichvar <mlich...@redhat.com> --- uds.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/uds.c b/uds.c index 641a672..81a3f22 100644 --- a/uds.c +++ b/uds.c @@ -59,6 +59,7 @@ static int uds_open(struct transport *t, struct interface *iface, struct fdarray struct uds *uds = container_of(t, struct uds, t); const char *name = interface_name(iface); struct sockaddr_un sa; + struct stat st; int fd, err; fd = socket(AF_LOCAL, SOCK_DGRAM, 0); @@ -87,6 +88,14 @@ static int uds_open(struct transport *t, struct interface *iface, struct fdarray uds->address.len = sizeof(sa); chmod(name, UDS_FILEMODE); + + /* Copy the ownership of the server's socket to allow it + to send a response if running under a non-root user. */ + if (strcmp(uds_path, name) && !stat(uds_path, &st) && + (st.st_uid || st.st_gid)) { + chown(name, st.st_uid, st.st_gid); + } + fda->fd[FD_EVENT] = -1; fda->fd[FD_GENERAL] = fd; return 0; -- 2.26.3 _______________________________________________ Linuxptp-devel mailing list Linuxptp-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxptp-devel