1 |
|
---|
2 |
|
---|
3 |
|
---|
4 |
|
---|
5 |
|
---|
6 |
|
---|
7 |
|
---|
8 |
|
---|
9 |
|
---|
10 |
|
---|
11 |
|
---|
12 |
|
---|
13 |
|
---|
14 |
|
---|
15 |
|
---|
16 |
use DBI; |
---|
17 |
use DBD::Pg; |
---|
18 |
|
---|
19 |
$path = $0; |
---|
20 |
$path =~ s/envpolicyupdate.pl$//i; |
---|
21 |
if ($pwd ne "./"){ |
---|
22 |
push( @INC, "$path"); |
---|
23 |
} |
---|
24 |
|
---|
25 |
require "foltialib.pl"; |
---|
26 |
|
---|
27 |
|
---|
28 |
$returnparam = getphpstyleconfig("useenvironmentpolicy"); |
---|
29 |
eval "$returnparam\n"; |
---|
30 |
|
---|
31 |
if ($useenvironmentpolicy == 1){ |
---|
32 |
$returnparam = getphpstyleconfig("environmentpolicytoken"); |
---|
33 |
eval "$returnparam\n"; |
---|
34 |
|
---|
35 |
my $data_source = sprintf("dbi:%s:dbname=%s;host=%s;port=%d", |
---|
36 |
$DBDriv,$DBName,$DBHost,$DBPort); |
---|
37 |
$dbh = DBI->connect($data_source,$DBUser,$DBPass) ||die $DBI::error;; |
---|
38 |
|
---|
39 |
$DBQuery = "SELECT userclass,name,passwd1 FROM foltia_envpolicy "; |
---|
40 |
|
---|
41 |
$envph = $dbh->prepare($DBQuery); |
---|
42 |
$envph->execute(); |
---|
43 |
|
---|
44 |
|
---|
45 |
unless (-e "$toolpath/.htpasswd"){ |
---|
46 |
$oserr = `touch $toolpath/.htpasswd`; |
---|
47 |
}else{ |
---|
48 |
$oserr = `mv $toolpath/.htpasswd $toolpath/htpasswd_foltia_old`; |
---|
49 |
$oserr = `touch $toolpath/.htpasswd`; |
---|
50 |
} |
---|
51 |
|
---|
52 |
while (@ref = $envph->fetchrow_array ){ |
---|
53 |
|
---|
54 |
if ($ref[0] == 0){ |
---|
55 |
|
---|
56 |
|
---|
57 |
|
---|
58 |
|
---|
59 |
|
---|
60 |
|
---|
61 |
|
---|
62 |
$htpasswd = "$ref[2]"; |
---|
63 |
}else{ |
---|
64 |
$htpasswd = "$ref[2]"."$environmentpolicytoken"; |
---|
65 |
} |
---|
66 |
|
---|
67 |
$oserr = `htpasswd -b $toolpath/.htpasswd $ref[1] $htpasswd`; |
---|
68 |
|
---|
69 |
|
---|
70 |
} |
---|
71 |
&writelog("envpolicyupdate htpasswd updated."); |
---|
72 |
|
---|
73 |
} |
---|