[Kc] Removing users from sudoers

Sterling Hanenkamp sterling at hanenkamp.com
Thu May 8 06:44:25 PDT 2008


On Thu, May 8, 2008 at 8:24 AM, Emmanuel Mejias <emmanuel.mejias at gmail.com>
wrote:
>
> This is what I have so far in Perl, but I'm not sure how to continue or how
> to add the sed line in here.
>
> *#!/usr/bin/perl -w
>
> # this script removes a user from sudoers file
>
> @mysites = ("Alpha", "Echo", "India", "Joliet", "Kilo", "November",
>                     "Papa", "Uniform", "Sierra", "Wiskey");
>
> open(FILE, "@mysite/local/etc/sudoers");
> @site = <FILE>;
> close(FILE);*
>
>
> I know I need to throw in a for loop, maybe a few, I don't know. I'm stuck!
>

Yep, you'll need a loop to go over the locations and another to apply the
s/// replacement to the lines of the file.

for my $site (@mysites) {
  open FILE, "$site/local/etc/sudoers" or die "cannot open sudoers for
$site: $!";
  while (<FILE>) { s/someuser// }
  close FILE;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.pm.org/pipermail/kc/attachments/20080508/7de06a03/attachment.html 


More information about the kc mailing list