Dmitriy Tarasov
Verified User
- Joined
- Nov 5, 2006
- Messages
- 43
Hello.
I have /tmp mounted with noexec, nosuid so If I try to run file
test.sh:
#!/bin/sh
echo "running"
in the following way
/tmp/test.sh
I get
-bash: /tmp/test.sh: /bin/sh: bad interpreter: Permission denied
but If I run it so
/bin/sh /tmp/test.sh
I get
running
I have found script that prevent it. Here it is:
#!/bin/sh
DIR4PROTECT="/tmp"
for dir in `cat $DIR4PROTECT`;do
FILE2DELETE=`find $dir -perm +1111 -print`
for file in `echo $FILE2DELETE`;do
if [ -f $file ];then
chmod 0000 $file
chown root.root $file
fi
done
done
But when I run It I get:
Cat: /tmp: Is a directory
And nothing else.
I don not know shell programming.
Could you, please, advise me how to make that script working.
I have /tmp mounted with noexec, nosuid so If I try to run file
test.sh:
#!/bin/sh
echo "running"
in the following way
/tmp/test.sh
I get
-bash: /tmp/test.sh: /bin/sh: bad interpreter: Permission denied
but If I run it so
/bin/sh /tmp/test.sh
I get
running
I have found script that prevent it. Here it is:
#!/bin/sh
DIR4PROTECT="/tmp"
for dir in `cat $DIR4PROTECT`;do
FILE2DELETE=`find $dir -perm +1111 -print`
for file in `echo $FILE2DELETE`;do
if [ -f $file ];then
chmod 0000 $file
chown root.root $file
fi
done
done
But when I run It I get:
Cat: /tmp: Is a directory
And nothing else.
I don not know shell programming.
Could you, please, advise me how to make that script working.