1Name:		munge
2Version:	0.5.14
3Release:	1%{?dist}
4
5# Disable test suite by default; add "--with check" to enable.
6%bcond_with check
7
8# Enable source file verification by default; add "--without verify" to disable.
9%bcond_without verify
10
11# Enable hardened build since munged is a long-running daemon.
12%global _hardened_build 1
13
14Summary:	MUNGE authentication service
15License:	GPLv3+
16URL:		https://dun.github.io/munge/
17Source0:	https://github.com/dun/munge/releases/download/%{name}-%{version}/%{name}-%{version}.tar.xz
18Source1:	https://github.com/dun/munge/releases/download/%{name}-%{version}/%{name}-%{version}.tar.xz.asc
19Source2:	https://github.com/dun.gpg
20
21BuildRequires:	gnupg2
22BuildRequires:	gcc
23BuildRequires:	bzip2-devel
24BuildRequires:	openssl-devel
25BuildRequires:	zlib-devel
26BuildRequires:	systemd
27BuildRequires:	procps
28Requires:	%{name}-libs%{?_isa} = %{version}-%{release}
29Requires(pre):	shadow-utils
30%{?systemd_requires}
31
32%description
33MUNGE (MUNGE Uid 'N' Gid Emporium) is an authentication service for creating
34and validating user credentials.  It is designed to be highly scalable for
35use in an HPC cluster environment.  It provides a portable API for encoding
36the user's identity into a tamper-proof credential that can be obtained by an
37untrusted client and forwarded by untrusted intermediaries within a security
38realm.  Clients within this realm can create and validate credentials without
39the use of root privileges, reserved ports, or platform-specific methods.
40
41%package devel
42Summary:	MUNGE authentication service development files
43License:	LGPLv3+
44BuildRequires:	pkgconfig
45Requires:	%{name}-libs%{?_isa} = %{version}-%{release}
46
47%description devel
48Development files for building applications that use libmunge.
49
50%package libs
51Summary:	MUNGE authentication service shared library
52License:	LGPLv3+
53Requires:	%{name} = %{version}-%{release}
54
55%description libs
56The shared library (libmunge) for running applications that use MUNGE.
57
58%prep
59%if %{with verify}
60%if %{defined gpgverify}
61%{gpgverify} --keyring='%{SOURCE2}' --signature='%{SOURCE1}' --data='%{SOURCE0}'
62%else
63gpg2 --import --import-options import-minimal --no-default-keyring \
64    --keyring ./keyring.gpg '%{SOURCE2}'
65gpgv2 --keyring ./keyring.gpg '%{SOURCE1}' '%{SOURCE0}'
66%endif
67%endif
68%setup -q
69
70%build
71%configure --disable-static \
72    --with-crypto-lib=openssl \
73    --with-logrotateddir=%{_sysconfdir}/logrotate.d \
74    --with-pkgconfigdir=%{_libdir}/pkgconfig \
75    --with-runstatedir=%{_rundir} \
76    --with-systemdunitdir=%{_unitdir}
77sed -i 's|^hardcode_libdir_flag_spec=.*|hardcode_libdir_flag_spec=""|g' libtool
78sed -i 's|^runpath_var=LD_RUN_PATH|runpath_var=DIE_RPATH_DIE|g' libtool
79%make_build
80
81%check
82%if %{with check}
83%make_build check \
84    LD_LIBRARY_PATH=%{buildroot}%{_libdir} \
85    MUNGE_ROOT=/tmp/munge-$$ VERBOSE=t verbose=t
86%endif
87
88%install
89%make_install
90touch %{buildroot}%{_sysconfdir}/munge/munge.key
91touch %{buildroot}%{_localstatedir}/lib/munge/munged.seed
92touch %{buildroot}%{_localstatedir}/log/munge/munged.log
93touch %{buildroot}%{_rundir}/munge/munged.pid
94
95%pre
96getent group munge >/dev/null || \
97    groupadd -r munge
98getent passwd munge >/dev/null || \
99    useradd -c "MUNGE authentication service" -d "%{_sysconfdir}/munge" \
100    -g munge -s /sbin/nologin -r munge
101exit 0
102
103%post
104if test ! -f %{_sysconfdir}/munge/munge.key; then
105    echo "Run %{_sbindir}/mungekey as the munge user to create a key."
106    echo "For example: \"sudo -u munge %{_sbindir}/mungekey -v\"."
107    echo "Refer to the mungekey(8) manpage for more information."
108fi
109%systemd_post munge.service
110
111%post libs -p /sbin/ldconfig
112
113%preun
114%systemd_preun munge.service
115
116%postun
117%systemd_postun_with_restart munge.service
118
119%postun libs -p /sbin/ldconfig
120
121%files
122%{!?_licensedir:%global license %doc}
123%license COPYING*
124%doc AUTHORS
125%doc DISCLAIMER*
126%doc HISTORY
127%doc JARGON
128%doc KEYS
129%doc NEWS
130%doc PLATFORMS
131%doc QUICKSTART
132%doc README
133%doc THANKS
134%doc doc/*
135%dir %attr(0700,munge,munge) %{_sysconfdir}/munge
136%attr(0600,munge,munge) %config(noreplace) %ghost %{_sysconfdir}/munge/munge.key
137%config(noreplace) %{_sysconfdir}/logrotate.d/munge
138%config(noreplace) %{_sysconfdir}/sysconfig/munge
139%dir %attr(0700,munge,munge) %{_localstatedir}/lib/munge
140%attr(0600,munge,munge) %ghost %{_localstatedir}/lib/munge/munged.seed
141%dir %attr(0700,munge,munge) %{_localstatedir}/log/munge
142%attr(0640,munge,munge) %ghost %{_localstatedir}/log/munge/munged.log
143%dir %attr(0755,munge,munge) %ghost %{_rundir}/munge
144%attr(0644,munge,munge) %ghost %{_rundir}/munge/munged.pid
145%{_bindir}/*
146%{_sbindir}/*
147%{_mandir}/man[^3]/*
148%{_unitdir}/munge.service
149
150%files devel
151%{_includedir}/*
152%{_libdir}/libmunge.la
153%{_libdir}/libmunge.so
154%{_libdir}/pkgconfig/munge.pc
155%{_mandir}/man3/*
156
157%files libs
158%{_libdir}/libmunge.so.2
159%{_libdir}/libmunge.so.2.0.0
160