nisopaccess.sh revision 7c478bd95313f5f23a4c958a745db2134aa03244
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License, Version 1.0 only
# (the "License"). You may not use this file except in compliance
# with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright (c) 1999 by Sun Microsystems, Inc.
# All rights reserved.
#pragma ident "%Z%%M% %I% %E% SMI"
EXIT=255
VERBOSE=0
REMOVE=0
LIST=0
{
echo "Usage: $0 [-v] directory operation rights"
echo " $0 [-r] [-v] directory operation"
echo " $0 [-l] [-v] directory [operation]"
}
# no_dot(): check if arg has a trailing dot.
no_dot()
{
then
return 0
fi
return 1
}
# parse_opt(): Parse options. Returns the number of arguments to shift
# in order to get to the non-option arguments.
{
do
v) VERBOSE=1;;
r) REMOVE=1;;
l) LIST=1;;
\?) print_usage
exit $EXIT;;
*) print_usage
exit $EXIT
esac
done
}
# unknown_op(): Check that operation (NIS_PING etc.) is known
{
case $OPERATION in
*) return 0;;
esac
return 1
}
# print_rights(): parse and print access rights
{
op=$1
shift
rights="<unknown>"
owner="<none>"
group="<none>"
while [ $# -gt 0 ]; do
case $1 in
shift
if [ $1 = ":" ]; then
shift
if [ $1 != "Group" ]; then
owner=$1
shift
fi
fi;;
shift
if [ $1 = ":" ]; then
shift
if [ $1 != "Access" ]; then
group=$1
shift
fi
fi;;
shift
if [ $1 = "Rights" ]; then
shift
if [ $1 = ":" ]; then
shift
rights=$1
while [ $# -gt 0 ]; do
shift
done
fi
fi;;
*)
shift;;
esac
done
return $?
}
# print_op(): print access rights for the specified operation
print_op()
{
if [ $? -eq 0 ]; then
print_rights $1 `niscat -oM \[op=$1\]$TBLNAME.$DIRECTORY`
fi
return $?
}
# Main
# Parse the options, if any
parse_opt $*
shift $?
# Check that we've got the correct number of arguments
case $# in
exit $EXIT
fi
DIRECTORY=$1;;
exit $EXIT
echo "The -l and -r options are mutually exclusive"
exit $EXIT
fi
LIST=2
fi
DIRECTORY=$1
OPERATION=$2
if unknown_op; then
echo "Unknown operation $OPERATION"
exit $EXIT
fi;;
exit $EXIT
fi
DIRECTORY=$1
OPERATION=$2
if unknown_op; then
echo "Unknown operation $OPERATION"
exit $EXIT
fi
RIGHTS=$3;;
*) print_usage
exit $EXIT;;
esac
# If no trailing dot in directory name, add the domain name
if no_dot $DIRECTORY;
then
fi
# Does the directory exist ?
STAT=$?
echo "$DIRECTORY: no such NIS+ directory"
exit $STAT
fi
# Does the table exist ?
TBLEXISTS=$?
# List all or just one operation
echo "No operation access table for $DIRECTORY"
exit 0
fi
echo "Listing access for all operations for $DIRECTORY"
fi
echo "Operation\t n---o---g---w---\t Owner\t\t\t Group"
echo ""
STAT=$?
done
exit $STAT
echo "No operation access table for $DIRECTORY"
exit 0
fi
echo "Listing access for $OPERATION for $DIRECTORY"
fi
exit $?
fi
# Remove an operation
echo "No operation access table for $DIRECTORY"
exit 0
fi
if [ $? -ne 0 ]; then
echo "No $OPERATION access control for $DIRECTORY"
fi
exit 0
else
echo "Removing $OPERATION access control for $DIRECTORY"
fi
exit $?
fi
fi
# Create the table if it doesn't exist already
echo "Creating access control table in $DIRECTORY"
fi
STAT=$?
exit $STAT
fi
fi
# If no entry for the operation, create it with requested rights
if [ $? -ne 0 ]; then
echo "Creating $OPERATION access control entry for $DIRECTORY"
fi
exit $?
fi
# Modify existing entry
echo "Changing $OPERATION access control entry for $DIRECTORY"
fi
exit $?