forked from m13253/dns-over-https
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
596 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
diff -Naur dns-over-https-2.1.2.org/systemd/doh-client.service dns-over-https-2.1.2/systemd/doh-client.service | ||
--- dns-over-https-2.1.2.org/systemd/doh-client.service 2019-09-10 12:08:35.177574074 +0200 | ||
+++ dns-over-https-2.1.2/systemd/doh-client.service 2019-09-10 12:10:05.473700374 +0200 | ||
@@ -7,12 +7,12 @@ | ||
|
||
[Service] | ||
AmbientCapabilities=CAP_NET_BIND_SERVICE | ||
-ExecStart=/usr/local/bin/doh-client -conf /etc/dns-over-https/doh-client.conf | ||
+ExecStart=/usr/bin/doh-client -conf /etc/dns-over-https/doh-client.conf | ||
LimitNOFILE=1048576 | ||
Restart=always | ||
RestartSec=3 | ||
Type=simple | ||
-User=nobody | ||
+User=doh-client | ||
|
||
[Install] | ||
WantedBy=multi-user.target | ||
diff -Naur dns-over-https-2.1.2.org/systemd/doh-server.service dns-over-https-2.1.2/systemd/doh-server.service | ||
--- dns-over-https-2.1.2.org/systemd/doh-server.service 2019-09-10 12:08:35.177574074 +0200 | ||
+++ dns-over-https-2.1.2/systemd/doh-server.service 2019-09-10 12:10:20.980273992 +0200 | ||
@@ -5,12 +5,12 @@ | ||
|
||
[Service] | ||
AmbientCapabilities=CAP_NET_BIND_SERVICE | ||
-ExecStart=/usr/local/bin/doh-server -conf /etc/dns-over-https/doh-server.conf | ||
+ExecStart=/usr/bin/doh-server -conf /etc/dns-over-https/doh-server.conf | ||
LimitNOFILE=1048576 | ||
Restart=always | ||
RestartSec=3 | ||
Type=simple | ||
-User=nobody | ||
+User=doh-server | ||
|
||
[Install] | ||
WantedBy=multi-user.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,240 @@ | ||
# vim: tabstop=4 shiftwidth=4 expandtab | ||
%global _hardened_build 1 | ||
# Debug package is empty anyway | ||
%define debug_package %{nil} | ||
|
||
%global _release 1 | ||
%global provider github | ||
%global provider_tld com | ||
%global project m13253 | ||
%global repo dns-over-https | ||
%global provider_prefix %{provider}.%{provider_tld}/%{project}/%{repo} | ||
%global import_path %{provider_prefix} | ||
|
||
#define commit 984df34ca7b45897ecb5871791e398cc160a4b93 | ||
|
||
%if 0%{?commit:1} | ||
%define shortcommit %(c=%{commit}; echo ${c:0:7}) | ||
%define _date %(date +'%%Y%%m%%dT%%H%%M%%S') | ||
%endif | ||
|
||
%define rand_id %(head -c20 /dev/urandom|od -An -tx1|tr -d '[[:space:]]') | ||
|
||
%if ! 0%{?gobuild:1} | ||
%define gobuild(o:) go build -ldflags "${LDFLAGS:-} -B 0x%{rand_id}" -a -v -x %{?**}; | ||
%endif | ||
|
||
%if ! 0%{?gotest:1} | ||
%define gotest() go test -ldflags "${LDFLAGS:-}" %{?**} | ||
%endif | ||
|
||
Name: %{repo} | ||
Version: 2.1.2 | ||
%if 0%{?commit:1} | ||
Release: %{_release}.git%{shortcommit}.%{_date}%{?dist} | ||
Source0: https://%{import_path}/archive/%{commit}.tar.gz | ||
%else | ||
Release: %{_release}%{?dist} | ||
Source0: https://%{import_path}/archive/v%{version}.tar.gz | ||
%endif | ||
Patch0: %{name}-%{version}-systemd.patch | ||
|
||
Summary: High performance DNS over HTTPS client & server | ||
License: MIT | ||
URL: https://github.com/m13253/dns-over-https | ||
|
||
|
||
# e.g. el6 has ppc64 arch without gcc-go, so EA tag is required | ||
# If go_compiler is not set to 1, there is no virtual provide. Use golang instead. | ||
#BuildRequires: %{?go_compiler:compiler(go-compiler)}%{!?go_compiler:golang} >= 1.10 | ||
BuildRequires: golang >= 1.10 | ||
BuildRequires: systemd | ||
BuildRequires: upx | ||
|
||
%description | ||
%{summary} | ||
|
||
%package common | ||
BuildArch: noarch | ||
Summary: %{summary} - common files | ||
|
||
%description common | ||
%{summary} | ||
|
||
%package server | ||
ExclusiveArch: %{?go_arches:%{go_arches}}%{!?go_arches:%{ix86} x86_64 %{arm}} | ||
Summary: %{summary} - Server | ||
Requires(pre): shadow-utils | ||
Requires(post): systemd | ||
Requires(preun): systemd | ||
Requires(postun): systemd | ||
|
||
%description server | ||
%{summary} | ||
|
||
%package client | ||
ExclusiveArch: %{?go_arches:%{go_arches}}%{!?go_arches:%{ix86} x86_64 %{arm}} | ||
Summary: %{summary} - Client | ||
Requires(pre): shadow-utils | ||
Requires(post): systemd | ||
Requires(preun): systemd | ||
Requires(postun): systemd | ||
|
||
%description client | ||
%{summary} | ||
|
||
%package selinux | ||
BuildArch: noarch | ||
|
||
Source3: doh_server.fc | ||
Source4: doh_server.if | ||
Source5: doh_server.te | ||
Source6: doh_client.fc | ||
Source7: doh_client.if | ||
Source8: doh_client.te | ||
|
||
BuildRequires: selinux-policy | ||
BuildRequires: selinux-policy-devel | ||
Requires: %{name} | ||
|
||
Requires(post): policycoreutils | ||
Requires(post): policycoreutils-python | ||
Requires(postun): policycoreutils | ||
|
||
Summary: SELinux policy for %{name} | ||
|
||
%description selinux | ||
%summary | ||
|
||
%prep | ||
%if 0%{?commit:1} | ||
%autosetup -n %{name}-%{commit} -p1 | ||
%else | ||
%autosetup -n %{name}-%{version} -p1 | ||
%endif | ||
|
||
mkdir -p selinux | ||
cp %{SOURCE3} %{SOURCE4} %{SOURCE5} %{SOURCE6} %{SOURCE7} %{SOURCE8} selinux | ||
|
||
%build | ||
cd selinux | ||
make -f /usr/share/selinux/devel/Makefile doh_server.pp doh_client.pp || exit | ||
cd - | ||
|
||
%set_build_flags | ||
%make_build \ | ||
PREFIX=%{_prefix} \ | ||
GOBUILD="go build -ldflags \"-s -w -B 0x%{rand_id}\" -a -v -x" | ||
|
||
%install | ||
%make_install \ | ||
PREFIX=%{_prefix} | ||
install -Dpm 0600 selinux/doh_server.pp %{buildroot}%{_datadir}/selinux/packages/doh_server.pp | ||
install -Dpm 0644 selinux/doh_server.if %{buildroot}%{_datadir}/selinux/devel/include/contrib/doh_server.if | ||
install -Dpm 0600 selinux/doh_client.pp %{buildroot}%{_datadir}/selinux/packages/doh_client.pp | ||
install -Dpm 0644 selinux/doh_client.if %{buildroot}%{_datadir}/selinux/devel/include/contrib/doh_client.if | ||
|
||
mkdir -p %{buildroot}%{_docdir}/%{name} | ||
mv %{buildroot}%{_sysconfdir}/%{name}/*.example %{buildroot}%{_docdir}/%{name} | ||
|
||
mkdir -p %{buildroot}%{_libdir} | ||
mv %{buildroot}%{_sysconfdir}/NetworkManager %{buildroot}%{_libdir}/ | ||
|
||
for i in $(find %{_buildroot}%{_bindir} -type f) | ||
do | ||
upx $i | ||
done | ||
|
||
%files common | ||
%license LICENSE | ||
%doc Changelog.md Readme.md | ||
|
||
%files server | ||
%{_libdir}/NetworkManager/dispatcher.d/doh-server | ||
%{_docdir}/%{name}/doh-server.conf.example | ||
%config(noreplace) %{_sysconfdir}/%{name}/doh-server.conf | ||
%{_bindir}/doh-server | ||
%{_unitdir}/doh-server.service | ||
|
||
%files client | ||
%{_libdir}/NetworkManager/dispatcher.d/doh-client | ||
%{_docdir}/%{name}/doh-client.conf.example | ||
%config(noreplace) %{_sysconfdir}/%{name}/doh-client.conf | ||
%{_bindir}/doh-client | ||
%{_unitdir}/doh-client.service | ||
|
||
%pre server | ||
test -d %{_sharedstatedir}/home || mkdir -p %{_sharedstatedir}/home | ||
getent group doh-server > /dev/null || groupadd -r doh-server | ||
getent passwd doh-server > /dev/null || \ | ||
useradd -r -d %{_sharedstatedir}/home/doh-server -g doh-server \ | ||
-s /sbin/nologin -c "%{name} - server" doh-server | ||
exit 0 | ||
|
||
%pre client | ||
test -d %{_sharedstatedir}/home || mkdir -p %{_sharedstatedir}/home | ||
getent group doh-client > /dev/null || groupadd -r doh-client | ||
getent passwd doh-client > /dev/null || \ | ||
useradd -r -d %{_sharedstatedir}/home/doh-client -g doh-client \ | ||
-s /sbin/nologin -c "%{name} - client" doh-client | ||
exit 0 | ||
|
||
%post server | ||
%systemd_post doh-server.service | ||
|
||
%preun server | ||
%systemd_preun doh-server.service | ||
|
||
%postun server | ||
%systemd_postun_with_restart doh-server.service | ||
|
||
%post client | ||
%systemd_post doh-client.service | ||
|
||
%preun client | ||
%systemd_preun doh-client.service | ||
|
||
%postun client | ||
%systemd_postun_with_restart doh-client.service | ||
|
||
%files selinux | ||
%{_datadir}/selinux/packages/doh_server.pp | ||
%{_datadir}/selinux/devel/include/contrib/doh_server.if | ||
%{_datadir}/selinux/packages/doh_client.pp | ||
%{_datadir}/selinux/devel/include/contrib/doh_client.if | ||
|
||
%post selinux | ||
semodule -n -i %{_datadir}/selinux/packages/doh_server.pp | ||
semodule -n -i %{_datadir}/selinux/packages/doh_client.pp | ||
if /usr/sbin/selinuxenabled ; then | ||
/usr/sbin/load_policy | ||
/usr/sbin/fixfiles -R %{name}-server restore | ||
/usr/sbin/fixfiles -R %{name}-client restore | ||
fi; | ||
semanage -i - << __eof | ||
port -a -t doh_server_port_t -p tcp "8053" | ||
port -a -t doh_client_port_t -p udp "5380" | ||
__eof | ||
exit 0 | ||
|
||
%postun selinux | ||
if [ $1 -eq 0 ]; then | ||
semanage -i - << __eof | ||
port -d -t doh_server_port_t -p tcp "8053" | ||
port -d -t doh_client_port_t -p udp "5380" | ||
__eof | ||
|
||
semodule -n -r doh_server | ||
semodule -n -r doh_client | ||
if /usr/sbin/selinuxenabled ; then | ||
/usr/sbin/load_policy | ||
/usr/sbin/fixfiles -R %{name}-server restore | ||
/usr/sbin/fixfiles -R %{name}-client restore | ||
fi; | ||
fi; | ||
exit 0 | ||
|
||
%changelog | ||
* Tue Sep 10 2019 fuero <[email protected]> 2.1.2-1 | ||
- initial package | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/usr/bin/doh-client -- gen_context(system_u:object_r:doh_client_exec_t,s0) | ||
/usr/lib/systemd/system/doh-client.service -- gen_context(system_u:object_r:doh_client_unit_file_t,s0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
|
||
## <summary>policy for doh_client</summary> | ||
|
||
######################################## | ||
## <summary> | ||
## Execute doh_client_exec_t in the doh_client domain. | ||
## </summary> | ||
## <param name="domain"> | ||
## <summary> | ||
## Domain allowed to transition. | ||
## </summary> | ||
## </param> | ||
# | ||
interface(`doh_client_domtrans',` | ||
gen_require(` | ||
type doh_client_t, doh_client_exec_t; | ||
') | ||
|
||
corecmd_search_bin($1) | ||
domtrans_pattern($1, doh_client_exec_t, doh_client_t) | ||
') | ||
|
||
###################################### | ||
## <summary> | ||
## Execute doh_client in the caller domain. | ||
## </summary> | ||
## <param name="domain"> | ||
## <summary> | ||
## Domain allowed access. | ||
## </summary> | ||
## </param> | ||
# | ||
interface(`doh_client_exec',` | ||
gen_require(` | ||
type doh_client_exec_t; | ||
') | ||
|
||
corecmd_search_bin($1) | ||
can_exec($1, doh_client_exec_t) | ||
') | ||
######################################## | ||
## <summary> | ||
## Execute doh_client server in the doh_client domain. | ||
## </summary> | ||
## <param name="domain"> | ||
## <summary> | ||
## Domain allowed to transition. | ||
## </summary> | ||
## </param> | ||
# | ||
interface(`doh_client_systemctl',` | ||
gen_require(` | ||
type doh_client_t; | ||
type doh_client_unit_file_t; | ||
') | ||
|
||
systemd_exec_systemctl($1) | ||
systemd_read_fifo_file_passwd_run($1) | ||
allow $1 doh_client_unit_file_t:file read_file_perms; | ||
allow $1 doh_client_unit_file_t:service manage_service_perms; | ||
|
||
ps_process_pattern($1, doh_client_t) | ||
') | ||
|
||
|
||
######################################## | ||
## <summary> | ||
## All of the rules required to administrate | ||
## an doh_client environment | ||
## </summary> | ||
## <param name="domain"> | ||
## <summary> | ||
## Domain allowed access. | ||
## </summary> | ||
## </param> | ||
## <param name="role"> | ||
## <summary> | ||
## Role allowed access. | ||
## </summary> | ||
## </param> | ||
## <rolecap/> | ||
# | ||
interface(`doh_client_admin',` | ||
gen_require(` | ||
type doh_client_t; | ||
type doh_client_unit_file_t; | ||
') | ||
|
||
allow $1 doh_client_t:process { signal_perms }; | ||
ps_process_pattern($1, doh_client_t) | ||
|
||
tunable_policy(`deny_ptrace',`',` | ||
allow $1 doh_client_t:process ptrace; | ||
') | ||
|
||
doh_client_systemctl($1) | ||
admin_pattern($1, doh_client_unit_file_t) | ||
allow $1 doh_client_unit_file_t:service all_service_perms; | ||
optional_policy(` | ||
systemd_passwd_agent_exec($1) | ||
systemd_read_fifo_file_passwd_run($1) | ||
') | ||
') |
Oops, something went wrong.