#!/usr/bin/perl # # lcuserdel # # Scott Harrison # October 27, 2000 use strict; # This script is a setuid script (chmod 6755) that should # be run by user 'www'. It DOES NOT delete directories. # All it does is remove a user's entries from # /etc/passwd, /etc/groups, and /etc/smbpasswd. # Standard input usage # First line is USERNAME # Command-line arguments [USERNAME] # Yes, but be very careful here (don't pass shell commands) # and this is only supported to allow perl-system calls. # Usage within code # # $exitcode=system("NAME")/256; # print "uh-oh" if $exitcode; # These are the exit codes. # Security $ENV{'PATH'}=""; # Nullify path information. $ENV{'BASH_ENV'}=""; # Nullify shell environment information. # Do not print error messages if there are command-line arguments my $noprint=0; if (@ARGV) { $noprint=1; } open (IN, "; close IN; my $wwwid; for my $l (@lines) { chop $l; my @F=split(/\:/,$l); if ($F[0] eq 'www') {$wwwid=$F[2];} } if ($wwwid!=$<) { print("User ID mismatch. This program must be run as user 'www'\n") unless $noprint; exit 1; } &disable_root_capability; # Gather input. Should only be 3 values. my @input; if (@ARGV==3) { @input=@ARGV; } elsif (@ARGV) { print("Error. This program needs 3 command-line arguments (username, old password, new password).\n") unless $noprint; exit 2; } else { @input=<>; if (@input!=3) { print("Error. Three lines need to be entered into standard input.\n") unless $noprint; exit 3; } map {chop} @input; } # Handle case of another lcpasswd process unless (&try_to_lock("/tmp/lock_lcpasswd")) { print "Error. Too many other simultaneous password change requests being made.\n" unless $noprint; exit 4; }