Search code examples
sessiontclcentos7argvrhel6

Does $argv behave the same between Centos and RHEL systems


I am trying to troubleshoot an old TCL accounting script called GOTS - Grant Of The System. What it does is creates a time stamped logfile entry for each user login and another for the logout. The problem is it is not creating the second log file entry on logout. I think I tracked down the area where it is going wrong and I have attached it here. FYI the log file exists and it does not exit with the error "GOTS was called incorrectly!!". It should be executing the if then for [string match "$argv" "end_session"]

This software runs properly on RHEL Linux 6.9 but fails as described on Centos 7. I am thinking that there is a system variable or difference in the $argv argument vector for the different systems that creates this behavior.

Am I correct in suspecting $argv and if not does anyone see the true problem?

How do I print or display the $argv values on logout?

# Find out if we're beginning or ending a session
if { [string match "$argv" "end_session"] } {
    if { ![file writable $Log] } {
    onErrorNotify "4 LOG"
    }
    set ifd [open $Log a]
    puts $ifd "[clock format [clock seconds]]\t$Instrument\t$LogName\t$GroupName"
    close $ifd
    unset ifd
    exit 0
} elseif { [string match "$argv" "begin_session"] == 0 } {
    puts stderr "GOTS was called incorrectly!!"
    exit -1
} 

end_session is populated by the /etc/gdm/PostSession/Default file

#!/bin/sh


### Begin GOTS PostSession
#  Do not run GOTS if root is logging out
if test "${USER}" == "root" ; then
    exit 0
fi

/usr/local/lib/GOTS/gots end_session > /var/tmp/gots_postsession.log 2> /var/tmp/gots_postsession.log
exit 0
### End GOTS PostSession

This is the postsession log file:

Application initialization failed: couldn't connect to display ":1"
Error in startup script: invalid command name "option"
    while executing
"option add *Font "-adobe-new century schoolbook-medium-r-*-*-*-140-*-*-*-*-*-*""
    (file "/usr/local/lib/GOTS/gots" line 26)

After a lot of troubleshooting we have determined that for whatever reason Centos is not allowing part of the /etc/gdm/PostSession/default file to execute:

fi

/usr/local/lib/GOTS/gots end_session  

But it does update the PostSession.log file as it should .. . Does anyone have any idea what could be interfering with only part of the PostSession/default?


Solution

  • So it turns out that our script has certain elements that depend upon the Xserver running on logout to display some of the GUI error messages. This from:

    Gnome Configuration

    "When a user terminates their session, GDM will run the PostSession script. Note that the Xserver will have been stopped by the time this script is run, so it should not be accessed.

    Note that the PostSession script will be run even when the display fails to respond due to an I/O error or similar. Thus, there is no guarantee that X applications will work during script execution."

    We are having to rewrite those error message callouts so they simply write the errors to a file instead of depending on the display. The errors are for things that should be there in the beginning anyway.