Changed process communication to use stdin for the message because of security concerns.
parent
5a03ddd7e0
commit
fa8857dfc5
|
@ -8,7 +8,6 @@ https://home-assistant.io/components/notify.command_line/
|
||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
import subprocess
|
import subprocess
|
||||||
import shlex
|
|
||||||
from homeassistant.helpers import validate_config
|
from homeassistant.helpers import validate_config
|
||||||
from homeassistant.components.notify import (
|
from homeassistant.components.notify import (
|
||||||
DOMAIN, BaseNotificationService)
|
DOMAIN, BaseNotificationService)
|
||||||
|
@ -38,10 +37,12 @@ class CommandLineNotificationService(BaseNotificationService):
|
||||||
|
|
||||||
def send_message(self, message="", **kwargs):
|
def send_message(self, message="", **kwargs):
|
||||||
""" Send a message to a command_line. """
|
""" Send a message to a command_line. """
|
||||||
|
|
||||||
try:
|
try:
|
||||||
subprocess.check_call(
|
proc = subprocess.Popen(self.command, universal_newlines=True,
|
||||||
"{} {}".format(self.command,
|
stdin=subprocess.PIPE, shell=True)
|
||||||
shlex.quote(message)),
|
proc.communicate(input=message)
|
||||||
shell=True)
|
if proc.returncode != 0:
|
||||||
except subprocess.CalledProcessError:
|
_LOGGER.error('Command failed: %s', self.command)
|
||||||
_LOGGER.error('Command failed: %s', self.command)
|
except subprocess.SubprocessError:
|
||||||
|
_LOGGER.error('Error trying to exec Command: %s', self.command)
|
||||||
|
|
Loading…
Reference in New Issue