diff --git a/linuxptp-droproot.patch b/linuxptp-droproot.patch index d3bb2ac..a15bec2 100644 --- a/linuxptp-droproot.patch +++ b/linuxptp-droproot.patch @@ -1095,3 +1095,125 @@ index 7b76061..93701fb 100644 void pmc_destroy(struct pmc *pmc); int pmc_get_transport_fd(struct pmc *pmc); +commit b0ecbf554414309e740a9ae29e2805bde57b7c6b +Author: Miroslav Lichvar +Date: Thu Jan 29 12:20:20 2026 +0100 + + clock: Create reversed compatibility symlink to uds_address. + + If the ptp4l config specified the previous default uds_address (e.g. it + was based on configs/default.cfg) and pmc, phc2sys, ts2phc, or tz2alt + was used in its default configuration, it would stop working after + upgrading to a newer linuxptp version using the new default address. + + If uds_address is /var/run/ptp4l, create the /var/run/ptp directory and + symlink /var/run/ptp/ptp4l -> ../ptp4l to keep the tools working with + the new default address. + + Also, mention the symlinks in the man page. + + Reviewed-by: Jacob Keller + Signed-off-by: Miroslav Lichvar + +diff --git a/clock.c b/clock.c +index 17484d8..5886ca1 100644 +--- a/clock.c ++++ b/clock.c +@@ -1285,8 +1285,6 @@ struct clock *clock_create(enum clock_type type, struct config *config, + */ + + uds_ifname = config_get_string(config, NULL, "uds_address"); +- if (!strcmp(uds_ifname, "/var/run/ptp/ptp4l")) +- create_symlink("ptp/ptp4l", "/var/run/ptp4l"); + c->uds_rw_if = interface_create(uds_ifname, NULL); + if (config_set_section_int(config, interface_name(c->uds_rw_if), + "announceReceiptTimeout", 0)) { +@@ -1307,8 +1305,6 @@ struct clock *clock_create(enum clock_type type, struct config *config, + + uds_ifname = config_get_string(config, NULL, "uds_ro_address"); + c->uds_ro_if = interface_create(uds_ifname, NULL); +- if (!strcmp(uds_ifname, "/var/run/ptp/ptp4lro")) +- create_symlink("ptp/ptp4lro", "/var/run/ptp4lro"); + if (config_set_section_int(config, interface_name(c->uds_ro_if), + "announceReceiptTimeout", 0)) { + return NULL; +@@ -1475,6 +1471,17 @@ struct clock *clock_create(enum clock_type type, struct config *config, + return NULL; + } + ++ /* Create symlinks for compatibility with previous default addresses. */ ++ if (!strcmp(interface_name(c->uds_rw_if), "/var/run/ptp/ptp4l")) { ++ create_symlink("ptp/ptp4l", "/var/run/ptp4l"); ++ } else if (!strcmp(interface_name(c->uds_rw_if), "/var/run/ptp4l")) { ++ create_uds_directory("/var/run/ptp", user); ++ create_symlink("../ptp4l", "/var/run/ptp/ptp4l"); ++ } ++ if (!strcmp(interface_name(c->uds_ro_if), "/var/run/ptp/ptp4lro")) { ++ create_symlink("ptp/ptp4lro", "/var/run/ptp4lro"); ++ } ++ + /* Create the ports. */ + STAILQ_FOREACH(iface, &config->interfaces, list) { + if (clock_add_port(c, phc_device, phc_index, timestamping, iface)) { +diff --git a/ptp4l.8 b/ptp4l.8 +index d66843f..8250cf3 100644 +--- a/ptp4l.8 ++++ b/ptp4l.8 +@@ -1045,6 +1045,11 @@ start if it does not exist, with owner set to the user specified by the + .B user + option. The default is /var/run/ptp/ptp4l. + ++If the address is /var/run/ptp/ptp4l or /var/run/ptp4l (which was the default ++in older versions), ++.B ptp4l ++will create a symbolic link at the other location for compatibility. ++ + .TP + .B uds_file_mode + File mode of the UNIX domain socket used for receiving local management +@@ -1058,6 +1063,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/ptp/ptp4lro. + ++With the default address ++.B ptp4l ++will create a symbolic link at /var/run/ptp4lro (which was the default in older ++versions) for compatibility. ++ + .TP + .B uds_ro_file_mode + File mode of the second (read-only) UNIX domain socket used for receiving +commit 39d88af366b0fe76680232ada8ccd8b773ab5d2f +Author: Miroslav Lichvar +Date: Mon Feb 2 15:15:05 2026 +0100 + + clock: Create symlinks also for addresses not starting with /var. + + This might be needed on systems that have /var/run linked to /run. + + Signed-off-by: Miroslav Lichvar + +diff --git a/clock.c b/clock.c +index 5886ca1..0e46ea3 100644 +--- a/clock.c ++++ b/clock.c +@@ -1472,13 +1472,16 @@ struct clock *clock_create(enum clock_type type, struct config *config, + } + + /* Create symlinks for compatibility with previous default addresses. */ +- if (!strcmp(interface_name(c->uds_rw_if), "/var/run/ptp/ptp4l")) { ++ if (!strcmp(interface_name(c->uds_rw_if), "/var/run/ptp/ptp4l") || ++ !strcmp(interface_name(c->uds_rw_if), "/run/ptp/ptp4l")) { + create_symlink("ptp/ptp4l", "/var/run/ptp4l"); +- } else if (!strcmp(interface_name(c->uds_rw_if), "/var/run/ptp4l")) { ++ } else if (!strcmp(interface_name(c->uds_rw_if), "/var/run/ptp4l") || ++ !strcmp(interface_name(c->uds_rw_if), "/run/ptp4l")) { + create_uds_directory("/var/run/ptp", user); + create_symlink("../ptp4l", "/var/run/ptp/ptp4l"); + } +- if (!strcmp(interface_name(c->uds_ro_if), "/var/run/ptp/ptp4lro")) { ++ if (!strcmp(interface_name(c->uds_ro_if), "/var/run/ptp/ptp4lro") || ++ !strcmp(interface_name(c->uds_ro_if), "/run/ptp/ptp4lro") ) { + create_symlink("ptp/ptp4lro", "/var/run/ptp4lro"); + } + diff --git a/linuxptp.fc b/linuxptp.fc index c0a31f6..1c4fd1b 100644 --- a/linuxptp.fc +++ b/linuxptp.fc @@ -8,4 +8,5 @@ /usr/sbin/phc2sys -- gen_context(system_u:object_r:phc2sys_exec_t,s0) /usr/sbin/timemaster -- gen_context(system_u:object_r:timemaster_exec_t,s0) +/run/ptp(/.*)? gen_context(system_u:object_r:timemaster_var_run_t,s0) /run/timemaster(/.*)? gen_context(system_u:object_r:timemaster_var_run_t,s0) diff --git a/linuxptp.te b/linuxptp.te index 0548955..068333f 100644 --- a/linuxptp.te +++ b/linuxptp.te @@ -168,12 +168,11 @@ allow ptp4l_t self:netlink_route_socket rw_netlink_socket_perms; allow ptp4l_t phc2sys_t:unix_dgram_socket sendto; -create_lnk_files_pattern(ptp4l_t, var_run_t, var_run_t) - manage_dirs_pattern(ptp4l_t, timemaster_var_run_t, timemaster_var_run_t) manage_files_pattern(ptp4l_t, timemaster_var_run_t, timemaster_var_run_t) +manage_lnk_files_pattern(ptp4l_t, timemaster_var_run_t, timemaster_var_run_t) manage_sock_files_pattern(ptp4l_t, timemaster_var_run_t, timemaster_var_run_t) -files_pid_filetrans(ptp4l_t, timemaster_var_run_t, { dir file sock_file }) +files_pid_filetrans(ptp4l_t, timemaster_var_run_t, { dir file lnk_file sock_file }) manage_dirs_pattern(ptp4l_t, timemaster_tmpfs_t, timemaster_tmpfs_t) manage_files_pattern(ptp4l_t, timemaster_tmpfs_t, timemaster_tmpfs_t)