[comp.unix.ultrix] Help with limiting the number of user Processes

craig@cutmcvax.OZ (Craig Farrell) (11/16/89)

 Dear Ultrix'ers,

	Thankyou for all the replies on limiting the number of processes
a user process can have, however just changing MAXUPROC is not enough.
We would like to be able to restrict the processes on a per-user basis,
so some people can fork off as many processes as the like while others
can be restricted to a particular number of processes. 

	Again we are aware of kre's Mush stuff (we are using it now)
but do not wish to have to port it to ultrix because of the number
of kernel  and utility changes involved. Is there any alternative 
to restrict the number of processes a user can have on a per-user basis.


							Thanx for any help
							or suggestions.
							Craig Farrell.

PLease e-mail responses  to craig@cutmcvax.oz
-------------------------------------------------------------------------
    ___    _    ____    _   ___
   /   \__/ \__/    \__/ \_/   \
  |           |O O              |
   \         _|     __         /
    \_______/ |     | \_______/
             /     _/
          __/    _/
         /) (o _/
         \    /           Hey Rocky watch me pull a rabbit from my hat!
          \__/

From: Craig Farrell
Organisation: Curtin University West Australia.
ACSnet: craig@cutmcvax.oz
UUCP: ...!uunet!munnari!cutmcvax!craig
ARPA: craig%cutmcvax.oz@uunet.UU.NET

grr@cbmvax.UUCP (George Robbins) (11/21/89)

In article <122@cutmcvax.OZ> craig@cutmcvax.oz (Craig Farrell) writes:
> 
>  Dear Ultrix'ers,
> 
> 	Thankyou for all the replies on limiting the number of processes
> a user process can have, however just changing MAXUPROC is not enough.
> We would like to be able to restrict the processes on a per-user basis,
> so some people can fork off as many processes as the like while others
> can be restricted to a particular number of processes. 

You neglect to mention whether or not you have source.  If you are willing
to have the decision based on something simple like having the maxuprc
limit not apply to users with gid < 100 or with even uids or some other
kludge, the changes are trivial. 

Go to the module /sys/src/sys/kern_fork.c and in the routine fork1() find
a line that looks something like:  (i.e. has a reference to maxuprc)

	if (p2==NULL || (u.u_uid!=0 && (p2==procNPROC-1 || a>maxuprc))) {

and change the "a>maxuproc" to something like "(a>maxuproc && u.u_gid>=100)"

A more sophisticate approach would be to look a the list of groups that
the user belongs to and use the presence of group 13 or something similar
to indicate whether the limit applies, since this would be more dynamic.

If you don't have source, you can still patch the routine fork1, but this
get's a bit more painful.

-- 
George Robbins - now working for,	uucp: {uunet|pyramid|rutgers}!cbmvax!grr
but no way officially representing	arpa: cbmvax!grr@uunet.uu.net
Commodore, Engineering Department	fone: 215-431-9255 (only by moonlite)