[Why] 'load custom dnsmasq.conf' step will cp custom config to WORKSPACE, but when a user without permission execute this step, cp will failed.
So add 'set -e' at the beginning of the script to solve this problem.
Signed-off-by: Yu Chuan 13186087857@163.com --- container/dnsmasq/start | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/container/dnsmasq/start b/container/dnsmasq/start index ff4247046eb1..b2eefbd89c16 100755 --- a/container/dnsmasq/start +++ b/container/dnsmasq/start @@ -2,6 +2,8 @@ # SPDX-License-Identifier: MulanPSL-2.0+ # Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved.
+set -e + . $CCI_SRC/container/defconfig.sh
docker_rm dnsmasq
On Tue, Nov 03, 2020 at 04:47:23PM +0800, Yu Chuan wrote:
[Why] 'load custom dnsmasq.conf' step will cp custom config to WORKSPACE, but when a user without permission execute this step, cp will failed.
So add 'set -e' at the beginning of the script to solve this problem.
Add 'set -d' can solve without permission? You should make the changlog more clear.
Thanks, Xueliang
Signed-off-by: Yu Chuan 13186087857@163.com
container/dnsmasq/start | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/container/dnsmasq/start b/container/dnsmasq/start index ff4247046eb1..b2eefbd89c16 100755 --- a/container/dnsmasq/start +++ b/container/dnsmasq/start @@ -2,6 +2,8 @@ # SPDX-License-Identifier: MulanPSL-2.0+ # Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved.
+set -e
. $CCI_SRC/container/defconfig.sh
docker_rm dnsmasq
2.23.0
On Tue, Nov 03, 2020 at 06:32:43PM +0800, Cao Xueliang wrote:
On Tue, Nov 03, 2020 at 04:47:23PM +0800, Yu Chuan wrote:
[Why] 'load custom dnsmasq.conf' step will cp custom config to WORKSPACE, but when a user without permission execute this step, cp will failed.
So add 'set -e' at the beginning of the script to solve this problem.
Add 'set -d' can solve without permission?
^e
You should make the changlog more clear.
Thanks, Xueliang
Signed-off-by: Yu Chuan 13186087857@163.com
container/dnsmasq/start | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/container/dnsmasq/start b/container/dnsmasq/start index ff4247046eb1..b2eefbd89c16 100755 --- a/container/dnsmasq/start +++ b/container/dnsmasq/start @@ -2,6 +2,8 @@ # SPDX-License-Identifier: MulanPSL-2.0+ # Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved.
+set -e
. $CCI_SRC/container/defconfig.sh
docker_rm dnsmasq
2.23.0
On Tue, Nov 03, 2020 at 06:33:28PM +0800, Cao Xueliang wrote:
On Tue, Nov 03, 2020 at 06:32:43PM +0800, Cao Xueliang wrote:
On Tue, Nov 03, 2020 at 04:47:23PM +0800, Yu Chuan wrote:
[Why] 'load custom dnsmasq.conf' step will cp custom config to WORKSPACE, but when a user without permission execute this step, cp will failed.
So add 'set -e' at the beginning of the script to solve this problem.
Add 'set -d' can solve without permission?
^e
About 'set -e': Exit immediately if a simple cmd exits with a non-zero status.
About cp failed: yuchuan@crystal ~/tmp% ls -hl total 0 -rw-rw-r-- 1 yuchuan yuchuan 0 Nov 4 08:56 1.txt drwxrwxr-x 2 root root 6 Nov 4 08:56 root-only yuchuan@crystal ~/tmp% cp 1.txt root-only cp: cannot create regular file 'root-only/1.txt': Permission denied yuchuan@crystal ~/tmp% echo $? 1 yuchuan@crystal ~/tmp% cp 1.txt 2.txt yuchuan@crystal ~/tmp% echo $? 0
And I have tested this script, when this script was executed by user whom without permission, this script will exit immediately, and the remaining code won't be executed.
-------- Thanks Yu Chuan
You should make the changlog more clear.
Thanks, Xueliang
Signed-off-by: Yu Chuan 13186087857@163.com
container/dnsmasq/start | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/container/dnsmasq/start b/container/dnsmasq/start index ff4247046eb1..b2eefbd89c16 100755 --- a/container/dnsmasq/start +++ b/container/dnsmasq/start @@ -2,6 +2,8 @@ # SPDX-License-Identifier: MulanPSL-2.0+ # Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved.
+set -e
. $CCI_SRC/container/defconfig.sh
docker_rm dnsmasq
2.23.0
What if other commands like "kill" failed?
Thanks, Fengguang
On Tue, Nov 03, 2020 at 04:47:23PM +0800, Yu Chuan wrote:
[Why] 'load custom dnsmasq.conf' step will cp custom config to WORKSPACE, but when a user without permission execute this step, cp will failed.
So add 'set -e' at the beginning of the script to solve this problem.
Signed-off-by: Yu Chuan 13186087857@163.com
container/dnsmasq/start | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/container/dnsmasq/start b/container/dnsmasq/start index ff4247046eb1..b2eefbd89c16 100755 --- a/container/dnsmasq/start +++ b/container/dnsmasq/start @@ -2,6 +2,8 @@ # SPDX-License-Identifier: MulanPSL-2.0+ # Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved.
+set -e
. $CCI_SRC/container/defconfig.sh
docker_rm dnsmasq
2.23.0
On Tue, Nov 03, 2020 at 07:02:34PM +0800, Wu Fengguang wrote:
What if other commands like "kill" failed?
Ok, I'll consider the error situation of other code lines.
-------- Thanks Yu Chuan
Thanks, Fengguang
On Tue, Nov 03, 2020 at 04:47:23PM +0800, Yu Chuan wrote:
[Why] 'load custom dnsmasq.conf' step will cp custom config to WORKSPACE, but when a user without permission execute this step, cp will failed.
So add 'set -e' at the beginning of the script to solve this problem.
Signed-off-by: Yu Chuan 13186087857@163.com
container/dnsmasq/start | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/container/dnsmasq/start b/container/dnsmasq/start index ff4247046eb1..b2eefbd89c16 100755 --- a/container/dnsmasq/start +++ b/container/dnsmasq/start @@ -2,6 +2,8 @@ # SPDX-License-Identifier: MulanPSL-2.0+ # Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved.
+set -e
. $CCI_SRC/container/defconfig.sh
docker_rm dnsmasq
2.23.0