Commit Graph

1768 Commits

Author SHA1 Message Date
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
Joris Vink 8bbdaedf94 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
Joris Vink bcf0355704 Add clock_gettime to keymgr process 2019-10-03 15:55:19 +02:00
Frederic Cambus 85981e22cc Allow the nanosleep syscall, it is used in kore_accesslog(). 2019-10-03 15:53:36 +02:00
Joris Vink 5e6a8d42cf include sys/socket.h in net.c 2019-10-03 12:19:36 +02:00
Joris Vink e59dcfb236 fix doc link 2019-09-27 23:55:42 +02:00
Joris Vink 4cfff12b46 mention sandboxing 2019-09-27 23:53:15 +02:00
Joris Vink d0e46adfb1 kill norwegian debug 2019-09-27 20:08:16 +02:00
Joris Vink 46375303cb Allow multiple binds on new server directive. 2019-09-27 20:00:35 +02:00
Joris Vink 5c18f4ac41 python acquire method mispelled.
from fcambus@
2019-09-27 13:49:09 +02:00
Joris Vink be70118bf2 move l->tls check upwards 2019-09-27 12:33:48 +02:00
Joris Vink 46127459d9 fix BSDs after last commit 2019-09-27 12:31:17 +02:00
Joris Vink 7350131232 Allow listening of tls/notls ports at the same time.
Before kore needed to be built with NOTLS=1 to be able to do non TLS
connections. This has been like this for years.

It is time to allow non TLS listeners without having to rebuild Kore.

This commit changes your configuration format and will break existing
applications their config.

Configurations now get listener {} contexts:

listen default {
	bind 127.0.0.1 8888
}

The above will create a listener on 127.0.0.1, port 8888 that will serve
TLS (still the default).

If you want to turn off TLS on that listener, specify "tls no" in that
context.

Domains now need to be attached to a listener:

Eg:
	domain * {
		attach	default
	}

For the Python API this kills kore.bind(), and kore.bind_unix(). They are
replaced with:

	kore.listen("name", ip=None, port=None, path=None, tls=True).
2019-09-27 12:27:04 +02:00
Joris Vink 0d72f11902 make sure we can still run normal apps even with PYTHON=1 2019-09-26 20:38:02 +02:00
Joris Vink f725ca228c alter python skeleton from kodev create -p.
adds the kore.config.file setting (required a fix for -c) and the
kore.config.deployment option is set to "development".
2019-09-26 19:58:13 +02:00
Joris Vink 1f7405b1d3 2019 was here 9 months ago 2019-09-26 16:44:42 +02:00
Joris Vink 555856ab0a fix usage for python builds.
while here, force a module or script as a cli argument and
fix kodev run to pass the config if inside of a module.
2019-09-26 16:41:52 +02:00
Joris Vink b7163f35ce allow readlink syscall 2019-09-26 16:29:45 +02:00
Joris Vink d4ba6f3485 allow more net related syscalls for python. 2019-09-26 16:13:42 +02:00
Joris Vink 9d7ef805f0 hide rcall properly if needed 2019-09-26 16:05:01 +02:00
Joris Vink 937c39f041 Many many Python improvements.
- Kore can now fully be configured via Python code if one wants nothing to
  do with configuration files.

- Kore can now start single python files and no longer requires them to be
  inside a module directory.

- Pass all regex capture groups to the handler methods, allowing you to
  get access to them immediately.

- Change python websocket_handshake to take callable objects directly.

- Added a new deployment configuration option. If set to "dev" or
  "development" Kore will automatically foreground, no chroot / etc.
  If set to "production" Kore *will* chroot, drop privs, etc.

- Many more..

These are all backported from a project that I was working on a while
ago. I decided these should go back into mainline Kore.
2019-09-26 15:49:00 +02:00
Joris Vink 296fe7a6d4 seccomp improvements.
More BPF helper macros, more helper for granular syscall checking.
Use these throughout kore where it makes sense.

The new helpers:

- KORE_SYSCALL_DENY_ARG(name, arg, value, errno):
	Deny the system call with errno if the argument matches value.

- KORE_SYSCALL_DENY_MASK(name, arg, mask, errno):
	Deny the system call with errno if the mask argument does not match
	the exact mask given.

- KORE_SYSCALL_DENY_WITH_FLAG(name, arg, flag, errno):
	Deny the system call with errno if the argument contains the
	given flag.

The reverse also exists:

- KORE_SYSCALL_ALLOW_ARG()
- KORE_SYSCALL_ALLOW_MASK()
- KORE_SYSCALL_ALLOW_WITH_FLAG()
2019-09-26 13:51:53 +02:00
Joris Vink 4ed6136693 add 2 more missing syscalls for musl to keymgr. 2019-09-26 10:20:30 +02:00
Joris Vink 9dc12af1a4 add rt_sigprocmask for keymgr seccomp policy 2019-09-26 10:06:32 +02:00
Joris Vink a64be43ccf add writev to keymgr, needed on some platforms 2019-09-26 10:02:58 +02:00
Joris Vink c6c253305a swap sockets to use send/recv and update seccomp. 2019-09-26 09:53:51 +02:00
Joris Vink 0314521658 shuffle some stuff around 2019-09-26 09:28:12 +02:00
Joris Vink aafecb9485 Make sure filters from the hook are added first.
This allows user seccomp filters to be added before the kore ones which
means developers can override our own settings.
2019-09-26 09:22:33 +02:00
Joris Vink a5f6805484 seccomp improvements for developers.
- Add KORE_SECCOMP_FILTER() as a helpful shortcut to create your
  application seccomp filter. You can still roll your own and hook
  into kore_seccomp_hook() yourself to load your filters.

- Add KORE_SYSCALL_ALLOW_LOG(_name)
	Allows a system call but will log it.
2019-09-26 09:20:57 +02:00
Joris Vink c1affbbd74 simplify bpf rule generation, add deny macro. 2019-09-25 23:41:43 +02:00
Joris Vink 61b8a9e90d fix tpyo 2019-09-25 16:14:58 +02:00
Joris Vink de97318a95 hide seccomp logs behind !quiet 2019-09-25 16:14:17 +02:00
Joris Vink 233415a7bb close the wrapped socket instead of the os one. 2019-09-25 15:47:14 +02:00
Joris Vink 4bc39f19af add lstat to worker seccomp filter 2019-09-25 15:44:03 +02:00
Joris Vink eab94eda49 move libressl support to minimum 3.3.0. 2019-09-25 15:39:39 +02:00
Joris Vink 54ca865c11 add a few more syscalls for keymgr.
different platforms may do different things
2019-09-25 15:04:12 +02:00
Joris Vink 68e90507f4 properly seccomp keymgr 2019-09-25 14:41:09 +02:00
Joris Vink e7352a3634 fix - that snuck in 2019-09-25 14:32:17 +02:00