2017-01-12 23:38:51 +01:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2016 Stanislav Yudin <stan@endlessinsomnia.com>
|
2022-01-31 22:02:06 +01:00
|
|
|
* Copyright (c) 2017-2022 Joris Vink <joris@coders.se>
|
2017-01-12 23:38:51 +01:00
|
|
|
*
|
|
|
|
* Permission to use, copy, modify, and distribute this software for any
|
|
|
|
* purpose with or without fee is hereby granted, provided that the above
|
|
|
|
* copyright notice and this permission notice appear in all copies.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
|
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
|
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
|
|
* ANY SPECIAL, DIRECT, 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 WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __H_PYTHON_H
|
|
|
|
#define __H_PYTHON_H
|
|
|
|
|
2017-01-25 22:41:57 +01:00
|
|
|
#undef _POSIX_C_SOURCE
|
|
|
|
#undef _XOPEN_SOURCE
|
|
|
|
|
2021-01-28 13:34:43 +01:00
|
|
|
#define PY_SSIZE_T_CLEAN 1
|
|
|
|
|
2017-01-12 23:38:51 +01:00
|
|
|
#include <Python.h>
|
2019-09-16 20:11:42 +02:00
|
|
|
#include <frameobject.h>
|
2017-01-12 23:38:51 +01:00
|
|
|
|
|
|
|
void kore_python_init(void);
|
2018-11-12 09:01:05 +01:00
|
|
|
void kore_python_preinit(void);
|
2017-01-12 23:38:51 +01:00
|
|
|
void kore_python_cleanup(void);
|
2018-10-15 20:18:54 +02:00
|
|
|
void kore_python_coro_run(void);
|
2018-10-26 19:19:47 +02:00
|
|
|
void kore_python_proc_reap(void);
|
2019-10-22 17:06:32 +02:00
|
|
|
int kore_python_coro_pending(void);
|
2017-01-12 23:38:51 +01:00
|
|
|
void kore_python_path(const char *);
|
2018-10-15 20:18:54 +02:00
|
|
|
void kore_python_coro_delete(void *);
|
2021-05-02 00:23:11 +02:00
|
|
|
void kore_python_routes_resolve(void);
|
2018-10-16 13:16:36 +02:00
|
|
|
void kore_python_log_error(const char *);
|
2017-01-12 23:38:51 +01:00
|
|
|
|
|
|
|
PyObject *kore_python_callable(PyObject *, const char *);
|
|
|
|
|
Allow configuring seccomp on Linux via the python api.
A new hook in the koreapp class is called right before seccomp
is enabled. This hook receives a Kore seccomp object which has
the following methods:
seccomp.allow("syscall")
seccomp.allow_arg("syscall", arg, value)
seccomp.allow_flag("syscall", arg, flag)
seccomp.allow_mask("syscall", arg, mask)
seccomp.deny("syscall")
seccomp.deny_arg("syscall", arg, value, errno=EACCES)
seccomp.deny_flag("syscall", arg, flag, errno=EACCES)
seccomp.deny_mask("syscall", arg, mask, errno=EACCES)
This allows you to finetune the seccomp filters for your application
from inside your koreapp.
2019-10-04 10:59:48 +02:00
|
|
|
#if defined(__linux__)
|
|
|
|
void kore_python_seccomp_cleanup(void);
|
2019-10-04 11:28:14 +02:00
|
|
|
void kore_python_seccomp_hook(const char *);
|
Allow configuring seccomp on Linux via the python api.
A new hook in the koreapp class is called right before seccomp
is enabled. This hook receives a Kore seccomp object which has
the following methods:
seccomp.allow("syscall")
seccomp.allow_arg("syscall", arg, value)
seccomp.allow_flag("syscall", arg, flag)
seccomp.allow_mask("syscall", arg, mask)
seccomp.deny("syscall")
seccomp.deny_arg("syscall", arg, value, errno=EACCES)
seccomp.deny_flag("syscall", arg, flag, errno=EACCES)
seccomp.deny_mask("syscall", arg, mask, errno=EACCES)
This allows you to finetune the seccomp filters for your application
from inside your koreapp.
2019-10-04 10:59:48 +02:00
|
|
|
#endif
|
|
|
|
|
2017-01-12 23:38:51 +01:00
|
|
|
extern struct kore_module_functions kore_python_module;
|
|
|
|
extern struct kore_runtime kore_python_runtime;
|
|
|
|
|
2021-12-22 09:50:26 +01:00
|
|
|
#define KORE_PYTHON_SIGNAL_HOOK "koreapp.signal"
|
2019-09-26 20:38:02 +02:00
|
|
|
#define KORE_PYTHON_TEARDOWN_HOOK "koreapp.cleanup"
|
|
|
|
#define KORE_PYTHON_CONFIG_HOOK "koreapp.configure"
|
|
|
|
#define KORE_PYTHON_DAEMONIZED_HOOK "koreapp.daemonized"
|
2021-12-22 09:50:26 +01:00
|
|
|
#define KORE_PYTHON_WORKER_STOP_HOOK "koreapp.workerstop"
|
|
|
|
#define KORE_PYTHON_WORKER_START_HOOK "koreapp.workerstart"
|
2019-09-26 20:38:02 +02:00
|
|
|
|
2017-01-12 23:38:51 +01:00
|
|
|
#endif
|