3 # Save authentication options
5 require './squid-lib.pl';
6 $access{'proxyauth'} || &error($text{'eauth_ecannot'});
8 &lock_file($config{'squid_conf'});
10 $whatfailed = $text{'sauth_ftsao'};
12 if ($in{'authfile_def'}) {
13 &save_directive($conf, "proxy_auth", [ ]);
16 $in{'authfile'} =~ /^\// || &error($text{'sauth_iomuf'});
17 if (!-r $in{'authfile'}) {
18 &open_tempfile(AUTH, ">$in{'authfile'}");
19 &close_tempfile(AUTH);
20 ($user, $group) = &get_squid_user($conf);
22 @uinfo = getpwnam($user);
23 @ginfo = getgrnam($group);
24 chown($uinfo[2], $ginfo[2], $in{'authfile'});
25 chmod(0644, $in{'authfile'});
28 push(@vals, $in{'authfile'});
29 if (!$in{'authdom_def'}) {
30 $in{'authdom'}=~/^\S+$/ || &error($text{'sauth_iomd'});
31 push(@vals, $in{'authdom'});
33 &save_directive($conf, "proxy_auth",
34 [ { 'name' => 'proxy_auth',
35 'values' => \@vals } ]);
39 # check if the proxy_auth directive is supported
40 $out = `$config{'squid_path'} -f $config{'squid_conf'} -k check 2>&1`;
41 if ($out =~ /proxy_auth/) {
42 # it isn't .. roll back
43 &save_directive($conf, "proxy_auth", [ ]);
45 &error($text{'sauth_msg1'});
47 &unlock_file($config{'squid_conf'});