LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   Xp user opens file via Samba, but file is not locked after opening??? (https://www.linuxquestions.org/questions/linux-networking-3/xp-user-opens-file-via-samba-but-file-is-not-locked-after-opening-458705/)

marisdembovskis 06-27-2006 05:41 AM

Xp user opens file via Samba, but file is not locked after opening???
 
Hi, forum!

I have linux/windows network.

Problem:
When XP users edit the file, after moment I open the same file with Fedora, the file is not locked and also not read only! And I can write on Fedora this file, however XP users
are editing the file.

It shouldn't be so!


Is there solution for this, to lock the opened file?
So that other users can not write to it?
Any ideas from forum?

Thanks

Maris

jschiwal 06-27-2006 09:56 PM

Read the section on Locks and Oplocks:
http://www.faqs.org/docs/samba/ch08.html

marisdembovskis 06-29-2006 02:57 AM

Thanks, jschiwal!
I read that link. And tried that all out. And my report to all is here below:


I test and play with all the lock variants
locking
strict locking
oplocks
veto oplock files
My configuration now:
oplocks = yes
level2 oplocks = Yes
strict locking = yes


And the situation is following:
I have Lin server + XP user + Lin user.

1.Xp user opens water.xls via Samba
2.Samba locks the file.
3.Lin user opens the file water.xls after 20 seconds via NFS.
4.As Samba has locked the file, Lin users see (water.xls READ ONLY)
SO far seems everything is working really FINE. Problems start when we go further on.
5.Lin users after 5 minutes tries to open water.xls to edit it, in the same time XP user is still working with it.
6.Lin user opens water.xls and it is WRITABLE. , however XP user still edits it.
7.The result is corrupted file, not saved file, information lost for XP user, time lost for XP user.
What happened?

Problem:


Samba locks the file fine, however after one Lin user try to open the file lock is broken by Lin user. So next time Lin users opens the file – file is not locked, because samba lock ir broken.
But Samba lock is made: by XP user opening file or by XP user saving file.
So for example, to ensure that file is locked Xp user needs to save file each time (it locks file again, if it was unlocked), when Lin user opens the file (unlocks it).


It is is possible to open file on Lin first time Read Only, then close it. And after a three seconds open it and now it is writable. So Lin user can hack the file just with two times opening the locked file. Not good, right? In real life it means: that file is editing Xp user, then comes Lin user first time, after a time Lin users hopes, that file is not edited any more and he opens the file, however in 30% the file is still editing by XP user. The Lin users does changes and save all, but XP user looses his job.


Thanks for help to everyone!
Are there any ideas how to solve this?

Maris

jschiwal 06-30-2006 12:12 AM

You said that the Linux user opened the file using NFS. NFS is different from Samba. If it is a Samba server, do you need both? If you have the linux users' home pages on this server, then the answer may be yes, but you don't need to offer the same directory as both a samba share and an NFS share.

You might also want to look into some sort of revision control system is several users edit the same files.

Here is a proposal for Unified File Locking: http://samba.osmirror.nl/samba/ftp/specs/UFL_spec.pdf

It is dated, but may explain the process and point you in the right direction. I found it entering a google search for the terms "samba nfs file locking interaction". There were several other search results as well.

marisdembovskis 06-30-2006 06:31 AM

Thanks, jschiwal for help.
About server, Yes, I need both of them.
On the server are documents, used by Win and Lin users. Lin users access them via NFS and Win users via Samba. And usually it so, XP users edit documents with 2003 MS office and Lin users edit the same documents with Ooo 2.02. Everything is really fine, except file locking.

Because we have a lot of cases, when at the same time document is accessed by different users.

I will try to look around.
and see what can I do.
I will post if I will succeed here.
need a lot of reading and googling.

jschiwal 06-30-2006 08:33 AM

Why couldn't Linux users access shares using samba instead of NFS? The locking problem is due to NFS. The NFS locks are advisory. I believe that the Samba locks are, or can be configured to be manditory.

marisdembovskis 07-03-2006 03:39 AM

Thanks for help.
Actually I could make everything through Samba, but then the problem is with Ooo. Saving, Viewing.
Because of this Linux users need NFS system to access the documents.

:)

you say, that NFS loks are stronger than Samba, is there a way how to make NFS looking and accepting Samba locks and not breaking them?

Thanks, anyway!

jschiwal 07-03-2006 05:12 AM

We may need to back up a bit. Here is a more recent document concerning CIFS and NFS.
http://www.redbooks.ibm.com/redpapers/pdfs/redp4176.pdf

It mentions that NFSV4 provides whole file locking, and not just byte-range locking. Which version of nfs is your system(s) using? How old is your kernel?

Take a look in your running kernel's .config file:
#
# Network File Systems
#
CONFIG_NFS_FS=m
CONFIG_NFS_V3=y
CONFIG_NFS_V3_ACL=y
CONFIG_NFS_V4=y
CONFIG_NFS_DIRECTIO=y
CONFIG_NFSD=m
CONFIG_NFSD_V2_ACL=y
CONFIG_NFSD_V3=y
CONFIG_NFSD_V3_ACL=y
CONFIG_NFSD_V4=y
CONFIG_NFSD_TCP=y
CONFIG_LOCKD=m
CONFIG_LOCKD_V4=y
CONFIG_EXPORTFS=m
CONFIG_NFS_ACL_SUPPORT=m
CONFIG_NFS_COMMON=y

Is NFS Version 4 enabled.

The manpage for lockd states that all it does is start the NFS Lock Manager (NLM) in the kernel, which most kernels start anyway, so lockd isn't needed anymore, but it doesn't hurt starting it.


The book "UNIX Filesystems--Evolution, Design, and Implementation" describes a mandatory locking hack. Mandatory locking can be enabled on a file if the set group ID bit is set, and the execute bit is cleared. Probably not too usefull, sorry. Your best bet may be to look into the features of NFS V4.
Try the sourceforge home page: http://nfs.sourceforge.net/

marisdembovskis 07-04-2006 03:30 AM

NFS works!!!
 
I solved the problem, with installing SFU.

Instal SFU35SEL_EN.exe (it is MIcrosoft utility for Win clients tu understand UNIX). Package was !!! 217 MB !!!

http://www.microsoft.com/technet/int...u/default.mspx
http://www.microsoft.com/windows/sfu...ds/default.asp
Installed in standart way.
So now Lin users can not break the lock if they open document couple times. File all the time is read only, except nobody is writing to it! (Specially Win users via Samba)




thanks, jschiwal!
I will also try you solution

Take a look in your running kernel's .config file:
#
# Network File Systems
#
CONFIG_NFS_FS=m
CONFIG_NFS_V3=y
CONFIG_NFS_V3_ACL=y
CONFIG_NFS_V4=y
CONFIG_NFS_DIRECTIO=y
CONFIG_NFSD=m
CONFIG_NFSD_V2_ACL=y
CONFIG_NFSD_V3=y
CONFIG_NFSD_V3_ACL=y
CONFIG_NFSD_V4=y
CONFIG_NFSD_TCP=y
CONFIG_LOCKD=m
CONFIG_LOCKD_V4=y
CONFIG_EXPORTFS=m
CONFIG_NFS_ACL_SUPPORT=m
CONFIG_NFS_COMMON=y


Thanks a lot!
I'm really :)!


Now I only need to create automatic backup solution (still dont know, how it will look like) but then win/lin network will be integrated. (and now it seems it took 3-5 months to make all from scratch)

:)

Maris


All times are GMT -5. The time now is 07:39 AM.