diff options
author | Richard Sharpe <sharpe@samba.org> | 2001-01-24 12:32:20 +0000 |
---|---|---|
committer | Richard Sharpe <sharpe@samba.org> | 2001-01-24 12:32:20 +0000 |
commit | d53f9716bb10efe164b67f9916ab5e59880c9b7c (patch) | |
tree | f6f6754017c4958e89d54b05613512ec7740e778 | |
parent | 327e2b302991455d48fdbc7c05874c4fdad03e79 (diff) | |
download | samba-d53f9716bb10efe164b67f9916ab5e59880c9b7c.tar.gz samba-d53f9716bb10efe164b67f9916ab5e59880c9b7c.tar.bz2 samba-d53f9716bb10efe164b67f9916ab5e59880c9b7c.zip |
Fix a problem with smbc_unlink on directories where it was returning EACCES
instead of EPERM and a problem with SMBC_OPEN where it ignored an error
from the underlying cli_open routine and cheerfully returned a bogus FD.
(This used to be commit 68614bac5a1a4109fdfb728aeae6956b13c64d8f)
-rw-r--r-- | source3/libsmb/libsmbclient.c | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/source3/libsmb/libsmbclient.c b/source3/libsmb/libsmbclient.c index f51ae42280..7cf5ad7dd7 100644 --- a/source3/libsmb/libsmbclient.c +++ b/source3/libsmb/libsmbclient.c @@ -618,7 +618,16 @@ int smbc_open(const char *fname, int flags, mode_t mode) } - fd = cli_open(&srv->cli, path, flags, DENY_NONE); + if ((fd = cli_open(&srv->cli, path, flags, DENY_NONE)) < 0) { + + /* Handle the error ... */ + + free(smbc_file_table[slot]); + smbc_file_table[slot] = NULL; + errno = smbc_errno(&srv->cli); + return -1; + + } /* Fill in file struct */ @@ -860,6 +869,35 @@ int smbc_unlink(const char *fname) if (!cli_unlink(&srv->cli, path)) { errno = smbc_errno(&srv->cli); + + if (errno == EACCES) { /* Check if the file is a directory */ + + int err, saverr = errno; + struct stat st; + size_t size = 0; + uint16 mode = 0; + time_t m_time = 0, a_time = 0, c_time = 0; + SMB_INO_T ino = 0; + + if (!smbc_getatr(srv, path, &mode, &size, + &c_time, &a_time, &m_time, &ino)) { + + /* Hmmm, bad error ... What? */ + + errno = smbc_errno(&srv->cli); + return -1; + + } + else { + + if (IS_DOS_DIR(mode)) + errno = EPERM; + else + errno = saverr; /* Restore this */ + + } + } + return -1; } |