summaryrefslogtreecommitdiff
path: root/uxc.c
Commit message (Collapse)AuthorAgeFilesLines
* uxc: fix potential NULL-pointer dereferenceDaniel Golle2022-04-131-0/+3
| | | | | | | | | Check for NULL returned by strrchr() and return error in that case. It should not be reachable as the string should always contain a '/' character, but follow best practices anyway. Coverity CID: 1500356 Dereference null return value Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* uxc: remove unused printf parameterDaniel Golle2022-02-181-1/+1
| | | | | | | | Remove unused string paramter from asprintf. Fixes build with glibc because warnings are treated as errors. Fixes: df1123e ("uxc: add support for user-defined settings") Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* uxc: clean up error handlingDaniel Golle2022-02-181-74/+85
| | | | | | | | Use negative return value to indicate errors and positive return value for quantitative information. Use 'bool' return type for some functions which never throw an error. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* uxc: allow editing settings using 'create'Daniel Golle2022-02-181-45/+49
| | | | | | | | | Users may want to change settings of a container other than just whether it is being started on boot or not. Allow changing the user-defined settings by utilizing the existing command line parameters in combination with the 'create' call. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* uxc: add support for user-defined settingsDaniel Golle2022-02-181-75/+263
| | | | | | | | | Instead of keeping both, the container defintion and settings in the same file, split-off the user-defined settings into a separate file. This has the advantage that user-defined settings are retained in case the container definition is replaced or updated. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* uxc: fix two minor issues reported by CoverityDaniel Golle2021-12-261-1/+3
| | | | | | Fixes CID 1496022 (UNINIT) and CID 1496023 (RESOURCE_LEAK). Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* uxc: usage message cosmeticsDaniel Golle2021-12-201-12/+12
| | | | | | Fix tabs in usage message. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* uxc: integrate console into uxcDaniel Golle2021-12-201-14/+203
| | | | | | | Prepare to get rid of ujail-console by integrating console features into uxc. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* uxc: consider uvol and etc location for configurationsDaniel Golle2021-12-201-31/+40
| | | | | | | | Rather than switching to consider only uvol location for configuration files once that path is existing, consider both locations. Plus some small style fixes here and there while at it. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* uxc: add missing 'break' statementDaniel Golle2021-10-171-1/+1
| | | | | | | | | Without the break statement the next element in the iteration will overwrite the found attributes. Stop iterating once entry has been found, so matching attributes will be used. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* uxc: don't free the stackDaniel Golle2021-10-131-3/+0
| | | | | | | It's generally a bad idea to free variables which are stored on stack. Better don't do that ;) Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* uxc: fix segfault caused by use-after-freeDaniel Golle2021-10-131-1/+1
| | | | | | Don't free blob_buf which was sent via ubus. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* uxc: add JSON output option for 'list' commandDaniel Golle2021-09-151-12/+60
| | | | Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* uxc: move mountpoint of persistent config to /var/run/uxcDaniel Golle2021-08-301-1/+1
| | | | | | | Using /var/state/uxc turns out to be not the smartest thing to do, use /var/run/uxc instead. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* uxc: free string returned by blobmsg_format_json_indent()Daniel Golle2021-08-241-1/+10
| | | | | | Coverity ID: 1490068 Resource leak Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* uxc.c: fix coverity resource leak warningKevin Darbyshire-Bryant2021-08-221-0/+1
| | | | | | | | | | | | 707 blob_buf_free(&req); 708 CID 1490412: (RESOURCE_LEAK) Handle variable "f" going out of scope leaks the handle. 709 return 0; Add a close before we return Signed-off-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
* uxc: support config in uvolDaniel Golle2021-08-151-4/+12
| | | | | | | In case '/var/state/uxc' exists and is a directory (or symlink pointing to a directory), use that instead of '/etc/uxc'. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* uxc: fix help outputDaniel Golle2021-08-151-1/+1
| | | | | | | CLI option 'mounts' is wrongly called 'volumes' in help output. Fix that. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* uxc: fix a bunch of issues discovered by CoverityDaniel Golle2021-08-151-28/+40
| | | | | | | | | | | | | Coverity CID: 1490024 Resource leak Coverity CID: 1490032 Resource leak Coverity CID: 1490039 Resource leak Coverity CID: 1490051 Resource leak Coverity CID: 1490055 Resource leak Coverity CID: 1490061 Resource leak Coverity CID: 1490068 Resource leak Coverity CID: 1490104 Resource leak Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* uxc: always handle asprintf() return valueDaniel Golle2021-08-041-4/+10
| | | | | | Error out in case asprintf() returns -1. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* uxc: resolve volume UUIDs by name of UCI fstab sectionDaniel Golle2021-07-251-2/+67
| | | | | | | | | Allow identifying volumes which are required for a container to start by their UCI section name in /etc/config/fstab, which is also where 'uvol' puts the volume name. Using filesystem UUID instead is still possible as well. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* uxc: don't restart containers when mount shows upDaniel Golle2021-07-251-0/+5
| | | | | | | | | | procd triggers 'uxc boot' every time a new mount shows up which results in containers to be restarted which had already been run and may have ended reguarly, crashed or deliberately stopped. As the intention of 'uxc boot' is to start containers which were still waiting for volumes to become ready, really do only that. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* uxc: check for required blockd mountsDaniel Golle2021-07-151-7/+108
| | | | | | | | | | When calling `uxc boot` it can happen that some required storage volumes are not yet mounted. Make sure mountpoints exist for all required volumes before starting a container using `uxc boot`. (uxc' init-script will take care of calling `uxc boot` every time a new block mount is added) Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* uxc: implement support for rootfs overlay in containersDaniel Golle2021-07-151-41/+79
| | | | | | | | | | ujail already supports having a (temporary) overlayfs on top of a containers rootfs. This is very useful for "dirty" containers which assume / is writable. Support this in uxc at the time a container is created and keep the settings on subsequent re-creates (or reboots). Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* uxc: also delete procd runtime state on 'delete'Daniel Golle2020-11-221-0/+18
| | | | Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* uxc: fix incomplete commitDaniel Golle2020-11-221-1/+4
| | | | | Fixes: 04a2edd ("uxc: make force-delete kill container process") Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* uxc: make force-delete kill container processDaniel Golle2020-11-211-2/+14
| | | | | | | | Don't allow to delete running containers unless '--force' is specified. If '--force' is specified, send KILL signal to container process before deleting it. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* uxc: mimic runc cmdline by using getopt_longDaniel Golle2020-10-281-62/+171
| | | | | | | Imitate runc (or crun) cmdline parameters. This allows using uxc as runtime with podman. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* uxc: remove debugging left-overDaniel Golle2020-07-301-1/+0
| | | | Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* uxc: use new container.%s kill ubus APIDaniel Golle2020-07-291-11/+17
| | | | Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* uxc: fix create operationDaniel Golle2020-07-291-1/+8
| | | | | | | | The 'create' operation needs uxc to reload it's configuration, so after adding the container to uxc' persistent state tracking the follow-up call to create the run-time can find it. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* uxc: behave more like a compliant OCI run-timeDaniel Golle2020-07-281-24/+174
| | | | | | | | | | | | | | | | | | | | | Follow CLI syntax as described in OCI run-time spec[1]. In addition, allow 'create' call also without 'path' parameter to re-create previously created containers, also after reboot. Usual workflow: uxc create debian /mnt/sda3/debian uxc start debian uxc kill debian 1 uxc create debian uxc start debian ... To create a container and have it automatically launched at boot: uxc create debian /mnt/sda3/debian true [1]: https://github.com/opencontainers/runtime-spec/blob/master/runtime.md#operations Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* uxc: fix build with uClibc-ngDaniel Golle2020-07-141-0/+4
| | | | | | Also here _GNU_SOURCE was missing. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* uxc: fix 'stop' commandDaniel Golle2020-07-131-1/+1
| | | | | | | The 'stop' command was requesting an invalid ubus method. Fix method name to make 'stop' operation work. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* uxc: add container management CLI toolDaniel Golle2020-07-101-0/+590
As procd can now provide a fully fetured container runtime using ujail, add a (for now) simple CLI tool to list, add, delete, start and stop OCI-complaint container bundles and selecting whether they should be launched on boot. In future commits, this will be extended to provide state output, take care of hooks, send signals and fetch remote container images in accordance with the Open Container Initiative Runtime Specification. Signed-off-by: Daniel Golle <daniel@makrotopia.org>