How to disallow logout

Evan Geller thespin at gmail.com
Fri Sep 10 07:41:27 UTC 2010


Perhaps you could write something to wrap your shell... basically you
could set your login shell to this wrapper. First thing the wrapper
would do is exec and wait on the shell, and when the shell exits,
check what needs to be checked, and should any of these checks fail,
respawn the shell and dump the user back into their login shell. That
way you can't neglect any funky corner cases of the shell exiting...
the shell exits, the checks happen.

In this example, the user is forced to exit 3 times. The experience is
pretty seemless, the only issue is that the user will lose their
environment after failing and ending up back in the new respawned
shell, but I don't see how this would be an issue if the user is
hastefully logging out.

shell-A$ for i in 1 2 3; do bash; echo poop; done
child-1-of-A$ exit
exit
poop
child-2-of-A$ exit
exit
poop
child-3-of-A$ exit
exit
poop
shell-A$ exit
exit
parent-of-A% exit

E

On Thu, Sep 9, 2010 at 8:34 PM, Atom Smasher <atom at smasher.org> wrote:
> On Thu, 9 Sep 2010, Aryeh Friedman wrote:
>
>> I have a directory that must not exist on logout and rm -rf is not
>> sufficent to do it because the contents need to be processed by our version
>> control system.
>
> =====================
>
> what i would do... make an alias or function of "logout" and/or "exit" in
> the init file that's parsed when the shell starts. alias it to a script or
> assign it to a function that does what you need.
>
> if your shell supports logging out with ^D (or any other keybinding) then
> the details may be shell-specific, but the idea would be to either disable
> it, or bind it to the script.
>
>
> --
>        ...atom
>
>  ________________________
>  http://atom.smasher.org/
>  762A 3B98 A3C3 96C9 C6B7 582A B88D 52E4 D9F5 7808
>  -------------------------------------------------
>
>        "The reasonable man adapts himself to the world; the
>         unreasonable one persists in trying to adapt the world to
>         himself. Therefore all progress depends on the
>         unreasonable man."
>                -- George Bernard Shaw
>
> _______________________________________________
> freebsd-hackers at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
> To unsubscribe, send any mail to "freebsd-hackers-unsubscribe at freebsd.org"
>



-- 
---
Evan Geller
thespin at gmail.com


More information about the freebsd-hackers mailing list