version 1.1, 2000/10/27 23:42:33
|
version 1.2, 2000/10/28 17:53:01
|
Line 7
|
Line 7
|
|
|
use strict; |
use strict; |
|
|
# This script is a setuid script that should |
# This script is a setuid script (chmod 6755) that should |
# be run by user 'www'. It DOES NOT delete directories. |
# be run by user 'www'. It DOES NOT delete directories. |
# All it does is remove a user's entries from |
# All it does is remove a user's entries from |
# /etc/passwd, /etc/groups, and /etc/smbpasswd. |
# /etc/passwd, /etc/groups, and /etc/smbpasswd. |
Line 21 use strict;
|
Line 21 use strict;
|
# Yes, but be very careful here (don't pass shell commands) |
# Yes, but be very careful here (don't pass shell commands) |
# and this is only supported to allow perl-system calls. |
# 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 |
# Security |
$ENV{'PATH'}=""; # Nullify path information. |
$ENV{'PATH'}=""; # Nullify path information. |
$ENV{'BASH_ENV'}=""; # Nullify shell environment 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, "</etc/passwd"); |
|
my @lines=<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; |
|
} |
|
|
|
|
|
|