Operating System - HP-UX
1834926 Members
2708 Online
110071 Solutions
New Discussion

Re: how to restrict or kill if a user have more than one process?

 
SOLVED
Go to solution
Cem Tugrul
Esteemed Contributor

how to restrict or kill if a user have more than one process?

Hello Everybody,
i have BaaN Erp Software on my hp-ux11i and
BaaN clients installed on W2k-nt-xp machines
so they connect to system from a GUI.i have license problem so i want every users must have a single process so no chance to 2nd proc
if users try then want my system to logout 2nd
proc request...but how?
Please share your precious decisions...
Best Regards,
Our greatest duty in this life is to help others. And please, if you can't
11 REPLIES 11
Mark Grant
Honored Contributor

Re: how to restrict or kill if a user have more than one process?

This is fairly easy to do if you just want to stop people loggin in more than once but would be rather risky to do on the number of processes a user has. To do it on the number of logins you can just do something like

[ `who am i|wc -l` -gt 1 ] && exit

in the users .profile

However, doing it per process is going to be a problem because you can't be sure how many processes a user is going to use in a single session. Maybe the GUI forks off another process to do a bit of work from time to time.

Maybe I am mis-understanding you though, that does happen quite a lot :)
Never preceed any demonstration with anything more predictive than "watch this"
T G Manikandan
Honored Contributor

Re: how to restrict or kill if a user have more than one process?

Just give a try on this,

Just wrap the Baan startup file in a shell script and advise users to use that script to startup Baan.

like

x=`ps -ef|grep Bann|grep -v grep |wc -l`
if [ $x -eq 0 ]
then

else
echo you cannot start more than one Baan process
fi

RAC_1
Honored Contributor
Solution

Re: how to restrict or kill if a user have more than one process?

If your OS is 11.0 or upwards, you can control no. of loings through /etc/default/security file.

Add this line to the file
NO_LOGINS_ALLOWED=x

This applies to non-root users only.

Anil
There is no substitute to HARDWORK
Cem Tugrul
Esteemed Contributor

Re: how to restrict or kill if a user have more than one process?

Hi T G & Mark,
Thank's so much for your kind concern...
Here is my system specs below;

#ps -ef|egrep -i bshell|wc -l
131

#ps -ef|egrep -i bshell|sort -n
ut4eo 28986 28985 21 08:48:39 ? 7:14 bshell (ut4eo@MNTRANKPC000357:688/SOCKET) -1 545 0 1
ut4es 25537 25536 0 15:31:11 ? 0:00 bshell (ut4es@ma061ut4es:392/SOCKET) -1 545 0 1
ut4fk 3766 3764 4 13:48:25 ? 3:26 bshell (ut4fk@ma140ut4fk:496/SOCKET) -1 545 0 1
ut4ha 22610 22609 0 15:07:07 ? 0:03 bshell (ut4ha@MNTRANKTPC00353:1896/SOCKET) -1 545 0 1 -set BSE_
ut4ia 28105 28104 0 15:53:32 ? 0:00 bshell (ut4ia@ma023ut4ia:1100/SOCKET) -1 545 0 1
ut4me 3020 3019 0 13:42:13 ? 0:02 bshell (ut4me@mntranktpc00681:2140/SOCKET) -1 545 0 1
ut4me 4396 4395 0 13:54:22 ? 0:22 bshell (ut4me@mntrankpc000412:804/SOCKET) -1 545 0 1
ut4me 15502 15499 0 14:08:07 ? 1:00 bshell (ut4me@mntranktpc00683:824/SOCKET) -1 545 0 1
ut4me 21328 21327 0 14:56:06 ? 0:03 bshell (ut4me@mntrankpc000418:856/SOCKET) -1 545 0 1
ut4mk 28471 28470 4 15:55:32 ? 0:00 bshell (ut4mk@mntranktpc00409:195/SOCKET) -1 545 0 1 -set BSE_L
ut5aa 1706 1705 0 13:33:01 ? 1:00 bshell (ut5aa@mntranktpc00064:324/SOCKET) -1 545 0 1
ut5at 25077 25076 0 15:28:16 ? 0:00 bshell (ut5at@ma045ut5at:1636/SOCKET) -1 545 0 1
ut5ek 19511 19510 0 14:40:34 ? 2:48 bshell (ut5ek@mntrankpc000212:1324/SOCKET) -1 545 0 1
ut5ho 15924 15923 0 14:10:30 ? 0:52 bshell (ut5ho@mntranktpc00712:836/SOCKET) -1 545 0 1
ut5md 28198 28196 2 15:54:38 ? 0:00 bshell (ut5md@ma045ut5md:1400/SOCKET) -1 545 0 1
ut5oa 25747 25744 0 15:33:50 ? 0:01 bshell (ut5oa@mntranktpc00507:1036/SOCKET) -1 545 0 1
ut5sk 26652 26651 0 08:21:26 ? 0:13 bshell (ut5sk@ma011ut5sk:96/SOCKET) -1 545 0 1

As you seen BaaN depends on proc name bshell..
i have put some restriction lines in users .profile file but not executed!!!!
they are still able to logon system...
via telnet i have written a syntax below;

num=1
if [ $( who | grep -c $LOGNAME ) -gt $num ]
then
echo you can not logon system because
you have still proc at least!!!
exit 1
fi
it works!!! but users have a BaaN client GUI software installed on their PC's and there is
configuration menu like;
Host name:ip adress of my hp-ux
Connect As:login(hp-ux loginname)
BShell Env;
BSE:/baan/bse(hp-ux path)
BShell name:bshell
Command:

So all settings that i have...
Our greatest duty in this life is to help others. And please, if you can't
Roberto Polli
Trusted Contributor

Re: how to restrict or kill if a user have more than one process?

For me RAC solution is the better one.

Peace, R.
Cem Tugrul
Esteemed Contributor

Re: how to restrict or kill if a user have more than one process?

Hi Roberta,
Could you please try to give brief detail about
RAC?i do not have any information...

Best Regards,
Our greatest duty in this life is to help others. And please, if you can't
Cem Tugrul
Esteemed Contributor

Re: how to restrict or kill if a user have more than one process?

if i can able to run a script named 2.sh like below every seconds seems my problem solved

#!/bin/ksh
proc_say=1
aktif_proc=`ps -ef|egrep -i bshell|grep -v grep|egrep -i ut1ct|grep -c ut1ct`
if [ $aktif_proc -gt $proc_say ]
then
kill -9 `ps -ef|egrep -i bshell|grep -v grep|egrep -i ut1ct|tail -1|awk '{print $2}'`
else
exit 1
fi
This is for test for single username "ut1ct"
So How can i run this script in every seconds???

Please Help,
Our greatest duty in this life is to help others. And please, if you can't
Mel Burslan
Honored Contributor

Re: how to restrict or kill if a user have more than one process?

Cem,

you do not want to run this process every second, as it will kill your machine's resources to start with.

I could not quite understand how the two different types of logins, one via telnet, other via GUI can be differentiated ? what does the GUI do on the server ? Does it log in using the username and password and execute one command and exit right after that ? or how does it work ? If there is a client/server architecture set, and there is a server process listening the connections from GUI clients, they will circumvent the .profile totally.
________________________________
UNIX because I majored in cryptology...
Roberto Polli
Trusted Contributor

Re: how to restrict or kill if a user have more than one process?

In his posting RAC says to edit the
/etc/default/security
file.

It should be the cleaner solution to avoid multiple logins to non-root.

try it before other solutions.

Peace, R.
Cem Tugrul
Esteemed Contributor

Re: how to restrict or kill if a user have more than one process?

Hi Roberto &RAC,
i do not have a such kind of file...
i have hp-ux11i and 11.00
/etc/default/security
so should i create?if so what is the ACL options?

King Regards,
Our greatest duty in this life is to help others. And please, if you can't
Cem Tugrul
Esteemed Contributor

Re: how to restrict or kill if a user have more than one process?

found solution from another forum...
Our greatest duty in this life is to help others. And please, if you can't