3 # convert a passwd(5) and optional supplementary file into the new
6 # Please NOTE: None of the TACACS code available here comes with any
8 # Copyright (c) 1995-1998 by Cisco systems, Inc.
10 # Permission to use, copy, modify, and distribute this software for any
11 # purpose and without fee is hereby granted, provided that this
12 # copyright and permission notice appear on all copies of the software and
13 # supporting documentation, the name of Cisco Systems, Inc. not be used
14 # in advertising or publicity pertaining to distribution of the
15 # program without specific prior permission, and notice be given
16 # in supporting documentation that modification, copying and distribution is by
17 # permission of Cisco Systems, Inc.
19 # Cisco Systems, Inc. makes no representations about the suitability of this
20 # software for any purpose. THIS SOFTWARE IS PROVIDED ``AS IS''
21 # AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT
22 # LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23 # FOR A PARTICULAR PURPOSE.
25 die 'Usage: convert.pl <password file> [-g] [ <supplementary file> ]'
31 $acl_valid = 0; # is acl valid in gid field?
33 $pwfile = shift(@ARGV);
35 local($arg) = shift(@ARGV);
36 $acl_valid++, next if ($arg eq '-g');
41 open(SUP, $supfile) || die "Can't read $supfile -- $!";
46 local($user, $inacl, $outacl, $arap, $chap) = split(/:/);
48 if (defined $sup{$user,'user'}) {
49 die "User $user is multiply defined on lines $sup{$user,'user'} and $. of $supfile";
52 $sup{$user,'user'} = $.;
53 $sup{$user,'inacl'} = $inacl;
54 $sup{$user,'outacl'} = $outacl;
55 $sup{$user,'arap'} = $arap;
56 $sup{$user,'chap'} = $chap;
61 open(PASSWD, $pwfile) || die "Can't read $pwfile -- $!";
67 local($user, $pass, $uid, $gid, $gcos, $home, $exp) = split(/:/);
71 print "user = $user {\n";
72 print " login = des $pass\n";
74 print " member = $gid\n";
79 print " name = \"$gcos\"\n";
81 print " name = $gcos\n";
85 if ($exp =~ /\S+\s+\d+\s+\d+/) {
86 print " expires = \"$exp\"\n";
90 print " service = exec {\n";
91 print " acl = $gid\n";
95 local($outacl) = $sup{$user,'outacl'};
96 local($inacl) = $sup{$user,'inacl'};
97 if ($inacl ne '' || $outacl ne '') {
98 print " service = slip {\n";
99 print " inacl = $inacl\n" if $inacl ne '';
100 print " outacl = $outacl\n" if $outacl ne '';
103 print " service = ppp protocol = ip {\n";
104 print " inacl = $inacl\n" if $inacl ne '';
105 print " outacl = $outacl\n" if $outacl ne '';
109 print " arap = $sup{$user,'arap'}\n" if $sup{$user,'arap'} ne '';
110 print " chap = $sup{$user,'chap'}\n" if $sup{$user,'chap'} ne '';
116 foreach $user (keys %users) {
117 next if $users{$user} != 1;
118 # This user only in supfile
119 print "user = $user {\n";
120 local($outacl) = $sup{$user,'outacl'};
121 local($inacl) = $sup{$user,'inacl'};
122 if ($inacl ne '' || $outacl ne '') {
123 print " service = slip {\n";
124 print " inacl = $inacl\n" if $inacl ne '';
125 print " outacl = $outacl\n" if $outacl ne '';
128 print " service = ppp protocol = ip {\n";
129 print " inacl = $inacl\n" if $inacl ne '';
130 print " outacl = $outacl\n" if $outacl ne '';
134 print " arap = $sup{$user,'arap'}\n" if $sup{$user,'arap'} ne '';
135 print " chap = $sup{$user,'chap'}\n" if $sup{$user,'chap'} ne '';
139 exit 0 if ($acl_valid);
141 foreach $group (keys %groups) {
142 print "group = $group { }\n";