#!/usr/bin/perl
###############################################################################
#
# File:         NS.secure.permissions
# RCS:          $Header: $
# Description:  secure permissions for NS
# Author:       Christian Limpach <chris@nice.ch>
# Created:      Tue Apr  4 19:37:13 1995
# Modified:     Tue Apr  4 20:04:31 1995 (Christian Limpach) chris@nice.ch
# Language:     Perl
# Package:      N/A
# Status:       Experimental (Do Not Distribute)
#
# (C) Copyright 1995, Christian Limpach, all rights reserved.
# This is free software, and you are welcome to redistribute it
# under certain conditions; see ftp://nice.ethz.ch/users/chris/TERMS
# for details. This software comes with ABSOLUTELY NO WARRANTY.
#
###############################################################################

($root) = @ARGV;
die "root must be absolute" unless $root =~ m#^/#;
$root =~ s#/$##;

sub chmodu {
    ($perm, $file) = @_;
    chmod $perm, $file if -u $file;
}

# PrintManager doesn't need to be setuid root here
chmodu 0755, "$root/NextApps/PrintManager.app/PrintManager";

# neither do all the preferences modules
while (<$root/usr/lib/Preferences/*>) {
    chmodu 0755, $_;
}

# we don't use NeXT's uucp
$uucp = getpwnam("uucp");
while (<$root/usr/bin/*>) {
    ($dev,$ino,$mode,$nlink,$uid)=stat;
    chmodu 0111, $_ if ($uid == $uucp);
}
while (<$root/usr/lib/uucp/*>) {
    ($dev,$ino,$mode,$nlink,$uid)=stat;
    m#/uuxqt$# && chmodu 0110, $_;
    chmodu 0111, $_ if ($uid == $uucp);
}
