-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsudo_detail.php
125 lines (110 loc) · 3.66 KB
/
sudo_detail.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
<?php
// This file is a little uggly - it is basically only a _LOADER_
// for Sudoers information (with a little require at the bottom
// to actually SHOW this information as well).
if(@($_REQUEST["action"] != 'add')) {
// {{{ Setup session etc
if(!class_exists('pql')) {
require("./include/pql_session.inc");
require($_SESSION["path"]."/include/pql_config.inc");
}
require($_SESSION["path"]."/include/pql_sudoers.inc");
// }}}
}
// {{{ Retreive all users
if($_REQUEST["domain"]) {
if(pql_get_define("PQL_CONF_SUBTREE_USERS"))
$subrdn = pql_get_define("PQL_CONF_SUBTREE_USERS") . ",";
$userdn = $subrdn . $_REQUEST["domain"];
$filter = pql_get_define("PQL_CONF_REFERENCE_USERS_WITH", $_REQUEST["rootdn"])."=*";
$users = $_pql->get_dn($userdn, $filter);
// Extract 'human readable' name from the user DN's found
$user_results = pql_left_htmlify_userlist($_REQUEST["rootdn"], $_REQUEST["domain"],
$userdn, $users, ($links = NULL));
}
// }}}
// {{{ Retreive all computers
if(pql_get_define("PQL_CONF_SUBTREE_COMPUTERS")) {
$subrdn = pql_get_define("PQL_CONF_SUBTREE_COMPUTERS") . ",";
}
$computer_results = $_pql->get_dn($_SESSION["USER_SEARCH_DN_CTR"],
'(&(cn=*)(objectclass=ipHost)(ipHostNumber=*))');
if(is_array($computer_results)) {
sort($computer_results);
}
// }}}
// {{{ Retreive all sudo roles
if($_REQUEST["domain"]) {
// {{{ Called from Users->[domain]->Sudo
if(pql_get_define("PQL_CONF_SUBTREE_SUDOERS"))
$subrdn = pql_get_define("PQL_CONF_SUBTREE_SUDOERS") . ",";
$sudodn = $subrdn . $_REQUEST["domain"];
$filter = pql_get_define("PQL_ATTR_OBJECTCLASS").'=sudoRole';
$sudo_results = $_pql->search($sudodn, $filter);
if(is_array($sudo_results))
asort($sudo_results);
// }}}
} elseif(($_REQUEST["host"] == 'Global') and ($_REQUEST["ref"] == 'global')) {
// {{{ Called from Computers->Global->Sudo Administration
// Setup a filter containing all physical hosts we know about
$filter = '(&(objectClass=sudoRole)(cn=*)(|';
for($i=0; $computer_results[$i]; $i++) {
// Get the FQDN from the host DN
$physical = $_pql->get_attribute($computer_results[$i], pql_get_define("PQL_ATTR_CN"));
$filter .= "(sudoHost=$physical)";
}
$filter .= '))';
foreach($_pql->ldap_basedn as $dn) {
$dn = pql_format_normalize_dn($dn);
$tmp = $_pql->get_dn($dn, $filter);
pql_add2array($sudo_results, $tmp);
}
if(is_array($sudo_results)) {
// Get ALL information about these SUDO roles
sort($sudo_results);
for($i=0; $sudo_results[$i]; $i++) {
$roles[] = $_pql->search($sudo_results[$i], 'objectClass=*', 'BASE');
}
}
$sudo_results = $roles;
// }}}
} else {
// {{{ Called from physical host details->Sudo Administration
// Get the FQDN from the host DN
$physical = $_pql->get_attribute($_REQUEST["host"], pql_get_define("PQL_ATTR_CN"));
$filter = "(&(objectClass=sudoRole)(cn=*)(sudoHost=$physical))";
$sudo_results = array();
foreach($_pql->ldap_basedn as $dn) {
$dn = pql_format_normalize_dn($dn);
$tmp = $_pql->get_dn($dn, $filter);
pql_add2array($sudo_results, $tmp);
}
if(is_array($sudo_results)) {
// Get ALL information about these SUDO roles
sort($sudo_results);
for($i=0; $sudo_results[$i]; $i++) {
$roles[] = $_pql->search($sudo_results[$i], 'objectClass=*', 'BASE');
}
}
$sudo_results = $roles;
// }}}
}
if(is_array($sudo_results) and !@$sudo_results[0]) {
// Make sure it's a numbered array...
$tmp = $sudo_results;
unset($sudo_results);
$sudo_results[] = $tmp;
}
// }}}
if(@($_REQUEST["action"] != 'add')) {
// Load the sudo details page
require($_SESSION["path"]."/tables/domain_details-sudoers.inc");
}
/*
* Local variables:
* mode: php
* mode: font-lock
* tab-width: 4
* End:
*/
?>