Commit Graph

1964 Commits

Author SHA1 Message Date
Alibek Omarov c2aec319b8 kodev: add support for generating Clang compilation database
* generated sources for assets are skipped through filepath check
  it's fine for now, but probably should be redone
* despite Kore supports JSON manipulation, kodev doesn't share this code
  so for now JSON file is being regenerated each build
* tested in Qt Creator, works OK
2023-03-22 06:54:37 +03:00
Alibek Omarov 65683b91a4 kodev: split generating compiler commandline to separate function
args array is supposed to hold 34 + CFLAGS_MAX pointers and like the original
function lacks any checks
2023-03-22 06:53:34 +03:00
Alibek Omarov ceab01b2cd kodev: small improvement, fix argv offset, making that argv[0] current command name
* so potential getopt users are happy now
* and no more very specific check for "create" command in main()
2023-03-22 06:45:56 +03:00
Joris Vink 15071f5a14 Change http_argument_urldecode().
Takes a new parameter now `qs`, if set to 1 it'll urldecode
according to how its always done it before.

If not set to 0 (for posts for example), the decoder will allow
\n and \r in addition to the other ones.
2023-03-12 23:35:18 +01:00
Joris Vink 21839aeaa2 demote sched_setaffinity log message to a notice. 2023-03-08 20:30:34 +01:00
Joris Vink d49d65dfa0 Reshuffle call to kore_platform_worker_setcpu().
Its better to place this inside of kore_worker_privsep(), this
way it'll be called for each process still and we can do it
before we sandbox the processes completely.
2023-03-08 20:28:49 +01:00
Joris Vink 21f466c8b6 Move CPU pinning to kore_worker_started().
When trying to pin a worker to a certain CPU, Kore will log
if it fails but still continue.

The problem is that it tried to do it a bit early and the logging
facilities were not yet setup, causing it to be unable to continue
if kore_log() was called too early.

By moving it to kore_worker_started() we are certain all facilities
are up and running correctly.
2023-03-08 20:11:49 +01:00
Joris Vink 66e893f1d4 Python API domain improvement.
Add redirect() method to add a redirect on a domain much like
in the Kore configuration file.

eg:

domain.redirect("^/account/(.*)$", 301, "https://site/account/$1")
2023-03-04 23:15:49 +01:00
Joris Vink a68a53c59e new contributer I owe a beer too 2023-03-01 17:15:12 +01:00
Joris Vink 4e38d8a323 Allow clock_gettime64() if defined. 2023-03-01 17:11:27 +01:00
Joris Vink ecbc373433 revert some labbing in kore_realloc() 2023-03-01 16:41:33 +01:00
Joris Vink 13f9921679 cleanup 2023-03-01 16:35:11 +01:00
Joris Vink 3e944e106b Change kore_realloc() behaviour a bit.
If kore_realloc() decides that a new block must be allocated it will
explicitly call the new kore_free_zero() function to erase the
contents of the old block once the move is done.
2023-03-01 16:29:06 +01:00
Daniel Melani a5342a0120 Remove libressl log message.
The feature has been removed.
2023-02-22 19:15:42 +01:00
Joris Vink 83d1ff1013 Get rid of the openssl libcrypto allocation hooks.
In practice this rarely works anyway as other libs can end up
allocating things before we even reach main() as demonstrated
on the discord channel earlier.
2023-01-25 08:00:45 +01:00
Joris Vink 9fec810ce8 add lua to built-ins log 2023-01-23 21:56:49 +01:00
Joris Vink 98fba44147 mention lua in readme 2023-01-23 21:34:22 +01:00
Joris Vink 24390b8d6b Allow setting of LUA_VERSION for pkg-config. 2023-01-23 21:33:11 +01:00
Joris Vink 4718bae098 Initial lua runtime.
Works enough so one can do basic configuration and handle HTTP.
2023-01-21 23:41:35 +01:00
Joris Vink 2f5d274059 Rework runtime init a little bit.
It was hardcoded that if KORE_USE_PYTHON was defined we would
look at the passed argument on the command-line as the python
script or module to be run.

This won't work when adding more runtimes.

So instead call a kore_runtime_resolve() function that in
turn calls each available runtime its resolve function.

That resolve function will check if its a script / module
that it can load, and if so will load it.

This way we can remove all those KORE_USE_PYTHON blocks in the
Kore startup path and we pave the way for lua.
2023-01-16 21:00:01 +01:00
Joris Vink d21c0aab5f Call kore_tls_init() earlier at startup. 2023-01-06 10:54:07 +01:00
Joris Vink e8da0574c3 remove post-receive hook on copy 2023-01-05 22:57:14 +01:00
Joris Vink a421e7a9cd Add memory protection with KORE_MEM_GUARD.
When KORE_MEM_GUARD is set in the environment when Kore is started
it will enable a few memory protection techniques for all kore pools:

1) The metadata is placed away from the actual user pointer returned.

2) Each entry in a pool is placed in such a way that it is followed
   immediately by a guard page which has PROT_NONE. Accessing a guard
   page will cause an immediate crash.

