[SunRay-Users] Zenity in the _PRE script?

Craig Bender Craig.Bender at oracle.com
Tue Mar 1 22:20:08 EET 2011

Session_PRE/POST run as root
Application_PRE/POST run as the kiosk user.

Why are you doing it as an app?  An app means you already have a 
session, and if your session configures different apps based on DTU 
location, you have a chicken egg thing.

If you need to do something as root in a app pre it can't without doing 
one of two things.  See below

But just so you understand why you are not seeing the Zenity Dialog, it 
could be one of three reasons:

1) You have a root check in your pre-script
2) The script locked down so only root can execute it
3) Your Zenity script isn't just setting variable, it's holding udesktop 
-e open (via a pipe) or the variable that it's setting is referenced 
with a by another variable that contains the utdesktop -e command.  The 
script can't process that variable, because you're not root, so it bails.

Here's what you can do

Best (safest and recommended) Method:

Run Zenity as an app pre.

Make sure the location info is empty
Do your zenity to ask for info
Instead of running utdesktop, store this info in /tmp/<SunRay TerminalID.loc
pkill -U $USER (this will kill your kiosk session)

Create a Session post that looks in /tmp for <SunRay TerminalID.loc
Run utdesktop -e <contents of that file>
rm that file (or don't, the session cleanup process should remove it)


Next is not real good method, and you need install expect since "su" 
doesn't take STDIN, but let's you do it and not end the session.
Same as above, but also ask for the root password, will call that AskLoc.sh
Instead of storing the info, pass both to another script, let's call it 

You pre script will call AskLoc.sh and AskLoc.sh will call SetLoc with 
$loc and $rootpw variables

Scripts will look like this:

set -x

MYDISP=$(echo $DISPLAY | sed 's/.*:\([^.]*\).*/\1/')
MYMAC=$(sed -n 's/^TERMINAL_ID=[^.]*\.//p' 

theLoc=`/opt/SUNWut/sbin/utdesktop -o | \
             grep \$MYMAC | \
             /usr/bin/awk -F, '{print $3;}'`

if [ -z "$theLoc" ] ; then

         thePrinter=$(/usr/bin/zenity --entry \
         --title="Enter Location" \
         --text="Enter the Location of this Sun Ray :" \
         --entry-text "Location" )
	rootPW=$(/usr/bin/zenity --entry \
         --title="Root Password" \
         --text="Enter the Root Password to Set the Location:" \
         --entry-text "password" \
	--hide-text )	
	/opt/scripts/SetLoc.sh $MYMAC $theLoc $rootPW


#!/usr/bin/expect -f
set MYMAC [lindex $argv 0]
set theLoc [lindex $argv 1]
set password [lindex $argv 2]
spawn su -c "/opt/SUNWut/sbin/utdesktop -e '$MYMAC,,$theLoc'"
expect "*Password: "
send  "$password\r"
expect eof

On 3/1/11 8:47 AM, Art Peck wrote:
> I have a script the updates the Location field for the DTU using
> utdesktop. It works fine as long as I run it as root, since utdesktop
> requires root to do the "-e" option. Hmm.
> I set it up to run as the KIOSK_SESSION_PRE script, but that doesn't
> seem to work. I never see the zenity text entry box. I'm wondering if
> something is blocking me from doing zenity at the time the _PRE runs?
> Other than RBAC and the priviledged shell, are there any other choices??
> Art
> _______________________________________________
> SunRay-Users mailing list
> SunRay-Users at filibeto.org
> http://www.filibeto.org/mailman/listinfo/sunray-users

More information about the SunRay-Users mailing list