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