3) Each entry is marked with PROT_NONE until it is allocated. Once it
   is returned to a pool it becomes PROT_NONE again, protecting against
   use after frees.

This commit also removes the magic goo from the mem facitilies such
as kore_malloc and friends and moves these as canaries into the kore
pool facilities instead.

Note that using this will increase memory pressure and decrease performance.

It is recommended to enable this during development to catch bugs.
2023-01-05 22:47:29 +01:00
Joris Vink 922ce7fefb Force OpenSSL to use Kore allocators.
LibreSSL does not support this, which is fair as its designed
for OpenBSD which has malloc and friends that do nice things.
2023-01-05 19:23:24 +01:00
Joris Vink 4a9c7efda7 retire kodev.1, was unmaintained. 2023-01-05 10:07:44 +01:00
Joris Vink 044ddf4a8e stagit files moved to kore-site repository. 2023-01-05 10:06:46 +01:00
Joris Vink fac651a89e Retire kore-build scripts. 2023-01-05 09:53:19 +01:00
Joris Vink 770df43d1e Add static stagit files for git.kore.io 2023-01-05 09:50:20 +01:00
Joris Vink 0a0416b7a7 finally, use git.kore.io in the hook. 2023-01-05 09:26:46 +01:00
Joris Vink 7608312120 use stagit instead of stagit-index. 2023-01-05 09:25:56 +01:00
Joris Vink 5d69879d87 Shuffle stuff around in the hook. 2023-01-05 09:25:06 +01:00
Joris Vink d677632732 Add the old update stuff into the hook. 2023-01-05 09:23:56 +01:00
Joris Vink 7632705c64 Version control the post-receive githook. 2023-01-05 09:14:57 +01:00
Joris Vink 4ecd6d5603 Add kore_platform_random_uint32(). 2023-01-04 11:48:19 +01:00
Joris Vink 7b48959c32 Python HTTP API improvement: add req.headers()
Calling req.headers() will return all the request headers in
a dictionary to the caller.
2022-12-29 12:58:43 +01:00
Joris Vink 7a6753ca33 Force lowercase on internal HTTP header names. 2022-12-29 12:58:21 +01:00
Joris Vink 46af5aa11b more workarounds for curl 7.87 2022-12-28 16:05:14 +01:00
Joris Vink 7f27677904 work around curl 7.87 curl_easy_setopt() being broken. 2022-12-28 16:04:18 +01:00
Joris Vink f59ee8e29e constify another RSA pointer. 2022-12-28 15:55:19 +01:00
Joris Vink 81987cd022 openssl 3 works for now. 2022-12-28 15:51:14 +01:00
Joris Vink f82e4fe967 kill debug 2022-12-28 15:49:42 +01:00
Joris Vink 8b701a9f0e Change how we handle EVP_PKEY for privsep.
We used to just call EVP_PKEY_get1_RSA() and set the domain
and RSA_METHOD on that.

But with OpenSSL 3, the EVP_PKEY_get1_RSA() function returns a cached
copy of the internal provider struct and any changes we make are not
reflected back. So we can't use it to set the domain and custom method.

Instead just create our own EVP_PKEY from scratch, coupled with an
RSA key that contains just n and e from the public key.

Works with both 1.1.x and 3.0.x.
2022-12-28 15:43:56 +01:00
Joris Vink 17b6f3bbc6 Disable deprecated warnings for OpenSSL 3.
Until the replacement is done, make sure Kore builds against OpenSSL 3
so it can be used as most distros made the move towards it.
2022-12-28 11:09:15 +01:00
Joris Vink 6ccae503ae allow override of python3-config. 2022-12-28 11:08:55 +01:00
Joris Vink 369fc4fa01 Add newfstatat in common Kore seccomp whitelist. 2022-11-02 22:13:10 +01:00
Joris Vink dd93790d80 Improve kore.proc in the Python API.
Allow passing of an env keyword, allowing you to set environment variables
that may be required by the subprocess.

The env keyword must be a list with correctly formed environment variables.

eg:

proc = kore.proc("/bin/myproc",
    env=[
        "LD_LIBRARY_PATH=/my/path"
    ]
)
2022-10-19 08:04:16 +02:00
Joris Vink eab8dcd9ac Constify in parameter for kore_strip_chars() 2022-10-19 07:34:14 +02:00
Joris Vink f34d21caa7 Hack around some hidden Python symbols.
The _PyInterpreterFrame_GetLine() is hidden in dynamic libs so
roll our own variant of it.

Shuffle the old code so we always end up calling python_resolve_frame_line()
no matter the Python version.
2022-09-26 08:48:29 +02:00
Joris Vink d7cef82362 Python improvements: Rework corotracing for 3.11.
In the upcoming Python 3.11 release the PyCoroObject no longer
has a full PyFrameObject, but instead their internal frame
struct _PyInterpreterFrame. Use that when we are building
against 3.11 or higher so we can still provide useful tracing
functionality (and so that it builds).
2022-09-25 00:29:08 +02:00
Joris Vink 377295c04c Update README after 4.2.3 release 2022-09-08 13:08:31 +02:00