Page 2 of 2

Re: Configuration error after upgrade to 2.7

Posted: Mon Apr 27, 2015 1:30 pm
by lmiltchev
No, the nagios user doesn't have a password. It seems to me, this is a sudoers issue. Can you post the sudoers file, so that we can take a look at it? Also, do you have configs in the "/etc/sudoers.d/" directory?

Code: Select all

ll /etc/sudoers.d/
What is the output of the following command?

Code: Select all

visudo -c

Re: Configuration error after upgrade to 2.7

Posted: Mon Apr 27, 2015 2:02 pm
by JakeHatMacys
lmiltchev wrote:No, the nagios user doesn't have a password. It seems to me, this is a sudoers issue. Can you post the sudoers file, so that we can take a look at it? Also, do you have configs in the "/etc/sudoers.d/" directory?

Code: Select all

ll /etc/sudoers.d/
What is the output of the following command?

Code: Select all

visudo -c
The file is pretty big and has a lot of company specific entries. Any aspecs you want to see specifically? I would need to PM it if anything.

Code: Select all

[root@esu2v239 ~]# ll /etc/sudoers.d/
total 0

Code: Select all

[root@esu2v239 etc]# visudo -c
visudo: Warning: unused Cmnd_Alias SWLIST_HP
visudo: Warning: unused Host_Alias TWS_SYSTEMS_AIX
/etc/sudoers: parsed OK

Re: Configuration error after upgrade to 2.7

Posted: Mon Apr 27, 2015 2:37 pm
by lmiltchev
Here's a "sample" sudoers - you can compare it to yours:

Code: Select all

## Sudoers allows particular users to run various commands as
## the root user, without needing the root password.
##
## Examples are provided at the bottom of the file for collections
## of related commands, which can then be delegated out to particular
## users or groups.
##
## This file must be edited with the 'visudo' command.

## Host Aliases
## Groups of machines. You may prefer to use hostnames (perhaps using
## wildcards for entire domains) or IP addresses instead.
# Host_Alias     FILESERVERS = fs1, fs2
# Host_Alias     MAILSERVERS = smtp, smtp2

## User Aliases
## These aren't often necessary, as you can use regular groups
## (ie, from files, LDAP, NIS, etc) in this file - just use %groupname
## rather than USERALIAS
# User_Alias ADMINS = jsmith, mikem


## Command Aliases
## These are groups of related commands...

## Networking
# Cmnd_Alias NETWORKING = /sbin/route, /sbin/ifconfig, /bin/ping, /sbin/dhclient, /usr/bin/net, /sbin/iptables, /usr/bin/rfcomm, /usr/bin/wvdial, /sbin/iwconfig, /sbin/mii-tool

## Installation and management of software
# Cmnd_Alias SOFTWARE = /bin/rpm, /usr/bin/up2date, /usr/bin/yum

## Services
# Cmnd_Alias SERVICES = /sbin/service, /sbin/chkconfig

## Updating the locate database
# Cmnd_Alias LOCATE = /usr/bin/updatedb

## Storage
# Cmnd_Alias STORAGE = /sbin/fdisk, /sbin/sfdisk, /sbin/parted, /sbin/partprobe, /bin/mount, /bin/umount

## Delegating permissions
# Cmnd_Alias DELEGATING = /usr/sbin/visudo, /bin/chown, /bin/chmod, /bin/chgrp

## Processes
# Cmnd_Alias PROCESSES = /bin/nice, /bin/kill, /usr/bin/kill, /usr/bin/killall

## Drivers
# Cmnd_Alias DRIVERS = /sbin/modprobe

# Defaults specification

#
# Disable "ssh hostname sudo <cmd>", because it will show the password in clear.
#         You have to run "ssh -t hostname sudo <cmd>".
#
##################################################Defaults    requiretty

#
# Refuse to run if unable to disable echo on the tty. This setting should also be
# changed in order to be able to use sudo without a tty. See requiretty above.
#
Defaults   !visiblepw

