0

I have some python scripts that are on a Samba server. I first used them under Windows and now want to use them on a Linux machine. Therefore I mounted the server folder on my Linux machine (Kubuntu 16.04) using the following:

sudo mount -t cifs //[IP address]/Share Share -o username=guest

Now I want to run the python files in this share directory on the Linux machine. A problem arises when python has to write to files in this directory (I create .PNG files and write to a .CSV file to log my results):

IOError: [Errno 13] Permission denied: 'filename.png'

This makes kind of sense... The permissions of such files are:

-rw-rw-r--+ 1 nobody nogroup

The .PNG file I write to is actually created at that moment. So the result is an empty file with the permissions as above.

Permissions of the files that were already there (created on Windows) are:

-rwxrw-rw-+ 1 nobody nogroup

Can anyone help me out here?
I would want to be able to write to the file. It should still work/be accessible on the windows computer.

I am not sure where the problem is. I don't know why the files are owned by nobody, even if those files were just created. Then the reason for not being able to write to it is of course that the group permissions are read-only and the file is part of nogroup.

I access the same files on a Windows computer (which is not the server) and I can read and write and do whatever I want there just fine.

So my question is then, why are the files owned by nobody and part of nogroup and how do I fix this?

Iris
  • 101
  • Are you sure the share is not read-only? As the file has mode ugo+rw, the CIFS is declaring that anyone should be able to write to it (though obviously something denies the write when it is actually attempted). It makes sense that you can't chown since CIFS doesn't have the concept of file ownership. – DepressedDaniel Jan 10 '17 at 06:39
  • Sorry if this is a stupid question/reply, but I think not. I access the same files on a Windows computer (which is not the server) and I can read and write and do whatever I want there just fine.. – Iris Jan 10 '17 at 06:45
  • Well, that's new info that was not in your question. Then the reason for not being able to write to it is of course that the group permissions are read-only this is not accurate with respect to the rest of the question which says that the permissions are -rw-rw-rw- which clearly means anyone can read and write. – DepressedDaniel Jan 10 '17 at 21:35
  • That edit and your first comment were made at the same time approximately, so I think you didn't see it then. You are right though, there was a mistake in my question, it had a w too many. I fixed that now – Iris Jan 11 '17 at 00:44
  • 1
    @DepressedDaniel CIFS does have ownership. And groups. And permissions. Lots of all of them. – Chris Davies Jan 11 '17 at 00:56
  • Does that mean there's a way to fix the ownership in this network share folder? If so, could you tell me how? – Iris Jan 11 '17 at 01:02
  • I don't know what the + means, sorry about that. The permissions of the top most directory are drwxrwxrwx+ 13 root root. If I go down owner changes to nobody nogroup. However because of your question I just noticed some differences between directories so I'll go check on that now – Iris Jan 11 '17 at 01:34
  • @Christopher I tried your options but it doesn't seem to make a difference. I cannot use the fmask or dmask options. – Iris Jan 11 '17 at 02:41
  • Also the question has changed quite a bit by now. It is now more like 'How to access a Shared directory on a Samba server in Kubuntu?'. Should I edit the question or create a new one? – Iris Jan 11 '17 at 02:42
  • I edited the question – Iris Jan 11 '17 at 02:53
  • Solved!! Someone fixed it for me last night – Iris Jan 12 '17 at 00:33

1 Answers1

1

There are a number of possible issues here.

  • you mount the share as the guest user. If this account doesn't have sufficient permissions to create the file you'll hit problems
  • you don't use -o noperm, so the client tries to preempt permissions checking - as well as whatever the server wants to enforce
  • does the empty PNG file already exist, or can you be completely sure it's created by your script?
  • depending on whether the server is Windows or Samba you may have server-side filesystem permissions interacting with Windows permissions
Chris Davies
  • 116,213
  • 16
  • 160
  • 287
  • I also tried to mount with my username, there was no difference. I don't know the details about the server, that's a difficulty here. Also I'm really sure the PNG is created by my script – Iris Jan 11 '17 at 01:38
  • I just learned the server is on Samba. – Iris Jan 11 '17 at 01:45
  • @Iris please try the mount again but use username=guest,defaults,noperm as your options string. – Chris Davies Jan 11 '17 at 07:30
  • I just tried, the result is the same, unfortunately – Iris Jan 11 '17 at 08:05