It is currently Tue, 07 Dec 2021 02:09:55 GMT



 
Author Message
 Calling logout or exit within PERL

On BSD unix how can I call the logout command from perl

ie system("logout");
or system("exit");

where is exit or logout on the system a ,find reveals them not,
how can I call exit or logout

Also how can one disable CTRL C and CTRL Z so a user cannot interupt my
perl program

Thanks in advance



 Sun, 29 Nov 1998 03:00:00 GMT   
 Calling logout or exit within PERL

In article <01bb57f7.ac71d320$6e0d038c@pc-molly>,

"logout" or "exit" makes the shell exit, if you do system("exit"); all
you do is start a shell which exits, not exit your previous one.  There
is no clean way a program can logout the user, you could kill all his
processes if you're sure the user doesn't want to (or isn't allowed to)
leave background tasks or be logged on more than once at the same time,
with something like:

  kill 1, -1;  sleep 2; kill 9 -1;

Alternatively, you can kill the script's parent process, which will
usually be the main shell:

  kill 9, getppid;

  $SIG{'INT'} = 'IGNORE';
  $SIG{'TSTP'} = 'IGNORE';

and you probably also want to disable ^\ with:

  $SIG{'QUIT'} = 'IGNORE';

Note that the security provided by this is not as strong as it may seem;
the user can press ^Z while perl is compiling your script.  If you want
to make it impossible for the user to get to a shell, make the shell
"exec" the perl script, so that when the script terminates the user
finds himself logged out automatically.   Even like this, the user can
press ^C early enough in the login sequence that ultimately calls the
perl script...

If you want a secure restricted environment for a user, it's better to
set a special login shell for them, which would be a little C program
that would execl() the perl script.  Make sure it doesn't depend on  
and can't be subverted by initial settings of environment variables
too, as those can often be passed to login processes.

        -Roger
--
e-mail: roger.espel.ll...@ens.fr
WWW & PGP key: http://www.eleves.ens.fr:8080/home/espel/index.html



 Sun, 29 Nov 1998 03:00:00 GMT   
 Calling logout or exit within PERL

On 12 Jun 1996 00:38:52 GMT, mollyt <mol...@yoyo.cc.monash.edu.au> wrote:

exit(exit_status);

Set the tty to raw mode

--
Brian Mitchell                          br...@saturn.net
Unix Security / Perl / WWW / CGI        http://www.saturn.net/~brian
"I never give them hell. I just tell the truth and they think it's hell"
- H. Truman



 Sun, 29 Nov 1998 03:00:00 GMT   
 Calling logout or exit within PERL

|> On BSD unix how can I call the logout command from perl
|>
|> ie system("logout");
|> or system("exit");
|>
|>
|> where is exit or logout on the system a ,find reveals them not,
|> how can I call exit or logout

assuming your login shell is your session leader you could use

kill(session_id, SIGHUP);

the problem maybe to get the session_id in perl.
in c there is a system call getsid()
on systems supporting it you may use the syscall() system call
with the appropriate constant as first parameter to do a getsid()

|> Also how can one disable CTRL C and CTRL Z so a user cannot interupt my
|> perl program

add code like the following to your perl program:

$SIG{'INT'} = 'int_handler';
$SIG{'TSTP'} = 'tstp_handler';

sub int_handler
{
 local($sig) = @_;
 print "this program cannot be interupted\n";

sub tstp_handler
{
 local($sig) = @_;
 print "this program cannot be stopped from the kyboard\n";

kf

--



 Mon, 30 Nov 1998 03:00:00 GMT   
 
   [ 4 post ] 

Similar Threads

1. calling perl within c

2. exit()-System or C Library call, return vs exit

3. Perl system() call never returns (Solaris 2.5.1, Perl 5.004_03)

4. logout from within a script

5. logout from within a shell script?

6. logout from within a sh script - possible?

7. How to logout from within the script?

8. Changing the logout script for exit button

9. CDE exit-logout difference

10. ***How can I exit program and logout at once?***


 
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software