mcdonald@AEDC-VAX.AF.MIL (04/25/91)
I have implemented a password aging scheme in our NIS environment. The way I am checking password dates to see if a password has expired is with a c-prog that I want to execute in /etc/profile & /etc/cshrc. If the password has expired then I exec my yppasswd changer and force the user to change his password. My problem arises when the user hits Ctrl-C when he first logs in which kills the execution of /etc/cshrc, thus my expiration checker does not get executed. How can I trap these signals in a csh? In a Bourne shell all I have to do is trap them with the trap command. vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv | Kenneth M. McDonald * OAO Corp * Arnold Engineering Development Center | | MS 120 * Arnold AFS, TN 37389-9998 * (615) 454-3413 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ INTERNET: mcdonald@aedc-vax.af.mil LOCAL: c60244@ccfiris
mcdonald@AEDC-VAX.AF.MIL (04/25/91)
After reading the man page on csh I found I could ignore signals by: onintr - onintr onintr label vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv | Kenneth M. McDonald * OAO Corp * Arnold Engineering Development Center | | MS 120 * Arnold AFS, TN 37389-9998 * (615) 454-3413 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ INTERNET: mcdonald@aedc-vax.af.mil LOCAL: c60244@ccfiris
chawley@sundiver.esd.sgi.com (Christopher J. Hawley) (04/26/91)
In article <9104242103.AA11863@ccfiris.aedc>, mcdonald@AEDC-VAX.AF.MIL writes: |> My problem arises when the user hits Ctrl-C when he first logs |> in which kills the execution of /etc/cshrc, thus my expiration checker does |> not get executed. How can I trap these signals in a csh? Read the description of the csh builtin command "onintr" in csh(1) . It provides a barely adequate (IMHO) means of intercepting interrupt signals; used in conjunction with some stty(1) contortions to disable other signals from the keyboard, you could write something similar to the following: ... # Assume we're executing from a tty. # Save tty settings, disable signals except for SIGINT set ottymode = `stty -g` stty quit '^-' # "undef" on some BSD systems # Trap interrupts to clean-up portion of script onintr interrupted ... <commands to change password> ... goto finished # Clean-up handling (executed when interrupted) interrupted: ... <commands to undo partial changes, set return status> ... # Here to complete task, restore terminal modes, return status. # Restore original tty settings stty $ottymode; unset ottymode # Revert to previous interrupt handling (if sourced inline) onintr # Exit with return status (if subshell or aborted) exit($returnstatus) |> In a Bourne shell all I have to do is trap them with the trap command. Y'know, that's probably the easiest way to accomplish the task... use an explicit invocation: /bin/sh chgpwdscript Use the trap builtin and set SHELL=/bin/sh within chgpwdscript . |> | Kenneth M. McDonald * OAO Corp * Arnold Engineering Development Center | |> | MS 120 * Arnold AFS, TN 37389-9998 * (615) 454-3413 | #include "std_disclaimer.h" /* My opinions are my own... in my opinion, standard discs are lame. */ --- Christopher J. Hawley / esper chawley@sundiver.esd.sgi.com Silicon Graphics, Inc. 1L-945 phone: 415 / 335-1621 Mountain View, CA 94039-7311 USA 408 / 243-1042 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Nicht nur wie schnell Sie fahren, sondern _wie_ Sie schnell fahren."
fsfacca@AVELON.LERC.NASA.GOV (Tony Facca) (04/26/91)
> password. My problem arises when the user hits Ctrl-C when he first logs > in which kills the execution of /etc/cshrc, thus my expiration checker does > not get executed. How can I trap these signals in a csh? > In a Bourne shell all I have to do is trap them with the trap command. > In C Shell you would user "onintr -" to turn off all interrupts, and then "onintr" to turn them back on after the critical section of code. If you have an interrupt handler, you can branch to it using "onintr xxx" where xxx is a label, as in "goto xxx". ----------------------------------------------------------------------------- Tony Facca | fsfacca@avelon.lerc.nasa.gov | phone: 216-433-8318 ----------------------------------------------------------------------------- You are at Witt's end. Passages lead off in *all* directions.