From 309770985d16ca25555b7f1509298368a14776e8 Mon Sep 17 00:00:00 2001 From: Krzysztof Jackiewicz Date: Mon, 11 Mar 2013 15:00:06 +0100 Subject: [PATCH] Smack labels for databases are restored after database removal [Issue#] N/A [Feature/Bug] N/A [Problem] After calling wrt_reset_all.sh wrt database labels are reset to "_" [Cause] Db files are removed and created with default label [Solution] Old label is stored and applied to newly created files [Verification] 1.Check /opt/dbspace/.wrt.db* labels with chsmack [filename]. It should be "wrt-commons::db_wrt" 2.Run wrt_reset_all.sh. Check labels again. They should be the same. Change-Id: I885638d482c921fadea0a74d773ce8a548387483 --- etc/wrt_commons_create_clean_db.sh | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/etc/wrt_commons_create_clean_db.sh b/etc/wrt_commons_create_clean_db.sh index d333d9d..f1287c2 100755 --- a/etc/wrt_commons_create_clean_db.sh +++ b/etc/wrt_commons_create_clean_db.sh @@ -16,8 +16,22 @@ for name in wrt wrt_autosave wrt_custom_handler do + # extract smack label before removal + DB_LABEL="" + if [ -f /opt/dbspace/.$name.db ] + then + DB_LABEL=`chsmack /opt/dbspace/.$name.db | sed -r "s/.*access=\"([^\"]+)\"/\1/"` + fi rm -f /opt/dbspace/.$name.db + + # extract smack label before removal + JOURNAL_LABEL="" + if [ -f /opt/dbspace/.$name.db-journal ] + then + JOURNAL_LABEL=`chsmack /opt/dbspace/.$name.db-journal | sed -r "s/.*access=\"([^\"]+)\"/\1/"` + fi rm -f /opt/dbspace/.$name.db-journal + SQL="PRAGMA journal_mode = PERSIST;" sqlite3 /opt/dbspace/.$name.db "$SQL" SQL=".read /usr/share/wrt-engine/"$name"_db.sql" @@ -27,7 +41,20 @@ do chown 0:6026 /opt/dbspace/.$name.db-journal chmod 660 /opt/dbspace/.$name.db chmod 660 /opt/dbspace/.$name.db-journal + pkill -9 security-serv + + # restore smack label + if [ -n "$DB_LABEL" ] + then + chsmack -a $DB_LABEL /opt/dbspace/.$name.db + fi + + # restore smack label + if [ -n "$JOURNAL_LABEL" ] + then + chsmack -a $JOURNAL_LABEL /opt/dbspace/.$name.db-journal + fi done -- 2.7.4