Return an empty directory for a stat on a share we aren't allowed to
authorTim Potter <tpot@samba.org>
Tue, 2 Jan 2001 23:42:36 +0000 (23:42 +0000)
committerTim Potter <tpot@samba.org>
Tue, 2 Jan 2001 23:42:36 +0000 (23:42 +0000)
connect to.  This gives a permission denied when a cd is attempted, but
not a permission denied in the directory listing one level up.
(This used to be commit 9255e526244578e092abc306491d5862469da775)

source3/smbwrapper/smbw_stat.c

index c84140f3629ae05debf34414b125a4fde2933c0d..926075c864f82bd48c2a2ae1f007f9b3ccbc9472 100644 (file)
@@ -180,6 +180,7 @@ int smbw_stat(const char *fname, struct stat *st)
        size_t size=0;
        uint16 mode=0;
        SMB_INO_T ino = 0;
+       int result = 0;
 
        ZERO_STRUCTP(st);
 
@@ -200,8 +201,19 @@ int smbw_stat(const char *fname, struct stat *st)
        /* get a connection to the server */
        srv = smbw_server(server, share);
        if (!srv) {
+
+               /* For shares we aren't allowed to connect to, return
+                  an empty directory */
+
+               if (server[0] && share[0] && !path[0] && errno == EACCES) {
+                       mode = aDIR | aRONLY;
+                       smbw_setup_stat(st, path, size, mode);
+                       goto done;
+               }
+
                /* smbw_server sets errno */
-               goto failed;
+               result = -1;
+               goto done;
        }
 
        DEBUG(4,("smbw_stat\n"));
@@ -221,7 +233,8 @@ int smbw_stat(const char *fname, struct stat *st)
                                 &mode, &size, &c_time, &a_time, &m_time,
                                 &ino)) {
                        errno = smbw_errno(&srv->cli);
-                       goto failed;
+                       result = -1;
+                       goto done;
                }
        }
 
@@ -234,10 +247,7 @@ int smbw_stat(const char *fname, struct stat *st)
        st->st_mtime = m_time;
        st->st_dev = srv->dev;
 
+ done:
        smbw_busy--;
-       return 0;
-
- failed:
-       smbw_busy--;
-       return -1;
+       return result;
 }