Solaris / OpenSolaris This forum is for the discussion of Solaris and OpenSolaris.
General Sun, SunOS and Sparc related questions also go here. |
| Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
11-15-2010, 02:10 AM
|
#1
|
|
LQ Newbie
Registered: Jun 2010
Posts: 9
Rep:
|
script needs su commands but is run by user
My system is as follows:-
System = SunOS
Node = pinn810-1
Release = 5.10
KernelID = Generic_118855-36
Machine = i86pc
I need to write a script that runs as a cron job but runs commands that require su privilages. OR that any (non su) user logging on can open a terminal shell and run the script. The script changing privilages on the fly to do the task. EG: If I have files ending with a certain extension in the login home directory, I would like any user logging on, to run a script that would delete the files. The script would have to be executable by the user but have 'su' rights to delete the files. I know I can use the chmod command to set file privilages but I believe the script needs to change ownership to a 'su', do the job, then change back again to the user.
Thanks and regards
Last edited by mervclel; 11-15-2010 at 02:12 AM.
|
|
|
|
11-15-2010, 11:51 AM
|
#2
|
|
Member
Registered: Apr 2004
Location: Oxford, UK
Distribution: Ubuntu, Debian, various
Posts: 229
Rep:
|
Hi,
In general, if you have a setup where files are being left in a user's home directory with permissions such that the user is unable to delete them, the problem is with the files being created with the wrong permissions in the first place. However, if you want to just work around the problem as you described then what you want, I believe, is "sudo". ( http://www.gratisoft.us/sudo/)
Sudo is a standard part of Linux distros nowadays but also supported on Solaris,SunOS etc. It gives you very fine control over who can run privileged processes, what they can run and if they are authenticated by password. The sudo documentation should explain the setup better than I can, so I won't go into that here.
Hope that helps.
TIM
|
|
|
|
11-15-2010, 12:02 PM
|
#3
|
|
Senior Member
Registered: Mar 2004
Location: Cary, NC, USA
Distribution: Fedora, Kubuntu, RedHat, CentOS, SuSe
Posts: 1,288
Rep:
|
It doesn't matter what the permissions are on files in a user's home directory. If the user owns his home directory, and is able to write to the directory, he is able to delete ANY files in it no matter who owns them.
Try this:
Code:
% ls -la asdf.txt
ls: cannot access asdf.txt: No such file or directory
% sudo touch asdf.txt
% ls -la asdf.txt
-rw-r--r--. 1 root root 0 Nov 15 13:01 asdf.txt
% rm asdf.txt
rm: remove write-protected regular empty file `asdf.txt'? y
% ls -la asdf.txt
ls: cannot access asdf.txt: No such file or directory
%
HTH
Forrest
|
|
|
|
11-15-2010, 10:14 PM
|
#4
|
|
LQ 5k Club
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian Squeeze (server), Slackware 13.37 (netbook), Slackware64 14.0 (desktop),
Posts: 8,358
|
Quote:
Originally Posted by mervclel
I would like any user logging on, to run a script that would delete the files. The script would have to be executable by the user but have 'su' rights to delete the files. I know I can use the chmod command to set file privilages but I believe the script needs to change ownership to a 'su', do the job, then change back again to the user.
|
Sounds messy and scary. Are these files readable by the ordinary user? If so they could make a copy of them, remove the original and do whatever they want with the copy. An alternative approach would be for a script run by root's cron to look for these files and change owner, group and permissions as required. The best solution would be to stop these files being created ... ?
Last edited by catkin; 11-15-2010 at 10:14 PM.
Reason: Tidying
|
|
|
|
11-24-2010, 09:18 PM
|
#5
|
|
LQ Newbie
Registered: Jun 2010
Posts: 9
Original Poster
Rep:
|
Thanks for your replies. You are right about the owner being able to delete the files. The tar files are generated when the user restores archived data from an ext RAID. The application running then converts the file into useful info for analysis. The issue has been that these files never get deleted and this has on occasion pushed the home folder to 100%. major issues. I did some further testing yesterday and think I have it beaten. My issue has been that I haven't been putting the full path in a rm command within a cron job script. I did this manually and it worked. So my cron job will run monday night. So I will check on Tuesday morning. Hope this will be the end of it.
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 02:17 AM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|