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

SCP failed with "Permission denied" and error not reported to user code. #392

Closed
gantzm opened this issue Jun 29, 2023 · 3 comments
Closed
Labels
bug An issue describing a bug in the code
Milestone

Comments

@gantzm
Copy link

gantzm commented Jun 29, 2023

Version

2.10.0

Bug description

I'm attempting to scp a file from a Dropbear instance. I don't have permissions to copy the file. Dropbear reports permission denied, but that failure is never reported up to the calling code.

Actual behavior

The ScpHelper class logged this:

receiveNextCmd - ACK=1: scp: /directory1/directory2/file.xml: Permission denied

But this error appears to get ignored and never reported back to my calling code. I don't receive any calls to my instance of ScpTransferEventListener. The call to download on the ScpClient just returns, no exceptions or anything.

When I look at the code in ScpHelper it appears to just log the error ACK and continue on:

    // NOTE: we rely on the fact that an SCP command does not start with an ACK code
    protected int receiveNextCmd() throws IOException {
        int c = in.read();
        if (c == -1) {
            return c;
        }

        if (c == ScpAckInfo.OK) {
            return c;
        }

        if ((c == ScpAckInfo.WARNING) || (c == ScpAckInfo.ERROR)) {
            String line = ScpIoUtils.readLine(in, csIn, true);
            if (log.isDebugEnabled()) {
                log.debug("receiveNextCmd - ACK={}", new ScpAckInfo(c, line));
            }
        }

        return c;
    }

Expected behavior

I would expect this information to show up in the ScpAckInfo parameter of a call to handleFileEventAckInfo. Or possibly an exception thrown to indicate a failure.

Relevant log output

receiveNextCmd - ACK=1: scp: /directory1/directory2/file.xml: Permission denied

Other information

No response

@lgoldstein
Copy link
Contributor

See also #428

lgoldstein pushed a commit to lgoldstein/mina-sshd that referenced this issue Nov 10, 2023
…led due to missing file or lacking permissions
lgoldstein pushed a commit to lgoldstein/mina-sshd that referenced this issue Nov 10, 2023
…led due to missing file or lacking permissions
lgoldstein pushed a commit to lgoldstein/mina-sshd that referenced this issue Nov 10, 2023
…led due to missing file or lacking permissions
lgoldstein pushed a commit to lgoldstein/mina-sshd that referenced this issue Nov 10, 2023
…led due to missing file or lacking permissions
lgoldstein pushed a commit to lgoldstein/mina-sshd that referenced this issue Nov 10, 2023
…led due to missing file or lacking permissions
lgoldstein pushed a commit to lgoldstein/mina-sshd that referenced this issue Nov 10, 2023
…led due to missing file or lacking permissions
@lgoldstein
Copy link
Contributor

See my reply for PR#428 - it may be the case that the server is signalling the permissions problem as a WARNING rather than an ERROR (see also the proposed fix for next version). Thank you though for helping focus the problematic code block - it helped a lot in diagnosing this issue as weel as PR#428

asfgit pushed a commit that referenced this issue Nov 23, 2023
@tomaswolf tomaswolf added the bug An issue describing a bug in the code label Jan 4, 2024
@tomaswolf tomaswolf added this to the 2.12.0 milestone Jan 4, 2024
@tomaswolf
Copy link
Member

Should have been fixed by commit f908189.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An issue describing a bug in the code
Projects
None yet
Development

No branches or pull requests

3 participants