!5 pid校验,防止误判

Merge pull request !5 from njzlisme/master
This commit is contained in:
openeuler-ci-bot 2020-03-04 15:14:05 +08:00 committed by Gitee
commit b39a9196d2
2 changed files with 61 additions and 1 deletions

View File

@ -0,0 +1,45 @@
From bab9f6ff2345fb5a1db048349fe088c1ee7d440b Mon Sep 17 00:00:00 2001
From: Anonymous_Z <zhangrui182@huawei.com>
Date: Tue, 3 Mar 2020 17:36:41 +0800
Subject: [PATCH] dhcp: recheck whether last pid was held by other process
Signed-off-by: zhanglu <zhanglu37@huawei.com>
---
client/dhclient.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/client/dhclient.c b/client/dhclient.c
index 9f8ba06..97b04e0 100644
--- a/client/dhclient.c
+++ b/client/dhclient.c
@@ -774,15 +774,26 @@ main(int argc, char **argv) {
}
} else {
FILE *pidfp = NULL;
+ FILE *commfp = NULL;
long temp = 0;
pid_t dhcpid = 0;
int dhc_running = 0;
char procfn[256] = "";
+ char pidname_path[256] = "";
+ char pidname[256] = "";
if ((pidfp = fopen(path_dhclient_pid, "re")) != NULL) {
if ((fscanf(pidfp, "%ld", &temp)==1) && ((dhcpid=(pid_t)temp) > 0)) {
snprintf(procfn,256,"/proc/%u",dhcpid);
- dhc_running = (access(procfn, F_OK) == 0);
+ snprintf(pidname_path,256,"%s/comm",procfn);
+
+ if(access(procfn, F_OK) == 0) {
+ if((commfp = fopen(pidname_path, "r")) != NULL) {
+ fscanf(commfp, "%s", pidname);
+ dhc_running = (strncmp("dhclient", pidname, strlen("dhclient")) == 0);
+ fclose(commfp);
+ }
+ }
}
fclose(pidfp);
--
1.8.3.1

View File

@ -3,7 +3,7 @@
Name: dhcp Name: dhcp
Version: 4.3.6 Version: 4.3.6
Release: 35 Release: 37
Summary: Dynamic host configuration protocol software Summary: Dynamic host configuration protocol software
#Please don't change the epoch on this package #Please don't change the epoch on this package
Epoch: 12 Epoch: 12
@ -69,6 +69,8 @@ Patch9000: dhcp-fix-dhclient-default-len-64-to-128.patch
Patch9001: bugfix-dhcpd-2038-problem.patch Patch9001: bugfix-dhcpd-2038-problem.patch
Patch9002: adds-address-prefix-len-to-dhclient-cli.patch Patch9002: adds-address-prefix-len-to-dhclient-cli.patch
Patch9003: dhcpd-coredump-infiniband.patch Patch9003: dhcpd-coredump-infiniband.patch
Patch9004: bugfix-dhclient-check-if-pid-was-held.patch
BuildRequires: gcc autoconf automake libtool openldap-devel krb5-devel libcap-ng-devel bind-export-devel BuildRequires: gcc autoconf automake libtool openldap-devel krb5-devel libcap-ng-devel bind-export-devel
BuildRequires: systemd systemd-devel BuildRequires: systemd systemd-devel
@ -204,6 +206,7 @@ install -D -p -m 0644 contrib/ldap/dhcp.schema $RPM_BUILD_ROOT%{_sysconfdir}/ope
find $RPM_BUILD_ROOT -type f -name "*.la" -delete -print find $RPM_BUILD_ROOT -type f -name "*.la" -delete -print
%check %check
make check
%pre %pre
%global gid_uid 177 %global gid_uid 177
@ -305,6 +308,18 @@ exit 0
%{_mandir}/man3/omapi.3.gz %{_mandir}/man3/omapi.3.gz
%changelog %changelog
* Tue Mar 3 2020 zhanglu<zhanglu37@huawei.com> - 4.3.6-37
- Type:bugfix
- ID:NA
- SUG:restart
- DESC: recheck if last pid was held by other process
* Fri Feb 21 2020 zhanglu<zhanglu37@huawei.com> - 4.3.6-36
- Type:enhancement
- ID:NA
- SUG:NA
- DESC: add make check
* Wed Jan 22 2020 zhanglu<zhanglu37@huawei.com> - 4.3.6-35 * Wed Jan 22 2020 zhanglu<zhanglu37@huawei.com> - 4.3.6-35
- Type:bugfix - Type:bugfix
- ID:NA - ID:NA