]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
chown: warn about USER.GROUP
authorPaul Eggert <eggert@cs.ucla.edu>
Fri, 25 Feb 2022 02:17:23 +0000 (18:17 -0800)
committerPaul Eggert <eggert@cs.ucla.edu>
Fri, 25 Feb 2022 02:19:40 +0000 (18:19 -0800)
Suggested by Dan Jacobson (Bug#44770).
* src/chown.c, src/chroot.c (main):
Issue warnings if obsolete USER.GROUP notation is present.

NEWS
doc/coreutils.texi
src/chown.c
src/chroot.c

diff --git a/NEWS b/NEWS
index eec705b2f4a255cc59d08e2f5e46c3b69aea0a34..af6596b062a3053b981c04d178f110b7bca32560 100644 (file)
--- 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.
 
index 641680e11059103b156eaeaa6eb48de5fc4f7a33..e9be0993ac8cf3c18854585585a6e0c906dbc9ca 100644 (file)
@@ -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
index 329b0f4dca8f3f0950cba9f8ef40c2ce6c369324..07cc907a42fb50e815dbcfdb444e772cbf730b8d 100644 (file)
@@ -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"
index 1cd04300c8931cc1d78159167e2c0939fa0d1208..be9601304252e617311d1452bef1516c93d6e007 100644 (file)
@@ -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.