Minor fix in the compatibility library.
Signed-off-by: wangzhiqiang <wangzhiqiang95@huawei.com> (cherry picked from commit c5fa3c54ad925d72ccaa47c63e03f40bd711db56)
This commit is contained in:
parent
1798855b33
commit
4bd3e38227
60
Minor-fix-in-the-compatibility-library.patch
Normal file
60
Minor-fix-in-the-compatibility-library.patch
Normal file
@ -0,0 +1,60 @@
|
||||
From 3e63a788d4c7b5cb1173937118135c2bcca35a02 Mon Sep 17 00:00:00 2001
|
||||
From: Sergey Poznyakoff <gray@gnu.org>
|
||||
Date: Fri, 3 Mar 2023 13:52:56 +0200
|
||||
Subject: [PATCH] Minor fix in the compatibility library.
|
||||
|
||||
* compat/dbmopen.c (ndbm_open_dir_file0): Don't try to unlink
|
||||
the 1.8-compatible dir file or create a missing one if the database
|
||||
is being opened read-only.
|
||||
---
|
||||
compat/dbmopen.c | 26 +++++++++++++++++++++-----
|
||||
1 file changed, 21 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/compat/dbmopen.c b/compat/dbmopen.c
|
||||
index b11af98..cb979b5 100644
|
||||
--- a/compat/dbmopen.c
|
||||
+++ b/compat/dbmopen.c
|
||||
@@ -81,12 +81,21 @@ ndbm_open_dir_file0 (const char *file_name, int pagfd, int mode)
|
||||
{
|
||||
if (st.st_dev == pagst.st_dev && st.st_ino == pagst.st_ino)
|
||||
{
|
||||
- if (unlink (file_name))
|
||||
+ if (flags == O_RDONLY)
|
||||
{
|
||||
- if ((mode & GDBM_OPENMASK) == GDBM_READER)
|
||||
- /* Ok, try to cope with it. */
|
||||
- return pagfd;
|
||||
- else if (errno != ENOENT)
|
||||
+ /*
|
||||
+ * Don't touch the link if the database is opened read-only.
|
||||
+ * Return a meaningful file descriptor for the sake
|
||||
+ * of those programs that compare it with pagfd trying
|
||||
+ * to detect old GDBM versions (as Sendmail does).
|
||||
+ */
|
||||
+ if ((fd = open ("/dev/null", flags)) == -1)
|
||||
+ gdbm_set_errno (NULL, GDBM_FILE_OPEN_ERROR, TRUE);
|
||||
+ return fd;
|
||||
+ }
|
||||
+ else if (unlink (file_name))
|
||||
+ {
|
||||
+ if (errno != ENOENT)
|
||||
{
|
||||
gdbm_set_errno (NULL, GDBM_FILE_OPEN_ERROR, TRUE);
|
||||
return -1;
|
||||
@@ -138,6 +147,13 @@ ndbm_open_dir_file0 (const char *file_name, int pagfd, int mode)
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
+ else if (flags == O_RDONLY)
|
||||
+ {
|
||||
+ /* See the comment above. */
|
||||
+ if ((fd = open ("/dev/null", flags)) == -1)
|
||||
+ gdbm_set_errno (NULL, GDBM_FILE_OPEN_ERROR, TRUE);
|
||||
+ return fd;
|
||||
+ }
|
||||
|
||||
/* File does not exist. Create it. */
|
||||
fd = open (file_name, flags | O_CREAT, pagst.st_mode & 0777);
|
||||
--
|
||||
2.33.0
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
Name: gdbm
|
||||
Version: 1.18.1
|
||||
Release: 7
|
||||
Release: 8
|
||||
Epoch: 1
|
||||
Summary: A library of database functions that work similar to the standard UNIX dbm
|
||||
License: GPLv3+
|
||||
@ -13,6 +13,7 @@ Patch2: gdbm_dump-fix-command-line-error-detection.patch
|
||||
Patch3: 0002-Fix-location-tracking-in-gdbmtool.-Fix-the-recover-c.patch
|
||||
Patch4: 0003-Fix-semantics-of-gdbm_load-r.patch
|
||||
Patch5: 0004-Improve-handling-of-u-in-gdbm_load.patch
|
||||
Patch6: Minor-fix-in-the-compatibility-library.patch
|
||||
|
||||
BuildRequires: gcc libtool gettext readline-devel git bison flex texinfo
|
||||
|
||||
@ -104,6 +105,9 @@ fi
|
||||
%{_infodir}/*.info*
|
||||
|
||||
%changelog
|
||||
* Mon Mar 20 2023 wangzhiqiang <wangzhiqiang95@huawei.com> - 1:1.18.1-8
|
||||
- Minor fix in the compatibility library
|
||||
|
||||
* Tue Jul 5 2022 wangzhiqiang <wangzhiqiang95@huawei.com> - 1:1.18.1-7
|
||||
- fix semantics of gdbm_load -r. improve handling of -u in gdbm_load
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user