代码拉取完成,页面将自动刷新
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 12/14] Improve handling of -u in gdbm_load
* tools/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 ++++++++-----
tools/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/tools/gdbm_load.c b/tools/gdbm_load.c
index 5d5e50e..e7e2ab1 100644
--- a/tools/gdbm_load.c
+++ b/tools/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;
--
2.33.0
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。