5 # The contents of this file are subject to the terms of the
6 # Common Development and Distribution License (the "License").
7 # You may not use this file except in compliance with the License.
9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 # or http://www.opensolaris.org/os/licensing.
11 # See the License for the specific language governing permissions
12 # and limitations under the License.
14 # When distributing Covered Code, include this CDDL HEADER in each
15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 # If applicable, add the following below this CDDL HEADER, with the
17 # fields enclosed by brackets "[]" replaced with your own identifying
18 # information: Portions Copyright [yyyy] [name of copyright owner]
23 # Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
26 .
/lib
/svc
/share
/smf_include.sh
28 LOGADM
=/etc
/logadm.conf
29 LOGADM_D
=${LOGADM%conf}d
35 # This is a temporary service to allow addition (only) to /etc/logadm.conf
36 # It is temporary in the sense that logadm(1M) should have its configuration
37 # migrated to SMF in the future.
41 # Display error message and exits with error code
53 # If there is no /etc/logadm.d we can bail
55 if [ ! -d ${LOGADM_D} ]; then
62 files
=$
(${LS} -t ${LOGADM} ${LOGADM_D}/*)
65 # If there is no /etc/logadm.conf create it and make sure it has the
66 # right ownership and permissions.
67 # Make sure this is done AFTER $files is set. Otherwise /etc/logadm.conf will be
68 # newer than all files is /etc/logadm.d and they will be skipped.
70 if [ ! -f ${LOGADM} ]; then
73 chown root
:sys
${LOGADM}
79 # If it is not a file, we skip it.
81 if [ ! -f ${f} ]; then
86 # We stop when files at /etc/logadm.d are older than /etc/logadm.conf
88 if [ ${f} = ${LOGADM} ]; then
93 # We ignore files that are not owned by root, group sys
94 # and have permissions different than 444
96 perm
=$
(${LS} -l ${f} | ${AWK} '{printf("%s %s:%s", $1, $3, $4)}')
98 msg_exit ${SMF_EXIT_ERR_FATAL} "${perm}"
100 if [ "${perm}" != "-r--r--r-- root:sys" ]; then
101 echo "Unexpected permission/ownership for ${f}"
102 echo " expected -r--r--r-- root:sys but got ${perm}"
103 echo " skipping ${f}"
108 # Discard comments (lines starting with #)
110 ${GREP} -v '^
#' ${f} | while read entry
112 sig
=$
(echo ${entry} | ${AWK} '{printf("%s\>", $1);}' 2>&1)
113 if [ $? != 0 ]; then # only happens if awk(1) fails
114 msg_exit ${SMF_EXIT_ERR_FATAL} "${sig}"
118 # if ${sig} is null but the previous command succeeded, we skip
120 if [ ! ${sig} ]; then
124 err_msg=$(${GREP} ^${sig} ${LOGADM} 2>&1)
127 echo "${entry}" >> ${LOGADM}
132 msg_exit ${SMF_EXIT_ERR_FATAL} "${err_msg}"