1
0
mirror of https://git.kore.io/kore.git synced 2024-11-16 06:56:33 +01:00
Commit Graph

1605 Commits

Author SHA1 Message Date
Joris Vink
eef1a05868 Change the way the linux syscall maps are made.
Use the syscall.h.in files from musl and generate the syscall maps
from there. Now we have proper support for x86_64, i386, arm and aarch64
to have syscall maps.
2019-11-06 11:57:25 +01:00
Joris Vink
b226b6ca89 Allow seccomp to work on arm64 and i386. 2019-11-05 13:12:43 +01:00
Joris Vink
aa01e5e504 If OPENSSL_PATH is set, append lib to it. 2019-11-04 21:16:00 +01:00
Joris Vink
68ce436fa7 expand previous commit further, check proto as well. 2019-11-04 07:23:21 +01:00
Joris Vink
0eab72f4cd Only call http_check_timeout on established clients. 2019-11-03 22:28:48 +01:00
Joris Vink
068b295427 remove error pledge, die hard. 2019-11-03 19:52:47 +01:00
Raymond Pasco
811b2eb3f0 Add dns to pledges when initializing curl
Without the dns pledge, curl can't resolve names on OpenBSD.
2019-11-03 11:47:49 +01:00
Joris Vink
8311c036d9 Add seccomp_tracing configuration option for linux.
If set to "yes" then Kore will trace its child processes and properly
notify you of seccomp violations while still allowing the syscalls.

This can be very useful when running Kore on new platforms that have
not been properly tested with seccomp, allowing me to adjust the default
policies as we move further.
2019-10-31 12:52:10 +01:00
Joris Vink
16afcb66d0 kodev MINIMAL=1 shouldn't include mime types either. 2019-10-31 09:55:14 +01:00
Joris Vink
ca17e08ad9 Add MIMINAL=1 build to kodev.
If the kodev tool is built with MINIMAL=1 it will not compile in
support for creating application skeletons, only to build apps, etc.

Building with MINIMAL=1 drops the openssl linkage.
2019-10-31 09:44:47 +01:00
Joris Vink
699ba3c0fe Make sure json offset advanced upon end of object/array. 2019-10-30 10:02:51 +01:00
Joris Vink
7b5046873a Make sure we wakeup the coroutine that called proc.reap().
We actually woke up the coroutine that originally spawned the process
when we reap it, but another coroutine may have taken over the object.

This mimics how we do things for the pysock_op things.
2019-10-29 15:12:20 +01:00
Joris Vink
ebee0f3752 nope, changed my mind, drop libressl 2.7.5. 2019-10-28 12:47:51 +01:00
Joris Vink
d001b022a7 Cleanup ifdef mess for different OpenSSL based libs.
Now everything that has the "newer" OpenSSL API (1.1.x) is hidden
behind a KORE_OPENSSL_NEWER_API define. Tone down minimum libressl
version again to 2.7.5.
2019-10-28 12:33:39 +01:00
Joris Vink
18c76abab3 use curl-config instead of pkg-config. 2019-10-28 12:18:15 +01:00
Joris Vink
4808365f8a Make sure things build with libressl 3.0.0 2019-10-27 21:20:47 +01:00
Joris Vink
5f03f991c9 Change kore_json_find() to operate on a kore_json_item.
This way you can call the lookup function on any JSON value that you
previously obtained (or the JSON context root).
2019-10-25 12:27:16 +02:00
Joris Vink
f637d617aa Allow SECCOMP_KILL_POLICY to be overwritten at build. 2019-10-23 15:01:31 +02:00
Joris Vink
99763d520b make sure we can run this outside the tree 2019-10-23 13:50:51 +02:00
Joris Vink
80a63fd4b1 Generate syscall maps from kernel tbl files if available.
If no tbl syscall files are available, fallback to using the dirty
/proc/kallsym trick that may or may not work.
2019-10-23 13:39:25 +02:00
Joris Vink
da959e8275 reset curl timer if nothing is running anymore. 2019-10-23 12:38:31 +02:00
Joris Vink
890eb78fd8 Improve our new JSON api a bit.
Allow JSON to be constructed via kore_json_create_item and its
handy macro family:
	- kore_json_create_object()
	- kore_json_create_array()
	- kore_json_create_string()
	- kore_json_create_number()
	- kore_json_create_literal().

Adds kore_json_item_tobuf() to convert a JSON item into a string
representation in a kore_buf data structure.

Renames the kore_json_get* family to kore_json_find* instead.

Allows for quite clean code:

	struct kore_buf		buf;
	struct kore_json_item	*root;

	root = kore_json_create_object(NULL, NULL);
	kore_json_create_string(root, "hello", "world");
	kore_json_create_number(root, "value", 2.241);

	kore_buf_init(&buf, 128);
	kore_json_item_tobuf(root, &buf);

	kore_json_item_free(root);
	kore_buf_cleanup(&buf);
2019-10-22 23:56:47 +02:00
Joris Vink
790d020ce9 Stop a python coro from getting stuck with httpclient.
In cases where a request is immediately completed in libcurl its multi
handle and no additional i/o is happening a coro can get stuck waiting
to be run.

