Skip to content

Instantly share code, notes, and snippets.

View oskarirauta's full-sized avatar

Oskari Rauta oskarirauta

View GitHub Profile
@oskarirauta
oskarirauta / 010-enable-disable-extroot-option.patch
Created February 27, 2024 12:09
disable_extroot config for fstools
--- a/block.c
+++ b/block.c
@@ -84,7 +84,7 @@ struct mount {
static struct vlist_tree mounts;
static struct blob_buf b;
static LIST_HEAD(devices);
-static int anon_mount, anon_swap, auto_mount, auto_swap, check_fs;
+static int anon_mount, anon_swap, auto_mount, auto_swap, check_fs, disable_extroot;
static unsigned int delay_root;
--- a/jail/jail.c
+++ b/jail/jail.c
@@ -585,7 +585,7 @@ static struct mknod_args default_devices
{ .path = "/dev/full", .mode = (S_IFCHR|S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH), .dev = makedev(1, 7) },
{ .path = "/dev/random", .mode = (S_IFCHR|S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH), .dev = makedev(1, 8) },
{ .path = "/dev/urandom", .mode = (S_IFCHR|S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH), .dev = makedev(1, 9) },
- { .path = "/dev/tty", .mode = (S_IFCHR|S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP), .dev = makedev(5, 0), .gid = 5 },
+ { .path = "/dev/tty", .mode = (S_IFCHR|S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH), .dev = makedev(5, 0), .gid = 5 },
{ 0 },
};
@oskarirauta
oskarirauta / cntr_env
Created February 23, 2024 20:34
uxc hook issue example configs
*** NEXT COMES WHAT WAS IN /tmp/cntr_env FILE WHEN CREATING CONTAINER, THIS LINE IS NOT INCLUDED IN FILE ***
SHLVL=1
PWD=/
31973
cntr
0::/services/cntr/cntr
0::/services/cntr/cntr
@oskarirauta
oskarirauta / instance.c
Created February 23, 2024 17:21
uxc infra container support
/*
* Copyright (C) 2013 Felix Fietkau <nbd@openwrt.org>
* Copyright (C) 2013 John Crispin <blogic@openwrt.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 2.1
* as published by the Free Software Foundation
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@oskarirauta
oskarirauta / 040-add-restart-command.patch
Created February 23, 2024 00:32
add restart function uxc
--- a/uxc.c
+++ b/uxc.c
@@ -82,6 +82,7 @@ enum uxc_cmd {
CMD_DISABLE,
CMD_DELETE,
CMD_CREATE,
+ CMD_RESTART,
CMD_UNKNOWN
};
@oskarirauta
oskarirauta / 030-make-alias-for-stop-command.patch
Created February 22, 2024 23:17
add stop command to uxc (alias to kill)
--- a/uxc.c
+++ b/uxc.c
@@ -1598,7 +1598,7 @@ int main(int argc, char **argv)
cmd = CMD_START;
else if(!strcmp("state", argv[optind]))
cmd = CMD_STATE;
- else if(!strcmp("kill", argv[optind]))
+ else if(!strcmp("kill", argv[optind]) || !strcmp("stop", argv[optind]))
cmd = CMD_KILL;
else if(!strcmp("enable", argv[optind]))
@oskarirauta
oskarirauta / 020-add-uxc-exec-function.patch
Created February 22, 2024 16:07
add exec function to openwrt's uxc
--- a/uxc.c
+++ b/uxc.c
@@ -27,6 +27,7 @@
#include <unistd.h>
#include <sys/stat.h>
#include <sys/types.h>
+#include <sched.h>
#include <libubus.h>
#include <libubox/avl-cmp.h>
@oskarirauta
oskarirauta / OptionSetAssociated.swift
Last active March 31, 2024 09:56
OptionSetAssociated: Swift's OptionSet with associated value for members.
import Foundation
public protocol OptionSetAssociated: OptionSet where RawValue: FixedWidthInteger {
var store: [RawValue: Any] { get set }
}
extension OptionSetAssociated {
public init<T>(_ member: Self, value: T) {
self.init(rawValue: member.rawValue)