#
# Preserving HOME has security implications since many programs
# use it when searching for configuration files. Note that HOME
# is already set when the the env_reset option is enabled, so
# this option is only effective for configurations where either
# env_reset is disabled or HOME is present in the env_keep list.
#
Defaults    always_set_home

Defaults    env_reset
Defaults    env_keep =  "COLORS DISPLAY HOSTNAME HISTSIZE INPUTRC KDEDIR LS_COLORS"
Defaults    env_keep += "MAIL PS1 PS2 QTDIR USERNAME LANG LC_ADDRESS LC_CTYPE"
Defaults    env_keep += "LC_COLLATE LC_IDENTIFICATION LC_MEASUREMENT LC_MESSAGES"
Defaults    env_keep += "LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER LC_TELEPHONE"
Defaults    env_keep += "LC_TIME LC_ALL LANGUAGE LINGUAS _XKB_CHARSET XAUTHORITY"

#
# Adding HOME to env_keep may enable a user to run unrestricted
# commands via sudo.
#
# Defaults   env_keep += "HOME"

Defaults    secure_path = /sbin:/bin:/usr/sbin:/usr/bin

## Next comes the main part: which users can run what software on
## which machines (the sudoers file can be shared between multiple
## systems).
## Syntax:
##
##      user    MACHINE=COMMANDS
##
## The COMMANDS section may have other options added to it.
##
## Allow root to run any commands anywhere
root    ALL=(ALL)       ALL

## Allows members of the 'sys' group to run networking, software,
## service management apps and more.
# %sys ALL = NETWORKING, SOFTWARE, SERVICES, STORAGE, DELEGATING, PROCESSES, LOCATE, DRIVERS

## Allows people in group wheel to run all commands
# %wheel        ALL=(ALL)       ALL

## Same thing without a password
# %wheel        ALL=(ALL)       NOPASSWD: ALL

## Allows members of the users group to mount and unmount the
## cdrom as root
# %users  ALL=/sbin/mount /mnt/cdrom, /sbin/umount /mnt/cdrom

## Allows members of the users group to shutdown this system
# %users  localhost=/sbin/shutdown -h now

## Read drop-in files from /etc/sudoers.d (the # here does not mean a comment)
#includedir /etc/sudoers.d

# NEEDED TO ALLOW NAGIOS TO CHECK SERVICE STATUS
Defaults:nagios !requiretty
nagios ALL=NOPASSWD: /usr/local/nagios/libexec/check_init_service
nagios ALL=NOPASSWD: /usr/local/nagiosxi/backup_xi.sh
nagios ALL=NOPASSWD: /usr/local/nagios/libexec/check_ora.sh

# ASTERISK-SPECIFIC CHECKS
# NOTE: You can uncomment the following line if you are monitoring Asterisk locally
#nagios ALL=NOPASSWD: /usr/local/nagios/libexec/check_asterisk_sip_peers.sh, /usr/local/nagios/libexec/nagisk.pl, /usr/sbin/asterisk

nagios ALL = NOPASSWD: /sbin/service

