Compare commits

...

11 Commits

Author SHA1 Message Date
openeuler-ci-bot
7315e0c5fa
!28 [sync] PR-23: hdparm: rename patches and fix one fd leak in sysfs_write_attr()
From: @openeuler-sync-bot 
Reviewed-by: @liuzhiqiang26 
Signed-off-by: @liuzhiqiang26
2022-03-01 12:49:16 +00:00
Zhiqiang Liu
97f1f71440 hdparm: rename patches and fix one fd leak in sysfs_write_attr()
rename patches and fix one fd leak in sysfs_write_attr().

Fix issue: https://gitee.com/src-openeuler/hdparm/issues/I4S2C0

Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
(cherry picked from commit 8f2ce8643ae9257830d4e27cedd46bca27aafd50)
2022-03-01 19:20:54 +08:00
openeuler-ci-bot
d8d728df27
!21 [sync] PR-16: 修复hdparm打印密码的问题
Merge pull request !21 from openeuler-sync-bot/sync-pr16-openEuler-20.03-LTS-to-openEuler-20.03-LTS-SP3
2022-01-24 02:23:45 +00:00
volcanodragon
e6eac7c4d7 fix patch error
(cherry picked from commit 7cd3b31c4ba87f4392cd21b413738d3f43271064)
2022-01-22 16:19:56 +08:00
linfeilong835
c4fe7ec414 update 9001-hdparam-Remove-security_password-printing.patch.
(cherry picked from commit ce90f6638cc9a39cdb48496757b8247050790b50)
2022-01-22 16:19:56 +08:00
linfeilong835
5080b949db update hdparm.spec.
(cherry picked from commit ad12631fbfdf326846731a544f04582658354889)
2022-01-22 16:19:56 +08:00
linfeilong835
4bba0fe3f2 add 9001-hdparam-Remove-security_password-printing.patch.
(cherry picked from commit 810634c7faea0c8aaa23ba784cbf563d8a26a145)
2022-01-22 16:19:56 +08:00
openeuler-ci-bot
d59bcf5328 !3 update hdparm to 9.58
Merge pull request !3 from lfl/master
2020-05-13 10:56:19 +08:00
wubo009
d0a51f2f87 update pkg in lts branch 2020-05-12 23:00:13 +08:00
openeuler-ci-bot
fb51eb91f2 !2 update package
Merge pull request !2 from geruijun/local
2020-01-08 17:07:44 +08:00
eulerstorage
4bde3b3dba update package 2020-01-07 12:01:28 +08:00
9 changed files with 127 additions and 78 deletions

View File

@ -1,47 +0,0 @@
Index: hdparm-9.43/sgio.c
===================================================================
--- hdparm-9.43.orig/sgio.c
+++ hdparm-9.43/sgio.c
@@ -17,6 +17,10 @@
#include <linux/hdreg.h>
+#ifndef DEMAND_SENSE_DATA
+ #define DEMAND_SENSE_DATA 0
+#endif
+
extern int verbose;
extern int prefer_ata12;
@@ -193,7 +197,7 @@ int sg16 (int fd, int rw, int dma, struc
unsigned char cdb[SG_ATA_16_LEN];
unsigned char sb[32], *desc;
struct scsi_sg_io_hdr io_hdr;
- int prefer12 = prefer_ata12, demanded_sense = 0;
+ int prefer12 = prefer_ata12;
if (tf->command == ATA_OP_PIDENTIFY)
prefer12 = 0;
@@ -302,14 +306,16 @@ int sg16 (int fd, int rw, int dma, struc
desc = sb + 8;
if (io_hdr.driver_status != SG_DRIVER_SENSE) {
- if (sb[0] | sb[1] | sb[2] | sb[3] | sb[4] | sb[5] | sb[6] | sb[7] | sb[8] | sb[9]) {
- static int second_try = 0;
- if (!second_try++)
+ static int second_try = 0;
+ if (!second_try++) {
+ if (sb[0] | sb[1] | sb[2] | sb[3] | sb[4] | sb[5] | sb[6] | sb[7] | sb[8] | sb[9]) {
fprintf(stderr, "SG_IO: questionable sense data, results may be incorrect\n");
- } else if (demanded_sense) {
- static int second_try = 0;
- if (!second_try++)
+ }
+#if DEMAND_SENSE_DATA
+ else {
fprintf(stderr, "SG_IO: missing sense data, results may be incorrect\n");
+ }
+#endif
}
} else if (sb[0] != 0x72 || sb[7] < 14 || desc[0] != 0x09 || desc[1] < 0x0c) {
dump_bytes("SG_IO: bad/missing sense data, sb[]", sb, sizeof(sb));

View File

@ -1,12 +0,0 @@
Index: hdparm-9.43/fallocate.c
===================================================================
--- hdparm-9.43.orig/fallocate.c
+++ hdparm-9.43/fallocate.c
@@ -41,6 +41,7 @@ int do_fallocate_syscall (const char *pa
exit(0);
}
err = errno;
+ close(fd);
unlink(path);
}
perror(path);

View File

@ -0,0 +1,16 @@
diff --git a/fallocate.c b/fallocate.c
index 4e60459..d73c0f9 100644
--- a/fallocate.c
+++ b/fallocate.c
@@ -39,9 +39,11 @@ int do_fallocate_syscall (const char *path, __u64 bytecount)
err = syscall(SYS_fallocate, fd, mode, offset, len);
if (err >= 0) {
fsync(fd);
+ close(fd);
exit(0);
}
err = errno;
+ close(fd);
unlink(path);
}
perror(path);

View File

@ -0,0 +1,51 @@
From deaa52e44c5464a8360e540d7b35895bc51e5143 Mon Sep 17 00:00:00 2001
From: Wenchao Hao <haowenchao@huawei.com>
Date: Mon, 30 Nov 2020 17:29:55 +0800
Subject: [PATCH] hdparam: Remove security_password printing
In consideration of security, passwd should not printed
in log, so this commit remove security_password printing
in code.
Signed-off-by: Wenchao Hao <haowenchao@huawei.com>
Signed-off-by: volcanodragon <linfeilong@huawei.com>
---
hdparm.c | 15 ++-------------
1 file changed, 2 insertions(+), 13 deletions(-)
diff --git a/hdparm.c b/hdparm.c
index 8045c87..3282d93 100644
--- a/hdparm.c
+++ b/hdparm.c
@@ -989,8 +989,8 @@ do_set_security (int fd)
exit(EINVAL);
}
if (!quiet) {
- printf(" Issuing %s command, password=\"%s\", user=%s",
- description, security_password, (data[0] & 1) ? "master" : "user");
+ printf(" Issuing %s command, user=%s",
+ description, (data[0] & 1) ? "master" : "user");
if (security_command == ATA_OP_SECURITY_SET_PASS)
printf(", mode=%s", data[1] ? "max" : "high");
printf("\n");
@@ -3004,17 +3004,6 @@ static void get_security_password (int handle_NULL)
} else if (!handle_NULL || strcmp(argp, "NULL")) {
strcpy(security_password, argp);
}
- printf("security_password:");
- if (!binary_passwd) {
- printf(" \"%s\"\n", security_password);
- } else {
- unsigned int i;
- for (i = 0; i < maxlen; ++i) {
- unsigned char c = security_password[i];
- printf(" %02x", c);
- }
- putchar('\n');
- }
while (*argp)
++argp;
}
--
1.8.3.1

