cp -p on CIFS mount does not preserve permissions and returns a permission denied error

Bug #276472 reported by Stefan on 2008-09-30
28
This bug affects 2 people
Affects Status Importance Assigned to Milestone
samba (Ubuntu)
Medium
Surbhi Palande
Hardy
Medium
Unassigned
Lucid
Medium
Unassigned

Bug Description

The original mtime is not preserved after a file is copied to a mounted CIFS directory.

root@laptop:~# cp -p /etc/hosts /mnt/temp/test/
root@laptop:~# ls -la /etc/hosts /mnt/temp/test/hosts
-rw-r--r-- 1 root root 354 2007-11-13 18:57 /etc/hosts
-rw-r--r-- 1 root root 354 2008-09-30 21:54 /mnt/temp/test/hosts

/mnt/temp is a CIFS mount.

Description: Ubuntu 8.04.1
Release: 8.04

Linux version 2.6.24-19-generic (buildd@terranova) (gcc version 4.2.3 (Ubuntu 4.2.3-2ubuntu7)) #1 SMP Wed Aug 20 22:56:21 UTC 2008

Related branches

Hi Stefan,

Thanks for the pointer to the upstream patch. This patch is already available in the upcoming Intrepid Ibex 8.10 kernel:

ogasawara@yoji:~/ubuntu-intrepid$ git log -p 50531444fac593c8c8e3ff2e41944d9507bb4665
commit 50531444fac593c8c8e3ff2e41944d9507bb4665
Author: Steve French <email address hidden>
Date: Fri Mar 14 19:21:31 2008 +0000

    [CIFS] Fix mtime on cp -p when file data cached but written out too late

If you could test Intrepid to verify this is fixed that would be great - http://www.ubuntu.com/testing/intrepid/beta . You should be able to test using a LiveCD. Once this is verified to be resolved with the Intrepid kernel we can probably attempt to get this patch through the SRU process (http://wiki.ubuntu.com/StableReleaseUpdates) if you want it backported to Hardy. Thanks.

Changed in linux:
status: New → Incomplete
Stefan (stefanp) wrote :

The bug is fixed in Ubuntu 8.10.

Tested on:
Linux version 2.6.27-4-generic (buildd@rothera) (gcc version 4.3.2 (Ubuntu 4.3.2-1ubuntu7) ) #1 SMP Wed Sep 24 01:30:51 UTC 2008

Can we have this backported to 8.04?

Haydar Alkaduhimi (haydarlinux) wrote :

I have installed ubuntu 8.10 beta and updated to the last version untill 16 oct 2008 and still have the same problem

