]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
.
authorJim Meyering <jim@meyering.net>
Fri, 1 Jul 1994 16:53:29 +0000 (16:53 +0000)
committerJim Meyering <jim@meyering.net>
Fri, 1 Jul 1994 16:53:29 +0000 (16:53 +0000)
src/chgrp.c
src/cp.c
src/mv.c
src/rm.c

index 74438ef93f6eff5ffa51854c87642a9e06344bca..cac9383d58b5f506b6db90e06003a6fba34fdb21 100644 (file)
@@ -53,6 +53,7 @@ struct group *getgrnam ();
 
 int lstat ();
 
+char *group_member ();
 char *savedir ();
 char *xmalloc ();
 char *xrealloc ();
@@ -208,9 +209,22 @@ change_file_group (file, group)
        describe_change (file, 1);
       if (chown (file, file_stats.st_uid, group))
        {
-         if (force_silent == 0)
-           error (0, errno, "%s", file);
          errors = 1;
+         if (force_silent == 0)
+           {
+             /* Give a more specific message.  Some systems set errno
+                to EPERM for both `inaccessible file' and `user not a member
+                of the specified group' errors.  */
+             if (errno == EPERM && !group_member (group))
+               {
+                 error (0, errno, "you are not a member of group `%s'",
+                        groupname);
+               }
+             else
+               {
+                 error (0, errno, "%s", file);
+               }
+           }
        }
     }
   else if (verbose && changes_only == 0)
index b190c6416c6aff84323f05816e9b6c5ee3544056..3fb200bd16ef1e8d25ebc8fadfa3641c664a2552 100644 (file)
--- a/src/cp.c
+++ b/src/cp.c
@@ -78,8 +78,8 @@ char *program_name;
    whether dereferencing of symlinks is done.  */
 static int (*xstat) ();
 
-/* If nonzero, copy all files except directories and, if not dereferencing
-   them, symbolic links, as if they were regular files. */
+/* If nonzero, copy all files except (directories and, if not dereferencing
+   them, symbolic links,) as if they were regular files. */
 static int flag_copy_as_regular = 1;
 
 /* If nonzero, dereference symbolic links (copy the files they point to). */
@@ -563,7 +563,7 @@ copy (src_path, dst_path, new_dst, device, ancestors)
            {
              if (flag_interactive)
                {
-                 if (eaccess_stat (&dst_sb, W_OK) != 0)
+                 if (eaccess_stat (&dst_sb, W_OK, dst_path) != 0)
                    fprintf (stderr,
                             "%s: overwrite `%s', overriding mode %04o? ",
                             program_name, dst_path,
@@ -808,7 +808,9 @@ copy (src_path, dst_path, new_dst, device, ancestors)
 
       /* If non-root uses -p, it's ok if we can't preserve ownership.
         But root probably wants to know, e.g. if NFS disallows it.  */
-      if (chown (dst_path, src_sb.st_uid, src_sb.st_gid)
+      if (chown (dst_path,
+                (myeuid == 0 ? src_sb.st_uid : myeuid),
+                src_sb.st_gid)
          && (errno != EPERM || myeuid == 0))
        {
          error (0, errno, "%s", dst_path);
index 3525c53aae63de3d0770e01189e5796cd1278952..e56a6eb231cb07bc9c5b695324c5defe299b48ed 100644 (file)
--- a/src/mv.c
+++ b/src/mv.c
@@ -282,7 +282,7 @@ do_move (source, dest)
        return 0;
 
       if (!override_mode && (interactive || stdin_tty)
-         && eaccess_stat (&dest_stats, W_OK))
+         && eaccess_stat (&dest_stats, W_OK, dest))
        {
          fprintf (stderr, "%s: replace `%s', overriding mode %04o? ",
                   program_name, dest,
index 722994735d7fbba8bae0fa10e0da13bf8a3dd40f..1365e665632e520ad4dd9f78f912635a8125016d 100644 (file)
--- a/src/rm.c
+++ b/src/rm.c
@@ -228,7 +228,7 @@ remove_file (statp)
      struct stat *statp;
 {
   if (!ignore_missing_files && (interactive || stdin_tty)
-      && eaccess_stat (statp, W_OK)
+      && eaccess_stat (statp, W_OK, pathname)
 #ifdef S_ISLNK
       && !S_ISLNK (statp->st_mode)
 #endif