7 Star 0 Fork 18

src-openEuler/gdbm

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
Improve-handling-of-u-in-gdbm_load.patch 2.30 KB
一键复制 编辑 原始数据 按行查看 历史
wangzhiqiang 提交于 2022-12-08 17:22 . update to version 1.23
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
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/src-openeuler/gdbm.git
git@gitee.com:src-openeuler/gdbm.git
src-openeuler
gdbm
gdbm
master

搜索帮助