mirror of
https://github.com/nicolargo/glances.git
synced 2026-03-12 10:56:53 -04:00
Improve secure.py
This commit is contained in:
@@ -9,10 +9,11 @@
|
||||
|
||||
"""Secures functions for Glances"""
|
||||
|
||||
from glances.globals import nativestr
|
||||
from subprocess import Popen, PIPE
|
||||
import re
|
||||
|
||||
from glances.globals import nativestr
|
||||
|
||||
|
||||
def secure_popen(cmd):
|
||||
"""A more or less secure way to execute system commands
|
||||
@@ -54,8 +55,10 @@ def __secure_popen(cmd):
|
||||
sub_cmd_split = [_[1:-1] if (_[0] == _[-1] == '"') or (_[0] == _[-1] == '\'') else _ for _ in tmp_split]
|
||||
p = Popen(sub_cmd_split, shell=False, stdin=sub_cmd_stdin, stdout=PIPE, stderr=PIPE)
|
||||
if p_last is not None:
|
||||
p_last.wait()
|
||||
# Allow p_last to receive a SIGPIPE if p exits.
|
||||
p_last.stdout.close()
|
||||
p_last.kill()
|
||||
p_last.wait()
|
||||
p_last = p
|
||||
sub_cmd_stdin = p.stdout
|
||||
|
||||
|
||||
@@ -33,7 +33,6 @@ from glances.plugins.plugin.model import GlancesPluginModel
|
||||
from glances.programs import processes_to_programs
|
||||
from glances.secure import secure_popen
|
||||
|
||||
|
||||
# Global variables
|
||||
# =================
|
||||
|
||||
|
||||
Reference in New Issue
Block a user