LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
LinkBack Search this Thread
Old 09-30-2008, 01:08 AM   #1
cdestiny
LQ Newbie
 
Registered: Jun 2007
Distribution: CentOS,Redhat
Posts: 25

Rep: Reputation: 15
Grant normal user to run certain script with root access


Hi,

Recently i have complain from user that the vnc session failed to create as the lock in /tmp/. The lock created eg: .X0-lock , .X1-lock . Only root can remove the lock.

So i have written a simple script for the user to trigger and remove the lock files.

Code:
#!/bin/sh

cd /tmp
ls -al | grep "\-lock" | awk '{print $9}' > /tmp/flist.txt
for i in `cat /tmp/flist.txt`
do
        cd /tmp
        rm -rf $i
done


echo "Finish flushing"
It running with root account.

So i visudo and add in the row
Code:
john ALL=NOPASSWD: /usr2/flush.sh
Then i su as john and run the flush script. These are the error message produced:

rm: cannot remove `.X0-lock': Operation not permitted
rm: cannot remove `.X1-lock': Operation not permitted


Please advice and let me know if i did something wrong. Thanks in advance.

Last edited by cdestiny; 09-30-2008 at 02:48 AM.
 
Old 09-30-2008, 01:23 AM   #2
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 59
Your script is dangerous, and will happily remove any files containing the letters "lock", such as "block", "clock", "someother.lock", and even ".X0-lock" as you've discovered. If you want to remove files named .lock*, simplify your entire script to the single command:

rm -f /tmp/.lock*
 
Old 09-30-2008, 01:51 AM   #3
cdestiny
LQ Newbie
 
Registered: Jun 2007
Distribution: CentOS,Redhat
Posts: 25

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by Mr. C. View Post
Your script is dangerous, and will happily remove any files containing the letters "lock", such as "block", "clock", "someother.lock", and even ".X0-lock" as you've discovered. If you want to remove files named .lock*, simplify your entire script to the single command:

rm -f /tmp/.lock*
Thanks for the reply.

I have edited my script on above.
The lock generated is usually X1-lock , not a .lock.
 
Old 09-30-2008, 01:54 AM   #4
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 59
I see. Your first post indicated "/tmp/.lock", so there's the disconnect.

Everything OK now?
 
Old 09-30-2008, 02:42 AM   #5
cdestiny
LQ Newbie
 
Registered: Jun 2007
Distribution: CentOS,Redhat
Posts: 25

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by Mr. C. View Post
I see. Your first post indicated "/tmp/.lock", so there's the disconnect.

Everything OK now?
Ah... i missed 1 important step. include sudo infront of the command......
It is now working. Thanks for your help.

Last edited by cdestiny; 09-30-2008 at 02:55 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to give root access to normal user for one day. unix_anand Linux - Security 3 10-14-2008 05:45 AM
providing the root access to normal user raghuvamsi Linux - General 3 06-11-2008 12:38 AM
how to run root command having normal user permission ravi.patil Linux - Newbie 7 05-21-2006 02:21 PM
Can you connect to internet as normal user without run pppd as root ? nasty_daemon Linux - Networking 2 09-13-2005 01:43 AM
Give Root Access To A Normal User waknauss Linux - Security 2 11-11-2004 09:00 AM


All times are GMT -5. The time now is 01:39 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration