# Problem with CIFS mounted samba share

## naju

Ok, I have a FreeBSD server (hostname = "serv") with samba 3.0.28 running. Here's what smb.conf looks like (only displaying one share):

```
[global]

        workgroup = HOME

        server string = FreeBSD samba server

        security = SHARE

        log level = 2

[usr]

        comment = serv /usr

        path = /usr

        read only = No

        hosts allow = 10.0.0.3, 10.0.0.4

```

On the Gentoo box, I mount it like this:

```
mount -t cifs -o iocharset=utf8,credentials=/root/.credentials2,uid=jester,gid=jester //serv/usr /mnt/servusr 

```

Note:  I'm running a 2.6.26-rc6 kernel, but the problem appears on many versions (I've tried a bunch) to make sure it wasn't a bug in the CIFS implementation.

Now, for some reason, I'm unable to create files or directory inside another directory in one command. For example:

```
~ $ cd servusr/

/mnt/servusr $ mkdir -p foo/bar

mkdir: cannot create directory `foo/bar': Permission denied

/mnt/servusr $ mkdir -p foo/bar

/mnt/servusr $

```

I have to create foo, then bar inside foo: 

```
~ $ cd servusr/

/mnt/servusr $ mkdir foo/

/mnt/servusr $ mkdir foo/bar

/mnt/servusr $

```

If I do the command as root (or sudo), it works.  This is really odd since there doesn't seem to be any permission problem here,

I can create files/delete/write/etc, I just can't do compound operations like above  (other examples would be doing svn checkout, or  extracting a tarball).  I have tried running the samba server on the Gentoo box instead with a similar configurations, and the problem isn't there.  Also, mounting the share as smbfs instead of cifs makes the problem go away (not an option since smbfs is going to be removed from the kernel soon).

Here's the output of smbd running in interactive mode with debug_level 3 on the FreeBSD server:

```
Transaction 51 of length 106

switch message SMBtrans2 (pid 63835) conn 0x83c2030

call_trans2qfilepathinfo: TRANSACT2_QPATHINFO: level = 512

dfs_redirect: Not redirecting //serv/usr/foo.

dfs_redirect: Path converted to non-dfs path foo

call_trans2qfilepathinfo: SMB_VFS_LSTAT of foo failed (No such file or directory)

unix_error_packet: error string = No such file or directory

error packet at smbd/trans2.c(3289) cmd=50 (SMBtrans2) NT_STATUS_OBJECT_NAME_NOT_FOUND

Transaction 52 of length 126

switch message SMBtrans2 (pid 63835) conn 0x83c2030

dfs_redirect: Not redirecting //serv/usr/foo.

dfs_redirect: Path converted to non-dfs path foo

call_trans2setfilepathinfo(6) foo (fnum -1) info_level=521 totdata=18

Transaction 53 of length 114

switch message SMBtrans2 (pid 63835) conn 0x83c2030

call_trans2qfilepathinfo: TRANSACT2_QPATHINFO: level = 512

dfs_redirect: Not redirecting //serv/usr/foo/bar.

dfs_redirect: Path converted to non-dfs path foo/bar

call_trans2qfilepathinfo: SMB_VFS_LSTAT of foo/bar failed (No such file or directory)

unix_error_packet: error string = No such file or directory

error packet at smbd/trans2.c(3289) cmd=50 (SMBtrans2) NT_STATUS_OBJECT_NAME_NOT_FOUND

```

Here's the same operation done with the samba server running on the Gentoo box itself (which doesn't fail):

```
Transaction 10 of length 118

switch message SMBtrans2 (pid 10778) conn 0x7fbd9a6ce7f0

call_trans2qfilepathinfo: TRANSACT2_QPATHINFO: level = 512

dfs_redirect: Not redirecting //localhost/test/foo.

dfs_redirect: Path converted to non-dfs path foo

call_trans2qfilepathinfo: SMB_VFS_LSTAT of foo failed (No such file or directory)

unix_error_packet: error string = No such file or directory

error packet at smbd/trans2.c(3337) cmd=50 (SMBtrans2) NT_STATUS_OBJECT_NAME_NOT_FOUND

Transaction 11 of length 138

switch message SMBtrans2 (pid 10778) conn 0x7fbd9a6ce7f0

dfs_redirect: Not redirecting //localhost/test/foo.

dfs_redirect: Path converted to non-dfs path foo

call_trans2setfilepathinfo(6) foo (fnum -1) info_level=521 totdata=18

Transaction 12 of length 126

switch message SMBtrans2 (pid 10778) conn 0x7fbd9a6ce7f0

call_trans2qfilepathinfo: TRANSACT2_QPATHINFO: level = 512

dfs_redirect: Not redirecting //localhost/test/foo/bar.

dfs_redirect: Path converted to non-dfs path foo/bar

call_trans2qfilepathinfo: SMB_VFS_LSTAT of foo/bar failed (No such file or directory)

unix_error_packet: error string = No such file or directory

error packet at smbd/trans2.c(3337) cmd=50 (SMBtrans2) NT_STATUS_OBJECT_NAME_NOT_FOUND

Transaction 13 of length 146

switch message SMBtrans2 (pid 10778) conn 0x7fbd9a6ce7f0

dfs_redirect: Not redirecting //localhost/test/foo/bar.

dfs_redirect: Path converted to non-dfs path foo/bar

call_trans2setfilepathinfo(6) foo/bar (fnum -1) info_level=521 totdata=18

```

Essentially the same output, same messages.  It looks like some kind of race condition when looking at "call_trans2qfilepathinfo: SMB_VFS_LSTAT of foo failed (No such file or directory)", like bar can't be created before foo is visible to the client.  But then this message appears on the linux samba server also, but the operation works.  But then it says "Permission denied", and running it as root works. I'm just stumped.

This is driving me nuts because I can't do the simplest of things in my shares (svn checkout, extract tarball) without running the same command many times, so if anyone can provide any kind of insight or lead as to what's causing that, I'd appreciate it.

----------

## SeaTiger

I don;t think it is race condition, it is just permission problem.

Does this user jester/jester has write permission for /usr in server serv? Usually only root/root can write to it.

On server "serv", you may have to add jester to the root group to write to /usr through samba. If that is really what you needed.

On the orther hand, you can create a directory away from /usr, usually, under /home/ and give jester write permission to it and share it out in samber.

----------

## naju

Sorry for the late reply.

No user jester doesn't have write permission, but I access the server as user root. "/root/.credentials2" contains precisely the credentials for that (sorry if this wasn't clear).  Like I said, if it's a permission problem and I'm not allowed to write to /usr, why can I write to it?  I just can't do compound commands as explained above.

----------

## naju

After more research, I found a crude fix for it.  it seems there are issues with the CIFS unix extensions, possibly related to the fact that the uids/gids differ on the client and server.  So I just set "unix extensions = no" in my smb.conf

It works for now, I hope I won't need unix extensions in the future though.

references:

http://ubuntuforums.org/archive/index.php/t-370096.html

http://www.experts-exchange.com/Networking/Linux_Networking/Q_23087363.html

----------

## plwrenn

I had the same exact problem. I was able to correct it by adding "noperm" to my mount options.

mount -t cifs -o iocharset=utf8,credentials=/root/.credentials2,uid=jester,gid=jester,noperm //serv/usr /mnt/servusr

----------

