summaryrefslogtreecommitdiffstats
path: root/source/libsmb/libsmbclient.c
diff options
context:
space:
mode:
authorRichard Sharpe <sharpe@samba.org>2001-01-24 12:32:20 +0000
committerRichard Sharpe <sharpe@samba.org>2001-01-24 12:32:20 +0000
commit68614bac5a1a4109fdfb728aeae6956b13c64d8f (patch)
tree849aa39f9eaab7de4e526e5c5545c8b8504d3994 /source/libsmb/libsmbclient.c
parent6e568332254cf60d6a1f411df960ac2ec5f4bf8e (diff)
downloadsamba-68614bac5a1a4109fdfb728aeae6956b13c64d8f.tar.gz
samba-68614bac5a1a4109fdfb728aeae6956b13c64d8f.tar.xz
samba-68614bac5a1a4109fdfb728aeae6956b13c64d8f.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.
Diffstat (limited to 'source/libsmb/libsmbclient.c')
-rw-r--r--source/libsmb/libsmbclient.c40
1 files changed, 39 insertions, 1 deletions
diff --git a/source/libsmb/libsmbclient.c b/source/libsmb/libsmbclient.c
index f51ae422809..7cf5ad7dd79 100644
--- a/source/libsmb/libsmbclient.c
+++ b/source/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;
}