Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fish] failed move to SSH server via fish panel deletes original file #3963

Closed
mc-butler opened this issue Jan 23, 2019 · 4 comments
Closed
Labels
area: vfs Virtual File System support prio: high Serious problem that could block progress ver: 4.8.22 Reproducible in version 4.8.22

Comments

@mc-butler
Copy link

Important

This issue was migrated from Trac:

Origin https://midnight-commander.org/ticket/3963
Reporter andvaranaut (jm.lopez@….com)
Mentions howaboutsynergy@….me

Description of the problem:

When moving files over SSH to a server using fish, if an I/O error is reported in the operation, the original file is deleted regardless of what the option chosen in the dialog is.

In particular, if you are using a non-root user and try to write in a privileged path, a "Cannot chmod target file" error is triggered (I/O error 121). If you choose Retry, the same dialog reappears; if you choose Skip, Skip all or Abort, the original file is deleted even though the move was unsuccessful.

The end result is that Midnight Commander deletes files without being asked to (and with no way to cancel the operation).

The bug is present both in the version packaged in my distro (4.8.18) and the current stable one (4.8.22). I have compiled it from source to test it out.

I'm rather sure that this is another facet of #3961. I'm opening a new ticket because a) it's a more generic problem (any I/O error might seemingly trigger the bug) and b) I have checked that it is still present in the current version, as requested by the bug reporting page.

Steps to reproduce:

  1. Create/get a non-root account in a SSH server.
  2. Connect to the server using fish. The root folder of the server comes up in the panel.
  3. Create a dummy file (eg. touch hello) in the other (local filesystem) panel.
  4. Use Move (F6) to try and move the dummy file from the local filesystem to the root of the SSH server.

Obtained Result

An I/O error dialog (error 121) comes up complaining that the remote chown of the file failed. If you choose Retry, the dialog comes up again. Choosing any option other than Retry deletes the original file.

Expected Result

Choosing any option other than Retry in the I/O error dialog should preserve the original file.

Result of mc -V:

GNU Midnight Commander 4.8.22
Built with GLib 2.56.3
Using the S-Lang library with terminfo database
With builtin Editor
With subshell support as default
With support for background operations
With mouse support on xterm
With support for X11 events
With internationalization support
With multiple codepages support
Virtual File Systems: cpiofs, tarfs, sfs, extfs, ftpfs, fish
Data types: char: 8; int: 32; long: 64; void *: 64; size_t: 64; off_t: 64;

Result of mc -F:

Home directory: /home/cepe
Profile root directory: /home/cepe

[System data]
    Config directory: /usr/local/etc/mc/
    Data directory:   /usr/local/share/mc/
    File extension handlers: /usr/local/libexec/mc/ext.d/
    VFS plugins and scripts: /usr/local/libexec/mc/
	extfs.d:        /usr/local/libexec/mc/extfs.d/
	fish:           /usr/local/libexec/mc/fish/

[User data]
    Config directory: /home/cepe/.config/mc/
    Data directory:   /home/cepe/.local/share/mc/
	skins:          /home/cepe/.local/share/mc/skins/
	extfs.d:        /home/cepe/.local/share/mc/extfs.d/
	fish:           /home/cepe/.local/share/mc/fish/
	mcedit macros:  /home/cepe/.local/share/mc/mc.macros
	mcedit external macros: /home/cepe/.local/share/mc/mcedit/macros.d/macro.*
    Cache directory:  /home/cepe/.cache/mc/

mc --configure-options is empty (I used a plain configure/make).

Thanks for your help!

@mc-butler
Copy link
Author

Changed by andvaranaut (jm.lopez@….com) on Jan 23, 2019 at 12:50 UTC (comment 1)

  • Component changed from mc-core to mc-vfs

@mc-butler
Copy link
Author

Changed by and on Feb 14, 2019 at 14:13 UTC (comment 2)

I can confirm.

fish stor/send helper function don't catch error at touch aka '>' and tee -a failure.
Following modified send/stor helper function report 500 in case of a failure.

#STOR $FISH_FILESIZE $FISH_FILENAME
FILENAME="/${FISH_FILENAME}"
echo "### 001"
if > "${FILENAME}"; then
    bss=4096
    bsl=4095
    if [ $FISH_FILESIZE -lt $bss ]; then
        bss=1;
        bsl=0;
    fi
    s=200
    while [ $FISH_FILESIZE -gt 0 ]; do
        cnt=`expr \\( $FISH_FILESIZE + $bsl \\) / $bss`
        o=`dd bs=$bss count=$cnt | tee -a "${FILENAME}"`
        if [ $? -ne 0 ] ; then
            s=500
            break
        fi
        n=`echo $o | wc -c`
        FISH_FILESIZE=`expr $FISH_FILESIZE - $n`
    done
    echo "### $s"
else
    echo "### 500"
fi

Sadly this is not enough, mc code don't handle error return of store function call I guess.

@mc-butler
Copy link
Author

Changed by andrew_b (@aborodin) on Feb 15, 2019 at 16:57 UTC (comment 2.3)

  • Milestone Future Releases deleted
  • Status changed from new to closed
  • Resolution set to duplicate

Closed as duplicate of #3128.
Replying to and:

I can confirm.

fish stor/send helper function don't catch error at touch aka '>' and tee -a failure.
Following modified send/stor helper function report 500 in case of a failure.

I moved the proposed patch to #3128.

@mc-butler
Copy link
Author

Changed by howaboutsynergy on May 6, 2019 at 9:12 UTC (comment 4)

  • Cc set to howaboutsynergy@….me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: vfs Virtual File System support prio: high Serious problem that could block progress ver: 4.8.22 Reproducible in version 4.8.22
Development

No branches or pull requests

1 participant