summaryrefslogtreecommitdiff
path: root/tools/gdbm_load.c
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2022-07-02 19:29:47 +0300
committerSergey Poznyakoff <gray@gnu.org>2022-07-02 19:29:47 +0300
commit4cfdc68fd862a4e80f42f14aa92cb25db08b2466 (patch)
treeaebde3c9d47a72da82b709614750d0d6797fdbbb /tools/gdbm_load.c
parent0591202918948d41e331094b283ff699ab916c54 (diff)
downloadgdbm-4cfdc68fd862a4e80f42f14aa92cb25db08b2466.tar.gz
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.
Diffstat (limited to 'tools/gdbm_load.c')
-rw-r--r--tools/gdbm_load.c9
1 files changed, 7 insertions, 2 deletions
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;