haydar@haydar-desktop:/mnt/haydar/svn$ rm -rf test
haydar@haydar-desktop:/mnt/haydar/svn$ mkdir test
haydar@haydar-desktop:/mnt/haydar/svn$ cd test/
haydar@haydar-desktop:/mnt/haydar/svn/test$ touch newfile
touch: setting times of `newfile': Not a directory
haydar@haydar-desktop:/mnt/haydar/svn/test$ ls
newfile
haydar@haydar-desktop:/mnt/haydar/svn/test$ cat newfile
haydar@haydar-desktop:/mnt/haydar/svn/test$ printf "hh\n" > newfile
bash: newfile: Not a directory
haydar@haydar-desktop:/mnt/haydar/svn/test$ cat newfile
haydar@haydar-desktop:/mnt/haydar/svn/test$ rm -f newfile
haydar@haydar-desktop:/mnt/haydar/svn/test$ printf "hh\n" > newfile
haydar@haydar-desktop:/mnt/haydar/svn/test$ cat newfile
hh

I hope tha this helps, also svn does not works correctly in this directory because of this bug.

@Stefan, I assume this is still resolved for you? I can then go ahead and open a Hardy nomination to get the patch backported.

@Haydar Alkaduhimi, please recreate the exact test case that Stefan showed in the description of this bug. No where did you prove to show a cp -p on a CIFS mount failed to preserve the timestamp/ownership. I'm not entirely convinced you have the same issue Stefan reported. Also, please include the output of 'cat /proc/version_signature' to verify which kernel you are using.

Stefan (stefanp) wrote :

Yes, please nominate the patch for Hardy.

Vipo (vitus-piroutz) wrote :

I'm also trapped and would need a backport for 8.04 LTS.
Please nominate.

Marking this Fix Released for Intrepid and will open the Hardy nomination. Thanks.

Changed in linux:
status: Incomplete → Fix Released
assignee: nobody → ubuntu-kernel-team
importance: Undecided → Medium
milestone: none → ubuntu-8.04.2
status: New → Triaged

Not fixed in Jaunty alpha

Still broken in Jaunty alpha 1.

Changed in linux:
status: Triaged → Incomplete

Setting this back to a "Triaged" state for Hardy. "Incomplete" implies there is not enough information to resolve the bug for Hardy which is not the case.

@Ethan, please provide evidence that this is not resolved in Jaunty. Ie I'd like to see the output of "mount" to prove you have a mounted CIFS directory and then recreate Stefan's test case he has documented in the bug description. The reason I say this is because the patch referenced here to resolve this issue is already in the Jaunty kernel. Thanks.

Changed in linux:
status: Incomplete → Triaged

Per a decision made by the Ubuntu Kernel Team, bugs will longer be assigned to the ubuntu-kernel-team in Launchpad as part of the bug triage process. The ubuntu-kernel-team is being unassigned from this bug report. Refer to https://wiki.ubuntu.com/KernelTeamBugPolicies for more information. Thanks.

Just posting a response I got from Ethan:

"Actually, I just found out that doing the cp as root *will* preserve
timestamps, so my problem is in gvfs, not cifs. I've got the same
directory mounted via GNOME's "Places menu/Connect to server/Windows
Share" and I can't copy to the VFS directory while preserving
timestamps."

Steve Langasek (vorlon) on 2009-01-23
Changed in linux:
milestone: ubuntu-8.04.2 → ubuntu-8.04.3
Stefan Bader (smb) on 2009-06-08
Changed in linux (Ubuntu Hardy):
assignee: nobody → Stefan Bader (stefan-bader-canonical)
Stefan Bader (smb) wrote :

The current status on this is: there seem to be two problems:
- cifs mount
- fuse mount (done through gui)

Both seem not to be fixed in the current version. Needing further debugging. Given that I remove the milestone for the Hardy release for the time being.

Changed in linux (Ubuntu Hardy):
milestone: ubuntu-8.04.3 → ubuntu-8.04.4
Stefan Bader (smb) wrote :

Setting this back to triaged as the following is still failing on 2.6.30-999-generic:

#> ls -l
total 4
-rw-r--r-- 1 stefan stefan 6 2009-06-19 10:18 a
-rw-r--r-- 1 stefan stefan 0 2009-06-19 10:18 b

#> sudo mount -tcifs -ocredentials=../<cred> //<server>/public /mnt
#> mkdir /mnt/Test
#> cp -a * /mnt/Test/
cp: setting permissions for `/mnt/Test/a': Permission denied
cp: setting permissions for `/mnt/Test/b': Permission denied
#> ls -la /mnt/Test/
total 4
drwxr-xr-x 2 stefan stefan 0 2009-06-19 10:26 .
drwxr-xr-x 9 stefan users 0 2009-06-19 10:26 ..
-rwx------ 1 stefan stefan 6 2009-06-19 10:26 a
-rw------- 1 stefan stefan 0 2009-06-19 10:18 b

So, access rights seem to change (execute bit for file is set and group and other rights get dropped) and the timestamp is only used for the empy file.

Changed in linux (Ubuntu):
assignee: nobody → Stefan Bader (stefan-bader-canonical)
status: Fix Released → Triaged
importance: Undecided → Medium
Stefan Bader (smb) wrote :

To decide whether this is rather a server or client side problem, the same test done on a current Hardy client (the server is Jaunty in both cases):

#> ls -la
total 12
drwxr-xr-x 2 stefan stefan 4096 2009-06-19 10:37 .
drwxr-xr-x 99 stefan stefan 4096 2009-06-19 10:37 ..
-rw-r--r-- 1 stefan stefan 6 2009-06-19 10:37 a
-rw-r--r-- 1 stefan stefan 0 2009-06-19 10:37 b
#> cp -a * /mnt/Test/
#> ls -la /mnt/Test/
total 1024
drwxr-xr-x 2 stefan stefan 0 2009-06-19 10:38 .
drwxr-xr-x 9 stefan users 0 2009-06-19 10:26 ..
-rw-r--r-- 1 stefan stefan 6 2009-06-19 10:38 a
-rw-r--r-- 1 stefan stefan 0 2009-06-19 10:37 b

So at least the bad access rights and the error on cp are a regression since Hardy. The fact that the timestamp is only preserved for empty files seems to be consistent between both.

Steve Langasek (vorlon) wrote :

Stefan, is this still realistically a target for ubuntu 8.04.4 (the last 8.04 LTS point release that's scheduled)? It sounds like we don't have a fix even in the latest kernels, so backporting isn't an option?

Steve Langasek wrote:
> Stefan, is this still realistically a target for ubuntu 8.04.4 (the last
> 8.04 LTS point release that's scheduled)? It sounds like we don't have
> a fix even in the latest kernels, so backporting isn't an option?

Hm, no I think its rather unrealistic to assume we get a fix for that.
To be honest I have been distracted by other things to much to have even
checked whether the problem persists on the current Karmic or Lucid kernels.
We probably should take back the milestone.

Update, links and workaround:

This bug is still present on Jaunty 9.04 with the following versions:
$ uname -srvm
Linux 2.6.28-17-generic #58-Ubuntu SMP Tue Dec 1 18:57:07 UTC 2009 i686
$ mount.cifs -V
mount.cifs version: 1.12-3.3.2
$ dpkg -l coreutils
ii coreutils 6.10-6ubuntu1 The GNU core utilities
$ dpkg -l samba
ii samba 2:3.3.2-1ubuntu3.2 SMB/CIFS file, print, and login server for Unix

( remote Samba server is Debian version 3.0.24-6etch10 )

This bug seems to have been both a coreutils bug and a samba bug. However, both are supposed to be fixed now.
See these:
  http://bugzilla.kernel.org/show_bug.cgi?id=6127
  http://bugzilla.kernel.org/show_bug.cgi?id=8437
  https://bugzilla.samba.org/show_bug.cgi?id=6520

A workaround seems to be to disable unix extensions. I understand it can be done on the server side, but I do it only on the client side by using the "nounix" mount option ( mount -o nounix,... ).

Steve Langasek (vorlon) wrote :

Milestone dropped for hardy; and targeted for lucid, we should at least try to get this resolved for the next LTS...

Changed in linux (Ubuntu Hardy):
milestone: ubuntu-8.04.4 → none
Surbhi Palande (csurbhi) on 2010-03-09
Changed in linux (Ubuntu Lucid):
assignee: Stefan Bader (stefan-bader-canonical) → Surbhi Palande (csurbhi)
Surbhi Palande (csurbhi) on 2010-03-15
Changed in linux (Ubuntu Lucid):
status: Triaged → In Progress
Surbhi Palande (csurbhi) wrote :

I cannot see the "The original mtime is not preserved after a file is copied to a mounted CIFS directory" in karmic/lucid (have not checked on the previous releases). However, I can still see the "permission denied" message on the cp -p. This message leads to a change in permissions. This is a bug in samba server in (set_unix_posix_default_acl() ). I will send a patch on the appropriate list soon.

Surbhi Palande (csurbhi) on 2010-03-15
summary: - cp -p on CIFS mount does not preserve timestamp
+ cp -p on CIFS mount does not preserve permissions and returns a
+ permission denied error
Surbhi Palande (csurbhi) wrote :

This is a bug in the samba server. Hence changing the package from linux to samba. I have attached a samba server patch and done brief testing with it.

affects: linux (Ubuntu Lucid) → samba (Ubuntu Lucid)
tags: added: patch
Thierry Carrez (ttx) wrote :

@Surbhi: Could you file a bug in upstream bugzilla (https://bugzilla.samba.org) to get some review on the bug and proposed patch ? If that's already done, please link the upstream bug here :)

Surbhi Palande (csurbhi) wrote :

Please ignore the above patch. A new resolution seems to be coming up. This was discussed on the samba-technical mailing list.

Thierry Carrez (ttx) wrote :

@Surbhi: any news ?

tags: added: patch-forwarded-upstream
Chuck Short (zulcss) wrote :

any news?

Chuck Short (zulcss) on 2010-08-11
Changed in samba (Ubuntu Hardy):
assignee: Stefan Bader (stefan-bader-canonical) → nobody
Changed in samba (Ubuntu Lucid):
assignee: Surbhi Palande (csurbhi) → nobody
Surbhi Palande (csurbhi) wrote :

I have kept a PPA "samba" at: https://launchpad.net/~csurbhi/+archive/ppa/
Can someone try it out and confirm if it works for them or not. If it is confirmed, I will resend this fix to the samba devel mailing list and we can get it in Ubuntu. Thanks for your help.

john reid (reidjr) wrote :

Surbhi,

Fix works for me. I haven't done extensive testing, so don't know if it breaks anything else, but the permissions problem is fixed.

excellent !

Launchpad Janitor (janitor) wrote :

This bug was fixed in the package samba - 2:3.5.4~dfsg-1ubuntu3

---------------
samba (2:3.5.4~dfsg-1ubuntu3) maverick; urgency=low

  * Add the translation of Unix Error code -ENOTSUP to NT Error Code
    NT_STATUS_NOT_SUPPORTED to prevent the Permission denied error.
    (LP: #276472)
 -- Surbhi Palande <email address hidden> Mon, 16 Aug 2010 15:09:30 +0300

Changed in samba (Ubuntu):
status: In Progress → Fix Released
Stefan (stefanp) wrote :

This is a kernel bug and it is still not fixed in the latest Ubuntu 8.04 LTS.

/mnt/temp is a CIFS mount:

root@ubuntu8:~# cp -p /etc/services /mnt/temp/
root@ubuntu8:~# ls -la /etc/services /mnt/temp/services
-rw-r--r-- 1 root root 18274 2007-12-03 23:04 /etc/services
-rw-r--r-- 1 root root 18274 2011-04-13 16:00 /mnt/temp/services

root@ubuntu8:~# uname -a
Linux ubuntu8 2.6.24-29-server #1 SMP Wed Mar 16 20:29:36 UTC 2011 i686 GNU/Linux

Rolf Leggewie (r0lf) wrote :

Hardy has seen the end of its life and is no longer receiving any updates. Marking the Hardy task for this ticket as "Won't Fix".

Changed in samba (Ubuntu Hardy):
status: Triaged → Won't Fix
Rolf Leggewie (r0lf) wrote :

lucid has seen the end of its life and is no longer receiving any updates. Marking the lucid task for this ticket as "Won't Fix".

Changed in samba (Ubuntu Lucid):
status: In Progress → Won't Fix
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.