Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

RE: Kill User

by Fastolfe (Vicar)
on Oct 30, 2000 at 21:25 UTC ( [id://39139]=note: print w/replies, xml ) Need Help??


in reply to Kill User

You may be interested in the =~ m// operation instead of grep. I'd also use $_ to simplify other stuff:
foreach (@users) { if (/$target/) { $rec = (split)[3]; if ($rec =~ /\D/) { next if $rec =~ /dtr/; ... etc
Though mainly this is just a style thing.

In addition, your outermost else block seems weird. The first test in the block is for /dtr/, which should never be true, since your outer test is for /\D/, or non-digits, which would have matched already.

When is $done set? use strict; would have alerted you that this is only used once in your code. Your script seems to be an infinite loop.

Also, a security note: if your PATH has been modified at all to cause you to run a different 'finger' than usual, or if someone is able to mangle their finger information so as to put arbitrary text on the 4th field, your `/usr/sbin/fuser -k /dev/tty$rec[3]` statement could potentially execute arbitrary code. As root, this could be a very bad thing. Consider perlsec and running with taint-checking enabled.

I don't mean for this to be a critique of your code.. I just feel you might be interested. :)

Replies are listed 'Best First'.
RE: RE: Kill User
by Octavian (Monk) on Oct 30, 2000 at 21:34 UTC
    finally someone who doesnt beat up on me ;) yes, it is meant to be an infinite loop, so if they try to log on again, it is still "hunting" them, this program was actually written very quickly during one of my "perl wars" with another sysadmin, in an attempt to get him off the system before he did something to me. I have never been to a perl class or anything of the sort, so to be honest, I have never heard of the strict command or seen it used. so that would explain why I didnt use that or used the system calls. my code should be improving now cause of this page ;)
      In that case, this site should help you immensely. Good luck.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://39139]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (3)
As of 2024-04-19 23:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found