zhhuabj

Untitled

Jul 1st, 2026
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.26 KB | None | 0 0
  1. diff --git a/debian/ovn-common.install b/debian/ovn-common.install
  2. index 91f7d206f..05c88f0ce 100644
  3. --- a/debian/ovn-common.install
  4. +++ b/debian/ovn-common.install
  5. @@ -14,6 +14,7 @@ usr/share/ovn/scripts/ovndb-servers.ocf
  6. usr/share/ovn/scripts/ovn-bugtool-nbctl-show
  7. usr/share/ovn/scripts/ovn-bugtool-sbctl-lflow-list
  8. usr/share/ovn/scripts/ovn-bugtool-sbctl-show
  9. +usr/lib/tmpfiles.d/ovn-tmpfiles.conf
  10. usr/share/man/man1/ovn-detrace.1
  11. usr/share/man/man5/ovn-ic-nb.5
  12. usr/share/man/man5/ovn-ic-sb.5
  13. diff --git a/debian/patches/avoid-recursive-chown-of-ovn-logdir.patch b/debian/patches/avoid-recursive-chown-of-ovn-logdir.patch
  14. new file mode 100644
  15. index 000000000..76cf0116b
  16. --- /dev/null
  17. +++ b/debian/patches/avoid-recursive-chown-of-ovn-logdir.patch
  18. @@ -0,0 +1,176 @@
  19. +Description: Manage OVN log ownership with tmpfiles.d.
  20. + ovn-ctl and ovn-lib currently chown the OVN log directory recursively
  21. + when services start. That can undo ownership set by distribution tooling
  22. + such as tmpfiles.d and logrotate. In particular, Debian and Ubuntu need
  23. + ovn-controller.log to remain root:adm so rsyslog can read it, but a later
  24. + OVN service restart may change it back to the OVN daemon user/group.
  25. + .
  26. + Add an OVN tmpfiles.d template for the log directory and
  27. + ovn-controller.log, with configurable log user, log group and tmpfiles.d
  28. + installation directory. Stop recursively changing the OVN log directory
  29. + ownership from ovn-ctl and ovn-lib at service startup.
  30. +Author: Zhang Hua <[email protected]>
  31. +Origin: upstream, https://github.com/ovn-org/ovn/commit/0c88c83b6d0ec2f62b8041061089ab8acfe31b5b
  32. +Bug: https://github.com/ovn-org/ovn/issues/310
  33. +Forwarded: not-needed
  34. +Last-Update: 2026-06-30
  35. +
  36. +diff --git a/Makefile.am b/Makefile.am
  37. +index 0f2389b25..79929ee6c 100644
  38. +--- a/Makefile.am
  39. ++++ b/Makefile.am
  40. +@@ -146,6 +146,7 @@ noinst_SCRIPTS =
  41. + OVSIDL_BUILT =
  42. + pkgdata_DATA =
  43. + sbin_SCRIPTS =
  44. ++tmpfiles_DATA =
  45. + scripts_SCRIPTS =
  46. + completion_SCRIPTS =
  47. + scripts_DATA =
  48. +@@ -163,6 +164,7 @@ endif
  49. + scriptsdir = $(pkgdatadir)/scripts
  50. + completiondir = $(sysconfdir)/bash_completion.d
  51. + pkgconfigdir = $(libdir)/pkgconfig
  52. ++tmpfilesdir = @TMPFILESDIR@
  53. +
  54. + # This ensures that files added to EXTRA_DIST are always distributed,
  55. + # even if they are inside an Automake if...endif conditional block that is
  56. +@@ -181,6 +183,8 @@ SUFFIXES += .in
  57. + sed \
  58. + -e 's,[@]PKIDIR[@],$(PKIDIR),g' \
  59. + -e 's,[@]LOGDIR[@],$(LOGDIR),g' \
  60. ++ -e 's,[@]LOGUSER[@],$(LOGUSER),g' \
  61. ++ -e 's,[@]LOGGROUP[@],$(LOGGROUP),g' \
  62. + -e 's,[@]DBDIR[@],$(DBDIR),g' \
  63. + -e 's,[@]PYTHON3[@],$(PYTHON3),g' \
  64. + -e 's,[@]OVN_RUNDIR[@],$(OVN_RUNDIR),g' \
  65. +diff --git a/configure.ac b/configure.ac
  66. +index 37e9e18f2..75978c409 100644
  67. +--- a/configure.ac
  68. ++++ b/configure.ac
  69. +@@ -91,6 +91,9 @@ OVS_CHECK_NETLINK
  70. + OVS_CHECK_LINUX_NETLINK
  71. + OVS_CHECK_OPENSSL
  72. + OVN_CHECK_LOGDIR
  73. ++OVN_CHECK_LOGUSER
  74. ++OVN_CHECK_LOGGROUP
  75. ++OVN_CHECK_TMPFILESDIR
  76. + OVN_CHECK_PYTHON3
  77. + OVN_CHECK_FLAKE8
  78. + OVN_CHECK_SPHINX
  79. +diff --git a/m4/ovn.m4 b/m4/ovn.m4
  80. +index f6e64545d..ea5081cc5 100644
  81. +--- a/m4/ovn.m4
  82. ++++ b/m4/ovn.m4
  83. +@@ -260,6 +260,37 @@ AC_DEFUN([OVN_CHECK_LOGDIR],
  84. + [LOGDIR='${localstatedir}/log/${PACKAGE}'])
  85. + AC_SUBST([LOGDIR])])
  86. +
  87. ++dnl Checks for the user that should own log files.
  88. ++AC_DEFUN([OVN_CHECK_LOGUSER],
  89. ++ [AC_ARG_WITH(
  90. ++ [log-user],
  91. ++ AS_HELP_STRING([--with-log-user=USER],
  92. ++ [user used for log files [[root]]]),
  93. ++ [LOGUSER=$withval],
  94. ++ [LOGUSER=root])
  95. ++ AC_SUBST([LOGUSER])])
  96. ++
  97. ++dnl Checks for the group that should own log files.
  98. ++AC_DEFUN([OVN_CHECK_LOGGROUP],
  99. ++ [AC_ARG_WITH(
  100. ++ [log-group],
  101. ++ AS_HELP_STRING([--with-log-group=GROUP],
  102. ++ [group used for log files [[root]]]),
  103. ++ [LOGGROUP=$withval],
  104. ++ [LOGGROUP=root])
  105. ++ AC_SUBST([LOGGROUP])])
  106. ++
  107. ++dnl Checks for the directory in which to install tmpfiles.d configuration.
  108. ++AC_DEFUN([OVN_CHECK_TMPFILESDIR],
  109. ++ [AC_ARG_WITH(
  110. ++ [tmpfilesdir],
  111. ++ AS_HELP_STRING([--with-tmpfilesdir=DIR],
  112. ++ [directory used for tmpfiles.d configuration
  113. ++ [[PREFIX/lib/tmpfiles.d]]]),
  114. ++ [TMPFILESDIR=$withval],
  115. ++ [TMPFILESDIR='${prefix}/lib/tmpfiles.d'])
  116. ++ AC_SUBST([TMPFILESDIR])])
  117. ++
  118. + dnl Checks for the directory in which to store the OVN database.
  119. + AC_DEFUN([OVN_CHECK_DBDIR],
  120. + [AC_ARG_WITH(
  121. +diff --git a/utilities/automake.mk b/utilities/automake.mk
  122. +index 579602920..21d49d3f7 100644
  123. +--- a/utilities/automake.mk
  124. ++++ b/utilities/automake.mk
  125. +@@ -26,6 +26,7 @@ EXTRA_DIST += \
  126. + utilities/ovn-ctl \
  127. + utilities/ovn-lib.in \
  128. + utilities/ovn-ctl.8.xml \
  129. ++ utilities/ovn-tmpfiles.conf.in \
  130. + utilities/ovn-docker-overlay-driver.in \
  131. + utilities/ovn-docker-underlay-driver.in \
  132. + utilities/ovn-nbctl.8.xml \
  133. +@@ -48,6 +49,7 @@ EXTRA_DIST += \
  134. + CLEANFILES += \
  135. + utilities/ovn-ctl.8 \
  136. + utilities/ovn-lib \
  137. ++ utilities/ovn-tmpfiles.conf \
  138. + utilities/ovn-docker-overlay-driver \
  139. + utilities/ovn-docker-underlay-driver \
  140. + utilities/ovn-nbctl.8 \
  141. +@@ -66,7 +68,9 @@ CLEANFILES += \
  142. + EXTRA_DIST += utilities/ovn-sim.in
  143. + noinst_SCRIPTS += utilities/ovn-sim
  144. +
  145. ++tmpfiles_DATA += utilities/ovn-tmpfiles.conf
  146. + utilities/ovn-lib: $(top_builddir)/config.status
  147. ++utilities/ovn-tmpfiles.conf: $(top_builddir)/config.status
  148. +
  149. + # ovn-nbctl
  150. + bin_PROGRAMS += utilities/ovn-nbctl
  151. +diff --git a/utilities/ovn-ctl b/utilities/ovn-ctl
  152. +index 2b33a25a1..15e5eaf82 100755
  153. +--- a/utilities/ovn-ctl
  154. ++++ b/utilities/ovn-ctl
  155. +@@ -276,9 +276,8 @@ $cluster_remote_port
  156. + upgrade_db "$file" "$schema"
  157. + fi
  158. +
  159. +- # Set the owner of the ovn_dbdir (with -R option) to OVN_USER if set.
  160. +- # This is required because the ovndbs are created with root permission
  161. +- # if not present when create_cluster/upgrade_db is called.
  162. ++ # Database files may be created as root before ovsdb-server drops
  163. ++ # privileges, so keep ownership aligned with OVN_USER when configured.
  164. + INSTALL_USER="$(id -un)"
  165. + INSTALL_GROUP="$(id -gn)"
  166. + [ "$OVN_USER" != "" ] && INSTALL_USER="${OVN_USER%:*}"
  167. +@@ -286,7 +285,6 @@ $cluster_remote_port
  168. +
  169. + chown -R $INSTALL_USER:$INSTALL_GROUP $ovn_dbdir
  170. + chown -R $INSTALL_USER:$INSTALL_GROUP $OVN_RUNDIR
  171. +- chown -R $INSTALL_USER:$INSTALL_GROUP $ovn_logdir
  172. + chown -R $INSTALL_USER:$INSTALL_GROUP $ovn_etcdir
  173. +
  174. + set ovsdb-server
  175. +diff --git a/utilities/ovn-lib.in b/utilities/ovn-lib.in
  176. +index f0f3dd2a7..ec5500d7b 100644
  177. +--- a/utilities/ovn-lib.in
  178. ++++ b/utilities/ovn-lib.in
  179. +@@ -133,7 +133,6 @@ start_ovn_daemon () {
  180. + set "$@" --detach
  181. + test X"$MONITOR" = Xno || set "$@" --monitor
  182. +
  183. +- chown -R $INSTALL_USER:$INSTALL_GROUP $ovn_logdir
  184. + chown -R $INSTALL_USER:$INSTALL_GROUP $ovn_rundir
  185. +
  186. + start_wrapped_daemon "$wrapper" $daemon "$priority" "$@"
  187. +diff --git a/utilities/ovn-tmpfiles.conf.in b/utilities/ovn-tmpfiles.conf.in
  188. +new file mode 100644
  189. +index 000000000..d37391f88
  190. +--- /dev/null
  191. ++++ b/utilities/ovn-tmpfiles.conf.in
  192. +@@ -0,0 +1,2 @@
  193. ++d @LOGDIR@ 0750 @LOGUSER@ @LOGGROUP@ -
  194. ++f @LOGDIR@/ovn-controller.log 0640 @LOGUSER@ @LOGGROUP@ -
  195. diff --git a/debian/patches/series b/debian/patches/series
  196. index a0b4d5671..400c6e5d9 100644
  197. --- a/debian/patches/series
  198. +++ b/debian/patches/series
  199. @@ -2,3 +2,4 @@ lp-2066194-tests-Ignore-ovs-vswitchd-received-packet-on-unknown.patch
  200. fix-nonascii-in-ovn-nb.xml.patch
  201. fix-ovn-vif-test-depends.patch
  202. lp-2147468-tests-Replace-unsupported-protocol-test.patch
  203. +avoid-recursive-chown-of-ovn-logdir.patch
  204. diff --git a/debian/rules b/debian/rules
  205. index d0b6de378..55ca23c7d 100755
  206. --- a/debian/rules
  207. +++ b/debian/rules
  208. @@ -25,6 +25,8 @@ override_dh_auto_configure:
  209. --sysconfdir=/etc \
  210. --with-dbdir=/var/lib/ovn \
  211. --with-ovs-source=$(CURDIR)/ovs \
  212. + --with-log-user=root \
  213. + --with-log-group=adm \
  214. --enable-ssl
  215. # Configure and build OVN VIF
  216. cd ovn-vif && \
  217. @@ -41,6 +43,8 @@ override_dh_auto_configure:
  218. --sysconfdir=/etc \
  219. --with-dbdir=/var/lib/ovn \
  220. --with-ovs-source=$(CURDIR)/ovs \
  221. + --with-log-user=root \
  222. + --with-log-group=adm \
  223. --enable-ssl \
  224. --with-vif-plug-provider=$(CURDIR)/ovn-vif
  225.  
Advertisement
Add Comment
Please, Sign In to add comment