testsuite: now has its own folder 65/180365/5
authorMichal Bloch <m.bloch@samsung.com>
Mon, 28 May 2018 11:39:20 +0000 (13:39 +0200)
committerMichal Bloch <m.bloch@samsung.com>
Wed, 30 May 2018 11:09:33 +0000 (13:09 +0200)
Running inside the /tmp folder is a potential security issue.

Change-Id: I540deabb722a828a522adc52982056d2690524d9
Signed-off-by: Michal Bloch <m.bloch@samsung.com>
configs/dlog.conf.test
packaging/dlog.spec
tests/dlog_test_pipe.in [changed mode: 0755->0644]

index 05ace04..026d534 100644 (file)
@@ -19,20 +19,20 @@ limiter|*|*=allow
 ##### Settings used by the logging daemon
 
 # Sockets that all programs connect to to receive a logging pipe.
-main_write_sock=/tmp/dlog_tests/main.wr
-apps_write_sock=/tmp/dlog_tests/apps.wr
-system_write_sock=/tmp/dlog_tests/system.wr
-radio_write_sock=/tmp/dlog_tests/radio.wr
-kmsg_write_sock=/tmp/dlog_tests/kmsg.wr
-syslog_write_sock=/tmp/dlog_tests/syslog.wr
+main_write_sock=/var/lib/dlog-tests/main.wr
+apps_write_sock=/var/lib/dlog-tests/apps.wr
+system_write_sock=/var/lib/dlog-tests/system.wr
+radio_write_sock=/var/lib/dlog-tests/radio.wr
+kmsg_write_sock=/var/lib/dlog-tests/kmsg.wr
+syslog_write_sock=/var/lib/dlog-tests/syslog.wr
 
 # Sockets that administrative programs connect to to manipulate the daemon.
-main_ctl_sock=/tmp/dlog_tests/main.ctl
-apps_ctl_sock=/tmp/dlog_tests/apps.ctl
-system_ctl_sock=/tmp/dlog_tests/system.ctl
-radio_ctl_sock=/tmp/dlog_tests/radio.ctl
-kmsg_ctl_sock=/tmp/dlog_tests/kmsg.ctl
-syslog_ctl_sock=/tmp/dlog_tests/syslog.ctl
+main_ctl_sock=/var/lib/dlog-tests/main.ctl
+apps_ctl_sock=/var/lib/dlog-tests/apps.ctl
+system_ctl_sock=/var/lib/dlog-tests/system.ctl
+radio_ctl_sock=/var/lib/dlog-tests/radio.ctl
+kmsg_ctl_sock=/var/lib/dlog-tests/kmsg.ctl
+syslog_ctl_sock=/var/lib/dlog-tests/syslog.ctl
 
 # Permissions for the relevant sockets.
 main_write_sock_rights=0222
index e9e623f..e9625c4 100644 (file)
@@ -86,6 +86,8 @@ Documentation for dlog
 
 %package -n dlog-tests
 Summary: dlog integration tests
+Requires: lib%{name} = %{?epoch:%{epoch}:}%{version}-%{release}
+Requires(post): /usr/bin/chsmack
 
 %description -n dlog-tests
 Integration tests for dlog.
@@ -124,6 +126,8 @@ install -m 0644 %SOURCE501 %{buildroot}/%{_udevrulesdir}/01-dlog.rules
 
 mkdir -p %{buildroot}/var/log/dlog
 
+mkdir -p %{buildroot}/var/lib/dlog-tests
+
 install -D scripts/210.dlog_upgrade_30to40.sh %{buildroot}/%{upgrade_file_path}/scripts/210.dlog_upgrade.sh
 
 %pre -n libdlog
@@ -212,3 +216,7 @@ fi
 %{_libexecdir}/libdlog/perf_libdlog
 %{_libexecdir}/libdlog/test_libdlog
 %{_datadir}/dlog.conf.test
+%dir %attr(755,log,log) /var/lib/dlog-tests
+
+%post -n dlog-tests
+chsmack -a System /var/lib/dlog-tests
old mode 100755 (executable)
new mode 100644 (file)
index e2457f3..d652710
@@ -20,7 +20,7 @@ ok(){
 export DLOG_CONFIG_PATH="@datadir@/dlog.conf.test"
 PATH=$PATH:@libexecdir@/libdlog/
 
-mkdir /tmp/dlog_tests
+TESTDIR=/var/lib/dlog-tests
 
 # Start the daemon, add some logs
 dlog_logger -b 99 -t 0 &
@@ -54,23 +54,23 @@ if [ $(dlogutil -s -d | wc -l) -eq 0 ]; then ok; else fail; fi
 dlogutil -g &> /dev/null && ok || fail
 
 # 12-19: test -f, -r and -n
-dlogutil -f /tmp/dlog_tests/dlog_test_file -d &> /dev/null && ok || fail
-dlogutil -f /tmp/dlog_tests/dlog_rotating_file -r 12 -n 3 & # 3 files at 12 KB each
+dlogutil -f $TESTDIR/dlog_test_file -d &> /dev/null && ok || fail
+dlogutil -f $TESTDIR/dlog_rotating_file -r 12 -n 3 & # 3 files at 12 KB each
 UTIL_PID=$!
 test_libdlog 100000
 sleep 1
-if [ -e /tmp/dlog_tests/dlog_test_file ]; then ok; else fail; fi
-if [ -e /tmp/dlog_tests/dlog_rotating_file.1 ]; then ok; else fail; fi
-if [ -e /tmp/dlog_tests/dlog_rotating_file.2 ]; then ok; else fail; fi
-if [ -e /tmp/dlog_tests/dlog_rotating_file.3 ]; then ok; else fail; fi
-if [ -e /tmp/dlog_tests/dlog_rotating_file.4 ]; then fail; else ok; fi
-if [ $(du /tmp/dlog_tests/dlog_rotating_file.3 | sed 's/\t\/tmp\/dlog_tests\/dlog_rotating_file\.3//g') -eq 16 ]; then ok; else fail; fi # the actual size is one sector more (so 12 -> 16) because the limit is checked after reaching it, not before
+if [ -e $TESTDIR/dlog_test_file ]; then ok; else fail; fi
+if [ -e $TESTDIR/dlog_rotating_file.1 ]; then ok; else fail; fi
+if [ -e $TESTDIR/dlog_rotating_file.2 ]; then ok; else fail; fi
+if [ -e $TESTDIR/dlog_rotating_file.3 ]; then ok; else fail; fi
+if [ -e $TESTDIR/dlog_rotating_file.4 ]; then fail; else ok; fi
+if [ $(du $TESTDIR/dlog_rotating_file.3 | sed "s#$TESTDIR/dlog_rotating_file.3##g") -eq 16 ]; then ok; else fail; fi # the actual size is one sector more (so 12 -> 16) because the limit is checked after reaching it, not before
 
 # Test -v
 # TODO
 
 # 20: test library
-dlogutil -f /tmp/dlog_tests/dlog_mt_test &
+dlogutil -f $TESTDIR/dlog_mt_test &
 MT_TEST=$!
 test_libdlog && ok || fail
 
@@ -82,4 +82,4 @@ echo "$FAILS / $TOTAL tests failed"
 kill $UTIL_PID
 kill $MT_TEST
 kill $LOGGER
-rm -rf /tmp/dlog_tests
+rm -rf $TESTDIR/*