Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
60ed1d2a
L
libvirt
项目概览
openeuler
/
libvirt
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
L
libvirt
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
60ed1d2a
编写于
8月 20, 2008
作者:
D
Daniel P. Berrange
1
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Avoid signal race in virExec
上级
f2172946
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
67 addition
and
1 deletion
+67
-1
ChangeLog
ChangeLog
+9
-0
qemud/remote_protocol.c
qemud/remote_protocol.c
+1
-0
qemud/remote_protocol.h
qemud/remote_protocol.h
+1
-0
qemud/remote_protocol.x
qemud/remote_protocol.x
+1
-0
src/internal.h
src/internal.h
+1
-0
src/util.c
src/util.c
+54
-1
未找到文件。
ChangeLog
浏览文件 @
60ed1d2a
Wed Aug 20 09:35:33 BST 2008 Daniel P. Berrange <berrange@redhat.com>
Avoid signal race in virExec()
* src/util.c: Block signals when forking and clear child's
signal handlers.
* src/remote_protocol.{c,h,x}: Add config.h include file
* src/internal.h: define pthread_sigmask interms of sigprocmask
for non-pthreads systems
Wed Aug 20 09:28:33 BST 2008 Daniel P. Berrange <berrange@redhat.com>
* src/util.c: Re-arrange virExec() to improve error reporting
...
...
qemud/remote_protocol.c
浏览文件 @
60ed1d2a
...
...
@@ -4,6 +4,7 @@
*/
#include "remote_protocol.h"
#include <config.h>
#include "internal.h"
bool_t
...
...
qemud/remote_protocol.h
浏览文件 @
60ed1d2a
...
...
@@ -13,6 +13,7 @@
extern
"C"
{
#endif
#include <config.h>
#include "internal.h"
#define REMOTE_MESSAGE_MAX 262144
#define REMOTE_STRING_MAX 65536
...
...
qemud/remote_protocol.x
浏览文件 @
60ed1d2a
...
...
@@ -36,6 +36,7 @@
* 'REMOTE_'. This makes names quite long.
*/
%
#
include
<
config
.
h
>
%
#
include
"internal.h"
/*----- Data types. -----*/
...
...
src/internal.h
浏览文件 @
60ed1d2a
...
...
@@ -22,6 +22,7 @@
#define pthread_mutex_destroy(lk)
/*empty*/
#define pthread_mutex_lock(lk)
/*empty*/
#define pthread_mutex_unlock(lk)
/*empty*/
#define pthread_sigmask(h, s, o) sigprocmask((h), (s), (o))
#endif
/* The library itself is allowed to use deprecated functions /
...
...
src/util.c
浏览文件 @
60ed1d2a
...
...
@@ -37,6 +37,7 @@
#include <sys/wait.h>
#endif
#include <string.h>
#include <signal.h>
#if HAVE_TERMIOS_H
#include <termios.h>
#endif
...
...
@@ -53,6 +54,10 @@
#include "memory.h"
#include "util-lib.c"
#ifndef NSIG
# define NSIG 32
#endif
#ifndef MIN
# define MIN(a, b) ((a) < (b) ? (a) : (b))
#endif
...
...
@@ -110,9 +115,23 @@ static int
_virExec
(
virConnectPtr
conn
,
const
char
*
const
*
argv
,
int
*
retpid
,
int
infd
,
int
*
outfd
,
int
*
errfd
,
int
non_block
)
{
int
pid
,
null
;
int
pid
,
null
,
i
;
int
pipeout
[
2
]
=
{
-
1
,
-
1
};
int
pipeerr
[
2
]
=
{
-
1
,
-
1
};
sigset_t
oldmask
,
newmask
;
struct
sigaction
sig_action
;
/*
* Need to block signals now, so that child process can safely
* kill off caller's signal handlers without a race.
*/
sigfillset
(
&
newmask
);
if
(
pthread_sigmask
(
SIG_SETMASK
,
&
newmask
,
&
oldmask
)
!=
0
)
{
ReportError
(
conn
,
VIR_ERR_INTERNAL_ERROR
,
_
(
"cannot block signals: %s"
),
strerror
(
errno
));
return
-
1
;
}
if
((
null
=
open
(
_PATH_DEVNULL
,
O_RDONLY
))
<
0
)
{
ReportError
(
conn
,
VIR_ERR_INTERNAL_ERROR
,
...
...
@@ -172,6 +191,16 @@ _virExec(virConnectPtr conn,
close
(
pipeerr
[
1
]);
*
errfd
=
pipeerr
[
0
];
}
/* Restore our original signal mask now child is safely
running */
if
(
pthread_sigmask
(
SIG_SETMASK
,
&
oldmask
,
NULL
)
!=
0
)
{
ReportError
(
conn
,
VIR_ERR_INTERNAL_ERROR
,
_
(
"cannot unblock signals: %s"
),
strerror
(
errno
));
return
-
1
;
}
*
retpid
=
pid
;
return
0
;
}
...
...
@@ -186,6 +215,30 @@ _virExec(virConnectPtr conn,
of being seen / logged */
virSetErrorFunc
(
NULL
,
NULL
);
/* Clear out all signal handlers from parent so nothing
unexpected can happen in our child once we unblock
signals */
sig_action
.
sa_handler
=
SIG_DFL
;
sig_action
.
sa_flags
=
0
;
sigemptyset
(
&
sig_action
.
sa_mask
);
for
(
i
=
1
;
i
<
NSIG
;
i
++
)
/* Only possible errors are EFAULT or EINVAL
The former wont happen, the latter we
expect, so no need to check return value */
sigaction
(
i
,
&
sig_action
,
NULL
);
/* Unmask all signals in child, since we've no idea
what the caller's done with their signal mask
and don't want to propagate that to children */
sigemptyset
(
&
newmask
);
if
(
pthread_sigmask
(
SIG_SETMASK
,
&
newmask
,
NULL
)
!=
0
)
{
ReportError
(
conn
,
VIR_ERR_INTERNAL_ERROR
,
_
(
"cannot unblock signals: %s"
),
strerror
(
errno
));
return
-
1
;
}
if
(
pipeout
[
0
]
>
0
)
close
(
pipeout
[
0
]);
if
(
pipeerr
[
0
]
>
0
)
...
...
tester丶
🤺
@ssszwink
mentioned in commit
0e4efa3d
·
9月 10, 2020
mentioned in commit
0e4efa3d
mentioned in commit 0e4efa3d53ffc9a02ce1dd73f7b240acfc9679e0
开关提交列表
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录