Menu

#181 s3cmd sync, permissions are not set correctly

Malfunction
open
nobody
None
5
2018-10-06
2018-10-03
No

I think that when I run "s3cmd sync s3://bucket/ ./", permissios are not set correctly (-rwxr-xr-x). I see this at Ubuntu host.

Show the bug, note perrmissions of file hello-s3cmd.txt are set to 775, that means, file is "executable".
I like that s3cmd prevented file timestamp.

$ s3cmd --version
s3cmd version 2.0.2

$ s3cmd sync s3://s3cmd-bug-demo-us-east-1/ ./
download: 's3://s3cmd-bug-demo-us-east-1/hello-s3cmd.txt' -> './hello-s3cmd.txt'  [1 of 1]
 66 of 66   100% in    0s   490.15 B/s  done
Done. Downloaded 66 bytes in 1.0 seconds, 66.00 B/s.

$ ls -l
-rwxrwxr-x  1 user  user     66 Oct  3 09:18 hello-s3cmd.txt

delete the file from local filesystem

$ rm hello-s3cmd.txt

The same but with awscli, permissions of file hello-s3cmd.txt are set to 664; I like it.

$ aws s3 sync s3://s3cmd-bug-demo-us-east-1/ ./
download: s3://s3cmd-bug-demo-us-east-1/hello-s3cmd.txt to ./hello-s3cmd.txt

$ ls -l
-rw-rw-r--  1 user  user     66 Oct  3 11:18 hello-s3cmd.txt

Discussion

  • Petr Slansky

    Petr Slansky - 2018-10-03

    "s3cmd get" sets permissions correctly (to 664), I like it:

    $ s3cmd get s3://s3cmd-bug-demo-us-east-1/hello-s3cmd.txt ./hello-get.txt
    download: 's3://s3cmd-bug-demo-us-east-1/hello-s3cmd.txt' -> './hello-get.txt'  [1 of 1]
     111 of 111   100% in    0s   191.82 B/s  done
    
    $ ls -l hello-get.txt 
    -rw-rw-r-- 1 user user 111 Oct  3 09:18 hello-get.txt
    
    $ umask
    0002
    
     
  • Petr Slansky

    Petr Slansky - 2018-10-06

    This is a patch. Could you review it and apply it?

    I checked the code and I see that file mode is set only in "sync" but not in "get" command. Maybe that "file mode" should not be set for files in "sync" but set only to empty directories.
    One more point, when I try "s3cmd get s3://s3cmd-bug-demo-us-east-1 --recursive", directory permissions are set correctly, so I guess that all code that plays with "mode" can be removed from "sync" section because that part is handled by "os" or python library...

    This is the easy fix, it doesn't change files to be executable; mode 0666 is -rw-rw-rw-.

    $ diff -u s3cmd s3cmd-fix 
    --- s3cmd   2018-10-06 15:47:42.789717115 +0200
    +++ s3cmd-fix   2018-10-06 15:49:14.371904366 +0200
    @@ -1411,7 +1411,7 @@
                 try:
                     # set permissions on destination file
                     if not is_empty_directory: # a normal file
    
    -                    mode = 0o777 - original_umask;
    +                    mode = 0o666 & ~original_umask;
                     else: # an empty directory, make them readable/executable
                         mode = 0o775
                     debug(u"mode=%s" % oct(mode))
    
     

Log in to post a comment.

MongoDB Logo MongoDB