#!/usr/sbin/openrc-run

description="Provide limited super user privileges to specific users"

depend() {
	need localmount
	before rmnologin
}

start() {
	if [ -d /run/systemd/system ]; then
		return 0
	fi

	ebegin "Setting up sudo privilege state"
	if [ -d /run/sudo ]; then
		find /run/sudo -exec touch -d @0 '{}' \;
	else
		mkdir /run/sudo /run/sudo/ts
		chown root:root /run/sudo /run/sudo/ts
		chmod 0711 /run/sudo
		chmod 0700 /run/sudo/ts
		[ -x /sbin/restorecon ] && /sbin/restorecon /run/sudo /run/sudo/ts
	fi
	eend 0
}
