|
Server : Apache System : Linux iZ6xhqomji47p1Z 5.10.134-15.al8.x86_64 #1 SMP Thu Jul 20 00:44:04 CST 2023 x86_64 User : www ( 1000) PHP Version : 8.1.30 Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv Directory : /proc/self/root/sbin/ |
#!/bin/bash
################################################################################
# Copyright 2011 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"). You may not
# use this file except in compliance with the License. A copy of the License is
# located at
#
# http://aws.amazon.com/apache2.0/
#
# or in the "license" file accompanying this file. This file is distributed on
# an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
# or implied. See the License for the specific language governing permissions
# and limitations under the License.
################################################################################
if [ $(/usr/bin/id -u) -ne 0 ]; then
echo "You are not root"
exit 1
fi
# Parse the few supported options
case "$1" in
--enable)
rm -f /var/lib/update-motd/disabled
exit 0;;
--disable)
mkdir -p /var/lib/update-motd/
touch /var/lib/update-motd/disabled
exit 0;;
'' | --force);;
*)
echo "update-motd [option]"
echo " --disable: Disable update-motd"
echo " --enable: Enable update-motd"
echo " --force: Ignore disabled setting"
exit 1;;
esac
# Just exit if update-motd is disabled and --force wasn't passed
if [ -e /var/lib/update-motd/disabled ] && [ "$1" != "--force" ]
then
exit 0
fi
if [ -d /etc/update-motd.d ]; then
TMPFILE=$(mktemp --tmpdir motd.XXXXX)
if [ -f /etc/motd.head ]; then
cat /etc/motd.head >> $TMPFILE
fi
# Simulated run-parts, wildcards in bash are expanded sorted
# Skip files ending in ~ or ,
for part in /etc/update-motd.d/*[^~,]; do
# Skip .rpmnew, etc.
[[ $part =~ \.rpm* ]] && continue
# Run only if it's a regular file and executable
if [ -f $part ] && [ -x $part ]; then
TMPPART=$(mktemp --tmpdir motd.partXXXXX)
if (timeout 10s $part > $TMPPART); then
cat $TMPPART >> $TMPFILE
fi
rm -f $TMPPART
fi
done
if [ -f /etc/motd.tail ]; then
cat /etc/motd.tail >> $TMPFILE
fi
# Only actually do the replacement if there is something in there
if [ -s $TMPFILE ]; then
# mktemp creates files with only user read-write permissions
chmod go+r $TMPFILE
mv $TMPFILE /var/lib/update-motd/motd
else
# Don't leave temp files
rm -f $TMPFILE
fi
fi