plugins/python/example*.py: pep8 fixes (mainly line too long)

This commit is contained in:
Robert Manner
2020-02-06 13:23:05 +01:00
committed by Todd C. Miller
parent 0f3631cc08
commit 45d2638571
8 changed files with 93 additions and 62 deletions

View File

@@ -1,27 +1,35 @@
import sudo
class DebugDemoPlugin(sudo.Plugin):
"""
An example sudo plugin demonstrating the debugging capabilities.
You can install it as an extra IO plugin for example by adding the following line to sudo.conf:
Plugin python_io python_plugin.so ModulePath=<path>/example_debugging.py ClassName=DebugDemoPlugin
You can install it as an extra IO plugin for example by adding the
following line to sudo.conf:
Plugin python_io python_plugin.so \
ModulePath=<path>/example_debugging.py \
ClassName=DebugDemoPlugin
To see the plugin's debug output, use the following line in sudo.conf:
Debug python_plugin.so /var/log/sudo_python_debug plugin@trace,c_calls@trace
^ ^-- the options for the logging
^----- the output will be placed here
Debug python_plugin.so \
/var/log/sudo_python_debug plugin@trace,c_calls@trace
^ ^-- the options for the logging
^----- the output will be placed here
The options for the logging is in format of multiple "subsystem@level" separated by commas (",").
The options for the logging is in format of multiple "subsystem@level"
separated by commas (",").
The most interesting subsystems are:
plugin Shows each call of sudo.debug API in the log
- py_calls Logs whenever a C function calls into the python module. (For example calling this __init__ function.)
- py_calls Logs whenever a C function calls into the python module.
(For example calling this __init__ function.)
c_calls Logs whenever python calls into a C sudo API function
You can also specify "all" as subsystem name to get the debug messages of all subsystems.
You can also specify "all" as subsystem name to get the debug messages of
all subsystems.
Other subsystems available:
internal logs internal functions of the python language wrapper plugin
internal logs internal functions of the python language wrapper
sudo_cb logs when sudo calls into its plugin API
load logs python plugin loading / unloading
@@ -38,21 +46,29 @@ class DebugDemoPlugin(sudo.Plugin):
See the sudo.conf manual for more details ("man sudo.conf").
"""
def __init__(self, plugin_options, **kwargs):
# Specify: "py_calls@info" debug option to show the call to this constructor and the arguments passed in
# Specify: "py_calls@info" debug option to show the call to this
# constructor and the arguments passed in
# Specifying "plugin@err" debug option will show this message (or any more verbose level)
sudo.debug(sudo.DEBUG.ERROR, "My demo purpose plugin shows this ERROR level debug message")
# Specifying "plugin@err" debug option will show this message
# (or any more verbose level)
sudo.debug(sudo.DEBUG.ERROR, "My demo purpose plugin shows "
"this ERROR level debug message")
# Specifying "plugin@info" debug option will show this message (or any more verbose level)
sudo.debug(sudo.DEBUG.INFO, "My demo purpose plugin shows this INFO level debug message")
# Specifying "plugin@info" debug option will show this message
# (or any more verbose level)
sudo.debug(sudo.DEBUG.INFO, "My demo purpose plugin shows "
"this INFO level debug message")
# If you raise the level to info or below, the call of the debug will also be logged.
# If you raise the level to info or below, the call of the debug
# will also be logged.
# An example output you will see in the debug log file:
# Dec 5 15:19:19 sudo[123040] __init__ @ /.../example_debugging.py:54 debugs:
# Dec 5 15:19:19 sudo[123040] My demo purpose plugin shows this ERROR level debug message
# Specify: "c_calls@diag" debug option to show this call and its arguments
# If you specify info debug level instead ("c_calls@info"),
# you will also see the python function and line from which you called the 'options_as_dict' function.
# Specify: "c_calls@diag" debug option to show this call and its
# arguments. If you specify info debug level instead ("c_calls@info"),
# you will also see the python function and line from which you called
# the 'options_as_dict' function.
self.plugin_options = sudo.options_as_dict(plugin_options)