Commit Graph

1816 Commits

Author SHA1 Message Date
Joris Vink cb0f5a4137 Make sure koreapp.onmsg can log errors from Python. 2020-12-18 19:48:17 +01:00
Joris Vink d10ee4438d Duplicate __progname for the call to openlog().
Kore will mangle the argv[] array for setting process names in
a more friendly way but that could cause syslog to spew mangled
data as the ident.
2020-12-08 11:33:26 +01:00
Joris Vink 9227347b90 Fix concurrency problem in coroutines.
If a coroutine is woken up from another coroutine running from an
http request we can end up in a case where the call path looks like:

0 kore_worker_entry
1 epoll wait		<- bound to pending timers
2 http_process		<- first coro sleep
3 kore_python_coro_run	<- wakes up request
4 http_process		<- wakes up another coroutine
5 return to kore_worker_entry

In the case where 4 wakes up another coroutine but 1 is bound to a timer
and no io activity occurs the coroutine isn't run until the timer fires.

Fix this issue by always checking for pending coroutines even if the
netwait isn't INFINITE.
2020-12-07 11:11:21 +01:00
Joris Vink fd2cda5a43 include inttypes.h in json.c 2020-11-27 16:34:38 +01:00
Joris Vink 5421b7726e kore_json_init() should take a const void for the data. 2020-11-23 10:48:04 +01:00
Joris Vink 802a78c0b0 Make sure we check if consume whitespace failed. 2020-11-21 13:01:42 +01:00
Joris Vink d7fbce37f5 Better parsing of JSON integers and numbers.
Add 2 new types:
	KORE_JSON_TYPE_INTEGER
		signed integer type, internally stored as s64.

	KORE_JSON_TYPE_INTEGER_U64
		unsigned integer type, internally stored as u64.

Kore JSON parser will prefer marking integers as INTEGER_U64 if it
was unsigned and did not have fractions.
2020-11-19 14:56:17 +01:00
Joris Vink 760dff8b3c allow tab escape in JSON strings. 2020-11-19 09:55:41 +01:00
Joris Vink e712e3a951 consume any initial whitespace in JSON data. 2020-11-19 09:22:16 +01:00
Joris Vink 8008fe8b60 Don't allow unknown escaped characters in JSON parser. 2020-11-19 09:10:12 +01:00
Joris Vink 8c32f8f63b Small improvements to JSON parser.
- Don't allow garbage at the end of the JSON data (except whitespace).
- Don't allow objects such as {"a":"b",} or [a,]
2020-11-19 09:07:42 +01:00
Joris Vink 8aa9af1f0c force a dependency between seccomp.c and $(PLATFORM). 2020-10-30 10:12:29 +01:00
Joris Vink 90bf36a37b whitespace 2020-10-28 15:44:18 +01:00
Joris Vink 262a2512f1 Do not dispatch signals to workers without a valid pid.
thanks rille.
2020-10-16 13:06:08 +02:00
Joris Vink ce360e15d6 Update examples with latest single binary changes.
- Use kore_default_getopt() to let Kore do all argument parsing
  for the examples. They don't do any option parsing themselves.
2020-10-08 20:26:11 +02:00
Joris Vink 8f743213aa Add my helper build scripts for building custom binaries.
Allows building Kore with several different component versions.

Eg:
	$ ./build-kore.sh 1.1.1h 3.9.0 7.72.0 1.41.0

	Will build Kore with OpenSSL 1.1.1h, Python 3.9.0, Curl 7.72.0
	and nghttp2 (for curl) 1.41.0
2020-10-08 13:53:48 +02:00
Joris Vink 67cf3e872b Add kore_default_getopt().
This handles the default option parsing in Kore and should be called
by single_binary=yes builds in kore_parent_configure() unless they
want to handle their own argument parsing.
2020-10-08 13:51:50 +02:00
Joris Vink 4313c0eab5 Python: Add kore.socket.recvmsg()
Returns the ancillary data to the caller as a list.
2020-10-02 11:27:52 +02:00
Frederic Cambus af99a4d9e2 Conditionally allow syscalls required to run on arm.
Those syscalls do not exist on other Kore supported platforms, so we
must check that they exist before allowing them.
2020-09-17 17:41:03 +02:00
Frederic Cambus 28ea1b3c7e Add missing tests for SYS_mmap, fixes the build on arm. 2020-09-17 17:41:00 +02:00
Frederic Cambus 7290944bf3 Add support for logging seccomp violations on arm.
On ARM EABI, the syscall number can be read from register r7.
2020-09-16 23:07:45 +02:00
Frederic Cambus 9deb2e71bf Use kore_worker_name() when logging worker exits in worker_reaper(). 2020-09-15 12:19:08 +02:00
Frederic Cambus debe6cb019 Mention the seccomp_tracing configuration option. 2020-09-14 23:21:21 +02:00
Frederic Cambus 60bc618c3f Allow the clock_nanosleep syscall, it is required for kore_accesslog().
glibc 2.31 calls clock_nanosleep in its nanosleep function.
2020-09-14 19:15:25 +02:00
Frederic Cambus 19573a7bf0 Also add DESTDIR in the uninstall targets in kore and kodev Makefiles. 2020-09-14 14:07:31 +02:00
Joris Vink a62c504a40 Set KORE_SOURCE for tools-build target. 2020-09-09 22:35:19 +02:00
Joris Vink e87ba0f2d8 Add flavors for kore-serve for all platforms. 2020-09-09 22:31:46 +02:00
Joris Vink 51e9c64fc0 strdup the application name. 2020-09-09 22:30:56 +02:00
Joris Vink cdb45118e2 kill unused variable 2020-09-09 22:22:54 +02:00
Joris Vink 814a994e99 Don't depend on pushd/popd 2020-09-09 22:18:59 +02:00
Joris Vink 21d1e5156b Add tools directory.
Includes the kore-serve utility that spins up a Kore instance
on the local directory and serves the contents via a filemap
on localhost port 8888.

