2 # Common functions for editing a PPP users file
8 open(SEC, $config{'pap_file'});
13 @w = &split_words($_);
16 $sec{'client'} = $w[0];
17 $sec{'server'} = $w[1];
18 $sec{'secret'} = $w[2];
22 $sec{'index'} = scalar(@rv);
31 # create_secret(&secret)
34 &open_tempfile(SEC, ">>$config{'pap_file'}");
35 &print_tempfile(SEC, &join_words($_[0]->{'client'}, $_[0]->{'server'},
36 $_[0]->{'secret'}, @{$_[0]->{'ips'}}),"\n");
40 # change_secret(&secret)
43 &replace_file_line($config{'pap_file'}, $_[0]->{'line'},
44 &join_words($_[0]->{'client'}, $_[0]->{'server'},
45 $_[0]->{'secret'}, @{$_[0]->{'ips'}})."\n");
48 # delete_secret(&secret)
51 &replace_file_line($config{'pap_file'}, $_[0]->{'line'});
59 while($s =~ /^\s*([^"\s]+|"([^"]*)")(.*)$/) {
60 push(@w, defined($2) ? $2 : $1);
70 if ($w =~ /^[a-zA-Z0-9\.\-]+$/) { push(@w, $w); }
71 else { push(@w, "\"$w\""); }
77 # Returns the given password, crypted if the user has configured it
80 if ($config{'encrypt_pass'}) {
83 $salt = chr(int(rand(26))+65).chr(int(rand(26))+65);
84 return &unix_crypt($_[0], $salt);