diff options
author | kyungwook tak <k.tak@samsung.com> | 2015-02-09 15:36:07 +0900 |
---|---|---|
committer | Maciej J. Karpiuk <m.karpiuk2@samsung.com> | 2015-02-17 12:15:52 +0100 |
commit | 4348335d0b2d7aec5f6aa7c62ca6a28c25cc9c4b (patch) | |
tree | 8b87196a96dcc8cf037404c31a820232312cb62b /data | |
parent | e0ef338b740caf2501c07e03893f32ad3fb66449 (diff) | |
download | key-manager-4348335d0b2d7aec5f6aa7c62ca6a28c25cc9c4b.tar.gz key-manager-4348335d0b2d7aec5f6aa7c62ca6a28c25cc9c4b.tar.bz2 key-manager-4348335d0b2d7aec5f6aa7c62ca6a28c25cc9c4b.zip |
CKM FileSystem versioning with file name format update mechanism
* DKEK format releaseed on kiran
(key-<uid>-<autoincreased num>)
* DKEK format on version 0.1.13
(key-<uid>)
(key-backup-<uid>)
* DKEK format on tizen 2.4 which has container feature
(not merged from knox-tct branch yet,
so not included about it in this commit)
(key-<zone name>-<uid>)
(key-backup-<zone name>-<uid>
Change-Id: I5ce62528d54268cccb7f9705daf0793aec782513
Signed-off-by: kyungwook tak <k.tak@samsung.com>
Diffstat (limited to 'data')
-rwxr-xr-x | data/scripts/230.key-manager-migrate-dkek.patch.sh | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/data/scripts/230.key-manager-migrate-dkek.patch.sh b/data/scripts/230.key-manager-migrate-dkek.patch.sh new file mode 100755 index 00000000..93a9a96f --- /dev/null +++ b/data/scripts/230.key-manager-migrate-dkek.patch.sh @@ -0,0 +1,64 @@ +#!/bin/bash + +CKM_DATA_PATH=/opt/data/ckm +VERSION_INFO_PATH=${CKM_DATA_PATH}/version-info +CURRENT_VERSION=1 + +migrate_from_0_to_1() +{ + ARR_UID=() + ARR_IDX=() + + # Extract uids from DKEK files + for uid in `ls ${CKM_DATA_PATH} | grep "^key-[0-9]*-[0-9]*$" | awk 'BEGIN { FS = "-" }; { print $2 }' | awk '!x[$0]++'` + do + ARR_UID+=($uid) + done + + for (( i = 0; i < ${#ARR_UID[@]}; i++ )) + do + idx_max=0 + idx_submax=0 + + uid=${ARR_UID[$i]} + ARR_IDX=() + # Extract autoincremented index per uids + for file in `ls ${CKM_DATA_PATH} | grep "^key-${uid}-[0-9]*$"` + do + idx=`echo $file | awk 'BEGIN { FS = "-" }; { print $3 }'` + ARR_IDX+=($idx) + done + + # Find max index(for key-<uid>) and submax index(for key-backup-<uid>) + for idx in ${ARR_IDX[@]} + do + if [ $idx -gt $idx_max ] + then + idx_submax=$idx_max + idx_max=$idx + fi + done + + # Rename file + # smack label setting isn't needed. + # (Because not remove/add new file, but just rename file) + mv "${CKM_DATA_PATH}/key-${uid}-${idx_max}" "${CKM_DATA_PATH}/key-${uid}" + if [ -f "${CKM_DATA_PATH}/key-${uid}-${idx_submax}" ] + then + mv "${CKM_DATA_PATH}/key-${uid}-${idx_submax}" "${CKM_DATA_PATH}/key-backup-${uid}" + fi + + # [Optional] Remove other key-<uid>-<numeric> files. + for file in `ls ${CKM_DATA_PATH} | grep "^key-${uid}-[0-9]*$"` + do + rm ${CKM_DATA_PATH}/${file} + done + done +} + +if [ ! -f ${VERSION_INFO_PATH} ] +then + echo "CKM VERSION_INFO NOT EXIST." + echo "$CURRENT_VERSION" > $VERSION_INFO_PATH + migrate_from_0_to_1 +fi |