Operating System - HP-UX
1827295 Members
4039 Online
109717 Solutions
New Discussion

swapinfo execute permission

 
Alex Lavrov.
Honored Contributor

swapinfo execute permission

Hello, I created a user named alex, and when I'm logged in with this user, I have permission to run swapinfo, so I wrote a script that runs and calculate some values from swapinfo, but for some reason inside the script I get:
/usr/sbin/swapinfo: Execute permission denied.

I can run swapinfo as alex, but can't run it in the script? If so, how can I calculate swap utilization if I'm not root? (this script should not run as root).

thanx.
I don't give a damn for a man that can only spell a word one way. (M. Twain)
8 REPLIES 8
Jannik
Honored Contributor

Re: swapinfo execute permission

swapinfo:
-r-xr-xr-- 1 bin bin 24576 Feb 5 2001 /usr/sbin/swapinfo

so you need to be able to execute as bin group, ade alex user to bin group or du a:

chmod 555 /usr/sbin/swapinfo
jaton
Alex Lavrov.
Honored Contributor

Re: swapinfo execute permission

In my system:
-r-xr--r-x 1 bin bin 20480 Nov 9 2000 /usr/sbin/swapinfo

And it still does not explain why can I run it in shell and not in script.

thanx.
I don't give a damn for a man that can only spell a word one way. (M. Twain)
Victor BERRIDGE
Honored Contributor

Re: swapinfo execute permission

Hi,
I dont know your context, but for some security reason the execution of swapinfo were modified...
Now it can be in your script you have something not set...( PATH seems OK since /usr/sbin/swapinfo shows out). I dont undestand why execution was removed from group bin though...
You could make a copy of swapinfo where youre script is give alex full perms on it, change the name if you wish and see if it works now but dont forget to add its path in the script.

All the best
Victor
Kent Ostby
Honored Contributor

Re: swapinfo execute permission

Alex -- Check the path variable in the script . Is it set ?

Can you post the script here (from start to the swapinfo call at least) so we can take a look ?

Oz
"Well, actually, she is a rocket scientist" -- Steve Martin in "Roxanne"
Steven E. Protter
Exalted Contributor

Re: swapinfo execute permission

It may be some other command in your script or the permissions of the script or a script called that gives you the permission denied messge.

If you don't want root running this script, add logic to the top that forces an exit if the user is root.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Peter Godron
Honored Contributor

Re: swapinfo execute permission

Alex,
just to check through your script add
set -x
at the top and trace through the output.
Compare the out put of "env" from the command line and the script for differences.
Regards
Stephen Keane
Honored Contributor

Re: swapinfo execute permission

If you do

which swapinfo

as you, in shell, not in a script
do you get /usr/sbin/swapinfo ? If not, that would explain your eror, if you have a local copy of swapinfo on your PATH, but not in the PATH in the script, so the script is picking up the 'real' swapinfo which doesn't have world execute permission on it.

As an aside, why do HP do this? If you have world read permissions on the file you can always make a local copy and chmod it, so unless the code is smart and can tell where it is being run from, it's hardly a security feature is it?
Alex Lavrov.
Honored Contributor

Re: swapinfo execute permission

Hello all,
I jut did chmod 555 and it worked, something weird, but the problem is solved.
I did not want to do it, bt had no choise.


Thanx for the replies.
I don't give a damn for a man that can only spell a word one way. (M. Twain)