Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
J
jumpserver
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ops
jumpserver
Commits
14c48bc1
Commit
14c48bc1
authored
Oct 07, 2014
by
guanghongwei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sudo显示
parent
30cbf15b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
1 deletion
+37
-1
views.py
webroot/AutoSa/AutoSa/views.py
+15
-1
showSudo.html
webroot/AutoSa/templates/showSudo.html
+22
-0
No files found.
webroot/AutoSa/AutoSa/views.py
View file @
14c48bc1
...
...
@@ -120,12 +120,15 @@ class LDAPMgmt():
self
.
conn
.
simple_bind_s
(
admin_cn
,
admin_pass
)
def
list
(
self
,
filter
,
scope
=
ldap
.
SCOPE_SUBTREE
,
attr
=
None
):
result
=
{}
try
:
ldap_result
=
self
.
conn
.
search_s
(
self
.
ldap_base_dn
,
scope
,
filter
,
attr
)
for
entry
in
ldap_result
:
name
,
data
=
entry
for
k
,
v
in
data
.
items
():
print
'
%
s:
%
s'
%
(
k
,
v
)
print
'
%
s:
%
s'
%
(
k
,
v
)
result
[
k
]
=
v
return
result
except
ldap
.
LDAPError
,
e
:
print
e
...
...
@@ -605,6 +608,17 @@ def showSudo(request):
username
=
request
.
GET
.
get
(
'username'
)
if
not
username
:
return
HttpResponseRedirect
(
'/showUser/'
)
l
=
LDAPMgmt
()
result
=
l
.
list
(
'entryDN=cn=
%
s,Sudoers,
%
s'
%
(
str
(
username
),
ldap_base_dn
),
attr
=
[
'sudoHost'
,
'sudoCommand'
])
sudoHost
=
result
.
get
(
'sudoHost'
)
sudoCommand
=
result
.
get
(
'sudoCommand'
)
return
render_to_response
(
'showSudo.html'
,
{
'sudoHost'
:
sudoHost
,
'sudoCommand'
:
sudoCommand
,
'user_menu'
:
'active'
},
context_instance
=
RequestContext
(
request
))
...
...
webroot/AutoSa/templates/showSudo.html
0 → 100644
View file @
14c48bc1
{% extends 'base.html' %}
{% block content %}
<fieldset
>
<legend>
{{ username }}
</legend>
允许sudo的主机:
<ul
class=
"list-group"
>
{% for host in sudoHost %}
<li
class=
"list-group-item"
>
{{ host }}
</li>
{% endfor %}
</ul>
<br
/>
允许的sudo命令:
<ul
class=
"list-group"
>
{% for cmd in sudoCommand %}
<li
class=
"list-group-item"
>
{{ cmd }}
</li>
{% endfor %}
</ul>
</fieldset>
{% endblock %}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment