Weird permission problem

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
User avatar
WillemDH
Posts: 2320
Joined: Wed Mar 20, 2013 5:49 am
Location: Ghent
Contact:

Weird permission problem

Post by WillemDH »

Hello,

I have a weird permission problem with the /usr/local/nagios/libexec folder on my XI server. So I made a Reactor chain which updates the libexec scripts folder with the latest versions of plugins etc.

These were the original permissions:

Code: Select all

ls -la /usr/local/nagios/libexec
total 12376
drwxrwxr-x.  6 apache     nagios   12288 May 20 15:42 .
drwxr-xr-x.  9 root       root      4096 Jun 12  2014 ..
The user Reactor is uing to do stuff is called sysreactor. This user is in the nagios group:

Code: Select all

grep sysreactor /etc/group
nagios:x:500:nagios,apache,snmptt,sysreactor
The Reactor chain executes this command over SSH with the sysreactor user:

Code: Select all

/bin/cp -r /mnt/naf/scripts/* /usr/local/nagios/libexec/
But I'm getting this error:

Code: Select all

/bin/cp: cannot create regular file `/usr/local/nagios/libexec/check_lin_updates.py': Permission denied
This is already weird as the sysreactor user in the group and the nagios group has 7 as permissions, so it should be able to write files?
As a test I tried giving 777 to /usr/local/nagios/libexec

Code: Select all

ls -la /usr/local/nagios/libexec
total 12376
drwxrwxrwx.  6 apache     nagios   12288 May 20 15:42 .
drwxr-xr-x.  9 root       root      4096 Jun 12  2014 ..
Then tried again with same 'Permission denied' result. What could be causing this beahviour? On other servers with identical permissions (eg nls) this chains works perfect...

Grtz

Willem
Nagios XI 5.8.1
https://outsideit.net
User avatar
BanditBBS
Posts: 2474
Joined: Tue May 31, 2011 12:57 pm
Location: Scio, OH
Contact:

Re: Weird permission problem

Post by BanditBBS »

Willem, here are my perms:

Code: Select all

[root@iss-chi-nag05 ~]# ls -la /usr/local/nagios/libexec
total 13608
drwxrwsr-x 4 apache nagios   16384 May 19 16:28 .
drwxr-xr-x 9 nagios nagios    4096 Nov  9  2015 ..
2 of XI5.6.14 Prod/DR/DEV - Nagios LogServer 2 Nodes
See my projects on the Exchange at BanditBBS - Also check out my Nagios stuff on my personal page at Bandit's Home and at github
User avatar
WillemDH
Posts: 2320
Joined: Wed Mar 20, 2013 5:49 am
Location: Ghent
Contact:

Re: Weird permission problem

Post by WillemDH »

Tx Bandit,

These were in fact the original permissions like mine. My first code block was a bit wrong.

Code: Select all

ls -la /usr/local/nagios/libexec
total 12376
drwxrwsr-x.  6 apache     nagios   12288 May 20 15:42 .
drwxr-xr-x.  9 root       root      4096 Jun 12  2014 ..
I still have no clue though what's going on here.. I removed the s with chmod g-s [name] as a test, but I'm having the same issue with all. I even gave 777 to /usr/local/nagios/libexec and it still didn't work...

I just need to be able to create files in that directory with the sysreactor use. So why is this not possible then, seeing that sysreactor is in the nagios group?

Grtz
Nagios XI 5.8.1
https://outsideit.net
User avatar
hsmith
Agent Smith
Posts: 3539
Joined: Thu Jul 30, 2015 11:09 am
Location: 127.0.0.1
Contact:

Re: Weird permission problem

Post by hsmith »

Just a thought.. what are the permissions of the source file that user is trying to copy it from?

Can the sysreactor user touch files to the directory normally?
Former Nagios Employee.
me.
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: Weird permission problem

Post by tgriep »

Does the file

Code: Select all

/usr/local/nagios/libexec/check_lin_updates.py
Already exist in the folder and it is having issues over writing it?
Be sure to check out our Knowledgebase for helpful articles and solutions!
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: Weird permission problem

Post by ssax »

Have you validated that it is indeed doing it as the sysreactor user? Can you the SSH exec whoami into a file in /tmp or something?
User avatar
WillemDH
Posts: 2320
Joined: Wed Mar 20, 2013 5:49 am
Location: Ghent
Contact:

Re: Weird permission problem

Post by WillemDH »

Already exist in the folder and it is having issues over writing it?
No the file doesn't exist
Have you validated that it is indeed doing it as the sysreactor user?
I have tried executing the cp command after logging in as the user sysreactor on the server with

Code: Select all

su sysreactor
Same problem
Nagios XI 5.8.1
https://outsideit.net
User avatar
WillemDH
Posts: 2320
Joined: Wed Mar 20, 2013 5:49 am
Location: Ghent
Contact:

Re: Weird permission problem

Post by WillemDH »

Ha I found the problem. The issue is that the userid of the sysreactor user on the mounted naf was different then the one on the Nagios server.... This becasue starting from CentOS 7 enw users are created default with an id above 1000 and in CentOS 6 user id's start from 500. I had to make a script which changes the ifd of the user to match the one on the mounted volume.
For user starting with Reactor, it could be useful to mention this in a 'getting started' guide. Automation is best done with a separate non-root user. But the user id , primary and secondary group id of this user and related groups should be identical on all servers to prevent this kind of issues. (and be in the 1000+ range)

Thread can be closed.
Nagios XI 5.8.1
https://outsideit.net
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: Weird permission problem

Post by mcapra »

Glad you were able to resolve the issue! Locking this up
Former Nagios employee
https://www.mcapra.com/
Locked