I've run into a small problem when using GNU install.  I'm on Linux 2.2.19,
with the destination directory being mounted via smbfs.  (The remote end is
actually samba on Solaris, being used to export a ClearCase view.)  The
invocation of install is using the -m switch, but *not* the -o or -g switches.

install was exiting with an "operation not permitted" error.

Running strace, I could see the problem was coming from a call to chown() with
uid=gid=-1 (i.e. leave owner and group the same).  I've found that in the Linux
kernel, a chown call with either of these arguments =-1 is taken to mean "copy
that arg from what the file has now", rather than "don't bother changing the
file if both are -1".  That method would probably have been wrong anyway, since
the mtime needs to change at least.

The underlying problem is probably that smbfs doesn't support a chown
operation, as I doubt it's part of the SMB protocol.

So, I decided the easiest fix was in install.  If neither the -o nor -g
switches have been specified, don't bother trying to do chown() on the
destination file at all.  I've attached a patch to do this.

-- 
Richard | SuperH Core Architecture  ///                 .... At home ...
Curnow  | [EMAIL PROTECTED]    ///     [EMAIL PROTECTED]
        | http://www.superh.com/    /// http://www.rrbcurnow.freeuk.com/
--- install.c.orig      Thu Oct 25 13:15:02 2001
+++ install.c   Thu Oct 25 13:19:37 2001
@@ -465,15 +465,21 @@
      want to know.  But AFS returns EPERM when you try to change a
      file's group; thus the kludge.  */
 
-  if (chown (path, owner_id, group_id)
+  /* If we're not changing the owner or group, don't do chown at all.
+   * The chown operation doesn't seem to be permitted on smbfs. */
+
+  if ((owner_id != (uid_t) -1) || (group_id != (gid_t) -1)) 
+  {
+    if (chown (path, owner_id, group_id)
 #ifdef AFS
-      && errno != EPERM
+        && errno != EPERM
 #endif
-      )
+       )
     {
       error (0, errno, "cannot change ownership of %s", quote (path));
       err = 1;
     }
+  }
 
   if (!err && chmod (path, mode))
     {

Reply via email to