Ticket #3963 (closed defect: duplicate)

Opened 5 years ago

Last modified 5 years ago

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

Reported by: andvaranaut Owned by:
Priority: critical Milestone:
Component: mc-vfs Version: 4.8.22
Keywords: Cc: howaboutsynergy@…
Blocked By: Blocking:
Branch state: no branch Votes for changeset:

Description

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!

Change History

comment:1 Changed 5 years ago by andvaranaut

  • Component changed from mc-core to mc-vfs

comment:2 follow-up: ↓ 3 Changed 5 years ago by 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.

#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.

comment:3 in reply to: ↑ 2 Changed 5 years ago by andrew_b

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

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.

comment:4 Changed 5 years ago by howaboutsynergy

  • Cc howaboutsynergy@… added
Note: See TracTickets for help on using tickets.