1994-07-14 10:56:50 -03:00
|
|
|
/***********************************************************
|
1994-08-30 09:25:20 -03:00
|
|
|
Copyright 1994 by Lance Ellinghouse,
|
|
|
|
Cathedral City, California Republic, United States of America.
|
1994-07-14 10:56:50 -03:00
|
|
|
|
|
|
|
All Rights Reserved
|
|
|
|
|
2010-05-09 12:52:27 -03:00
|
|
|
Permission to use, copy, modify, and distribute this software and its
|
|
|
|
documentation for any purpose and without fee is hereby granted,
|
1994-07-14 10:56:50 -03:00
|
|
|
provided that the above copyright notice appear in all copies and that
|
2010-05-09 12:52:27 -03:00
|
|
|
both that copyright notice and this permission notice appear in
|
1994-08-30 09:25:20 -03:00
|
|
|
supporting documentation, and that the name of Lance Ellinghouse
|
2010-05-09 12:52:27 -03:00
|
|
|
not be used in advertising or publicity pertaining to distribution
|
1994-08-30 09:25:20 -03:00
|
|
|
of the software without specific, written prior permission.
|
1994-07-14 10:56:50 -03:00
|
|
|
|
1994-08-30 09:25:20 -03:00
|
|
|
LANCE ELLINGHOUSE DISCLAIMS ALL WARRANTIES WITH REGARD TO
|
1994-07-14 10:56:50 -03:00
|
|
|
THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
2010-05-09 12:52:27 -03:00
|
|
|
FITNESS, IN NO EVENT SHALL LANCE ELLINGHOUSE BE LIABLE FOR ANY SPECIAL,
|
|
|
|
INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
|
|
|
|
FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
|
|
|
|
NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
1994-08-30 09:25:20 -03:00
|
|
|
WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
1994-07-14 10:56:50 -03:00
|
|
|
|
|
|
|
******************************************************************/
|
|
|
|
|
1995-10-11 13:15:28 -03:00
|
|
|
/******************************************************************
|
|
|
|
|
|
|
|
Revision history:
|
|
|
|
|
2010-04-23 06:29:52 -03:00
|
|
|
2010/04/20 (Sean Reifschneider)
|
|
|
|
- Use basename(sys.argv[0]) for the default "ident".
|
|
|
|
- Arguments to openlog() are now keyword args and are all optional.
|
|
|
|
- syslog() calls openlog() if it hasn't already been called.
|
|
|
|
|
1998-05-08 18:52:55 -03:00
|
|
|
1998/04/28 (Sean Reifschneider)
|
|
|
|
- When facility not specified to syslog() method, use default from openlog()
|
|
|
|
(This is how it was claimed to work in the documentation)
|
|
|
|
- Potential resource leak of o_ident, now cleaned up in closelog()
|
|
|
|
- Minor comment accuracy fix.
|
|
|
|
|
1995-10-11 13:15:28 -03:00
|
|
|
95/06/29 (Steve Clift)
|
|
|
|
- Changed arg parsing to use PyArg_ParseTuple.
|
|
|
|
- Added PyErr_Clear() call(s) where needed.
|
|
|
|
- Fix core dumps if user message contains format specifiers.
|
2000-07-16 09:04:32 -03:00
|
|
|
- Change openlog arg defaults to match normal syslog behavior.
|
1995-10-11 13:15:28 -03:00
|
|
|
- Plug memory leak in openlog().
|
|
|
|
- Fix setlogmask() to return previous mask value.
|
|
|
|
|
|
|
|
******************************************************************/
|
|
|
|
|
1994-07-14 10:56:50 -03:00
|
|
|
/* syslog module */
|
|
|
|
|
1995-01-10 16:56:29 -04:00
|
|
|
#include "Python.h"
|
2020-04-14 22:24:57 -03:00
|
|
|
#include "osdefs.h" // SEP
|
1994-07-14 10:56:50 -03:00
|
|
|
|
|
|
|
#include <syslog.h>
|
|
|
|
|
2022-10-08 15:31:57 -03:00
|
|
|
/*[clinic input]
|
|
|
|
module syslog
|
|
|
|
[clinic start generated code]*/
|
|
|
|
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=478f4ac94a1d4cae]*/
|
|
|
|
|
|
|
|
#include "clinic/syslogmodule.c.h"
|
|
|
|
|
2022-11-29 18:58:20 -04:00
|
|
|
/* only one instance, only one syslog, so globals should be ok,
|
|
|
|
* these fields are writable from the main interpreter only. */
|
|
|
|
static PyObject *S_ident_o = NULL; // identifier, held by openlog()
|
2010-04-25 03:31:55 -03:00
|
|
|
static char S_log_open = 0;
|
1998-05-08 18:52:55 -03:00
|
|
|
|
2022-11-29 18:58:20 -04:00
|
|
|
static inline int
|
|
|
|
is_main_interpreter(void)
|
|
|
|
{
|
|
|
|
return (PyInterpreterState_Get() == PyInterpreterState_Main());
|
|
|
|
}
|
1998-05-08 18:52:55 -03:00
|
|
|
|
2010-04-23 06:29:52 -03:00
|
|
|
static PyObject *
|
|
|
|
syslog_get_argv(void)
|
|
|
|
{
|
2010-05-09 12:52:27 -03:00
|
|
|
/* Figure out what to use for as the program "ident" for openlog().
|
|
|
|
* This swallows exceptions and continues rather than failing out,
|
|
|
|
* because the syslog module can still be used because openlog(3)
|
|
|
|
* is optional.
|
|
|
|
*/
|
|
|
|
|
2010-12-08 19:31:48 -04:00
|
|
|
Py_ssize_t argv_len, scriptlen;
|
2010-05-09 12:52:27 -03:00
|
|
|
PyObject *scriptobj;
|
2011-09-28 02:41:54 -03:00
|
|
|
Py_ssize_t slash;
|
2013-11-07 18:07:29 -04:00
|
|
|
PyObject *argv = PySys_GetObject("argv");
|
2010-05-09 12:52:27 -03:00
|
|
|
|
|
|
|
if (argv == NULL) {
|
|
|
|
return(NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
argv_len = PyList_Size(argv);
|
|
|
|
if (argv_len == -1) {
|
|
|
|
PyErr_Clear();
|
|
|
|
return(NULL);
|
|
|
|
}
|
|
|
|
if (argv_len == 0) {
|
|
|
|
return(NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
scriptobj = PyList_GetItem(argv, 0);
|
2022-07-26 03:12:10 -03:00
|
|
|
if (scriptobj == NULL) {
|
|
|
|
PyErr_Clear();
|
|
|
|
return NULL;
|
|
|
|
}
|
2010-05-09 12:52:27 -03:00
|
|
|
if (!PyUnicode_Check(scriptobj)) {
|
|
|
|
return(NULL);
|
|
|
|
}
|
2011-10-11 17:11:42 -03:00
|
|
|
scriptlen = PyUnicode_GET_LENGTH(scriptobj);
|
2010-12-08 19:31:48 -04:00
|
|
|
if (scriptlen == 0) {
|
2010-05-09 12:52:27 -03:00
|
|
|
return(NULL);
|
|
|
|
}
|
|
|
|
|
2011-10-11 17:11:42 -03:00
|
|
|
slash = PyUnicode_FindChar(scriptobj, SEP, 0, scriptlen, -1);
|
2022-07-26 03:12:10 -03:00
|
|
|
if (slash == -2) {
|
|
|
|
PyErr_Clear();
|
2011-09-28 02:41:54 -03:00
|
|
|
return NULL;
|
2022-07-26 03:12:10 -03:00
|
|
|
}
|
2011-09-28 02:41:54 -03:00
|
|
|
if (slash != -1) {
|
2020-01-14 13:57:04 -04:00
|
|
|
return PyUnicode_Substring(scriptobj, slash + 1, scriptlen);
|
2010-05-09 12:52:27 -03:00
|
|
|
} else {
|
|
|
|
Py_INCREF(scriptobj);
|
|
|
|
return(scriptobj);
|
|
|
|
}
|
2010-04-23 06:29:52 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-10-08 15:31:57 -03:00
|
|
|
/*[clinic input]
|
|
|
|
syslog.openlog
|
|
|
|
|
|
|
|
ident: unicode = NULL
|
|
|
|
logoption as logopt: long = 0
|
|
|
|
facility: long(c_default="LOG_USER") = LOG_USER
|
|
|
|
|
|
|
|
Set logging options of subsequent syslog() calls.
|
|
|
|
[clinic start generated code]*/
|
|
|
|
|
2010-05-09 12:52:27 -03:00
|
|
|
static PyObject *
|
2022-10-08 15:31:57 -03:00
|
|
|
syslog_openlog_impl(PyObject *module, PyObject *ident, long logopt,
|
|
|
|
long facility)
|
|
|
|
/*[clinic end generated code: output=5476c12829b6eb75 input=8a987a96a586eee7]*/
|
1994-07-14 10:56:50 -03:00
|
|
|
{
|
2022-11-29 18:58:20 -04:00
|
|
|
// Since the sys.openlog changes the process level state of syslog library,
|
|
|
|
// this operation is only allowed for the main interpreter.
|
|
|
|
if (!is_main_interpreter()) {
|
|
|
|
PyErr_SetString(PyExc_RuntimeError, "subinterpreter can't use syslog.openlog()");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2022-07-26 03:12:10 -03:00
|
|
|
const char *ident_str = NULL;
|
2010-05-09 12:52:27 -03:00
|
|
|
|
2022-07-26 03:12:10 -03:00
|
|
|
if (ident) {
|
|
|
|
Py_INCREF(ident);
|
2010-12-08 19:31:48 -04:00
|
|
|
}
|
2022-07-26 03:12:10 -03:00
|
|
|
else {
|
|
|
|
/* get sys.argv[0] or NULL if we can't for some reason */
|
|
|
|
ident = syslog_get_argv();
|
2010-12-08 19:31:48 -04:00
|
|
|
}
|
2010-05-09 12:52:27 -03:00
|
|
|
|
2022-07-26 03:12:10 -03:00
|
|
|
/* At this point, ident should be INCREF()ed. openlog(3) does not
|
|
|
|
* make a copy, and syslog(3) later uses it. We can't garbagecollect it.
|
2010-05-09 12:52:27 -03:00
|
|
|
* If NULL, just let openlog figure it out (probably using C argv[0]).
|
|
|
|
*/
|
2022-07-26 03:12:10 -03:00
|
|
|
if (ident) {
|
|
|
|
ident_str = PyUnicode_AsUTF8(ident);
|
|
|
|
if (ident_str == NULL) {
|
|
|
|
Py_DECREF(ident);
|
2010-12-08 19:31:48 -04:00
|
|
|
return NULL;
|
2022-07-26 03:12:10 -03:00
|
|
|
}
|
2010-12-08 19:31:48 -04:00
|
|
|
}
|
2022-07-26 03:12:10 -03:00
|
|
|
if (PySys_Audit("syslog.openlog", "Oll", ident ? ident : Py_None, logopt, facility) < 0) {
|
|
|
|
Py_DECREF(ident);
|
2020-02-13 03:47:42 -04:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2022-07-26 03:12:10 -03:00
|
|
|
openlog(ident_str, logopt, facility);
|
2010-05-09 12:52:27 -03:00
|
|
|
S_log_open = 1;
|
2022-07-26 03:12:10 -03:00
|
|
|
Py_XSETREF(S_ident_o, ident);
|
2010-05-09 12:52:27 -03:00
|
|
|
|
2017-01-23 03:47:21 -04:00
|
|
|
Py_RETURN_NONE;
|
1994-07-14 10:56:50 -03:00
|
|
|
}
|
|
|
|
|
1997-01-09 19:51:21 -04:00
|
|
|
|
2010-05-09 12:52:27 -03:00
|
|
|
|
2022-10-08 15:31:57 -03:00
|
|
|
/*[clinic input]
|
|
|
|
syslog.syslog
|
2010-05-09 12:52:27 -03:00
|
|
|
|
2022-10-08 15:31:57 -03:00
|
|
|
[
|
|
|
|
priority: int(c_default="LOG_INFO") = LOG_INFO
|
|
|
|
]
|
|
|
|
|
|
|
|
message: str
|
|
|
|
|
|
|
|
/
|
2010-05-09 12:52:27 -03:00
|
|
|
|
2022-10-08 15:31:57 -03:00
|
|
|
Send the string message to the system logger.
|
|
|
|
[clinic start generated code]*/
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
syslog_syslog_impl(PyObject *module, int group_left_1, int priority,
|
|
|
|
const char *message)
|
|
|
|
/*[clinic end generated code: output=c3dbc73445a0e078 input=ac83d92b12ea3d4e]*/
|
|
|
|
{
|
2020-02-13 03:47:42 -04:00
|
|
|
if (PySys_Audit("syslog.syslog", "is", priority, message) < 0) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2010-05-09 12:52:27 -03:00
|
|
|
/* if log is not opened, open it now */
|
|
|
|
if (!S_log_open) {
|
2022-11-29 18:58:20 -04:00
|
|
|
if (!is_main_interpreter()) {
|
|
|
|
PyErr_SetString(PyExc_RuntimeError, "subinterpreter can't use syslog.syslog() "
|
|
|
|
"until the syslog is opened by the main interpreter");
|
|
|
|
return NULL;
|
|
|
|
}
|
2022-10-08 15:31:57 -03:00
|
|
|
PyObject *openlog_ret = syslog_openlog_impl(module, NULL, 0, LOG_USER);
|
|
|
|
if (openlog_ret == NULL) {
|
2022-07-26 08:34:15 -03:00
|
|
|
return NULL;
|
2010-05-09 12:52:27 -03:00
|
|
|
}
|
2022-10-08 15:31:57 -03:00
|
|
|
Py_DECREF(openlog_ret);
|
2010-05-09 12:52:27 -03:00
|
|
|
}
|
|
|
|
|
2022-07-26 03:12:10 -03:00
|
|
|
/* Incref ident, because it can be decrefed if syslog.openlog() is
|
|
|
|
* called when the GIL is released.
|
|
|
|
*/
|
2022-11-16 05:39:47 -04:00
|
|
|
PyObject *ident = Py_XNewRef(S_ident_o);
|
2022-10-13 08:34:55 -03:00
|
|
|
#ifdef __APPLE__
|
|
|
|
// gh-98178: On macOS, libc syslog() is not thread-safe
|
|
|
|
syslog(priority, "%s", message);
|
|
|
|
#else
|
2010-05-09 12:52:27 -03:00
|
|
|
Py_BEGIN_ALLOW_THREADS;
|
|
|
|
syslog(priority, "%s", message);
|
|
|
|
Py_END_ALLOW_THREADS;
|
2022-10-13 08:34:55 -03:00
|
|
|
#endif
|
2022-07-26 03:12:10 -03:00
|
|
|
Py_XDECREF(ident);
|
2010-05-09 12:52:27 -03:00
|
|
|
Py_RETURN_NONE;
|
1994-07-14 10:56:50 -03:00
|
|
|
}
|
|
|
|
|
2022-10-08 15:31:57 -03:00
|
|
|
|
|
|
|
/*[clinic input]
|
|
|
|
syslog.closelog
|
|
|
|
|
|
|
|
Reset the syslog module values and call the system library closelog().
|
|
|
|
[clinic start generated code]*/
|
|
|
|
|
2010-05-09 12:52:27 -03:00
|
|
|
static PyObject *
|
2022-10-08 15:31:57 -03:00
|
|
|
syslog_closelog_impl(PyObject *module)
|
|
|
|
/*[clinic end generated code: output=97890a80a24b1b84 input=fb77a54d447acf07]*/
|
1994-07-14 10:56:50 -03:00
|
|
|
{
|
2022-11-29 18:58:20 -04:00
|
|
|
// Since the sys.closelog changes the process level state of syslog library,
|
|
|
|
// this operation is only allowed for the main interpreter.
|
|
|
|
if (!is_main_interpreter()) {
|
|
|
|
PyErr_SetString(PyExc_RuntimeError, "sunbinterpreter can't use syslog.closelog()");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2020-02-13 03:47:42 -04:00
|
|
|
if (PySys_Audit("syslog.closelog", NULL) < 0) {
|
|
|
|
return NULL;
|
|
|
|
}
|
2010-05-09 12:52:27 -03:00
|
|
|
if (S_log_open) {
|
|
|
|
closelog();
|
2014-02-09 07:33:53 -04:00
|
|
|
Py_CLEAR(S_ident_o);
|
2010-05-09 12:52:27 -03:00
|
|
|
S_log_open = 0;
|
|
|
|
}
|
2017-01-23 03:47:21 -04:00
|
|
|
Py_RETURN_NONE;
|
1994-07-14 10:56:50 -03:00
|
|
|
}
|
|
|
|
|
2022-10-08 15:31:57 -03:00
|
|
|
/*[clinic input]
|
|
|
|
syslog.setlogmask -> long
|
1995-10-11 13:15:28 -03:00
|
|
|
|
2022-10-08 15:31:57 -03:00
|
|
|
maskpri: long
|
|
|
|
/
|
|
|
|
|
|
|
|
Set the priority mask to maskpri and return the previous mask value.
|
|
|
|
[clinic start generated code]*/
|
|
|
|
|
|
|
|
static long
|
|
|
|
syslog_setlogmask_impl(PyObject *module, long maskpri)
|
|
|
|
/*[clinic end generated code: output=d6ed163917b434bf input=adff2c2b76c7629c]*/
|
|
|
|
{
|
2022-10-07 14:17:08 -03:00
|
|
|
if (PySys_Audit("syslog.setlogmask", "l", maskpri) < 0) {
|
2022-10-08 15:31:57 -03:00
|
|
|
return -1;
|
2020-02-13 03:47:42 -04:00
|
|
|
}
|
2022-10-08 15:31:57 -03:00
|
|
|
|
|
|
|
return setlogmask(maskpri);
|
1994-07-14 10:56:50 -03:00
|
|
|
}
|
|
|
|
|
2022-10-08 15:31:57 -03:00
|
|
|
/*[clinic input]
|
|
|
|
syslog.LOG_MASK -> long
|
|
|
|
|
|
|
|
pri: long
|
|
|
|
/
|
|
|
|
|
|
|
|
Calculates the mask for the individual priority pri.
|
|
|
|
[clinic start generated code]*/
|
|
|
|
|
|
|
|
static long
|
|
|
|
syslog_LOG_MASK_impl(PyObject *module, long pri)
|
|
|
|
/*[clinic end generated code: output=c4a5bbfcc74c7c94 input=534829cb7fb5f7d2]*/
|
1994-07-14 10:56:50 -03:00
|
|
|
{
|
2022-10-08 15:31:57 -03:00
|
|
|
return LOG_MASK(pri);
|
1994-07-14 10:56:50 -03:00
|
|
|
}
|
|
|
|
|
2022-10-08 15:31:57 -03:00
|
|
|
/*[clinic input]
|
|
|
|
syslog.LOG_UPTO -> long
|
|
|
|
|
|
|
|
pri: long
|
|
|
|
/
|
|
|
|
|
|
|
|
Calculates the mask for all priorities up to and including pri.
|
|
|
|
[clinic start generated code]*/
|
|
|
|
|
|
|
|
static long
|
|
|
|
syslog_LOG_UPTO_impl(PyObject *module, long pri)
|
|
|
|
/*[clinic end generated code: output=9eab083c90601d7e input=5e906d6c406b7458]*/
|
1994-07-14 10:56:50 -03:00
|
|
|
{
|
2022-10-08 15:31:57 -03:00
|
|
|
return LOG_UPTO(pri);
|
1994-07-14 10:56:50 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* List of functions defined in the module */
|
|
|
|
|
1994-08-30 09:25:20 -03:00
|
|
|
static PyMethodDef syslog_methods[] = {
|
2022-10-08 15:31:57 -03:00
|
|
|
SYSLOG_OPENLOG_METHODDEF
|
|
|
|
SYSLOG_CLOSELOG_METHODDEF
|
|
|
|
SYSLOG_SYSLOG_METHODDEF
|
|
|
|
SYSLOG_SETLOGMASK_METHODDEF
|
|
|
|
SYSLOG_LOG_MASK_METHODDEF
|
|
|
|
SYSLOG_LOG_UPTO_METHODDEF
|
2010-05-09 12:52:27 -03:00
|
|
|
{NULL, NULL, 0}
|
1994-07-14 10:56:50 -03:00
|
|
|
};
|
|
|
|
|
2008-06-11 02:26:20 -03:00
|
|
|
|
2020-05-04 22:49:46 -03:00
|
|
|
static int
|
|
|
|
syslog_exec(PyObject *module)
|
1994-07-14 10:56:50 -03:00
|
|
|
{
|
2020-05-04 22:49:46 -03:00
|
|
|
#define ADD_INT_MACRO(module, macro) \
|
|
|
|
do { \
|
|
|
|
if (PyModule_AddIntConstant(module, #macro, macro) < 0) { \
|
|
|
|
return -1; \
|
|
|
|
} \
|
|
|
|
} while (0)
|
2010-05-09 12:52:27 -03:00
|
|
|
/* Priorities */
|
2020-05-04 22:49:46 -03:00
|
|
|
ADD_INT_MACRO(module, LOG_EMERG);
|
|
|
|
ADD_INT_MACRO(module, LOG_ALERT);
|
|
|
|
ADD_INT_MACRO(module, LOG_CRIT);
|
|
|
|
ADD_INT_MACRO(module, LOG_ERR);
|
|
|
|
ADD_INT_MACRO(module, LOG_WARNING);
|
|
|
|
ADD_INT_MACRO(module, LOG_NOTICE);
|
|
|
|
ADD_INT_MACRO(module, LOG_INFO);
|
|
|
|
ADD_INT_MACRO(module, LOG_DEBUG);
|
2010-05-09 12:52:27 -03:00
|
|
|
|
|
|
|
/* openlog() option flags */
|
2020-05-04 22:49:46 -03:00
|
|
|
ADD_INT_MACRO(module, LOG_PID);
|
|
|
|
ADD_INT_MACRO(module, LOG_CONS);
|
|
|
|
ADD_INT_MACRO(module, LOG_NDELAY);
|
2012-03-29 08:15:45 -03:00
|
|
|
#ifdef LOG_ODELAY
|
2020-05-04 22:49:46 -03:00
|
|
|
ADD_INT_MACRO(module, LOG_ODELAY);
|
2012-03-29 08:15:45 -03:00
|
|
|
#endif
|
1998-08-04 19:53:56 -03:00
|
|
|
#ifdef LOG_NOWAIT
|
2020-05-04 22:49:46 -03:00
|
|
|
ADD_INT_MACRO(module, LOG_NOWAIT);
|
1998-08-04 19:53:56 -03:00
|
|
|
#endif
|
1995-10-11 13:15:28 -03:00
|
|
|
#ifdef LOG_PERROR
|
2020-05-04 22:49:46 -03:00
|
|
|
ADD_INT_MACRO(module, LOG_PERROR);
|
1995-10-11 13:15:28 -03:00
|
|
|
#endif
|
|
|
|
|
2010-05-09 12:52:27 -03:00
|
|
|
/* Facilities */
|
2020-05-04 22:49:46 -03:00
|
|
|
ADD_INT_MACRO(module, LOG_KERN);
|
|
|
|
ADD_INT_MACRO(module, LOG_USER);
|
|
|
|
ADD_INT_MACRO(module, LOG_MAIL);
|
|
|
|
ADD_INT_MACRO(module, LOG_DAEMON);
|
|
|
|
ADD_INT_MACRO(module, LOG_AUTH);
|
|
|
|
ADD_INT_MACRO(module, LOG_LPR);
|
|
|
|
ADD_INT_MACRO(module, LOG_LOCAL0);
|
|
|
|
ADD_INT_MACRO(module, LOG_LOCAL1);
|
|
|
|
ADD_INT_MACRO(module, LOG_LOCAL2);
|
|
|
|
ADD_INT_MACRO(module, LOG_LOCAL3);
|
|
|
|
ADD_INT_MACRO(module, LOG_LOCAL4);
|
|
|
|
ADD_INT_MACRO(module, LOG_LOCAL5);
|
|
|
|
ADD_INT_MACRO(module, LOG_LOCAL6);
|
|
|
|
ADD_INT_MACRO(module, LOG_LOCAL7);
|
1994-07-14 10:56:50 -03:00
|
|
|
|
1998-05-08 18:52:55 -03:00
|
|
|
#ifndef LOG_SYSLOG
|
2010-05-09 12:52:27 -03:00
|
|
|
#define LOG_SYSLOG LOG_DAEMON
|
1998-05-08 18:52:55 -03:00
|
|
|
#endif
|
|
|
|
#ifndef LOG_NEWS
|
2010-05-09 12:52:27 -03:00
|
|
|
#define LOG_NEWS LOG_MAIL
|
1998-05-08 18:52:55 -03:00
|
|
|
#endif
|
|
|
|
#ifndef LOG_UUCP
|
2010-05-09 12:52:27 -03:00
|
|
|
#define LOG_UUCP LOG_MAIL
|
1998-05-08 18:52:55 -03:00
|
|
|
#endif
|
|
|
|
#ifndef LOG_CRON
|
2010-05-09 12:52:27 -03:00
|
|
|
#define LOG_CRON LOG_DAEMON
|
1998-05-08 18:52:55 -03:00
|
|
|
#endif
|
|
|
|
|
2020-05-04 22:49:46 -03:00
|
|
|
ADD_INT_MACRO(module, LOG_SYSLOG);
|
|
|
|
ADD_INT_MACRO(module, LOG_CRON);
|
|
|
|
ADD_INT_MACRO(module, LOG_UUCP);
|
|
|
|
ADD_INT_MACRO(module, LOG_NEWS);
|
2012-03-29 08:15:45 -03:00
|
|
|
|
|
|
|
#ifdef LOG_AUTHPRIV
|
2020-05-04 22:49:46 -03:00
|
|
|
ADD_INT_MACRO(module, LOG_AUTHPRIV);
|
2012-03-29 08:15:45 -03:00
|
|
|
#endif
|
|
|
|
|
2020-05-04 22:49:46 -03:00
|
|
|
return 0;
|
1994-07-14 10:56:50 -03:00
|
|
|
}
|
2020-05-04 22:49:46 -03:00
|
|
|
|
|
|
|
static PyModuleDef_Slot syslog_slots[] = {
|
|
|
|
{Py_mod_exec, syslog_exec},
|
|
|
|
{0, NULL}
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Initialization function for the module */
|
|
|
|
|
|
|
|
static struct PyModuleDef syslogmodule = {
|
|
|
|
PyModuleDef_HEAD_INIT,
|
|
|
|
.m_name = "syslog",
|
|
|
|
.m_size = 0,
|
|
|
|
.m_methods = syslog_methods,
|
|
|
|
.m_slots = syslog_slots,
|
|
|
|
};
|
|
|
|
|
|
|
|
PyMODINIT_FUNC
|
|
|
|
PyInit_syslog(void)
|
|
|
|
{
|
|
|
|
return PyModuleDef_Init(&syslogmodule);
|
2022-07-26 03:12:10 -03:00
|
|
|
}
|