reading passwd file with gdm

Joe Marcus Clarke marcus at freebsd.org
Tue Jun 10 23:46:17 PDT 2003


On Tue, 10 Jun 2003, Glenn Johnson wrote:

> I am trying to parse the master.passwd file during gdm logins to see if
> the passwd has reached its expiration time.  The following command works
> on the command line and in a simple sh script that I tested:
>
> CHANGE=`perl -e "print join(':', getpwnam ('$USER'));" | awk -F: '{print $5}'`
>
> However, it does not work when put into gdm/PreSession/Default.
>
> Here is my PreSession/Default file.  I put in an echo command to see the
> values.
>
> --begin gdm/PreSession/Default--
>
> #!/bin/sh
> #
> # Note that any setup should come before the sessreg command as
> # that must be 'exec'ed for the pid to be correct (sessreg uses the parent
> # pid)
> #
> # Note that output goes into the .xsession-errors file for easy debugging
> #
> PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin
> xrdb /etc/X11/Xresources
> xmessage -nearmouse -file /etc/motd -default okay
>
> if /usr/bin/which -s xsetroot > /dev/null 2>&1; then
> 	xsetroot -cursor_name left_ptr -solid "#363047"
> fi
>
> TIME=`date +%s`
> CHANGE=`perl -e "print join(':', getpwnam ('$USER'));" | awk -F: '{print $5}'`
> echo TIME is $TIME CHANGE is $CHANGE EXPIRED is $EXPIRED > ~/aging
> if [ "$EXPIRED" = "yes" ]; then
>     xterm -e passwd
> fi
>
> if /usr/bin/which -s sessreg > /dev/null 2>&1; then
> 	# some output for easy debugging
> 	echo "$0: Registering your session with wtmp and utmp"
> 	echo "$0: running: sessreg -a -w /var/log/wtmp -u /var/run/utmp -x \"$X_SERVERS\" -h \"$REMOTE_HOST\" -l $DISPLAY $USER"
>
> 	exec sessreg -a -w /var/log/wtmp -u /var/run/utmp -x "$X_SERVERS" -h "$REMOTE_HOST" -l $DISPLAY $USER
> 	# this is not reached
> fi
>
> # some output for easy debugging
> echo "$0: could not find the sessreg utility, cannot update wtmp and utmp"
> exit 0
>
> --end gdm/PreSession/Default--
>
> Here are the contents of the ~/aging file:
>
> TIME is 1055258058 CHANGE is EXPIRED is
>
> Does any one have any idea why that perl command is not working when run
> in the gdm PreSession/Default script?

It _MAY_ be that the $USER variable substitution isn't happening correctly
(though I don't know why).  Try using Perl's %ENV hash to get it:

CHANGE=`perl -e "print join(':', getpwnam ($ENV{'USER'}));" | awk -F:
'{print $5}'`

Joe

>
> Thanks.
>
> --
> Glenn Johnson
> USDA, ARS, SRRC			 Phone: (504) 286-4252
> New Orleans, LA 70124		e-mail: gjohnson at srrc.ars.usda.gov
> _______________________________________________
> freebsd-gnome at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-gnome
> To unsubscribe, send any mail to "freebsd-gnome-unsubscribe at freebsd.org"
>
>

PGP Key : http://www.marcuscom.com/pgp.asc


More information about the freebsd-gnome mailing list