Skip to content

Commit 122a26a

Browse files
author
Cameron Norman
committed
Add AppArmor profile
1 parent 342a5e0 commit 122a26a

File tree

4 files changed

+77
-2
lines changed

4 files changed

+77
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ src/redshift-gtk/__pycache__/
5656
/data/appdata/redshift-gtk.appdata.xml
5757
/data/applications/redshift.desktop
5858
/data/applications/redshift-gtk.desktop
59+
/data/apparmor/usr.bin.redshift
5960

6061
*.su
6162
*.gch

Makefile.am

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ SYSTEMD_USER_UNIT_IN_FILES = \
3939
APPDATA_IN_FILES = \
4040
data/appdata/redshift-gtk.appdata.xml.in
4141

42+
APPARMOR_IN_FILES = \
43+
data/apparmor/usr.bin.redshift.in
44+
4245

4346
# Icons
4447
if ENABLE_GUI
@@ -103,6 +106,17 @@ appdata_DATA = $(APPDATA_IN_FILES:.xml.in=.xml)
103106
endif
104107

105108

109+
# AppArmor profile
110+
if ENABLE_APPARMOR
111+
apparmordir = @sysconfdir@/apparmor.d
112+
apparmor_DATA = $(APPARMOR_IN_FILES:.in=)
113+
114+
$(apparmor_DATA): $(APPARMOR_IN_FILES) Makefile
115+
$(AM_V_GEN)$(MKDIR_P) $(@D) && \
116+
sed -e "s|\@bindir\@|$(bindir)|g" "$(srcdir)/$(@:=.in)" > $@
117+
endif
118+
119+
106120

107121
EXTRA_DIST = \
108122
$(EXTRA_ROOTDOC_FILES) \
@@ -111,12 +125,14 @@ EXTRA_DIST = \
111125
$(_UBUNTU_MONO_LIGHT_FILES) \
112126
$(DESKTOP_IN_FILES) \
113127
$(SYSTEMD_USER_UNIT_IN_FILES) \
114-
$(APPDATA_IN_FILES)
128+
$(APPDATA_IN_FILES) \
129+
$(APPARMOR_IN_FILES)
115130

116131
CLEANFILES = \
117132
$(desktop_DATA) \
118133
$(systemduserunit_DATA) \
119-
$(appdata_DATA)
134+
$(appdata_DATA) \
135+
$(apparmor_DATA)
120136

121137

122138
# Update PO translations

configure.ac

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,21 @@ AS_IF([test -n "$with_systemduserunitdir" -a "x$with_systemduserunitdir" != xno]
331331
AM_CONDITIONAL([ENABLE_SYSTEMD], [test "x$enable_systemd" != xno])
332332

333333

334+
# Check for AppArmor
335+
AC_MSG_CHECKING([whether to enable AppArmor profile])
336+
AC_ARG_ENABLE([apparmor], [AC_HELP_STRING([--enable-apparmor],
337+
[enable AppArmor profile])],
338+
[enable_apparmor=$enableval],[enable_apparmor=no])
339+
AS_IF([test "x$enable_apparmor" != xno], [
340+
AC_MSG_RESULT([yes])
341+
enable_apparmor=yes
342+
], [
343+
AC_MSG_RESULT([no])
344+
enable_apparmor=no
345+
])
346+
AM_CONDITIONAL([ENABLE_APPARMOR], [test "x$enable_apparmor" != xno])
347+
348+
334349
# Checks for header files.
335350
AC_CHECK_HEADERS([locale.h stdint.h stdlib.h string.h unistd.h signal.h])
336351

@@ -373,4 +388,5 @@ echo "
373388
GUI: ${enable_gui}
374389
Ubuntu icons: ${enable_ubuntu}
375390
systemd units: ${enable_systemd} ${systemduserunitdir}
391+
AppArmor profile: ${enable_apparmor}
376392
"

data/apparmor/usr.bin.redshift.in

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# ------------------------------------------------------------------
2+
#
3+
# Copyright (C) 2015 Cameron Norman <[email protected]>
4+
#
5+
# This program is free software: you can redistribute it and/or modify
6+
# it under the terms of the GNU General Public License as published by
7+
# the Free Software Foundation, either version 3 of the License, or
8+
# (at your option) any later version.
9+
#
10+
# This program is distributed in the hope that it will be useful,
11+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
# GNU General Public License for more details.
14+
#
15+
# You should have received a copy of the GNU General Public License
16+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
17+
#
18+
# ------------------------------------------------------------------
19+
20+
#include <tunables/global>
21+
@bindir@/redshift {
22+
#include <abstractions/base>
23+
#include <abstractions/nameservice>
24+
#include <abstractions/dbus-strict>
25+
#include <abstractions/X>
26+
27+
dbus send
28+
bus=system
29+
path=/org/freedesktop/GeoClue2/Client/[0-9]*,
30+
31+
dbus receive
32+
bus=system
33+
path=/org/freedesktop/GeoClue2/Manager,
34+
35+
# Allow but log any other dbus activity
36+
audit dbus bus=system,
37+
38+
owner @{HOME}/.config/redshift.conf r,
39+
40+
# Site-specific additions and overrides. See local/README for details.
41+
#include <local/usr.bin.redshift>
42+
}

0 commit comments

Comments
 (0)