#!/bin/sh
# Figure out our root directory
ROOTDIR=$(pwd)
unset CHROOT
if test "${ROOTDIR}" != "/"; then
  CHROOT="chroot ${ROOTDIR} "
  ROOTDIR="${ROOTDIR}/"
fi
config() {
  NEW="$1"
  OLD="$(dirname $NEW)/$(basename $NEW .new)"
  # If there's no config file by that name, mv it over:
  if [ ! -r $OLD ]; then
    mv $NEW $OLD
  elif [ "$(cat $OLD | md5sum)" = "$(cat $NEW | md5sum)" ]; then
    # toss the redundant copy
    rm $NEW
  fi
  # Otherwise, we leave the .new copy for the admin to consider...
}
## List of conf files to check.  The conf files in your package should end in .new
config etc/sudoers.new

# Fix permissions
${CHROOT} /bin/chmod 4711 /usr/bin/sudo

( cd usr/lib64/sudo ; rm -rf libsudo_util.so )
( cd usr/lib64/sudo ; ln -sf libsudo_util.so.0.0.0 libsudo_util.so )
( cd usr/lib64/sudo ; rm -rf libsudo_util.so.0 )
( cd usr/lib64/sudo ; ln -sf libsudo_util.so.0.0.0 libsudo_util.so.0 )
( cd usr/man/man8 ; rm -rf sudoedit.8 )
( cd usr/man/man8 ; ln -sf sudo.8 sudoedit.8 )
( cd usr/bin ; rm -rf sudoedit )
( cd usr/bin ; ln -sf sudo sudoedit )
