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?

11
  • 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 6: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 6: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 0:44
  • 1
    @DepressedDaniel CIFS does have ownership. And groups. And permissions. Lots of all of them. – roaima Jan 11 '17 at 0:56
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
4
  • 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 1:38
  • I just learned the server is on Samba. – Iris Jan 11 '17 at 1:45
  • @Iris please try the mount again but use username=guest,defaults,noperm as your options string. – roaima Jan 11 '17 at 7:30
  • I just tried, the result is the same, unfortunately – Iris Jan 11 '17 at 8:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.