Blob Blame History Raw
%global _hardened_build 1
# Define pkgdocdir for releases that don't define it already
%{!?_pkgdocdir: %global _pkgdocdir %{_docdir}/%{name}}

Name:    sslh
Version: 1.17
Release: 2%{?dist}
Summary: Applicative protocol(SSL/SSH) multiplexer
License: GPLv2
URL:     http://www.rutschle.net/tech/sslh.shtml
Source0: http://www.rutschle.net/tech/%{name}-v%{version}.tar.gz
Patch0:  00-systemd-tuning.patch

BuildRequires: libconfig-devel
BuildRequires: libcap-devel
BuildRequires: tcp_wrappers-devel
BuildRequires: systemd

Requires(pre):    shadow-utils
Requires(post):   systemd
Requires(preun):  systemd
Requires(postun): systemd

%description
sslh accepts connections on specified ports, and forwards them further
based on tests performed on the first data packet sent by the remote
client.

Probes for HTTP, SSL, SSH, OpenVPN, tinc, XMPP are implemented, and
any other protocol that can be tested using a regular expression, can
be recognized. A typical use case is to allow serving several services
on port 443 (e.g. to connect to ssh from inside a corporate firewall,
which almost never block port 443) while still serving HTTPS on that port.

Hence sslh acts as a protocol multiplexer, or a switchboard. Its name
comes from its original function to serve SSH and HTTPS on the same port.


%prep
%setup -q -n %{name}-v%{version}
%patch0 -p1

%build
./genver.sh >version.h
make %{?_smp_mflags} USELIBWRAP=1 USELIBCAP=1 CFLAGS="%{optflags}" %{name}
pod2man --section=8 --release=%{version} --center=" " %{name}.pod > %{name}.8
iconv --from=ISO-8859-1 --to=UTF-8 ChangeLog > ChangeLog.conv && \
touch -r ChangeLog ChangeLog.conv && \
mv ChangeLog.conv ChangeLog

%install
mkdir -p %{buildroot}%{_sbindir}
mkdir -p %{buildroot}%{_sysconfdir}/sysconfig
mkdir -p %{buildroot}%{_pkgdocdir}
mkdir -p %{buildroot}%{_mandir}/man8
mkdir -p %{buildroot}%{_unitdir}
cp -p %{name}-fork %{buildroot}%{_sbindir}/%{name}
cp -p %{name}-select %{buildroot}%{_sbindir}/%{name}-select
cp -p basic.cfg %{buildroot}/etc/%{name}.cfg
cp -p %{name}.8 %{buildroot}%{_mandir}/man8/
cp -p scripts/systemd.sslh.service %{buildroot}%{_unitdir}/%{name}.service
cat > %{buildroot}%{_sysconfdir}/sysconfig/%{name} << EOF
#
# The options passed to the sslh binary can be provided here
# Defaults to passing the configuration file to the daemon
#
DAEMON_OPTS="-F /etc/sslh.cfg"
EOF


%pre
getent group %{name} >/dev/null || groupadd -r %{name}
getent passwd %{name} >/dev/null || \
    useradd -r -g %{name} -d /dev/null -s /sbin/nologin \
    -c "SSLH daemon" %{name}
exit 0

%post
%systemd_post sslh.service

%preun
%systemd_preun sslh.service

%postun
%systemd_postun_with_restart sslh.service 

%files
%doc README.md ChangeLog example.cfg
%license COPYING
%doc %{_mandir}/man8/%{name}.8*
%attr(0755,root,root) %{_sbindir}/%{name}
%attr(0755,root,root) %{_sbindir}/%{name}-select
%{_unitdir}/%{name}.service
%config(noreplace) %attr(0644,root,root) %{_sysconfdir}/%{name}.cfg
%config(noreplace) %attr(0644,root,root) %{_sysconfdir}/sysconfig/%{name}




%changelog
* Mon Jul 20 2015 James Hogarth <james.hogarth@gmail.com> - 1.17-2
- Make sslh.cfg argument overrideable from sysconfig BZ#1221320
* Wed Mar 18 2015 James Hogarth <james.hogarth@gmail.com> - 1.17-1
- Initial packaging of sslh 1.17