User_Alias      NAGIOSXI=nagios
User_Alias      NAGIOSXIWEB=apache
NAGIOSXI ALL = NOPASSWD:/etc/init.d/nagios start
NAGIOSXI ALL = NOPASSWD:/etc/init.d/nagios stop
NAGIOSXI ALL = NOPASSWD:/etc/init.d/nagios restart
NAGIOSXI ALL = NOPASSWD:/etc/init.d/nagios reload
NAGIOSXI ALL = NOPASSWD:/etc/init.d/nagios status
NAGIOSXI ALL = NOPASSWD:/etc/init.d/nagios checkconfig
NAGIOSXI ALL = NOPASSWD:/etc/init.d/ndo2db start
NAGIOSXI ALL = NOPASSWD:/etc/init.d/ndo2db stop
NAGIOSXI ALL = NOPASSWD:/etc/init.d/ndo2db restart
NAGIOSXI ALL = NOPASSWD:/etc/init.d/ndo2db reload
NAGIOSXI ALL = NOPASSWD:/etc/init.d/ndo2db status
NAGIOSXI ALL = NOPASSWD:/etc/init.d/npcd start
NAGIOSXI ALL = NOPASSWD:/etc/init.d/npcd stop
NAGIOSXI ALL = NOPASSWD:/etc/init.d/npcd restart
NAGIOSXI ALL = NOPASSWD:/etc/init.d/npcd reload
NAGIOSXI ALL = NOPASSWD:/etc/init.d/npcd status
NAGIOSXI ALL = NOPASSWD:/usr/bin/nmap *
NAGIOSXI ALL = NOPASSWD:/usr/local/nagiosxi/scripts/upgrade_to_latest.sh
NAGIOSXI ALL = NOPASSWD:/usr/local/nagiosxi/scripts/change_timezone.sh
NAGIOSXI ALL = NOPASSWD:/usr/local/nagiosxi/scripts/manage_services.sh *
NAGIOSXIWEB ALL = NOPASSWD:/usr/bin/tail -100 /var/log/messages
NAGIOSXIWEB ALL = NOPASSWD:/usr/bin/tail -100 /var/log/httpd/error_log
NAGIOSXIWEB ALL = NOPASSWD:/usr/bin/tail -100 /var/log/mysqld.log
NAGIOSXIWEB ALL = NOPASSWD:/usr/bin/nmap *
NAGIOSXIWEB ALL = NOPASSWD:/etc/init.d/snmptt restart
NAGIOSXIWEB ALL = NOPASSWD:/usr/local/nagiosxi/scripts/repair_databases.sh
NAGIOSXIWEB ALL = NOPASSWD:/usr/local/nagiosxi/scripts/manage_services.sh *
There may be some mods to the file - it's out of one of my test boxes. I am not sure if this is the "default" but it should give you an idea of what to look for.

Re: Configuration error after upgrade to 2.7

Posted: Mon Apr 27, 2015 3:48 pm
by BanditBBS

Re: Configuration error after upgrade to 2.7

Posted: Tue Apr 28, 2015 8:53 am
by JakeHatMacys
This is at the bottom of my sudoers file:

Code: Select all

User_Alias      NAGIOSXI=nagios
User_Alias              NAGIOSXIWEB=apache
NAGIOSXI ALL = NOPASSWD:/etc/init.d/nagios start
NAGIOSXI ALL = NOPASSWD:/etc/init.d/nagios stop
NAGIOSXI ALL = NOPASSWD:/etc/init.d/nagios restart
NAGIOSXI ALL = NOPASSWD:/etc/init.d/nagios reload
NAGIOSXI ALL = NOPASSWD:/etc/init.d/nagios status
NAGIOSXI ALL = NOPASSWD:/etc/init.d/nagios checkconfig
NAGIOSXI ALL = NOPASSWD:/etc/init.d/ndo2db start
NAGIOSXI ALL = NOPASSWD:/etc/init.d/ndo2db stop
NAGIOSXI ALL = NOPASSWD:/etc/init.d/ndo2db restart
NAGIOSXI ALL = NOPASSWD:/etc/init.d/ndo2db reload
NAGIOSXI ALL = NOPASSWD:/etc/init.d/ndo2db status
NAGIOSXI ALL = NOPASSWD:/etc/init.d/npcd start
NAGIOSXI ALL = NOPASSWD:/etc/init.d/npcd stop
NAGIOSXI ALL = NOPASSWD:/etc/init.d/npcd restart
NAGIOSXI ALL = NOPASSWD:/etc/init.d/npcd reload
NAGIOSXI ALL = NOPASSWD:/etc/init.d/npcd status
NAGIOSXI ALL = NOPASSWD:/usr/bin/nmap *
NAGIOSXI ALL = NOPASSWD:/usr/local/nagiosxi/scripts/upgrade_to_latest.sh
NAGIOSXI ALL = NOPASSWD:/usr/local/nagiosxi/scripts/change_timezone.sh
NAGIOSXI ALL = NOPASSWD:/usr/local/nagiosxi/scripts/manage_services.sh *
NAGIOSXIWEB ALL = NOPASSWD:/usr/bin/tail -100 /var/log/messages
NAGIOSXIWEB ALL = NOPASSWD:/usr/bin/tail -100 /var/log/httpd/error_log
NAGIOSXIWEB ALL = NOPASSWD:/usr/bin/tail -100 /var/log/mysqld.log
NAGIOSXIWEB ALL = NOPASSWD:/usr/bin/nmap *
NAGIOSXIWEB ALL = NOPASSWD:/etc/init.d/snmptt restart
NAGIOSXIWEB ALL = NOPASSWD:/usr/local/nagiosxi/scripts/repair_databases.sh
NAGIOSXIWEB ALL = NOPASSWD:/usr/local/nagiosxi/scripts/manage_services.sh *
Is that all I need or am I missing something?

