1861 Commits

Author SHA1 Message Date
Joris Vink
b20d26e839 Throw exception is TLS backend isnt supported. 2022-02-18 09:17:58 +01:00
Joris Vink
feb90208ef Add kore_tls_x509_data().
Use it in the Python code, which requires it.
2022-02-18 09:14:30 +01:00
Joris Vink
169a4e7c5d wrap 2 more syscalls in ifdefs. 2022-02-17 14:46:33 +01:00
Joris Vink
3c3a93e5c5 Add missing header files for SHA1/SHA2. 2022-02-17 14:11:39 +01:00
Joris Vink
d8505bab0d Always add -rdynamic to LDFLAGS. 2022-02-17 14:59:36 +02:00
Joris Vink
99a1581e19 Initial work splitting OpenSSL code away.
This work moves all TLS / crypto related code into a tls_openssl.c
file and adds a tls_none.c which contains just stubs.

Allows compilation of Kore with TLS_BACKEND=none to remove building
against OpenSSL.

Also adds code for SHA1/SHA2 taken from openssh-portable so we don't
depend on those being present anymore in libcrypto.
2022-02-17 13:45:28 +01:00
Joris Vink
6dc162e7ee Handle ECHILD when reaping workers on shutdown.
If the child process is already dead we must handle it accordingly
instead of getting stuck waiting on it.
2022-02-16 12:32:20 +01:00
Joris Vink
23d762d682 Allow parent to send msgs to workers via kore_msg.
It wasn't possible for the parent process to send messages
directly via kore_msg_send() to other worker processes.

This is now rectified to from the parent process one can call
kore_msg_send() with a worker destination and it'll work.
2022-02-01 10:36:07 +01:00
Joris Vink
b3f54e290a Change parent behaviour when calling waitpid().
Wait for any process in our process group only instead of WAIT_ANY.

This allows the parent process to start subprocesses that end up
in different process groups which are handled in user code instead
completely (using signalfd for example).
2022-02-01 10:34:12 +01:00
Joris Vink
833ca646e7 i forgot, it's 2022. 2022-01-31 22:02:06 +01:00
Joris Vink
a82cb168eb The python examples don't need building.
So they can be removed from the examples Makefile.
2022-01-31 20:55:46 +01:00
Joris Vink
23047d4c2f Rework generic example configuration.
This adjusts the configuration to contain updated routing configs.
2022-01-31 20:44:14 +01:00
Joris Vink
a29700f26d Bring back page authentication via config.
Inside of the new route handlers the "authenticate" keyword can
be specified to let the route authenticate via a previously
configured authentication block.

The ability to do this went missing in a previous commit that overhauled
the routing structure of the configuration.
2022-01-31 15:13:34 +01:00
Joris Vink
41a4be384e Increase ACME signop timeout.
Just noticed the 5 seconds wasn't enough when renewing all
certificates in my own setup (i have about 30 ACME domains via Kore).

Bumped it to 30 seconds instead.
2022-01-29 08:55:50 +01:00
Joris Vink
93ec99c23e Only enable accesslog vacuum if needed.
If no accesslogs are enabled, the parent has no need for
the vacuum timer to be activated.

This way the parent blocks in epoll_wait() instead of waking up
for no reason when there are no accesslogs enabled.
2022-01-28 14:29:58 +01:00
Joris Vink
93a4fe2a15 Worker hook rework.
This commit adds improved hooks for Python and a new signal delivery hook.

For the Python API kore_worker_configure() and kore_worker_teardown() had
to be implemented before this commit. Now one can create a workerstart
and workerend method in their koreapp as those will be called when
they exist.

The new signal hook is either kore_worker_signal() or koreapp.signal.

This new hook is called after the worker event code handles the received
signal itself first.

With this commit there is also a new kore_signal_trap() API call allowing
you to more easily trap new signals. This API also also exported to the
Python part of the code under kore.sigtrap()
2021-12-22 09:50:26 +01:00
Joris Vink
d8113e4545 Reset dom->acme_cert upon clearing. 2021-12-19 00:14:33 +01:00
Joris Vink
ff19ce7652 Python: add a protocol member to kore.httprequest
This returns a string depending on the protocol used (https / http) for
the HTTP request.
2021-12-17 16:52:13 +01:00
Joris Vink
a3800fa57e Python: allocate py_req in the http_request_free hook if needed.
Makes it possible to mix on_free with other runtimes.
2021-12-15 12:19:04 +01:00
Joris Vink
e545657023 make sure we only call rt->on_free if req has route 2021-12-15 12:16:37 +01:00
Joris Vink
e8e01980fc Python: allow route hooks via kore.route().
Adding the hooks keyword with a dictionary attached to specify
the relevant hooks will hook them for the given route.

Eg:

domain.route("/", self.index, methods=["get"],
    hooks={
        "on_free": self.request_free
    }
)

