Commit 19343540 authored by Jiajun Liu's avatar Jiajun Liu

fix line break bug

some system user '\n\r' as line break, if we split commands by '\n',
then '\r' will be considered as part of commands which will break sudo
authentication. we can use splitlines function to avoid the problem.
parent 915adb2f
...@@ -484,7 +484,7 @@ def cmd_add(request): ...@@ -484,7 +484,7 @@ def cmd_add(request):
if request.method == 'POST': if request.method == 'POST':
name = request.POST.get('name') name = request.POST.get('name')
dept_id = request.POST.get('dept_id') dept_id = request.POST.get('dept_id')
cmd = ','.join(request.POST.get('cmd').split('\n')) cmd = ','.join(request.POST.get('cmd').splitlines())
comment = request.POST.get('comment') comment = request.POST.get('comment')
dept = DEPT.objects.filter(id=dept_id) dept = DEPT.objects.filter(id=dept_id)
...@@ -514,7 +514,7 @@ def cmd_add_adm(request): ...@@ -514,7 +514,7 @@ def cmd_add_adm(request):
if request.method == 'POST': if request.method == 'POST':
name = request.POST.get('name') name = request.POST.get('name')
cmd = ','.join(request.POST.get('cmd').split('\n')) cmd = ','.join(request.POST.get('cmd').splitlines())
comment = request.POST.get('comment') comment = request.POST.get('comment')
try: try:
...@@ -552,7 +552,7 @@ def cmd_edit(request): ...@@ -552,7 +552,7 @@ def cmd_edit(request):
cmd_group_id = request.POST.get('cmd_group_id') cmd_group_id = request.POST.get('cmd_group_id')
name = request.POST.get('name') name = request.POST.get('name')
dept_id = request.POST.get('dept_id') dept_id = request.POST.get('dept_id')
cmd = ','.join(request.POST.get('cmd').split('\n')) cmd = ','.join(request.POST.get('cmd').splitlines())
comment = request.POST.get('comment') comment = request.POST.get('comment')
cmd_group = CmdGroup.objects.filter(id=cmd_group_id) cmd_group = CmdGroup.objects.filter(id=cmd_group_id)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment