doc/sudo_plugin_python: document returning error string
This commit is contained in:

committed by
Todd C. Miller

parent
8f79d5c1c7
commit
bd465b3087
@@ -117,10 +117,24 @@ If a function returns
|
|||||||
(for example, if it does not call return),
|
(for example, if it does not call return),
|
||||||
it will be considered to have returned
|
it will be considered to have returned
|
||||||
\fRsudo.RC.OK\fR.
|
\fRsudo.RC.OK\fR.
|
||||||
If an exception is raised, the backtrace will be shown to the user and
|
If an exception is raised (other than sudo.PluginError), the backtrace will be
|
||||||
the plugin function will return
|
shown to the user and the plugin function will return
|
||||||
\fRsudo.RC.ERROR\fR.
|
\fRsudo.RC.ERROR\fR.
|
||||||
If that is not acceptable, you must catch the exception and handle it yourself.
|
If that is not acceptable, you must catch the exception and handle it yourself.
|
||||||
|
.sp
|
||||||
|
Instead of just returning
|
||||||
|
\fRsudo.RC.ERROR\fR
|
||||||
|
result code the plugin can also provide a message describing the problem.
|
||||||
|
This can be done by raising the special exception:
|
||||||
|
.nf
|
||||||
|
.sp
|
||||||
|
.RS 6n
|
||||||
|
raise sudo.PluginError("Message")
|
||||||
|
.RE
|
||||||
|
.fi
|
||||||
|
.PP
|
||||||
|
This added message will be used by the audit plugins.
|
||||||
|
.sp
|
||||||
.SS "Python Plugin Loader"
|
.SS "Python Plugin Loader"
|
||||||
Running the Python interpreter and bridging between C and Python is
|
Running the Python interpreter and bridging between C and Python is
|
||||||
handled by the
|
handled by the
|
||||||
|
@@ -99,10 +99,21 @@ If a function returns
|
|||||||
(for example, if it does not call return),
|
(for example, if it does not call return),
|
||||||
it will be considered to have returned
|
it will be considered to have returned
|
||||||
.Dv sudo.RC.OK .
|
.Dv sudo.RC.OK .
|
||||||
If an exception is raised, the backtrace will be shown to the user and
|
If an exception is raised (other than sudo.PluginError), the backtrace will be
|
||||||
the plugin function will return
|
shown to the user and the plugin function will return
|
||||||
.Dv sudo.RC.ERROR .
|
.Dv sudo.RC.ERROR .
|
||||||
If that is not acceptable, you must catch the exception and handle it yourself.
|
If that is not acceptable, you must catch the exception and handle it yourself.
|
||||||
|
|
||||||
|
Instead of just returning
|
||||||
|
.Dv sudo.RC.ERROR
|
||||||
|
result code the plugin can also provide a message describing the problem.
|
||||||
|
This can be done by raising the special exception:
|
||||||
|
.Bd -literal -offset indent
|
||||||
|
raise sudo.PluginError("Message")
|
||||||
|
.Ed
|
||||||
|
.Pp
|
||||||
|
This added message will be used by the audit plugins.
|
||||||
|
|
||||||
.Ss Python Plugin Loader
|
.Ss Python Plugin Loader
|
||||||
Running the Python interpreter and bridging between C and Python is
|
Running the Python interpreter and bridging between C and Python is
|
||||||
handled by the
|
handled by the
|
||||||
|
Reference in New Issue
Block a user