Used by myself when hacking on the kore website.
2020-09-09 22:14:29 +02:00
Joris Vink 4e384167f0 The version.c file has moved.
Therefor make sure kodev knows the correct place to look for it
and include it in single binary builds.
2020-09-09 21:27:07 +02:00
Joris Vink 2dca8fd6cc Add an install-sources target.
This will place the required sources for building
single binary builds under $PREFIX/share/kore.

The kodev utility will now pickup this KORE_SOURCE path automatically
unless another one is given via the conf/build.conf file or the KORE_SOURCE
environment path.
2020-09-09 21:09:40 +02:00
Joris Vink d7dd9707d7 Remove getopt() for KORE_SINGLE_BINARY.
If KORE_SINGLE_BINARY is enabled, remove the getopt() call that
Kore does itself. This way all arguments are passed to the
kore_parent_configure() hook as-is allowing developers to
more easily implement their own option handling.
2020-09-08 22:38:06 +02:00
Frederic Cambus 3bf5896cfb Add DESTDIR support in both kore and kodev Makefiles. 2020-09-08 21:28:58 +02:00
Joris Vink f6af4a27f4 Enable type-limits warning.
Remove unneeded comparison in the JSON code.
via https://marc.info/?l=openbsd-ports&m=159958572325174&w=2
2020-09-08 19:29:15 +02:00
Joris Vink aaf8be40c2 Add casts for isxdigit and isspace.
The argument must be representable as an unsigned char or EOF.
2020-09-08 19:19:56 +02:00
Joris Vink 4498270bbe add missing contributer. 2020-09-08 19:13:31 +02:00
Joris Vink 5a3e174439 Add the BEERS file. 2020-09-08 19:12:00 +02:00
Frederic Cambus 3ac956c67d Use kore_worker_name() when logging worker shutdowns. 2020-09-08 15:15:33 +02:00
Frederic Cambus d9673857d8 Fix a couple of typos in various places. 2020-09-08 13:01:18 +02:00
Joris Vink 636469f555 Only reset accept_avail if we grabbed the lock.
Otherwise in certain scenarios it could mean that workers
unsuccessfully grabbed the lock, reset accept_avail and
no longer attempt to grab the lock afterwards.

This can cause a complete stall in workers processing requests.
2020-09-08 11:51:06 +02:00
Joris Vink 1d27558e39 nicer warning 2020-09-03 19:24:26 +02:00
Joris Vink b84c88a0e6 remove the yet wording. 2020-09-03 19:08:08 +02:00
Joris Vink 58247eec4a I don't support x86 on Linux, remove it.
Pointed out by entitled end user.
2020-09-03 19:05:43 +02:00
Tobias Kortkamp 85b26533b7 Unbreak build with multiple make jobs
Without it python_curlopt.h might not be available at the right
time when using something like make -j4:

src/python.c:50:10: fatal error: 'python_curlopt.h' file not found
         ^~~~~~~~~~~~~~~~~~
1 error generated.

Signed-off-by: Tobias Kortkamp <t@tobik.me>
2020-09-03 14:07:41 +02:00
Joris Vink 45f5ec97a2 we are at 4.0.0 2020-08-31 19:59:31 +02:00
Joris Vink 8097d22da7 whitespace fixes 2020-08-24 10:17:53 +02:00
Joris Vink 4aa53df3b6 Make sure curl state transitions work properly. 2020-08-17 16:45:10 +02:00
Joris Vink 8b9f7a6c12 improve our asynchronous curl support.
- Remove the edge trigger io hacks we had in place.
- Use level triggered io for the libcurl fds instead.
- Batch all curl events together and process them at the end
  of our worker event loop.
2020-08-17 15:15:04 +02:00