From d53f9716bb10efe164b67f9916ab5e59880c9b7c Mon Sep 17 00:00:00 2001 From: Richard Sharpe Date: Wed, 24 Jan 2001 12:32:20 +0000 Subject: 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) --- source3/libsmb/libsmbclient.c | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) (limited to 'source3/libsmb') 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; } -- cgit