Signed-off-by: Martin Pecka <[email protected]>
---
 config.c            | 2 ++
 configs/default.cfg | 1 +
 ptp4l.8             | 5 +++++
 uds.c               | 8 +++++++-
 4 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/config.c b/config.c
index a0b7c6b..9cd0314 100644
--- a/config.c
+++ b/config.c
@@ -35,6 +35,7 @@
 #include "util.h"
 
 #define UDS_FILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP) /*0660*/
+#define UDS_RO_FILEMODE (UDS_FILEMODE|S_IROTH|S_IWOTH) /*0666*/
 
 struct interface {
        STAILQ_ENTRY(interface) list;
@@ -335,6 +336,7 @@ struct config_item config_tab[] = {
        GLOB_ITEM_STR("uds_address", "/var/run/ptp4l"),
        PORT_ITEM_INT("uds_file_mode", UDS_FILEMODE, 0, 04777),
        GLOB_ITEM_STR("uds_ro_address", "/var/run/ptp4lro"),
+       PORT_ITEM_INT("uds_ro_file_mode", UDS_RO_FILEMODE, 0, 04777),
        PORT_ITEM_INT("unicast_listen", 0, 0, 1),
        PORT_ITEM_INT("unicast_master_table", 0, 0, INT_MAX),
        PORT_ITEM_INT("unicast_req_duration", 3600, 10, INT_MAX),
diff --git a/configs/default.cfg b/configs/default.cfg
index 30ca8af..1b5b806 100644
--- a/configs/default.cfg
+++ b/configs/default.cfg
@@ -94,6 +94,7 @@ udp6_scope            0x0E
 uds_address            /var/run/ptp4l
 uds_file_mode          0660
 uds_ro_address         /var/run/ptp4lro
+uds_ro_file_mode               0666
 #
 # Default interface options
 #
diff --git a/ptp4l.8 b/ptp4l.8
index 34f2b50..e33454a 100644
--- a/ptp4l.8
+++ b/ptp4l.8
@@ -653,6 +653,11 @@ File mode of the UNIX domain socket used for receiving 
local management
 messages. The mode should be specified as an octal number, i.e. it
 should start with a 0 literal. The default mode is 0660.
 .TP
+.B uds_ro_file_mode
+File mode of the second (read-only) UNIX domain socket used for receiving
+local management messages. The mode should be specified as an octal number,
+i.e. it should start with a 0 literal. The default mode is 0666.
+.TP
 .B dscp_event
 Defines the Differentiated Services Codepoint (DSCP) to be used for PTP
 event messages. Must be a value between 0 and 63. There are several media
diff --git a/uds.c b/uds.c
index 6558959..6d39dc8 100644
--- a/uds.c
+++ b/uds.c
@@ -53,9 +53,11 @@ static int uds_close(struct transport *t, struct fdarray 
*fda)
 static int uds_open(struct transport *t, struct interface *iface, struct 
fdarray *fda,
                    enum timestamp_type tt)
 {
+       char *uds_ro_path = config_get_string(t->cfg, NULL, "uds_ro_address");
        char *uds_path = config_get_string(t->cfg, NULL, "uds_address");
        struct uds *uds = container_of(t, struct uds, t);
        const char *name = interface_name(iface);
+       const char* file_mode_cfg;
        struct sockaddr_un sa;
        mode_t file_mode;
        int fd, err;
@@ -78,7 +80,11 @@ static int uds_open(struct transport *t, struct interface 
*iface, struct fdarray
                return -1;
        }
 
-       file_mode = (mode_t)config_get_int(t->cfg, name, "uds_file_mode");
+       file_mode_cfg = "uds_file_mode";
+       // The RO UDS socket has a separate configuration for file mode
+       if (0 == strncmp(name, uds_ro_path, MAX_IFNAME_SIZE))
+               file_mode_cfg = "uds_ro_file_mode";
+       file_mode = (mode_t)config_get_int(t->cfg, name, file_mode_cfg);
 
        /* For client use, pre load the server path. */
        memset(&sa, 0, sizeof(sa));
-- 
2.17.1



_______________________________________________
Linuxptp-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel

Reply via email to