shithub: riscv

ref: fe1eb39db7ae6904924f3ab1f6f9b34416f2eb1b
dir: /sys/src/cmd/auth/status/

View raw version
#!/bin/rc

if(! ~ $#* 1){
	echo 'usage: auth/status user' >[1=2]
	exit usage
}

cd /mnt/keys/$1 > /dev/null >[2=1] && {
	stat=`{cat status}
	exp=`{cat expire}
	switch($exp){
	case never 0
		exp='never expires'
	case *
		exp=(expires on `{date $exp})
	}
	switch($stat){
	case expired
		echo user $1: plan 9 key has expired
	case *
		echo user $1: plan 9 key status is $stat and $exp
	}
	grep '^'$1'[ 	]' /adm/keys.who | tail -1
}
cd /mnt/netkeys/$1 > /dev/null >[2=1] && {
	stat=`{cat status}
	exp=`{cat expire}
	switch($exp){
	case never 0
		exp='never expires'
	case *
		exp=(expires on `{date $exp})
	}
	switch($stat){
	case expired
		echo user $1: network key has expired
	case *
		echo user $1: network key status is $stat and $exp
		auth/printnetkey $1
	}
	grep '^'$1'[ 	]' /adm/netkeys.who | tail -1
}