Bug 5797 - Moving readonly files fails
Summary: Moving readonly files fails
Status: RESOLVED FIXED
Alias: None
Product: Samba 3.2
Classification: Unclassified
Component: File services (show other bugs)
Version: 3.2.4
Hardware: x86 Windows XP
: P3 major
Target Milestone: ---
Assignee: Jeremy Allison
QA Contact: Samba QA Contact
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-09-26 10:58 UTC by Sebastian Krysmanski
Modified: 2008-10-06 05:09 UTC (History)
0 users

See Also:


Attachments
Patch for 3.2.x. (611 bytes, patch)
2008-09-26 17:19 UTC, Jeremy Allison
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Sebastian Krysmanski 2008-09-26 10:58:36 UTC
I have the following configuration at home:

* Linux box (Debian 4.0): Samba Server
* Windows box (Windows XP SP3): Samba Client

On the linux box I have a file that is read-only:

  -r--r--r-- 1 apache servergroup 37 2008-09-26 16:48 dir-props

The directory that contains this file has the following rights:

  drwxr-xr-x 2 apache servergroup 4096 2008-09-26 17:09 .svn

This directory is accessable through a Samba share. The Samba configuration is:

  [global]
  netbios name = deepthought
  server string = Samba Server
  workgroup = Maya Group
  security = user
  encrypt passwords = yes
  smb passwd file = /srv/config/samba/smbpasswd
  guest ok = yes
  null passwords = no
  browsable = yes
  browse list = yes

  [server]
  path = /srv
  create mask = 0644
  directory mask = 0755
  valid users = manski
  force user = apache
  read only = no
  store dos attributes = no
  map read only = yes

The problem now is that I can't move/rename this file (dir-props) with the Windows API function "MoveFileEx()" through the Samba client as the file is read-only. I get an "ERROR_ACCESS_DENIED" (Code 5).

When I, however, try to do the same thing on a "native" share (i.e. from another Windows XP box) everything is fine (i.e. no error and the file is renamed afterwards).

So, I think you should change this behaviour to fit the one of "native" Windows shares. An example where this method is used is a Subversion client that tries to do a commit on a Samba share (which doesn't work).

To test this behaviour you may use the following C (maybe C++) code:

  #include <Stdio.h>
  #include <Tchar.h>
  #include <Windows.h>

  TCHAR* from_file = "Z:\\test.txt";
  TCHAR* to_file = "Z:\\test2.txt";

  int _tmain(int argc, _TCHAR* argv[])
  {
    printf("%s\n", from_file);
    if (MoveFileEx(from_file, to_file, MOVEFILE_REPLACE_EXISTING | MOVEFILE_COPY_ALLOWED)) 
    {
      printf("Good");
    } 
    else 
    {
      printf("Error: %d", GetLastError());
    }

    return 0;
  }

I hope this helps.
Comment 1 Jeremy Allison 2008-09-26 15:46:46 UTC
Can you attach the binary of this program as an attachment to this bug. I don't have quick access to a Windows C compiler at the moment. Also a debug level 10 log from smbd when this program fails would help.
Thanks,
Jeremy.
Comment 2 Jeremy Allison 2008-09-26 17:19:40 UTC
Created attachment 3639 [details]
Patch for 3.2.x.

Here's the patch for 3.2.x. Will be in the next release. Thanks !
Jeremy.
Comment 3 Karolin Seeger 2008-10-06 05:09:04 UTC
Marking bug as fixed.
Please re-open if it is still an issue.

Thanks for reporting!