From d73d68edf520d765d90a27c2e749cf87eae962f1 Mon Sep 17 00:00:00 2001
From: Marta Rybczynska <marta.rybczynska@huawei.com>
Date: Tue, 20 Jul 2021 11:41:09 +0200
Subject: [PATCH] base-files: add shell timeout

It is a good practice to timeout the shell if no activity. Add a timeout
to the /etc/profile* settings in a separate script.

Signed-off-by: Marta Rybczynska <marta.rybczynska@huawei.com>
---
 .../recipes-core/base-files/base-files/profile.d/tmout.sh    | 5 +++++
 .../recipes-core/base-files/base-files_%.bbappend            | 5 +++++
 2 files changed, 10 insertions(+)
 create mode 100644 meta-ohos-staging/recipes-core/base-files/base-files/profile.d/tmout.sh

diff --git a/meta-ohos-staging/recipes-core/base-files/base-files/profile.d/tmout.sh b/meta-ohos-staging/recipes-core/base-files/base-files/profile.d/tmout.sh
new file mode 100644
index 00000000..7dfa4b34
--- /dev/null
+++ b/meta-ohos-staging/recipes-core/base-files/base-files/profile.d/tmout.sh
@@ -0,0 +1,5 @@
+# Shell timeout definition
+
+TMOUT=600
+readonly TMOUT
+export TMOUT
diff --git a/meta-ohos-staging/recipes-core/base-files/base-files_%.bbappend b/meta-ohos-staging/recipes-core/base-files/base-files_%.bbappend
index df1554ff..f3342bf2 100644
--- a/meta-ohos-staging/recipes-core/base-files/base-files_%.bbappend
+++ b/meta-ohos-staging/recipes-core/base-files/base-files_%.bbappend
@@ -1,4 +1,9 @@
+FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
+
+SRC_URI_append = "file://profile.d/tmout.sh"
 
 do_install_append () {
     sed -i 's/umask.*/umask 027/g' ${D}/${sysconfdir}/profile
+    install -d ${WORKDIR}/profile.d/ ${D}${sysconfdir}/profile.d/
+    install -m 0644 ${WORKDIR}/profile.d/tmout.sh ${D}${sysconfdir}/profile.d/tmout.sh
 }
-- 
GitLab