Testing privileges -lock lockfile /var/lock/subsys/..- Permission denied

Hi all,

I have to test some user priviliges. The goal is to be sure that an unauthorized user can't restart some modules (ssh, mysql etc...).
I'm trying to automate it with a shell script but in same cases I got the syslog broadcast message.

Is there any way to simply get a return code (allowed or not) without see the broadcast message on all terminals?

Thanks in advance

It'd help to see what your script actually is.

Hi,

thx for reply.
This script is really basic here there's the section I was talking about:

RC=0
for command in ${forbidden_command_array[@]}; do
   $command
   RC1=$(($?-EXP_RET_CODE)) 

   let "RC=(($RC || $RC1))"
done 

so at the end if RC is equal to zero means that all return codes were equal to the expected ones.
One pratical example that doesn't work is the command:

if an unauthorized user try to execute that command I got back the message:

And the script stop its execution. To get the prompt back I have to type Ctrl-C.
The problem for me is that I would like simply to get back the return code to comprare with the expected one.

Any idea?
thx

Hi all,

Here I report the solution I found.
My goal was to test some user privileges and be sure that they can't start/stop/restart some services. My problem was that running the test for an unauthorized user I got back a message on the console, as consequences the script got stuck until I press enter to get the prompt back.

The solution (not the best but it works) is to temporary redirect (for the test time) all the logs messages, that refers to the services you're testing, to a log file.
I did it with rsyslog and filtering by program name, here the link:
Filtering by program name - rsyslog wiki
In this way the error goes to the file and it does not block the console

Hope this help

Cheers