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
c6823be3
Commit
c6823be3
authored
Feb 23, 2016
by
yumaojun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复sudo 命令 小写all 引起的推送失败(map)
parent
7bfb1d19
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
13 deletions
+13
-13
utils.py
jperm/utils.py
+6
-0
views.py
jperm/views.py
+7
-13
No files found.
jperm/utils.py
View file @
c6823be3
...
...
@@ -68,6 +68,12 @@ def gen_keys(key="", key_path_dir=""):
return
key_path_dir
def
trans_all
(
str
):
if
str
.
strip
()
.
lower
()
==
"all"
:
return
str
.
upper
()
else
:
return
str
if
__name__
==
"__main__"
:
print
gen_keys
()
...
...
jperm/views.py
View file @
c6823be3
...
...
@@ -10,7 +10,7 @@ from jasset.models import Asset, AssetGroup
from
jperm.models
import
PermRole
,
PermRule
,
PermSudo
,
PermPush
from
jumpserver.models
import
Setting
from
jperm.utils
import
gen_keys
from
jperm.utils
import
gen_keys
,
trans_all
from
jperm.ansible_api
import
MyTask
from
jperm.perm_api
import
get_role_info
,
get_role_push_host
from
jumpserver.api
import
my_render
,
get_object
,
CRYPTOR
...
...
@@ -619,12 +619,9 @@ def perm_sudo_add(request):
raise
ServerError
(
u"sudo name 和 commands是必填项!"
)
pattern
=
re
.
compile
(
r'[\n,\r]'
)
deal_commands
=
list_drop_str
(
pattern
.
split
(
commands
),
u''
)
for
command
in
deal_commands
:
if
command
.
strip
()
.
lower
()
==
"all"
:
deal_commands
.
remove
(
command
)
deal_commands
.
append
(
command
.
upper
())
commands
=
', '
.
join
(
deal_commands
)
deal_space_commands
=
list_drop_str
(
pattern
.
split
(
commands
),
u''
)
deal_all_commands
=
map
(
trans_all
,
deal_space_commands
)
commands
=
', '
.
join
(
deal_all_commands
)
logger
.
debug
(
u'添加sudo
%
s:
%
s'
%
(
name
,
commands
))
if
get_object
(
PermSudo
,
name
=
name
):
...
...
@@ -661,12 +658,9 @@ def perm_sudo_edit(request):
raise
ServerError
(
u"sudo name 和 commands是必填项!"
)
pattern
=
re
.
compile
(
r'[\n,\r]'
)
deal_commands
=
list_drop_str
(
pattern
.
split
(
commands
),
u''
)
for
command
in
deal_commands
:
if
command
.
strip
()
.
lower
()
==
"all"
:
deal_commands
.
remove
(
command
)
deal_commands
.
append
(
command
.
upper
())
commands
=
', '
.
join
(
deal_commands
)
.
strip
()
deal_space_commands
=
list_drop_str
(
pattern
.
split
(
commands
),
u''
)
deal_all_commands
=
map
(
trans_all
,
deal_space_commands
)
commands
=
', '
.
join
(
deal_all_commands
)
.
strip
()
logger
.
debug
(
u'添加sudo
%
s:
%
s'
%
(
name
,
commands
))
sudo
.
name
=
name
.
strip
()
...
...
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