cjdns.spec 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. %define commit0 00a90f0997e2863dd218d04f95e24401f2037a4c
  2. %define shortcommit0 00a90f09
  3. Name: cjdns
  4. # major version is cjdns protocol version:
  5. Version: 16.0
  6. Release: 5%{?dist}
  7. Summary: The privacy-friendly network without borders
  8. Group: System Environment/Base
  9. License: GPL3
  10. URL: https://hyperboria.net/
  11. Source0: https://github.com/cjdelisle/cjdns/archive/%{commit0}.tar.gz#/%{name}-%{shortcommit0}.tar.gz
  12. # Add targeted selinux policy
  13. Patch0: cjdns.selinux.patch
  14. # Allow python2.6 for build. Python is not used during the build
  15. # process. The python tools allegedly depend on python2.7, but that can
  16. # be in Requires for the subpackage.
  17. Patch1: cjdns.el6.patch
  18. # Fix RLIMIT_NPROC - setuid() bug. In its low priv process, cjdroute calls
  19. #
  20. # setrlimit(RLIMIT_NPROC, &(struct rlimit){ 0, 0 })
  21. #
  22. # which on recent kernels prevents fork() or exec() after the following
  23. # setuid(). This is due to changes discussed here:
  24. #
  25. # https://lwn.net/Articles/451985/
  26. #
  27. # On the 2.6.32 kernel used by EL6, the above causes setuid() to fail.
  28. # This patch sets RLIMIT_NPROC to { 1, 1 } instead, which prevents
  29. # fork(), but not exec.
  30. Patch2: cjdns.nprocs.patch
  31. # Add setgid to Security_setUser().
  32. Patch3: cjdns.setgid.patch
  33. # Change defaults generated by cjdroute --genconf
  34. Patch4: cjdns.genconf.patch
  35. # Patch contributed init scripts to put cjdroute in /usr/sbin
  36. Patch5: cjdns.sbin.patch
  37. # FIXME: selinux prevents cjdroute from writing to /etc/cjdroute.conf
  38. # at first startup when run by the supplied init service scripts. This is
  39. # probably correct. But the initial config needs to be generated another way.
  40. # FIXME: getpwuid(uid) fails, because Security_admin has already done chroot.
  41. BuildRequires: nodejs, make
  42. #Requires:
  43. Prereq: /usr/sbin/useradd
  44. %description
  45. Cjdns implements an encrypted IPv6 network using public-key cryptography for
  46. address allocation and a distributed hash table for routing. This provides
  47. near-zero-configuration networking, and prevents many of the security and
  48. scalability issues that plague existing networks.
  49. %package selinux
  50. Summary: Targeted SELinux policy module for cjdns
  51. Group: System Environment/Base
  52. BuildRequires: policycoreutils, checkpolicy, selinux-policy-devel
  53. Requires: policycoreutils, selinux-policy, %{name}
  54. %description selinux
  55. Targeted SELinux policy module for cjdns.
  56. # FIXME: keep C tools separate?
  57. %package tools
  58. Summary: Command line tools for cjdns
  59. Group: System Environment/Base
  60. Requires: nodejs
  61. %description tools
  62. C language and nodejs tools for cjdns.
  63. %prep
  64. %setup -qn %{name}-%{commit0}
  65. %patch0 -b .selinux
  66. %if 0%{?rhel} == 6
  67. %patch1 -b .el6
  68. %patch2 -b .nprocs
  69. %endif
  70. %patch3 -b .setgid
  71. %patch4 -b .genconf
  72. %patch5 -b .sbin
  73. # FIXME: grep Version_CURRENT_PROTOCOL util/version/Version.h and
  74. # check that it matches major %{version}
  75. %build
  76. cd contrib/selinux
  77. ln -s /usr/share/selinux/devel/Makefile .
  78. make cjdns.pp
  79. cd -
  80. # nodejs based build system
  81. ./do
  82. # FIXME: use system libuv on compatible systems
  83. # bundled libuv is 0.11.4 with changes:
  84. # https://github.com/cjdelisle/cjdns/commits/master/node_build/dependencies/libuv
  85. %install
  86. rm -rf $RPM_BUILD_ROOT
  87. mkdir -p $RPM_BUILD_ROOT%{_sbindir}
  88. cp -p cjdroute $RPM_BUILD_ROOT%{_sbindir}
  89. # init support
  90. # FIXME: move cjdroute to /usr/sbin or /usr/lib/cjdns and patch init configs
  91. %if 0%{?rhel} == 6
  92. mkdir -p $RPM_BUILD_ROOT/%{_sysconfdir}/init
  93. cp -p contrib/upstart/cjdns.conf $RPM_BUILD_ROOT/%{_sysconfdir}/init
  94. %else
  95. mkdir -p $RPM_BUILD_ROOT%{_unitdir}
  96. cp -p contrib/systemd/cjdns.service $RPM_BUILD_ROOT%{_unitdir}
  97. %endif
  98. # chroot
  99. mkdir -p %{buildroot}/var/empty/cjdns
  100. # install selinux modules
  101. mkdir -p %{buildroot}%{_datadir}/selinux/targeted
  102. cp -p contrib/selinux/cjdns.pp %{buildroot}%{_datadir}/selinux/targeted
  103. ln contrib/selinux/cjdns.{te,fc} . # for doc dir
  104. # install c and nodejs tools
  105. mkdir -p %{buildroot}%{_prefix}/lib/cjdns/{node_build,contrib}
  106. cp -pr tools $RPM_BUILD_ROOT%{_prefix}/lib/cjdns
  107. cp -p node_build/Semaphore.js $RPM_BUILD_ROOT%{_prefix}/lib/cjdns/node_build
  108. cp -pr contrib/nodejs $RPM_BUILD_ROOT%{_prefix}/lib/cjdns/contrib
  109. # symlinks for selected nodejs tools
  110. mkdir -p %{buildroot}%{_bindir}
  111. for t in peerStats sessionStats cjdnslog publictoip6; do
  112. ln -sf %{_prefix}/lib/cjdns/tools/$t %{buildroot}%{_bindir}
  113. done
  114. %files
  115. %{!?_licensedir:%global license %%doc}
  116. %license LICENSE
  117. %doc README.md README_RU.md HACKING.md
  118. %attr(0100,root,root) /var/empty/cjdns
  119. %{_sbindir}/cjdroute
  120. %dir %{_prefix}/lib/cjdns
  121. %if 0%{?rhel} == 6
  122. /%{_sysconfdir}/init/*
  123. %else
  124. %{_unitdir}/*
  125. %endif
  126. %pre
  127. getent passwd cjdns > /dev/null || /usr/sbin/useradd -c "" \
  128. -r -d %{_prefix}/lib/cjdns -s /sbin/nologin %{name}
  129. # FIXME: how do you get upstart on EL6 to reload the service?
  130. %post
  131. %if 0%{?rhel} != 6
  132. %systemd_post cjdns.service
  133. %endif
  134. %preun
  135. %if 0%{?rhel} == 6
  136. if [ "$1" -eq 0 ]; then
  137. /sbin/initctl stop cjdns
  138. fi
  139. %else
  140. %systemd_preun cjdns.service
  141. %endif
  142. %postun
  143. %if 0%{?rhel} == 6
  144. if [ "$1" -ge 1 ]; then
  145. /sbin/initctl restart cjdns
  146. fi
  147. %else
  148. %systemd_postun_with_restart cjdns.service
  149. %endif
  150. %files selinux
  151. %doc cjdns.te cjdns.fc
  152. %{_datadir}/selinux/targeted/*
  153. %post selinux
  154. /usr/sbin/semodule -s targeted -i %{_datadir}/selinux/targeted/cjdns.pp \
  155. &>/dev/null || :
  156. %postun selinux
  157. if [ $1 -eq 0 ] ; then
  158. /usr/sbin/semodule -s targeted -r cjdns &> /dev/null || :
  159. fi
  160. %files tools
  161. %{_prefix}/lib/cjdns
  162. %{_bindir}/*
  163. %changelog
  164. * Thu Sep 24 2015 Stuart D. Gathman <stuart@gathman.org> 16.0-5
  165. - Restart cjdroute on update, stop on uninstall
  166. - symlink selected tools to bin
  167. - use /var/empty/cjdns for chroot
  168. - patch genconf to change chroot and setuser
  169. - TODO: patch cjdroute to remove module request, handle externally
  170. * Wed Sep 23 2015 Stuart D. Gathman <stuart@gathman.org> 16.0-4
  171. - Remove doc subpackage - only a meg of docs, and protocol is experimental.
  172. - Fix for RLIMIT_NPROC - setuid bug.
  173. - Add setgid to Security.c
  174. - add contrib/nodejs so tools work
  175. * Wed Sep 23 2015 Stuart D. Gathman <stuart@gathman.org> 16.0-3
  176. - Add selinux, doc and tools subpackages
  177. - Support EL6
  178. * Mon Sep 21 2015 Stuart D. Gathman <stuart@gathman.org> 16.0-2
  179. - nodejs not a runtime dependency of main package
  180. - move binaries to /usr/bin (good idea?)
  181. * Mon Sep 21 2015 Stuart D. Gathman <stuart@gathman.org> 16.0-1
  182. - Initial RPM