cjdns.spec 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  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 -p publictoip6 privatetopublic makekeys randombytes sybilsim \
  107. $RPM_BUILD_ROOT%{_prefix}/lib/cjdns
  108. cp -pr tools $RPM_BUILD_ROOT%{_prefix}/lib/cjdns
  109. cp -p node_build/Semaphore.js $RPM_BUILD_ROOT%{_prefix}/lib/cjdns/node_build
  110. cp -pr contrib/nodejs $RPM_BUILD_ROOT%{_prefix}/lib/cjdns/contrib
  111. # symlinks for selected nodejs tools
  112. mkdir -p %{buildroot}%{_bindir}
  113. for t in peerStats sessionStats cjdnslog publictoip6; do
  114. ln -sf %{_prefix}/lib/cjdns/tools/$t %{buildroot}%{_bindir}
  115. done
  116. %files
  117. %{!?_licensedir:%global license %%doc}
  118. %license LICENSE
  119. %doc README.md README_RU.md HACKING.md
  120. %attr(0100,root,root) /var/empty/cjdns
  121. %{_sbindir}/cjdroute
  122. %dir %{_prefix}/lib/cjdns
  123. %if 0%{?rhel} == 6
  124. /%{_sysconfdir}/init/*
  125. %else
  126. %{_unitdir}/*
  127. %endif
  128. %pre
  129. getent passwd cjdns > /dev/null || /usr/sbin/useradd -c "" \
  130. -r -d %{_prefix}/lib/cjdns -s /sbin/nologin %{name}
  131. # FIXME: how do you get upstart on EL6 to reload the service?
  132. %post
  133. %if 0%{?rhel} != 6
  134. %systemd_post cjdns.service
  135. %endif
  136. %preun
  137. %if 0%{?rhel} == 6
  138. if [ "$1" -eq 0 ]; then
  139. /sbin/initctl stop cjdns
  140. fi
  141. %else
  142. %systemd_preun cjdns.service
  143. %endif
  144. %postun
  145. %if 0%{?rhel} == 6
  146. if [ "$1" -ge 1 ]; then
  147. /sbin/initctl restart cjdns
  148. fi
  149. %else
  150. %systemd_postun_with_restart cjdns.service
  151. %endif
  152. %files selinux
  153. %doc cjdns.te cjdns.fc
  154. %{_datadir}/selinux/targeted/*
  155. %post selinux
  156. /usr/sbin/semodule -s targeted -i %{_datadir}/selinux/targeted/cjdns.pp \
  157. &>/dev/null || :
  158. %postun selinux
  159. if [ $1 -eq 0 ] ; then
  160. /usr/sbin/semodule -s targeted -r cjdns &> /dev/null || :
  161. fi
  162. %files tools
  163. %{_prefix}/lib/cjdns
  164. %{_bindir}/*
  165. %changelog
  166. * Thu Sep 24 2015 Stuart D. Gathman <stuart@gathman.org> 16.0-5
  167. - Restart cjdroute on update, stop on uninstall
  168. - symlink selected tools to bin
  169. - use /var/empty/cjdns for chroot
  170. - patch genconf to change chroot and setuser
  171. - TODO: patch cjdroute to remove module request, handle externally
  172. * Wed Sep 23 2015 Stuart D. Gathman <stuart@gathman.org> 16.0-4
  173. - Remove doc subpackage - only a meg of docs, and protocol is experimental.
  174. - Fix for RLIMIT_NPROC - setuid bug.
  175. - Add setgid to Security.c
  176. - add contrib/nodejs so tools work
  177. * Wed Sep 23 2015 Stuart D. Gathman <stuart@gathman.org> 16.0-3
  178. - Add selinux, doc and tools subpackages
  179. - Support EL6
  180. * Mon Sep 21 2015 Stuart D. Gathman <stuart@gathman.org> 16.0-2
  181. - nodejs not a runtime dependency of main package
  182. - move binaries to /usr/bin (good idea?)
  183. * Mon Sep 21 2015 Stuart D. Gathman <stuart@gathman.org> 16.0-1
  184. - Initial RPM