#!/bin/sh
#
# Unregister a binary
#
set -e

if [ ! -f /etc/suid.conf ]; then
	echo "Creating \"/etc/suid.conf\"..."
	cat > /etc/suid.conf <<EOF
# Configuration File for suid programs or special permissions
#
# The format is:
# package file user group permissions
EOF
fi

if [ "$1" = "-s" ]; then
        shift
        PACKAGE=$1
        shift
else
        PACKAGE=".*"
fi

if [ "$1" = "" ]; then
	echo "Usage: suidunregister [-s <package>] <path>"
	exit 1
fi

sed </etc/suid.conf -e "\%^$PACKAGE $1 %d" >/etc/suid.conf.new

cp /etc/suid.conf.new /etc/suid.conf
rm /etc/suid.conf.new

