Skip to content

Commit 95ebc6c

Browse files
authored
Merge pull request #35 from arakshit011/sfsconfig-enablement
Enablement of SFS-config and update persist partition path
2 parents fdd07c9 + ca58741 commit 95ebc6c

File tree

7 files changed

+60
-8
lines changed

7 files changed

+60
-8
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ include(GNUInstallDirs)
2626
set(MINKIDLC_BIN_DIR "${CMAKE_CURRENT_SOURCE_DIR}/idlc" CACHE PATH "Directory containing the idlc executable")
2727
set(SYSTEMD_UNIT_DIR "" CACHE PATH "Directory containing the systemd unit path")
2828
set(UDEV_DIR "" CACHE PATH "Directory containing the UDEV path")
29+
set(MINKIPC_LIBEXEC_DIR "" CACHE PATH "Directory containing the libexec script/binaries path")
2930

3031
if ("${MINKIDLC_BIN_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}/idlc")
3132
file(DOWNLOAD

listeners/libfsservice/cmn/cmn.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232
#define LEGACY_DATA_PATH "/data/misc/qsee/"
3333
#define LEGACY_PERSIST_PATH "/persist/data/"
3434
#define DATA_PATH "/var/tmp/qtee_supplicant/vendor/tzstorage/"
35-
#define PERSIST_PATH "/var/persist/qtee_supplicant/"
36-
#define PERSIST_MOUNT_PATH "/var/persist"
35+
#define PERSIST_PATH "/var/lib/tee/qtee_supplicant/"
36+
#define PERSIST_MOUNT_PATH "/var/lib/tee"
3737

3838
/* Secure File System - version 2 */
3939
#define GP_FS_VERSION 2

listeners/libfsservice/cmn/helper.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ static char *gp_whitelist_paths[] = {
2929

3030
bool is_persist_partition_mounted(void)
3131
{
32+
bool ret = false;
3233
FILE *f;
3334
struct mntent *entry;
3435

@@ -39,14 +40,16 @@ bool is_persist_partition_mounted(void)
3940

4041
while ((entry = getmntent(f))) {
4142
if (strcmp(entry->mnt_dir, PERSIST_MOUNT_PATH) == 0) {
42-
return true;
43+
ret = true;
44+
goto exit;
4345
}
4446
}
45-
endmntent(f);
47+
MSGE("Persist partition not mounted!\n");
4648

4749
exit:
48-
MSGE("Persist partition not mounted!\n");
49-
return false;
50+
if (f)
51+
endmntent(f);
52+
return ret;
5053
}
5154

5255
int check_dir_path(const char *path)

qtee_supplicant/CMakeLists.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,17 @@ target_link_libraries(${PROJECT_NAME}
4646
)
4747

4848
install(TARGETS ${PROJECT_NAME} DESTINATION "${CMAKE_INSTALL_BINDIR}")
49+
if (DEFINED MINKIPC_LIBEXEC_DIR AND NOT "${MINKIPC_LIBEXEC_DIR}" STREQUAL "")
50+
configure_file(sfs_config.in sfs_config @ONLY)
51+
install(PROGRAMS "${CMAKE_CURRENT_BINARY_DIR}/sfs_config" DESTINATION "${MINKIPC_LIBEXEC_DIR}")
52+
endif()
4953
if (DEFINED SYSTEMD_UNIT_DIR AND NOT "${SYSTEMD_UNIT_DIR}" STREQUAL "")
5054
configure_file(qteesupplicant.service.in qteesupplicant.service @ONLY)
5155
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/qteesupplicant.service" DESTINATION "${SYSTEMD_UNIT_DIR}")
56+
configure_file(sfsconfig.service.in sfsconfig.service @ONLY)
57+
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/sfsconfig.service" DESTINATION "${SYSTEMD_UNIT_DIR}")
5258
endif()
53-
if (DEFINED SYSTEMD_UNIT_DIR AND NOT "${UDEV_DIR}" STREQUAL "")
59+
if (DEFINED UDEV_DIR AND NOT "${UDEV_DIR}" STREQUAL "")
5460
configure_file(qcomtee-udev.rules.in 99-qcomtee-udev.rules @ONLY)
5561
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/99-qcomtee-udev.rules" DESTINATION ${UDEV_DIR})
5662
endif()

qtee_supplicant/qteesupplicant.service.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
[Unit]
44
Description=QTEE Supplicant Service
55
BindsTo=dev-tee0.device
6-
After=dev-tee0.device
6+
After=dev-tee0.device sfsconfig.service
77

88
[Service]
99
Type=exec

qtee_supplicant/sfs_config.in

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/sh
2+
#==============================================================================
3+
# FILE: sfs_config
4+
#
5+
# DESCRIPTION:
6+
# create files and give permissions to the files and directories needed by
7+
# secure file system
8+
#
9+
# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
10+
# SPDX-License-Identifier: BSD-3-Clause-Clear
11+
#==============================================================================
12+
set -e
13+
14+
if [ -e /var/lib/tee ]; then
15+
if [ ! -d /var/lib/tee/qtee_supplicant ]; then
16+
echo "Creating /var/lib/tee/qtee_supplicant"
17+
mkdir -p /var/lib/tee/qtee_supplicant
18+
fi
19+
chmod o+rwx /var/lib/tee/qtee_supplicant
20+
fi
21+
22+
if [ ! -d /var/tmp/qtee_supplicant/vendor/tzstorage ]; then
23+
echo "Creating /var/tmp/qtee_supplicant/vendor/tzstorage"
24+
mkdir -p /var/tmp/qtee_supplicant/vendor/tzstorage
25+
fi
26+
chmod o+rwx /var/tmp/qtee_supplicant/vendor/tzstorage
27+
28+
exit 0
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
2+
# SPDX-License-Identifier: BSD-3-Clause-Clear
3+
[Unit]
4+
Description=SFS Configuration Service
5+
SourcePath=@MINKIPC_LIBEXEC_DIR@/sfs_config
6+
7+
[Service]
8+
Type=oneshot
9+
RemainAfterExit=yes
10+
ExecStart=@MINKIPC_LIBEXEC_DIR@/sfs_config
11+
12+
[Install]
13+
WantedBy=multi-user.target
14+

0 commit comments

Comments
 (0)