File:
[LON-CAPA] /
loncom /
pwchange
Revision
1.9:
download - view:
text,
annotated -
select for diffs
Mon Feb 3 18:03:52 2003 UTC (21 years, 7 months ago) by
harris41
Branches:
MAIN
CVS tags:
version_2_8_X,
version_2_8_2,
version_2_8_1,
version_2_8_0,
version_2_7_X,
version_2_7_99_1,
version_2_7_99_0,
version_2_7_1,
version_2_7_0,
version_2_6_X,
version_2_6_99_1,
version_2_6_99_0,
version_2_6_3,
version_2_6_2,
version_2_6_1,
version_2_6_0,
version_2_5_X,
version_2_5_99_1,
version_2_5_99_0,
version_2_5_2,
version_2_5_1,
version_2_5_0,
version_2_4_X,
version_2_4_99_0,
version_2_4_2,
version_2_4_1,
version_2_4_0,
version_2_3_X,
version_2_3_99_0,
version_2_3_2,
version_2_3_1,
version_2_3_0,
version_2_2_X,
version_2_2_99_1,
version_2_2_99_0,
version_2_2_2,
version_2_2_1,
version_2_2_0,
version_2_1_X,
version_2_1_99_3,
version_2_1_99_2,
version_2_1_99_1,
version_2_1_99_0,
version_2_1_3,
version_2_1_2,
version_2_1_1,
version_2_1_0,
version_2_0_X,
version_2_0_99_1,
version_2_0_2,
version_2_0_1,
version_2_0_0,
version_1_99_3,
version_1_99_2,
version_1_99_1_tmcc,
version_1_99_1,
version_1_99_0_tmcc,
version_1_99_0,
version_1_3_X,
version_1_3_3,
version_1_3_2,
version_1_3_1,
version_1_3_0,
version_1_2_X,
version_1_2_99_1,
version_1_2_99_0,
version_1_2_1,
version_1_2_0,
version_1_1_X,
version_1_1_99_5,
version_1_1_99_4,
version_1_1_99_3,
version_1_1_99_2,
version_1_1_99_1,
version_1_1_99_0,
version_1_1_3,
version_1_1_2,
version_1_1_1,
version_1_1_0,
version_1_0_99_3,
version_1_0_99_2,
version_1_0_99_1,
version_1_0_99,
version_1_0_3,
version_1_0_2,
version_1_0_1,
version_1_0_0,
version_0_99_5,
version_0_99_4,
version_0_99_3,
version_0_99_2,
version_0_99_1,
version_0_99_0,
conference_2003,
bz5969,
HEAD,
GCI_1,
BZ5971-printing-apage,
BZ5434-fox
best wishes to all.
1: #!/usr/bin/perl
2:
3: # The Learning Online Network with CAPA
4: #
5: # pwchange - setuid script to change unix passwords
6: #
7: # YEAR=2001
8: #
9: # YEAR=2002
10: # 02/19 Matthew Hall
11: #
12: # $Id: pwchange,v 1.9 2003/02/03 18:03:52 harris41 Exp $
13: ###
14:
15: use strict;
16: my $noprint = 1;
17:
18:
19:
20: print "In pwchange\n" unless $noprint;
21: print "Real uid = $< effective uid = $> \n" unless $noprint;
22: # ------------------------------------------------------------------ Untainting
23: $ENV{'PATH'}='/bin:/usr/bin'; # Nullify path information.
24: delete @ENV{qw(IFS CDPATH ENV BASH_ENV)}; # nullify potential taints
25:
26: # ---------------------------- Make sure this process is running from user=root
27:
28: if (0 != $<) {
29: print "Username not root" unless $noprint;
30: exit 1;
31: }
32: # ----------------------------------------------- If not running setuid as root
33: if ($>!=0) {
34: print "Not setuid to root" unless $noprint;
35: exit 1;
36: }
37:
38: # ----------------------------------------------- Make sure arguments are valid
39: my $user=shift @ARGV;
40: $user=~/^(\w+)$/;
41: my $safe=$1;
42: print "Save user = $safe" unless $noprint;
43:
44: my $pword=<>;
45: chomp $pword;
46: unless (length($safe) and ($user eq $safe) and ($safe=~/^[A-Za-z]/)) {
47: exit 2;
48: }
49: print "Password = $pword" unless $noprint;
50: my $pbad=0;
51: foreach (split(//,$pword)) {if ((ord($_)<32)||(ord($_)>126)){$pbad=1;}}
52: exit 3 if $pbad;
53:
54: # --------------------------------------------------------- Call system command
55: open OUT,"|passwd --stdin $safe >/dev/null";
56: print OUT $pword;
57: print OUT "\n";
58: close OUT;
59:
60: # --------------------------------------- exit with status of command execution
61: exit $?/256;
62:
63: =head1 NAME
64:
65: pwchange - setuid script to change unix passwords
66:
67: =head1 DESCRIPTION
68:
69: Setuid script to change unix passwords.
70:
71: =head1 README
72:
73: Setuid script to change unix passwords.
74:
75: =head1 PREREQUISITES
76:
77: =head1 COREQUISITES
78:
79: =pod OSNAMES
80:
81: linux
82:
83: =pod SCRIPT CATEGORIES
84:
85: LONCAPA/Administrative
86:
87: =cut
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>