Ticket #3406: mc-3406-sftp-handle-stat-error-EACCESS.patch

File mc-3406-sftp-handle-stat-error-EACCESS.patch, 2.0 KB (added by and, 9 years ago)
  • src/vfs/sftpfs/internal.c

    From 52bdabe75e3811ecc10637cf08715c08df78da14 Mon Sep 17 00:00:00 2001
    From: Andreas Mohr <and@gmx.li>
    Date: Thu, 7 Jan 2016 19:04:06 +0000
    Subject: [PATCH] sftp handle LIBSSH2_FX_PERMISSION_DENIED as EACCES
    
    when libssh2_sftp_stat_ex(LIBSSH2_SFTP_STAT|LIBSSH2_SFTP_LSTAT) returns with
    LIBSSH2_ERROR_SFTP_PROTOCOL (-31) and LIBSSH2_FX_PERMISSION_DENIED (3)
    handle this error case like local stat/lstat() returns EACCES
    
    Signed-off-by: Andreas Mohr <and@gmx.li>
    ---
     src/vfs/sftpfs/internal.c | 12 ++++++++++++
     1 file changed, 12 insertions(+)
    
    diff --git a/src/vfs/sftpfs/internal.c b/src/vfs/sftpfs/internal.c
    index f060ecf..a05ca8b 100644
    a b sftpfs_lstat (const vfs_path_t * vpath, struct stat *buf, GError ** mcerror) 
    166166        if (res >= 0) 
    167167            break; 
    168168 
     169        if (res == LIBSSH2_ERROR_SFTP_PROTOCOL && 
     170            libssh2_sftp_last_error(super_data->sftp_session)  == LIBSSH2_FX_PERMISSION_DENIED) 
     171            return EACCES; 
     172 
    169173        if (res != LIBSSH2_ERROR_EAGAIN) 
    170174        { 
    171175            sftpfs_ssherror_to_gliberror (super_data, res, mcerror); 
    sftpfs_stat (const vfs_path_t * vpath, struct stat *buf, GError ** mcerror) 
    244248        if (res >= 0) 
    245249            break; 
    246250 
     251        if (res == LIBSSH2_ERROR_SFTP_PROTOCOL && 
     252            libssh2_sftp_last_error(super_data->sftp_session)  == LIBSSH2_FX_PERMISSION_DENIED) 
     253            return EACCES; 
     254 
    247255        if (res != LIBSSH2_ERROR_EAGAIN) 
    248256        { 
    249257            sftpfs_ssherror_to_gliberror (super_data, res, mcerror); 
    sftpfs_chmod (const vfs_path_t * vpath, mode_t mode, GError ** mcerror) 
    450458        if (res >= 0) 
    451459            break; 
    452460 
     461        if (res == LIBSSH2_ERROR_SFTP_PROTOCOL && 
     462            libssh2_sftp_last_error(super_data->sftp_session)  == LIBSSH2_FX_PERMISSION_DENIED) 
     463            return EACCES; 
     464 
    453465        if (res != LIBSSH2_ERROR_EAGAIN) 
    454466        { 
    455467            sftpfs_ssherror_to_gliberror (super_data, res, mcerror);