Prevent this by lowering netwait from KORE_WAIT_INFINITE if there
are pending python coroutines.
2019-10-22 17:06:32 +02:00
Joris Vink
0430c36a08 Adjust for new kore_curl_init() 2019-10-21 21:20:16 +02:00
Joris Vink
a119f18a23 Adjust to new kore_curl_init(). 2019-10-21 13:29:26 +02:00
Joris Vink
b64ae5d111 Allow kore_curl calls to be synchronous.
Changes kore_curl_init() to take a flag parameter, much like pgsql api
in which you specify KORE_CURL_ASYNC or KORE_CURL_SYNC.

If KORE_CURL_ASYNC is specified, Kore will behave as before.
If Kore_CURL_SYNC is specified, Kore will execute the libcurl immediately
and return once it has been completed.
2019-10-21 13:26:44 +02:00
Joris Vink
22ebfae240 missing kore_free() 2019-10-20 23:55:08 +02:00
Joris Vink
00f505e3f3 simplify strtod() error checking.
we can just check if errno is ERANGE and drop d == 0 comparison.
2019-10-20 23:43:54 +02:00
Joris Vink
88330a5fcd missing kore_free() 2019-10-20 23:42:37 +02:00
Joris Vink
dc55a48d87 Add native JSON parser example 2019-10-20 23:40:08 +02:00
Joris Vink
e94cc2f3a8 Yikes, add the actual JSON parser code.. 2019-10-20 23:30:10 +02:00
Joris Vink
06fa452c96 Add a full native JSON parser to Kore.
Mostly compliant, ignores \uXXXX in strings for now.

New API functions:

void kore_json_init(struct kore_json *json, const u_int8_t *data, size_t len);
  - Prepares JSON data for parsing.

int kore_json_parse(struct kore_json *json)
  - Parses the JSON data prepared via kore_json_init. Returns KORE_RESULT_ERROR
    if parsing failed or KORE_RESULT_OK if it succeeded.

struct kore_json_item *kore_json_get(struct kore_json *json, const char *path,
                                     int type);
  - Try to find the object matching a given search patch and type.

  eg, given a JSON structure of:
    {
      "reasons": {
        "strings": [
          "first reason",
          "second"
        ]
      }
    }

  one can obtain the second element in the reasons.strings array via:

    item = kore_json_get(json, "reasons/strings[0]", KORE_JSON_TYPE_STRING);

  Returns NULL if the item was not found or a type mismatch was hit,
  otherwise will return the item of that type.

  The kore_json_item data structure has a data member that contains the
  relevant bits depending on the type:

    KORE_JSON_TYPE_ARRAY, KORE_JSON_TYPE_OBJECT:
      the data.items member is valid.

    KORE_JSON_TYPE_STRING:
      the data.string member is valid.

    KORE_JSON_TYPE_NUMBER:
      the data.number member is valid.

    KORE_JSON_TYPE_LITERAL:
      the data.literal member is valid.

void kore_json_cleanup(struct kore_json *json);
  - Cleanup any resources

const char *kore_json_strerror(struct kore_json *json);
  - Return pointer to human readable error string.
2019-10-20 23:22:11 +02:00
Joris Vink
7da7141c21 remove FILEREF_DEBUG that sneaked in 2019-10-16 12:13:21 +02:00
Joris Vink
cdc3347120 Add kore.sendmsg(object, worker=None) to the python api.
This allows you to send Python objects that can be run through pickle
to other worker processes.

If your application implements koreapp.onmsg() you will be able to receive
these objects.
2019-10-16 12:05:27 +02:00
Joris Vink
ffb9fd2fc5 Align kore memory functions on 16-byte boundaries. 2019-10-15 21:33:43 +02:00
Joris Vink
e90e3749a7 use Py_InitializeEx and do not install python signals. 2019-10-15 21:18:38 +02:00
Joris Vink
bdc75556fe call PyErr_Clear() in python_callable(). 2019-10-15 16:03:39 +02:00
Joris Vink
a1c1245ef7 don't call Py_DECREF on list in configure 2019-10-15 15:53:08 +02:00
Joris Vink
0f4d5294ad store active pid into apid so it does not overwritten. 2019-10-15 14:25:57 +02:00
Joris Vink
bc33a5def4 Add kore.proc.pid, returns the PID of the proc. 2019-10-15 14:23:49 +02:00
Joris Vink
ec249390b1 Allow building with python3.8 2019-10-15 10:16:53 +02:00
Joris Vink
55f5b34dd9 Generate platform.h into OBJDIR if need be. 2019-10-07 16:23:21 +02:00
Joris Vink
3dcf94d1ae Add seccomp.bpf_stmt() method to Python api.
Allows a developer to create their own statements, the bpf_jmp equivalent
may follow later if I need it.
2019-10-07 13:44:31 +02:00
Joris Vink
0eb11794f5 Do not add keymgr its msg fd if not started.
Reshuffles the keymgr_active flag to keymgr.c and let it be figured out
from inside kore_server_start() instead of the worker init code.
2019-10-07 10:31:35 +02:00
Joris Vink
7209a67d47 unbreak DEBUG builds 2019-10-04 19:24:57 +02:00
Joris Vink
97523e2768 only register tls related msg callbacks if needed 2019-10-04 19:20:37 +02:00
Joris Vink
7bc1a92192 remove norwegian debug 2019-10-04 12:44:37 +02:00
Joris Vink
6c8970651c s/hook/method 2019-10-04 11:34:49 +02:00
Joris Vink
b0cf42726d Do not start keymgr if no tls enabled servers are present 2019-10-04 11:29:45 +02:00
Joris Vink
11cc5d304f let kore_python_seccomp_hook() take the hook name 2019-10-04 11:28:14 +02:00