Re: Configuration error after upgrade to 2.7

Posted: Tue Apr 28, 2015 9:21 am
by tgriep
Could you run the following to see if there is a password set for the nagios user? Post back the output please.

Code: Select all

grep nagios /etc/shadow
You also need to add these 2 lines in your sudoers file above the Nagios section.

Code: Select all

Defaults:nagios !requiretty
nagios ALL=NOPASSWD: /usr/local/nagios/libexec/check_init_service

Re: Configuration error after upgrade to 2.7

Posted: Tue Apr 28, 2015 11:59 am
by JakeHatMacys
tgriep wrote:Could you run the following to see if there is a password set for the nagios user? Post back the output please.

Code: Select all

grep nagios /etc/shadow
You also need to add these 2 lines in your sudoers file above the Nagios section.

Code: Select all

Defaults:nagios !requiretty
nagios ALL=NOPASSWD: /usr/local/nagios/libexec/check_init_service
I'm not sure what this means:

[root@esu2v239 etc]# grep nagios /etc/shadow
nagios:!!:16072:0:99999:7:::
You have new mail in /var/spool/mail/root
[root@esu2v239 etc]#

And okay i'll get that line added.

Re: Configuration error after upgrade to 2.7

Posted: Tue Apr 28, 2015 1:35 pm
by tgriep
The grep was for checking to see if the nagios account has a password set and yours do not have one set.
Let us know the outcome after you add the 2 lines.

Re: Configuration error after upgrade to 2.7

Posted: Fri May 01, 2015 12:29 pm
by JakeHatMacys
This is resolved, my Unix team added this to all our boxes, said they run SUDO a different way so none of the entries put in by the installation would have really worked:

Code: Select all

Defaults:nagios !requiretty

Host_Alias     NAGIOS = xxx1lxxx, xxx2vxxx, xxx2vxxx, xxx2vxxx, xxx2xxx  (took out box names)

Cmnd_Alias     NAGIOS=/usr/local/nagios/libexec/check_init_service, /etc/init.d/nagios *, /etc/init.d/ndo2db *, /etc/init.d/npcd *, /usr/bin/nmap *, /usr/local/nagiosxi/scripts/*
Cmnd_Alias     NAGIOSWEB = /usr/bin/tail -100 /var/log/messages, /usr/bin/tail -100 /var/log/httpd/error_log, /usr/bin/tail -100 /var/log/mysqld.log, /usr/bin/nmap *, /etc/init.d/snmptt restart, /usr/local/nagiosxi/scripts/*

nagios     NAGIOS = (root) NOPASSWD:NAGIOS
apache     NAGIOSWEB = (root) NOPASSWD:NAGIOSWEB

Re: Configuration error after upgrade to 2.7

Posted: Fri May 01, 2015 12:34 pm
by abrist
Great. You may want to pay attention to future version release notes in case we alter the behavior of our sudoer rules again as you have a non standard sudo environment.