(how do you quote a reply?)
MrHoffman: "If there's no good wall (no pun intended) here, some random not-privileged app service running in the background can present—for instance—a password-grabbing prompt."
The 'wall' program doesn't solicit input, so not a security risk in the sense you are describing.
I think I've come up with a simple solution. I can use osascript from within a script like the apccontrol shutdown script (interestingly, that script looks for growl being installed). A typical notification line in this script is:
echo "Apccontrol has done: ${APCUPSD} --killpower on UPS ${2}" | ${WALL}
where $WALL is aliased to either wall or growl, if found. I've created a script, 'gwall' as follows:
#!/bin/bash
# Get optional title
if [ "$1" = "-t" ]
then
title="$2"
shift 2
else
title="from $USER"
fi
# As with 'wall', either display file or stdin
if [ -z "$1" ]
then
msg=`cat`
else
msg=`cat $1`
fi
# Get console (GUI) users and send message
who | grep console | awk '{print $1}' | \
while read usr
do
su - $usr -c "/usr/bin/osascript -e 'display notification \"${msg}\" with title \"$title\"'"
done
echo "$msg" | wall
Like 'wall', this either takes stdin or the name of a file as $1. I've added the non-wall option -t to create a title other than the default "Script Editor". It looks for console users and send the message via osascript. To finish, it sends the message via wall for users logged into a terminal. The only drawback is that this can only be executed by root since is has to 'su' to the user getting the message, but for my purposes it's all I need.
So, I'll set the WALL variable in the apccontrol script to: WALL="/usr/local/bin/gwall -t \"from apccontrol\""
Someday, I may add an arg to make the notice require user acknowledgment (display alert), and perhaps an arg to change the persistence time (defaults write com.apple.notificationcenterui bannerTime [time in seconds]).