Signed-off-by: Martin Pecka <[email protected]>
---
config.c | 4 ++++
configs/default.cfg | 1 +
ptp4l.8 | 5 +++++
uds.c | 7 ++++---
4 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/config.c b/config.c
index 4f3ceb8..a0b7c6b 100644
--- a/config.c
+++ b/config.c
@@ -23,6 +23,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <sys/stat.h>
#include "as_capable.h"
#include "bmc.h"
@@ -33,6 +34,8 @@
#include "print.h"
#include "util.h"
+#define UDS_FILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP) /*0660*/
+
struct interface {
STAILQ_ENTRY(interface) list;
};
@@ -330,6 +333,7 @@ struct config_item config_tab[] = {
PORT_ITEM_INT("udp_ttl", 1, 1, 255),
PORT_ITEM_INT("udp6_scope", 0x0E, 0x00, 0x0F),
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("unicast_listen", 0, 0, 1),
PORT_ITEM_INT("unicast_master_table", 0, 0, INT_MAX),
diff --git a/configs/default.cfg b/configs/default.cfg
index 26817de..30ca8af 100644
--- a/configs/default.cfg
+++ b/configs/default.cfg
@@ -92,6 +92,7 @@ p2p_dst_mac 01:80:C2:00:00:0E
udp_ttl 1
udp6_scope 0x0E
uds_address /var/run/ptp4l
+uds_file_mode 0660
uds_ro_address /var/run/ptp4lro
#
# Default interface options
diff --git a/ptp4l.8 b/ptp4l.8
index 6ce7694..34f2b50 100644
--- a/ptp4l.8
+++ b/ptp4l.8
@@ -648,6 +648,11 @@ management messages, which is restricted to GET actions
and does not forward
messages to other ports. Access to this socket can be given to untrusted
applications for monitoring purposes. The default is /var/run/ptp4lro.
.TP
+.B uds_file_mode
+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 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 641a672..6558959 100644
--- a/uds.c
+++ b/uds.c
@@ -31,8 +31,6 @@
#include "transport_private.h"
#include "uds.h"
-#define UDS_FILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP) /*0660*/
-
struct uds {
struct transport t;
struct address address;
@@ -59,6 +57,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;
+ mode_t file_mode;
int fd, err;
fd = socket(AF_LOCAL, SOCK_DGRAM, 0);
@@ -79,6 +78,8 @@ 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");
+
/* For client use, pre load the server path. */
memset(&sa, 0, sizeof(sa));
sa.sun_family = AF_LOCAL;
@@ -86,7 +87,7 @@ static int uds_open(struct transport *t, struct interface
*iface, struct fdarray
uds->address.sun = sa;
uds->address.len = sizeof(sa);
- chmod(name, UDS_FILEMODE);
+ chmod(name, file_mode);
fda->fd[FD_EVENT] = -1;
fda->fd[FD_GENERAL] = fd;
return 0;
--
2.17.1
_______________________________________________
Linuxptp-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel