iSulad/0065-move-signal_routine-and-g_log_fd-to-common-and-and-s.patch
zhangxiaoyu 68738aa0f1 upgrade from upstream
Signed-off-by: zhangxiaoyu <zhangxiaoyu58@huawei.com>
2023-06-01 12:04:54 +08:00

94 lines
2.8 KiB
Diff

From bf0cdaea061f27938551a2f89ab89eda7afee853 Mon Sep 17 00:00:00 2001
From: zhongtao <zhongtao17@huawei.com>
Date: Sat, 13 May 2023 09:58:35 +0800
Subject: [PATCH 65/79] move signal_routine and g_log_fd to common and and some
incoming parameter verification
Signed-off-by: zhongtao <zhongtao17@huawei.com>
---
src/cmd/isulad-shim/common.c | 13 +++++++++++++
src/cmd/isulad-shim/common.h | 1 +
src/cmd/isulad-shim/main.c | 13 +------------
src/daemon/modules/runtime/isula/isula_rt_ops.c | 5 +++++
4 files changed, 20 insertions(+), 12 deletions(-)
diff --git a/src/cmd/isulad-shim/common.c b/src/cmd/isulad-shim/common.c
index 18443385..3787cdfb 100644
--- a/src/cmd/isulad-shim/common.c
+++ b/src/cmd/isulad-shim/common.c
@@ -29,6 +29,19 @@
#include <limits.h>
#include <time.h>
+int g_log_fd = -1;
+
+void signal_routine(int sig)
+{
+ switch (sig) {
+ case SIGALRM:
+ write_message(g_log_fd, ERR_MSG, "runtime timeout");
+ exit(EXIT_FAILURE);
+ default:
+ break;
+ }
+}
+
int set_fd_no_inherited(int fd)
{
int ret = SHIM_ERR;
diff --git a/src/cmd/isulad-shim/common.h b/src/cmd/isulad-shim/common.h
index b3f52dc3..8cef5de2 100644
--- a/src/cmd/isulad-shim/common.h
+++ b/src/cmd/isulad-shim/common.h
@@ -58,6 +58,7 @@ extern "C" {
#define CONTAINER_ACTION_REBOOT 129
#define CONTAINER_ACTION_SHUTDOWN 130
+void signal_routine(int sig);
void util_usleep_nointerupt(unsigned long usec);
/**
diff --git a/src/cmd/isulad-shim/main.c b/src/cmd/isulad-shim/main.c
index 0cccdf06..ed55805c 100644
--- a/src/cmd/isulad-shim/main.c
+++ b/src/cmd/isulad-shim/main.c
@@ -26,18 +26,7 @@
#include "common.h"
#include "process.h"
-int g_log_fd = -1;
-
-void signal_routine(int sig)
-{
- switch (sig) {
- case SIGALRM:
- write_message(g_log_fd, ERR_MSG, "runtime timeout");
- exit(EXIT_FAILURE);
- default:
- break;
- }
-}
+extern int g_log_fd;
static void set_timeout_exit(unsigned int timeout)
{
diff --git a/src/daemon/modules/runtime/isula/isula_rt_ops.c b/src/daemon/modules/runtime/isula/isula_rt_ops.c
index 85a2fbc8..510bb17f 100644
--- a/src/daemon/modules/runtime/isula/isula_rt_ops.c
+++ b/src/daemon/modules/runtime/isula/isula_rt_ops.c
@@ -1572,6 +1572,11 @@ out:
int rt_isula_kill(const char *id, const char *runtime, const rt_kill_params_t *params)
{
+ if (id == NULL || runtime == NULL || params == NULL || params->pid < 0) {
+ ERROR("Invalid arguments not allowed");
+ return -1;
+ }
+
if (util_process_alive(params->pid, params->start_time) == false) {
if (params->signal == params->stop_signal || params->signal == SIGKILL) {
WARN("Process %d is not alive", params->pid);
--
2.25.1