Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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 ]

share|improve this question

1 Answer 1

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
share|improve this answer
    
The point is to NOT give them sudo access and only give them access to restart/stop/start those services –  Phickey Jul 3 '12 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, –  Iain Jul 3 '12 at 16:57
1  
@lain: you are totally right. Just worked like you said. Thanks! –  Phickey Jul 3 '12 at 17:02

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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