summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2022-02-24 18:17:23 -0800
committerPaul Eggert <eggert@cs.ucla.edu>2022-02-24 18:19:40 -0800
commit8f31074cb4c9b023ef0aa47a0ce34c92745169b6 (patch)
treec0fe916938e82a966ea5fd8afa3caa22eeb37011
parent3abaa2ad6757c6b0619e6d44763ebf797d4c8a9c (diff)
downloadcoreutils-8f31074cb4c9b023ef0aa47a0ce34c92745169b6.tar.gz
chown: warn about USER.GROUP
Suggested by Dan Jacobson (Bug#44770). * src/chown.c, src/chroot.c (main): Issue warnings if obsolete USER.GROUP notation is present.
-rw-r--r--NEWS5
-rw-r--r--doc/coreutils.texi3
-rw-r--r--src/chown.c17
-rw-r--r--src/chroot.c9
4 files changed, 22 insertions, 12 deletions
diff --git a/NEWS b/NEWS
index eec705b2f..af6596b06 100644
--- a/NEWS
+++ b/NEWS
@@ -51,6 +51,11 @@ GNU coreutils NEWS -*- outline -*-
simple copies between regular files. This may be more efficient, by avoiding
user space copies, and possibly employing copy offloading or reflinking.
+ chown and chroot now warn about usages like "chown root.root f",
+ which have the nonstandard and long-obsolete "." separator that
+ causes problems on platforms where user names contain ".".
+ Applications should use ":" instead of ".".
+
cksum no longer allows abbreviated algorithm names,
so that forward compatibility and robustness is improved.
diff --git a/doc/coreutils.texi b/doc/coreutils.texi
index 641680e11..e9be0993a 100644
--- a/doc/coreutils.texi
+++ b/doc/coreutils.texi
@@ -11318,7 +11318,8 @@ or group ID, then you may specify it with a leading @samp{+}.
Some older scripts may still use @samp{.} in place of the @samp{:} separator.
POSIX 1003.1-2001 (@pxref{Standards conformance}) does not
require support for that, but for backward compatibility GNU
-@command{chown} supports @samp{.} so long as no ambiguity results.
+@command{chown} supports @samp{.} so long as no ambiguity results,
+although it issues a warning and support may be removed in future versions.
New scripts should avoid the use of @samp{.} because it is not
portable, and because it has undesirable results if the entire
@var{owner@samp{.}group} happens to identify a user whose name
diff --git a/src/chown.c b/src/chown.c
index 329b0f4dc..07cc907a4 100644
--- a/src/chown.c
+++ b/src/chown.c
@@ -227,11 +227,12 @@ main (int argc, char **argv)
case FROM_OPTION:
{
- char const *e = parse_user_spec (optarg,
- &required_uid, &required_gid,
- NULL, NULL);
+ bool warn;
+ char const *e = parse_user_spec_warn (optarg,
+ &required_uid, &required_gid,
+ NULL, NULL, &warn);
if (e)
- die (EXIT_FAILURE, 0, "%s: %s", e, quote (optarg));
+ error (warn ? 0 : EXIT_FAILURE, 0, "%s: %s", e, quote (optarg));
break;
}
@@ -297,10 +298,12 @@ main (int argc, char **argv)
}
else
{
- char const *e = parse_user_spec (argv[optind], &uid, &gid,
- &chopt.user_name, &chopt.group_name);
+ bool warn;
+ char const *e = parse_user_spec_warn (argv[optind], &uid, &gid,
+ &chopt.user_name,
+ &chopt.group_name, &warn);
if (e)
- die (EXIT_FAILURE, 0, "%s: %s", e, quote (argv[optind]));
+ error (warn ? 0 : EXIT_FAILURE, 0, "%s: %s", e, quote (argv[optind]));
/* If a group is specified but no user, set the user name to the
empty string so that diagnostics say "ownership :GROUP"
diff --git a/src/chroot.c b/src/chroot.c
index 1cd04300c..be9601304 100644
--- a/src/chroot.c
+++ b/src/chroot.c
@@ -354,10 +354,11 @@ main (int argc, char **argv)
Diagnose any failures. If any have failed, exit before execvp. */
if (userspec)
{
- char const *err = parse_user_spec (userspec, &uid, &gid, NULL, NULL);
-
- if (err && uid_unset (uid) && gid_unset (gid))
- die (EXIT_CANCELED, errno, "%s", (err));
+ bool warn;
+ char const *err = parse_user_spec_warn (userspec, &uid, &gid,
+ NULL, NULL, &warn);
+ if (err)
+ error (warn ? 0 : EXIT_CANCELED, 0, "%s", err);
}
/* If no gid is supplied or looked up, do so now.