View File

@ -1,13 +0,0 @@
Index: hdparm-9.43/geom.c
===================================================================
--- hdparm-9.43.orig/geom.c
+++ hdparm-9.43/geom.c
@@ -201,7 +201,7 @@ int get_dev_geometry (int fd, __u32 *cyl
__u64 hs = (*heads) * (*sects);
__u64 cyl = (*cyls);
__u64 chs = cyl * hs;
- if (chs < (*nsectors))
+ if (chs < (*nsectors) && hs)
*cyls = (*nsectors) / hs;
}
}

View File

@ -0,0 +1,33 @@
From ac3b725928b6b6c4a1188670a67ed5432744de26 Mon Sep 17 00:00:00 2001
From: Zhiqiang Liu <liuzhiqiang26@huawei.com>
Date: Tue, 1 Mar 2022 15:47:02 +0800
Subject: [PATCH] hdparm: fix fd leak in sysfs_write_attr()
In sysfs_write_attr(), if "fmt[0] != %", will return without
close fp.
Fix issue: https://gitee.com/src-openeuler/hdparm/issues/I4S2C0
Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
---
sysfs.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/sysfs.c b/sysfs.c
index 60b8146..722b2a9 100644
--- a/sysfs.c
+++ b/sysfs.c
@@ -60,8 +60,9 @@ static int sysfs_write_attr (char *path, const char *attr, const char *fmt, void
}
if (count < 0)
err = errno;
- fclose(fp);
}
+ if (!fp)
+ fclose(fp);
if (err && verbose) perror(path);
*pathtail = '\0';
return err;
--
1.8.3.1

Binary file not shown.

BIN
hdparm-9.58.tar.gz Normal file

Binary file not shown.

View File

@ -1,13 +1,13 @@
Name: hdparm
Version: 9.56
Version: 9.58
Release: 3
Summary: A system utility for setting or showing hard drive parameters
License: BSD
URL: https://sourceforge.net/projects/%{name}/
Source: https://downloads.sourceforge.net/%{name}/%{name}-%{version}.tar.gz
Patch0000: 0000-hdparm-9.43-ditch_dead_code.patch
Patch0001: 0001-hdparm-9.43-close_fd.patch
Patch0002: 0002-hdparm-9.43-get_geom.patch
Source0: https://downloads.sourceforge.net/%{name}/%{name}-%{version}.tar.gz
Patch1: 0001-hdparm-fallocate-close-fd.patch
Patch2: 0002-hdparam-Remove-security_password-printing.patch
Patch3: 0003-hdparm-fix-fd-leak-in-sysfs_write_attr.patch
BuildRequires: gcc git
@ -44,11 +44,32 @@ install -c -m 644 hdparm.8 $RPM_BUILD_ROOT/%{_mandir}/man8
%{_mandir}/man8/hdparm.8*
%changelog
* Tue Mar 01 2022 Zhiqiang Liu <liuzhiqiang26@huawei.com> - 9.58-3
- rename patches and fix one fd leak in sysfs_write_attr()
* Sat Jan 22 2022 linfeilong<linfeilong@huawei.com> - 9.58-2
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:delete password print for security
* Tue Apr 14 2020 linfeilong<linfeilong@huawei.com> - 9.58-1
- Type:enhancement
- ID:NA
- SUG:NA
- DESC:Update package to 9.58
* Tue Jan 7 2020 openEuler Buildteam <buildteam@openeuler.org> - 9.56-4
- Type:enhancement
- ID:NA
- SUG:NA
- DESC:Update package
* Fri Aug 30 2019 louhongxiang <louhongxiang@huawei.com> - 9.56-3
- Type:enhancemnet
- ID:NA
- SUG:NA
- DESCi:openEuler Debranding
- DESC:openEuler Debranding
* Wed Aug 21 2019 wubo <wubo40@huawei.com> - 9.56-2
- Package init and change patch name