These are the same hooks available via a normal Kore route configuration.
2021-12-14 23:15:21 +01:00
Joris Vink
97ef486d22 Fix indentation 2021-12-13 10:48:29 +01:00
Joris Vink
9845c8bbe1 Python: Add req.body_digest.
Returns the SHA256 digest of the uploaded body as a bytes object.
2021-12-13 10:45:00 +01:00
Joris Vink
774cc56ed2 Python: Add an req.connection.x509dict
This dictionary for now only contains the subject and issuer names
from the client certificate (if one was provided) with their
X509_NAME components.

Eg:

{
  "issuer": {
    "C": "SE",
    "O": "kore autogen: x509name-test",
    "CN": "localhost"
  },
  "subject": {
    "C": "SE",
    "O": "kore autogen: x509name-test",
    "CN": "localhost"
  }
}
2021-12-11 22:37:15 +01:00
Joris Vink
ca4ffa457c Add a kore_x509_issuer_name() function.
Rework the underlying X509_NAME juggling into a kore_x509name_foreach()
so that it can be called for multiple locations.
2021-12-11 22:36:31 +01:00
Joris Vink
cf6cf5f820 Always align pool element lengths properly.
Enforce 8-byte alignment on the pool element lengths.
2021-12-11 22:35:37 +01:00
Joris Vink
685f504564 Log if no TLS server was configured 2021-12-11 21:59:41 +01:00
Joris Vink
a641c29301 Add SYS_newfstatat to keymgr seccomp rules.
From Aurelien Jarno via patches@
2021-12-11 20:34:44 +01:00
Joris Vink
a54f806978 Don't let kore build with openssl 3 again.
The whole privilege separation breaks with OpenSSL 3, even if it builds.

I guess it is somewhat time to start on donutls.
2021-12-06 23:58:13 +01:00
Joris Vink
0337af2067 note on openssl 3 2021-12-06 21:27:11 +01:00
Joris Vink
06803e2592 Get kore to at least build with openssl 3 2021-12-06 21:21:21 +01:00
Joris Vink
93bf18be81 Handle DELETE maybe having a request body. 2021-12-06 14:44:07 +01:00
Joris Vink
480e589dd5 The DELETE method may have a request body. 2021-12-06 14:43:52 +01:00
Joris Vink
6b2609c2b8 Allow DELETE for kore.httpclient() to have body.
The DELETE method could have an HTTP body, so allow it in the
kore.httpclient() python call.
2021-12-06 14:16:58 +01:00
Joris Vink
a9ee15bff6 Improve closing of a kore.socket() in Python API.
When a kore.socket() is closed from any coroutine, make sure any other
coroutines waiting on events on the socket are awoken so they properly
can return errors.
2021-12-02 22:47:17 +01:00
Joris Vink
5ac62b17bc Python coro under-the-hood improvements.
- Change python coroutine id to a uint64_t.
- Add kore.task_id() to return active coro its id.
2021-12-02 21:58:13 +01:00
Joris Vink
86ecb85f03 use correct privsep name for acme 2021-12-02 19:33:20 +01:00
Joris Vink
0d39e5c62a Allow setting of TARGET_PLATFORM.
This overrides the linux seccomp building, useful
for cross compiling Kore to other linux architectures.
2021-11-29 15:43:43 +01:00
Joris Vink
efc7b3d9a6 Improve how the parent handles workers.
- Make sure we drain the worker log channel if it dies
  so we can flush out any lingering log messages.

- Get rid of the raise() in the parent to signal ourselves
  we should terminate. Instead depend on the new kore_quit.

- Always attempt to reap children one way or the other.
2021-11-03 17:23:05 +01:00
Joris Vink
155c7dfbde prefix fatal messages with FATAL 2021-11-03 17:22:53 +01:00
Joris Vink
a7e1d1d22a Remove keymgr cleaning keys logs.
its such a dumb log message, obviously its going to cleanup keys.
2021-11-03 17:16:34 +01:00
Joris Vink
01e85fd717 Two small python improvements.
- Decrement bytes count when python_cmsg_to_list() fails.
- Use correct define for PYSOCKET_TYPE_RECVFROM.
2021-11-03 15:19:43 +01:00
Joris Vink
5962a94504 wrap pipeline in PG_VERSION_NUM >= 140000 2021-10-27 22:39:29 +02:00
Joris Vink
960730a062 On MacOS put the OpenSSL flags under FEATURES_INC.
Use this to pick them up automatically for kodev.
2021-10-27 22:28:08 +02:00
Joris Vink
fa97544f01 Handle PGRES_PIPELINE_* for PQResult() 2021-10-27 22:27:42 +02:00
Joris Vink
c68eb0c705 make sure we add to LDFLAGS 2021-10-27 17:59:14 +02:00
Joris Vink
995b6b8586 On macos use pkg-config for openssl. 2021-10-27 14:34:06 +02:00
Joris Vink
98d5909b7d bring back python_import and python_path.
These were mistakingly removed a while ago.
2021-10-20 11:20:25 +02:00
Joris Vink
23b95448cc Hide worker logs behind kore_quiet. 2021-10-05 12:29:50 +02:00
Joris Vink
0af7258c30 Don't include kore config in all builds just yet. 2021-10-04 19:18:15 +02:00