Running inside the /tmp folder is a potential security issue.
Change-Id: I540deabb722a828a522adc52982056d2690524d9
Signed-off-by: Michal Bloch <m.bloch@samsung.com>
##### 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
%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.
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
%{_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
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 &
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
kill $UTIL_PID
kill $MT_TEST
kill $LOGGER
-rm -rf /tmp/dlog_tests
+rm -rf $TESTDIR/*