3

SYSTEM: CentOS release 6.2 (Final)

I am attempting to allow only users of a certain group lets call it websupport access to restart 2 services: mysqld and httpd

EDIT: I do not want to give these users sudo access

I have added these lines to /etc/sudoers:

%websupport ALL=NOPASSWD:/etc/init.d/httpd

and

%websupport ALL=NOPASSWD:/etc/init.d/mysqld

When logged in as the user and attempting to run:

/etc/init.d/httpd restart

I get this result:

rm: cannot remove '/var/run/httpd/httpd.pid': Permission Denied [FAILED]
rm: cannot remove '/var/lock/subsys/httpd' : Permission Denied
rm: cannot remove '/var/run/httpd/httpd.pid' : Permission Denied
Starting httpd: httpd: apr_sockaddr_info_get() failed for wssapache
httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
(13)Permission denied: make_sock: could not bind to address [::]:80
(13)Permission denied: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs [FAILED]

When attempting to run:

/etc/init.d/mysqld restart

I get this result:

cat: /var/run/mysqld/mysqld.pid: Permission denied Stopping mysqld: [FAILED]
Starting mysqld: [ OK ]

1 Answer 1

6

The entries in your sudoers look ok. What you need to so is use sudo to run the command e.g.

sudo etc/init.d/httpd restart

and

sudo etc/init.d/mysqld restart

You can combine the entries in sudoers too

%websupport ALL=NOPASSWD:/etc/init.d/mysqld, /etc/init.d/httpd
3
  • The point is to NOT give them sudo access and only give them access to restart/stop/start those services
    – Phickey
    Jul 3, 2012 at 16:52
  • 1
    @Phickey: You are misunderstanding the way sudo works. Using the scheme you outline and sudo they will only have access to the commands listed,
    – user9517
    Jul 3, 2012 at 16:57
  • 1
    @lain: you are totally right. Just worked like you said. Thanks!
    – Phickey
    Jul 3, 2012 at 17:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .