-1

I am running into a file permissions error when a custom python script is running as a service check, but when I run the script from the bash shell it runs fine. Here is more information on how this script is setup.

  • The script is intended to export data from nagios to another application
  • I have the remote smb share mounted with uid and gid set to a user which should have the correct permissions
  • Im using python 2.7.3 command txt = open(os.path.join("path/to/file","filename-to-open.txt"), "w") This is the line that throws the error.
  • Im using nagios version 4.0.8
  • nagios is running on a linux system and the target directory is also on a linux system

Any suggestions would be great.

  • There is very little information here that can help us to help you. For example, what are the permissions on the file being accessed, and all directories leading up to it? What user is running the process, and what groups are they in? – womble Sep 11 '15 at 2:53
0

Just so that if someone stumbles on this thread while searching for similar problems. It turns out the problem was with my samba.conf. This is what I started with.

force user = anadminuser
force group = users
inherit permissions = yes

This is a share where everyone can read and write but I had to change it. The parent folder of the share was setup as anadminuser as the owner and users as the group owner. I thought the inherit permissions directive would take care of all subfolder etc created on this share. However, I started to suspect that one or more settings in the global section of the samba.conf were dictating what permissions got applied (I dont know exactly which). Normally windows users access this share and the permissions were working just fine, but when a linux users connect I get different behaivor. So I added two lines.

force user = anadminuser
force group = users
force create mask = 0666
force directory mask = 0777
inherit permissions = yes

Evidently its most always a good idea that if your going to force users and groups then you probably want to force the create and directory masks as well. Otherwise you end up with the right owner and group on items created but the permissions will not always be what you expected.

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.