> > When my users (including me) try to sftp using the Win-2.2.0.exe
> > program to a 2.2.0 server, the file that they upload gets the error
> > below.   The file is also given root:root ownership and perms 0000.
> 
> Sometimes I really
> wonder how do they think... To blindly beleive what a windows box say...
> How does uid-gid calculated? How does 666 get calculated?

As far as I can tell they blindly believe to whatever the client says...
Both uid:gid (in numerical form!!!) and 0666 are provided by the client.
One can discuss access modes, but transferring numerical ids across
potentially distinct accounting systems is totally unacceptable.

> share a patch (for the sftp-server naturally:-) with the
> community...

Relative to 2.2.0:

*** ./lib/sshfilexfer/sshfilexfers.c.orig       Mon Jun 12 18:38:57 2000
--- ./lib/sshfilexfer/sshfilexfers.c    Sat Jul 15 13:18:54 2000
***************
*** 402,407 ****
--- 402,408 ----
          }
  
        /* If the attributes specify uid and gid, try to switch to them. */
+ #if 0 /* No way! See comment in SSH_FXP_FSETSTAT. <[EMAIL PROTECTED]> */
        if (attrs->flags & SSH_FILEXFER_ATTR_UIDGID)
          {
  #ifdef HAVE_FCHOWN
***************
*** 409,414 ****
--- 410,416 ----
            (void)fchown(fd, attrs->uid, attrs->gid);
  #endif /* HAVE_FCHOWN */
          }
+ #endif /* !yaw oN */
  
        /* Open was successful.  Wrap the real file handle to a handle object. */
        handle = ssh_file_server_new_handle(server, FALSE, name, (void *)fd);
***************
*** 721,726 ****
--- 723,729 ----
            ret = -1;
  #endif /* HAVE_TRUNCATE */
          }
+ #if 0 /* No way! See comment in SSH_FXP_FSETSTAT. <[EMAIL PROTECTED]> */
        if (attrs->flags & SSH_FILEXFER_ATTR_UIDGID)
          {
  #ifdef HAVE_CHOWN
***************
*** 730,739 ****
            ret = -1;
  #endif /* HAVE_CHOWN */
          }
        if (attrs->flags & SSH_FILEXFER_ATTR_PERMISSIONS)
          {
  #ifdef HAVE_CHMOD
!           if (chmod(name, attrs->permissions) < 0)
              ret = -1;
  #else /* HAVE_CHMOD */
            ret = -1;
--- 733,749 ----
            ret = -1;
  #endif /* HAVE_CHOWN */
          }
+ #endif /* !yaw oN */
        if (attrs->flags & SSH_FILEXFER_ATTR_PERMISSIONS)
          {
  #ifdef HAVE_CHMOD
!           /* See comment in SSH_FXP_FSETSTAT. <[EMAIL PROTECTED]> */
!           static mode_t u_mask=(mode_t)-1;
! 
!           if (u_mask == (mode_t)-1)
!             if ((u_mask=umask(022)) != 022) umask(u_mask);
! 
!           if (chmod(name, attrs->permissions&~u_mask) < 0)
              ret = -1;
  #else /* HAVE_CHMOD */
            ret = -1;
***************
*** 823,828 ****
--- 833,848 ----
            ret = -1;
  #endif /* HAVE_FTRUNCATE */
          }
+ #if 0
+       /*
+        * This goes against everything we're used to and even believe in,
+        * namely file transfer resetting numerical uid/gid potentially
+        * across distinct accounting systems. In either case the original
+        * reason for #if-ing out was that SSH for Windows (at least 2.2.0)
+        * tends to send bogus ownership (most notably root:root).
+        *
+        *                                      <[EMAIL PROTECTED]>
+        */
        if (attrs->flags & SSH_FILEXFER_ATTR_UIDGID)
          {
  #ifdef HAVE_FCHOWN
***************
*** 833,842 ****
  #endif /* HAVE_FCHOWN */
          }
  #endif /* WIN32 */
        if (attrs->flags & SSH_FILEXFER_ATTR_PERMISSIONS)
          {
  #ifdef HAVE_FCHMOD
!           if (fchmod(handle->fd, attrs->permissions) < 0)
              ret = -1;
  #else /* HAVE_FCHMOD */
  #ifndef WIN32
--- 853,875 ----
  #endif /* HAVE_FCHOWN */
          }
  #endif /* WIN32 */
+ #endif
        if (attrs->flags & SSH_FILEXFER_ATTR_PERMISSIONS)
          {
  #ifdef HAVE_FCHMOD
!           /*
!            * SSH for Windows (at least 2.2.0) tends to send bogus
!            * (most notably world-writable) permissions. Lets filter
!            * 'em through umask...
!            *
!            *                          <[EMAIL PROTECTED]>
!            */
!           static mode_t u_mask=(mode_t)-1;
! 
!           if (u_mask == (mode_t)-1)
!             if ((u_mask=umask(022)) != 022) umask(u_mask);
! 
!           if (fchmod(handle->fd, attrs->permissions&~u_mask) < 0)
              ret = -1;
  #else /* HAVE_FCHMOD */
  #ifndef WIN32

Cheers. Andy.

Reply via email to