logadm-upgrade revision f6e214c7418f43af38bd8c3a557e3d0a1d311cfa
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby# CDDL HEADER START
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby# The contents of this file are subject to the terms of the
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby# Common Development and Distribution License (the "License").
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby# You may not use this file except in compliance with the License.
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby# See the License for the specific language governing permissions
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby# and limitations under the License.
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby# When distributing Covered Code, include this CDDL HEADER in each
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby# If applicable, add the following below this CDDL HEADER, with the
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby# fields enclosed by brackets "[]" replaced with your own identifying
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby# information: Portions Copyright [yyyy] [name of copyright owner]
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby# CDDL HEADER END
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby# This is a temporary service to allow addition (only) to /etc/logadm.conf
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby# It is temporary in the sense that logadm(1M) should have its configuration
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby# migrated to SMF in the future.
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby# Display error message and exits with error code
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby# If there is no /etc/logadm.d we can bail
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltbyif [ ! -d ${LOGADM_D} ]; then
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby# Cache files
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby# If there is no /etc/logadm.conf create it and make sure it has the
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby# right ownership and permissions.
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby# Make sure this is done AFTER $files is set. Otherwise /etc/logadm.conf will be
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby# newer than all files is /etc/logadm.d and they will be skipped.
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltbyif [ ! -f ${LOGADM} ]; then
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby # If it is not a file, we skip it.
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby if [ ! -f ${f} ]; then
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby # We stop when files at /etc/logadm.d are older than /etc/logadm.conf
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby if [ ${f} = ${LOGADM} ]; then
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby # We ignore files that are not owned by root, group sys
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby # and have permissions different than 444
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby perm=$(${LS} -l ${f} | ${AWK} '{printf("%s %s:%s", $1, $3, $4)}')
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby if [ $? != 0 ]; then
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby if [ "${perm}" != "-r--r--r-- root:sys" ]; then
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby echo "Unexpected permission/ownership for ${f}"
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby echo " expected -r--r--r-- root:sys but got ${perm}"
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby echo " skipping ${f}"
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby # Discard comments (lines starting with #)
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby sig=$(echo ${entry} | ${AWK} '{printf("%s\>", $1);}' 2>&1)
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby if [ $? != 0 ]; then # only happens if awk(1) fails
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby # if ${sig} is null but the previous command succeeded, we skip
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby if [ ! ${sig} ]; then