Re: Exporting a variable as readonly in ksh

From: Randy Styka (comp-sun!aix-list@COMPGATE.COMPUTRON.COM)
Date: Mon Mar 10 2003 - 04:42:12 EST


twilleat@mhp.mercy.net wrote:
>
>I'm having a problem getting a variable to keep its readonly attribute.
>Here's what I'm doing:
>
>readonly TMOUT=1
>export TMOUT
>
>As expected, TMOUT has a value of 1 and you receive a message that it is
>readonly if you try to change it. If I now open a new ksh subshell, the
>TMOUT variable retains the value of 1 since it was exported. However, in
>this subshell the variable is not readonly and can be reset by a user.
>
>Is there any way to get the variable to be readonly in any subshell as well?
>
> / / | twilleat@mhp.mercy.net | \ \
>
This is indeed an interesting thing, and appears to be an AIX
feature (bug?). I tried the same test on our AIX5 box, Sun
Solaris, and HP/UX. On Sun and HP, the readonly status of the
exported variable was inherited by the subshell. But AIX
let me alter the variable within the subshell...

So what you are seeing is consistent on a test AIX box here.

As an aside, if what you are trying to do is to use TMOUT to
log off idle users, it's not the best method, since it only
affects users at a shell prompt, not in applications.

If you want a more general solution that will work in applications
also, our company has a product called LOGMON that will do this.
This software will allow you to log off users in applications,
and you can control the inactivity time by user, time of day,
application, etc. For details, send a message to
logmon@computron.com or visit www.logmon.com

And I think IBM should be notified of a bug in the readonly
status of variables in exported shells... Thanks!

+-----------------------------------------------------------------+
| Computronics Randy Styka, randy@computron.com |
| 4N165 Wood Dale Road Phone: 630/941-7767 |
| Addison, Illinois 60101 USA Fax: 630/941-7714 |
+-----------------------------------------------------------------+



This archive was generated by hypermail 2.1.7 : Wed Apr 09 2008 - 22:16:38 EDT