shithub: sirjofri_de

ref: ec4bf38b40ed9952e857292750d541c438a587b1
dir: /changeblog/1596011563.ms/

View raw version
.HTML Restrict RCPU User Access to Groups
.TL
Restrict RCPU User Access to Groups
.LP
This is how to restrict user access to groups.
You can use this to enable
.CW rcpu
access for all users of a specific group.
All other groups will not be allowed.
.LP
To allow access only to
.CW sys
group members: adjust your
.CW /rc/bin/service/tcp17019
.IP
.CW
#!/bin/rc
.br
userfile=/adm/users
.br
fn useringroup{
.br
	grep $1 $userfile | {
.br
		found=0
.br
		while(~ $found 0 && line=`:{read}){
.br
			if(~ $line(2) $2){
.br
				found=1
.br
			}
.br
		}
.br
		if(~ $found 1)
.br
			status=''
.br
		if not
.br
			status='not found'
.br
	}
.br
}
.br
if(~ $#* 3){
.br
	netdir=$3
.br
	remote=$2!`{cat $3/remote}
.br
}
.br
fn server {
.br
	~ $#remote 0 || echo -n $netdir $remote >/proc/$pid/args
.br
	rm -f /env/'fn#server'
.br
	. <{n=`{read} && ! ~ $#n 0 && read -c $n} >[2=1]
.br
}
.br
exec tlssrv -a /bin/rc -c 'useringroup $user sys && server'
.LP
This checks if the user is in group
.CW sys
and only then calls the
.CW server
function.
Otherwise the connection is terminated.
.LP
This is especially useful if you want a CPU server to expose filesystems
.I and
have cpu access for administrators only.