!57 Improve handling of -u in gdbm_load
From: @foolstrong Reviewed-by: @liuzhiqiang26 Signed-off-by: @liuzhiqiang26
This commit is contained in:
commit
89ce394262
78
Improve-handling-of-u-in-gdbm_load.patch
Normal file
78
Improve-handling-of-u-in-gdbm_load.patch
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
From 4cfdc68fd862a4e80f42f14aa92cb25db08b2466 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Sergey Poznyakoff <gray@gnu.org>
|
||||||
|
Date: Sat, 2 Jul 2022 19:29:47 +0300
|
||||||
|
Subject: [PATCH] Improve handling of -u in gdbm_load
|
||||||
|
|
||||||
|
* src/gdbm_load.c (main): Imply the owner login group if owner name
|
||||||
|
is followed by a :, and the current login group otherwise.
|
||||||
|
* doc/gdbm.texi: Document changes.
|
||||||
|
---
|
||||||
|
doc/gdbm.texi | 13 ++++++++-----
|
||||||
|
src/gdbm_load.c | 9 +++++++--
|
||||||
|
2 files changed, 15 insertions(+), 7 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/doc/gdbm.texi b/doc/gdbm.texi
|
||||||
|
index 4fa841f..037ae07 100644
|
||||||
|
--- a/doc/gdbm.texi
|
||||||
|
+++ b/doc/gdbm.texi
|
||||||
|
@@ -4119,13 +4119,16 @@ dump file will be added to that database, without removing the
|
||||||
|
existing keys. To overwrite the existing keys from the dump file, use
|
||||||
|
@option{--update --replace}.
|
||||||
|
|
||||||
|
-@item -u @var{user}[:@var{group}]
|
||||||
|
-@itemx --user=@var{user}[:@var{group}]
|
||||||
|
-Set file owner. The @var{user} can be either a valid user name or
|
||||||
|
+@item -u @var{owner}[:[@var{group}]]
|
||||||
|
+@itemx --user=@var{owner}[:[@var{group}]]
|
||||||
|
+Set file owner. The @var{owner} can be either a valid user name or
|
||||||
|
UID. Similarly, the @var{group} is either a valid group name or GID.
|
||||||
|
-If @var{group} is not given, the main group of @var{user} is used.
|
||||||
|
+If @var{group} is not given, the main group of @var{owner} is implied, if
|
||||||
|
+@var{owner} is followed by a @samp{:}, otherwise the login group of the
|
||||||
|
+current user is implied.
|
||||||
|
|
||||||
|
-User and group parts can be separated by a dot, instead of the colon.
|
||||||
|
+User and group parts can be separated by a dot, instead of the colon,
|
||||||
|
+but such usage is discouraged.
|
||||||
|
|
||||||
|
@item -h
|
||||||
|
@itemx --help
|
||||||
|
diff --git a/src/gdbm_load.c b/src/gdbm_load.c
|
||||||
|
index 5d5e50e..e7e2ab1 100644
|
||||||
|
--- a/src/gdbm_load.c
|
||||||
|
+++ b/src/gdbm_load.c
|
||||||
|
@@ -148,9 +148,10 @@ main (int argc, char **argv)
|
||||||
|
{
|
||||||
|
size_t len;
|
||||||
|
struct passwd *pw;
|
||||||
|
+ int delim;
|
||||||
|
|
||||||
|
len = strcspn (optarg, ".:");
|
||||||
|
- if (optarg[len])
|
||||||
|
+ if ((delim = optarg[len]) != 0)
|
||||||
|
optarg[len++] = 0;
|
||||||
|
pw = getpwnam (optarg);
|
||||||
|
if (pw)
|
||||||
|
@@ -187,7 +188,7 @@ main (int argc, char **argv)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
- else
|
||||||
|
+ else if (delim)
|
||||||
|
{
|
||||||
|
if (!pw)
|
||||||
|
{
|
||||||
|
@@ -200,6 +201,10 @@ main (int argc, char **argv)
|
||||||
|
}
|
||||||
|
owner_gid = pw->pw_gid;
|
||||||
|
}
|
||||||
|
+ else
|
||||||
|
+ {
|
||||||
|
+ owner_gid = getgid();
|
||||||
|
+ }
|
||||||
|
meta_mask |= GDBM_META_MASK_OWNER;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
--
|
||||||
|
1.8.3.1
|
||||||
|
|
||||||
@ -1,6 +1,6 @@
|
|||||||
Name: gdbm
|
Name: gdbm
|
||||||
Version: 1.22
|
Version: 1.22
|
||||||
Release: 8
|
Release: 9
|
||||||
Epoch: 1
|
Epoch: 1
|
||||||
Summary: A library of database functions that work similar to the standard UNIX dbm
|
Summary: A library of database functions that work similar to the standard UNIX dbm
|
||||||
License: GPLv3+
|
License: GPLv3+
|
||||||
@ -13,6 +13,7 @@ Patch2: gdbm_dump-fix-command-line-error-detection.patch
|
|||||||
Patch3: Fix-location-tracking-in-gdbmtool.-Fix-the-recover-c.patch
|
Patch3: Fix-location-tracking-in-gdbmtool.-Fix-the-recover-c.patch
|
||||||
Patch4: Fix-coredump-in-gdbmtool-history-command.patch
|
Patch4: Fix-coredump-in-gdbmtool-history-command.patch
|
||||||
Patch5: Fix-semantics-of-gdbm_load-r.patch
|
Patch5: Fix-semantics-of-gdbm_load-r.patch
|
||||||
|
Patch6: Improve-handling-of-u-in-gdbm_load.patch
|
||||||
|
|
||||||
BuildRequires: gcc libtool gettext readline-devel bison flex texinfo
|
BuildRequires: gcc libtool gettext readline-devel bison flex texinfo
|
||||||
|
|
||||||
@ -104,6 +105,9 @@ fi
|
|||||||
%{_infodir}/*.info*
|
%{_infodir}/*.info*
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Tue Jul 5 2022 wangzhqiang <wangzhiqiang95@huawei.com> - 1:1.22-9
|
||||||
|
- DESC: Improve handling of -u in gdbm_load
|
||||||
|
|
||||||
* Mon Jul 4 2022 wangzhqiang <wangzhiqiang95@huawei.com> - 1:1.22-8
|
* Mon Jul 4 2022 wangzhqiang <wangzhiqiang95@huawei.com> - 1:1.22-8
|
||||||
- DESC: Fix semantics of gdbm_load -r
|
- DESC: Fix semantics of gdbm_load -r
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user