plugins/python/example_{io,conversation}: avoid printing signal number
They are platform dependant, so their test would fail on some platforms. While we could create separate plugin for the tests, I like the idea that the examples are ensured to be working. I believe this is a good compromise for being able to auto update the test cases.
This commit is contained in:

committed by
Todd C. Miller

parent
40f2189586
commit
f3b7f3c0d4
@@ -65,7 +65,7 @@ class ReasonLoggerIOPlugin(sudo.Plugin):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def _signal_name(cls, signum):
|
def _signal_name(cls, signum):
|
||||||
try:
|
try:
|
||||||
return "{} ({})".format(signal.Signals(signum).name, signum)
|
return signal.Signals(signum).name
|
||||||
except Exception:
|
except Exception:
|
||||||
return "{}".format(signum)
|
return "{}".format(signum)
|
||||||
|
|
||||||
|
@@ -99,8 +99,7 @@ class SudoIOPlugin(sudo.Plugin):
|
|||||||
|
|
||||||
def log_suspend(self, signo: int) -> int:
|
def log_suspend(self, signo: int) -> int:
|
||||||
try:
|
try:
|
||||||
signal_name = signal.Signals(signo).name
|
signal_description = signal.Signals(signo).name
|
||||||
signal_description = "{} ({})".format(signal_name, signo)
|
|
||||||
except (AttributeError, ValueError):
|
except (AttributeError, ValueError):
|
||||||
signal_description = "signal {}".format(signo)
|
signal_description = "signal {}".format(signo)
|
||||||
|
|
||||||
|
@@ -1,3 +1,3 @@
|
|||||||
Please provide your reason for executing ('/bin/whoami',)
|
Please provide your reason for executing ('/bin/whoami',)
|
||||||
conversation suspend: signal SIGTSTP (20)
|
conversation suspend: signal SIGTSTP
|
||||||
conversation resume: signal was SIGCONT (18)
|
conversation resume: signal was SIGCONT
|
||||||
|
@@ -7,8 +7,8 @@ EXEC info [
|
|||||||
STD IN some standard input
|
STD IN some standard input
|
||||||
STD OUT some standard output
|
STD OUT some standard output
|
||||||
STD ERR some standard error
|
STD ERR some standard error
|
||||||
SUSPEND SIGTSTP (20)
|
SUSPEND SIGTSTP
|
||||||
SUSPEND SIGCONT (18)
|
SUSPEND SIGCONT
|
||||||
WINSIZE 200x100
|
WINSIZE 200x100
|
||||||
TTY IN some tty input
|
TTY IN some tty input
|
||||||
TTY OUT some tty output
|
TTY OUT some tty output
|
||||||
|
@@ -2,6 +2,6 @@ Example sudo python plugin will log to /some/not/writable/directory/sudo.log
|
|||||||
Traceback:
|
Traceback:
|
||||||
File "SRC_DIR/example_io_plugin.py", line 60, in __init__
|
File "SRC_DIR/example_io_plugin.py", line 60, in __init__
|
||||||
self._open_log_file(path.join(log_path, "sudo.log"))
|
self._open_log_file(path.join(log_path, "sudo.log"))
|
||||||
File "SRC_DIR/example_io_plugin.py", line 132, in _open_log_file
|
File "SRC_DIR/example_io_plugin.py", line 131, in _open_log_file
|
||||||
self._log_file = open(log_path, "a")
|
self._log_file = open(log_path, "a")
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user