Skip to content

fs/local: copy doesn't work with .. in pathname #4897

Description

@kartiksubbarao

What is the problem you are having with rclone?

I'm trying to copy a file referenced with .. in the pathname and it returns an error. Running strace on the process shows that .. is getting mangled to \357\274\216:

1028793 newfstatat(AT_FDCWD, "/tmp/\357\274\216\357\274\216/tmp/test.txt", 0xc00058b628, AT_SYMLINK_NOFOLLOW) = -1 ENOENT (No such file or directory)

What is your rclone version (output from rclone version)

rclone v1.53.3-DEV

  • os/arch: linux/amd64
  • go version: go1.15.5

Which OS you are using and how many bits (e.g. Windows 7, 64 bit)

Fedora 33, 64 bit

Which cloud storage system are you using? (e.g. Google Drive)

Google Drive

The command you were trying to run (e.g. rclone copy /tmp remote:tmp)

rclone copy /tmp/../tmp/test.txt gdrive:

A log from the command with the -vv flag (e.g. output from rclone -vv copy /tmp remote:tmp)

The debug log includes some user-specific information. Here is the output of the command without -vv, let me know if you need more info:

2021/01/02 13:36:20 ERROR : : error reading source directory: directory not found
2021/01/02 13:36:20 ERROR : Attempt 1/3 failed with 1 errors and: directory not found
2021/01/02 13:36:20 ERROR : : error reading source directory: directory not found
2021/01/02 13:36:20 ERROR : Attempt 2/3 failed with 1 errors and: directory not found
2021/01/02 13:36:20 ERROR : : error reading source directory: directory not found
2021/01/02 13:36:20 ERROR : Attempt 3/3 failed with 1 errors and: directory not found
2021/01/02 13:36:20 Failed to copy: directory not found

Activity

  1. animosity022 commented on Jan 3, 2021

    @animosity022
    Contributor

    Does seem like a bug, but why would you go into a directory to back up one to go back into again? Why not use /tmp/test.txt?

  2. kartiksubbarao commented on Jan 3, 2021

    @kartiksubbarao
    Author

    The script had a variable (e.g. BACKUPDIR) set to the directory to be backed up. The resulting backup file was stored one directory above that, and was referenced like so: $BACKUPDIR/../$BACKUPFILE. The eventual rclone command to archive the backup file to Google Drive looked something like this:

    rclone copy $BACKUPDIR/../$BACKUPFILE gdrive:
    
  3. animosity022 commented on Jan 3, 2021

    @animosity022
    Contributor

    It has to do with the encoding of the "." on the local file system as you noted above.

    I have to play around a bit, but I'd guess the local file system needs to not encode it as I can kinda get it working:

    felix@gemini:~$ rclone ls /etc/rsyslog.d/../hosts  --local-encoding None
    2021/01/03 14:44:41 NOTICE: os-release: Can't follow symlink without -L/--copy-links
    2021/01/03 14:44:41 NOTICE: mtab: Can't follow symlink without -L/--copy-links
    2021/01/03 14:44:41 NOTICE: rmt: Can't follow symlink without -L/--copy-links
    2021/01/03 14:44:41 NOTICE: localtime: Can't follow symlink without -L/--copy-links
    2021/01/03 14:44:41 NOTICE: vtrgb: Can't follow symlink without -L/--copy-links
          225 hosts
    
  4. ivandeex commented on Mar 16, 2021

    @ivandeex
    Member

    This is the way rclone works. It is by nature a cloud-first program so instead of normalizing the path it encodes . and .. (frequently used in paths on cloud storage) into utf-8. This might look odd, so rclone allows you to control the encoding (see https://rclone.org/overview/#encoding).

    For the time being you can stick with the --local-encoding=None kludge.

    Probably we can introduce an option to normalize paths before encoding and turn it on by default for local storage.

  5. changed the title [-]copy doesn't work with .. in pathname[/-] [+]fs/local: copy doesn't work with .. in pathname[/+] on Mar 16, 2021
  6. ivandeex commented on Mar 16, 2021

    @ivandeex
    Member

    This request is similar to #4948 but this one is for local filesystem while #4948 is for cloud storage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions