From 53fea93696af35da29110ff603fbc19b8616b1dc Mon Sep 17 00:00:00 2001 From: Mikael Magnusson Date: Thu, 29 Nov 2018 23:54:01 +0000 Subject: Sync patches --- patches/procd-master/0001-lxd-no-mounts.patch | 83 ++++++++++++++++++++++ .../procd-master/0002-lxd-shutdown-on-SIGPWR.patch | 45 ++++++++++++ ...003-docker-fix-problem-stopping-container.patch | 36 ++++++++++ .../procd-openwrt-18.06/0001-lxd-no-mounts.patch | 83 ++++++++++++++++++++++ .../0002-lxd-shutdown-on-SIGPWR.patch | 45 ++++++++++++ ...003-docker-fix-problem-stopping-container.patch | 36 ++++++++++ .../procd-openwrt-18.06/001_lxd_no_mounts.patch | 69 ------------------ .../procd-openwrt-18.06/002_lxd_signal_halt.patch | 28 -------- patches/procd-snapshot | 2 +- 9 files changed, 329 insertions(+), 98 deletions(-) create mode 100644 patches/procd-master/0001-lxd-no-mounts.patch create mode 100644 patches/procd-master/0002-lxd-shutdown-on-SIGPWR.patch create mode 100644 patches/procd-master/0003-docker-fix-problem-stopping-container.patch create mode 100644 patches/procd-openwrt-18.06/0001-lxd-no-mounts.patch create mode 100644 patches/procd-openwrt-18.06/0002-lxd-shutdown-on-SIGPWR.patch create mode 100644 patches/procd-openwrt-18.06/0003-docker-fix-problem-stopping-container.patch delete mode 100644 patches/procd-openwrt-18.06/001_lxd_no_mounts.patch delete mode 100644 patches/procd-openwrt-18.06/002_lxd_signal_halt.patch diff --git a/patches/procd-master/0001-lxd-no-mounts.patch b/patches/procd-master/0001-lxd-no-mounts.patch new file mode 100644 index 0000000..a0accf0 --- /dev/null +++ b/patches/procd-master/0001-lxd-no-mounts.patch @@ -0,0 +1,83 @@ +From 661b1bff9fc019aa554a47a6dd2aad2d609eaedf Mon Sep 17 00:00:00 2001 +From: Mikael Magnusson +Date: Fri, 24 Aug 2018 13:55:42 +0000 +Subject: [PATCH 1/3] lxd: no mounts + +--- + initd/early.c | 16 ---------------- + initd/zram.c | 6 ------ + plug/coldplug.c | 5 ----- + 3 files changed, 27 deletions(-) + +diff --git a/initd/early.c b/initd/early.c +index 2e15112..c41825a 100644 +--- a/initd/early.c ++++ b/initd/early.c +@@ -26,13 +26,6 @@ + #include "init.h" + #include "../libc-compat.h" + +-static void +-early_dev(void) +-{ +- mkdev("*", 0600); +- mknod("/dev/null", 0666, makedev(1, 3)); +-} +- + static void + early_console(const char *dev) + { +@@ -56,15 +49,6 @@ early_mounts(void) + { + unsigned int oldumask = umask(0); + +- mount("proc", "/proc", "proc", MS_NOATIME | MS_NODEV | MS_NOEXEC | MS_NOSUID, 0); +- mount("sysfs", "/sys", "sysfs", MS_NOATIME | MS_NODEV | MS_NOEXEC | MS_NOSUID, 0); +- mount("cgroup", "/sys/fs/cgroup", "cgroup", MS_NODEV | MS_NOEXEC | MS_NOSUID, 0); +- mount("tmpfs", "/dev", "tmpfs", MS_NOATIME | MS_NOSUID, "mode=0755,size=512K"); +- ignore(symlink("/tmp/shm", "/dev/shm")); +- mkdir("/dev/pts", 0755); +- mount("devpts", "/dev/pts", "devpts", MS_NOATIME | MS_NOEXEC | MS_NOSUID, "mode=600"); +- early_dev(); +- + early_console("/dev/console"); + if (mount_zram_on_tmp()) { + mount("tmpfs", "/tmp", "tmpfs", MS_NOSUID | MS_NODEV | MS_NOATIME, "mode=01777"); +diff --git a/initd/zram.c b/initd/zram.c +index b41bfd9..70049e6 100644 +--- a/initd/zram.c ++++ b/initd/zram.c +@@ -116,12 +116,6 @@ mount_zram_on_tmp(void) + waitpid(pid, NULL, 0); + } + +- ret = mount("/dev/zram0", "/tmp", "ext4", MS_NOSUID | MS_NODEV | MS_NOATIME, "errors=continue,noquota"); +- if (ret < 0) { +- ERROR("Can't mount /dev/zram0 on /tmp: %m\n"); +- return errno; +- } +- + LOG("Using up to %ld kB of RAM as ZRAM storage on /mnt\n", zramsize); + + ret = chmod("/tmp", 01777); +diff --git a/plug/coldplug.c b/plug/coldplug.c +index c6a89c3..72554c3 100644 +--- a/plug/coldplug.c ++++ b/plug/coldplug.c +@@ -43,13 +43,8 @@ void procd_coldplug(void) + char *argv[] = { "udevtrigger", NULL }; + unsigned int oldumask = umask(0); + +- umount2("/dev/pts", MNT_DETACH); +- umount2("/dev/", MNT_DETACH); +- mount("tmpfs", "/dev", "tmpfs", MS_NOSUID, "mode=0755,size=512K"); + ignore(symlink("/tmp/shm", "/dev/shm")); +- mkdir("/dev/pts", 0755); + umask(oldumask); +- mount("devpts", "/dev/pts", "devpts", MS_NOEXEC | MS_NOSUID, 0); + udevtrigger.cb = udevtrigger_complete; + udevtrigger.pid = fork(); + if (!udevtrigger.pid) { +-- +2.17.1 + diff --git a/patches/procd-master/0002-lxd-shutdown-on-SIGPWR.patch b/patches/procd-master/0002-lxd-shutdown-on-SIGPWR.patch new file mode 100644 index 0000000..82db467 --- /dev/null +++ b/patches/procd-master/0002-lxd-shutdown-on-SIGPWR.patch @@ -0,0 +1,45 @@ +From 0cad3ca4450ad2558067aa4c11574f89efd72394 Mon Sep 17 00:00:00 2001 +From: Mikael Magnusson +Date: Fri, 24 Aug 2018 13:56:12 +0000 +Subject: [PATCH 2/3] lxd: shutdown on SIGPWR + +--- + initd/init.c | 1 + + signal.c | 2 ++ + 2 files changed, 3 insertions(+) + +diff --git a/initd/init.c b/initd/init.c +index 0349e6e..29eee50 100644 +--- a/initd/init.c ++++ b/initd/init.c +@@ -77,6 +77,7 @@ main(int argc, char **argv) + sigaction(SIGTERM, &sa_shutdown, NULL); + sigaction(SIGUSR1, &sa_shutdown, NULL); + sigaction(SIGUSR2, &sa_shutdown, NULL); ++ sigaction(SIGPWR, &sa_shutdown, NULL); + + early(); + cmdline(); +diff --git a/signal.c b/signal.c +index 07dda9a..9974153 100644 +--- a/signal.c ++++ b/signal.c +@@ -44,6 +44,7 @@ static void signal_shutdown(int signal, siginfo_t *siginfo, void *data) + break; + case SIGUSR1: + case SIGUSR2: ++ case SIGPWR: + event = RB_POWER_OFF; + msg = "poweroff"; + break; +@@ -90,6 +91,7 @@ void procd_signal(void) + sigaction(SIGINT, &sa_shutdown, NULL); + sigaction(SIGUSR1, &sa_shutdown, NULL); + sigaction(SIGUSR2, &sa_shutdown, NULL); ++ sigaction(SIGPWR, &sa_shutdown, NULL); + sigaction(SIGSEGV, &sa_crash, NULL); + sigaction(SIGBUS, &sa_crash, NULL); + sigaction(SIGHUP, &sa_dummy, NULL); +-- +2.17.1 + diff --git a/patches/procd-master/0003-docker-fix-problem-stopping-container.patch b/patches/procd-master/0003-docker-fix-problem-stopping-container.patch new file mode 100644 index 0000000..34e9ca5 --- /dev/null +++ b/patches/procd-master/0003-docker-fix-problem-stopping-container.patch @@ -0,0 +1,36 @@ +From ac47a6ab039926f2939d07dc55333103c8a6ad0d Mon Sep 17 00:00:00 2001 +From: Mikael Magnusson +Date: Thu, 29 Nov 2018 22:10:42 +0000 +Subject: [PATCH 3/3] docker: fix problem stopping container + +--- + state.c | 13 +------------ + 1 file changed, 1 insertion(+), 12 deletions(-) + +diff --git a/state.c b/state.c +index ccf4104..bd59d7e 100644 +--- a/state.c ++++ b/state.c +@@ -157,18 +157,7 @@ static void state_enter(void) + else + LOG("- reboot -\n"); + +- /* Allow time for last message to reach serial console, etc */ +- sleep(1); +- +- /* We have to fork here, since the kernel calls do_exit(EXIT_SUCCESS) +- * in linux/kernel/sys.c, which can cause the machine to panic when +- * the init process exits... */ +- if (!vfork( )) { /* child */ +- reboot(reboot_event); +- _exit(EXIT_SUCCESS); +- } +- while (1) +- sleep(1); ++ exit(0); + #else + exit(0); + #endif +-- +2.17.1 + diff --git a/patches/procd-openwrt-18.06/0001-lxd-no-mounts.patch b/patches/procd-openwrt-18.06/0001-lxd-no-mounts.patch new file mode 100644 index 0000000..6bbd8f1 --- /dev/null +++ b/patches/procd-openwrt-18.06/0001-lxd-no-mounts.patch @@ -0,0 +1,83 @@ +From 991241149ad50b0ef5e221fe34d993ad67cb4174 Mon Sep 17 00:00:00 2001 +From: Mikael Magnusson +Date: Fri, 24 Aug 2018 13:55:42 +0000 +Subject: [PATCH 1/3] lxd: no mounts + +--- + initd/early.c | 16 ---------------- + initd/zram.c | 6 ------ + plug/coldplug.c | 5 ----- + 3 files changed, 27 deletions(-) + +diff --git a/initd/early.c b/initd/early.c +index 00fd946..dac07b9 100644 +--- a/initd/early.c ++++ b/initd/early.c +@@ -26,13 +26,6 @@ + #include "init.h" + #include "../libc-compat.h" + +-static void +-early_dev(void) +-{ +- mkdev("*", 0600); +- mknod("/dev/null", 0666, makedev(1, 3)); +-} +- + static void + early_console(const char *dev) + { +@@ -56,15 +49,6 @@ early_mounts(void) + { + unsigned int oldumask = umask(0); + +- mount("proc", "/proc", "proc", MS_NOATIME | MS_NODEV | MS_NOEXEC | MS_NOSUID, 0); +- mount("sysfs", "/sys", "sysfs", MS_NOATIME | MS_NODEV | MS_NOEXEC | MS_NOSUID, 0); +- mount("cgroup", "/sys/fs/cgroup", "cgroup", MS_NODEV | MS_NOEXEC | MS_NOSUID, 0); +- mount("tmpfs", "/dev", "tmpfs", MS_NOATIME | MS_NOSUID, "mode=0755,size=512K"); +- ignore(symlink("/tmp/shm", "/dev/shm")); +- mkdir("/dev/pts", 0755); +- mount("devpts", "/dev/pts", "devpts", MS_NOATIME | MS_NOEXEC | MS_NOSUID, "mode=600"); +- early_dev(); +- + early_console("/dev/console"); + if (mount_zram_on_tmp()) { + mount("tmpfs", "/tmp", "tmpfs", MS_NOSUID | MS_NODEV | MS_NOATIME, 0); +diff --git a/initd/zram.c b/initd/zram.c +index b41bfd9..70049e6 100644 +--- a/initd/zram.c ++++ b/initd/zram.c +@@ -116,12 +116,6 @@ mount_zram_on_tmp(void) + waitpid(pid, NULL, 0); + } + +- ret = mount("/dev/zram0", "/tmp", "ext4", MS_NOSUID | MS_NODEV | MS_NOATIME, "errors=continue,noquota"); +- if (ret < 0) { +- ERROR("Can't mount /dev/zram0 on /tmp: %m\n"); +- return errno; +- } +- + LOG("Using up to %ld kB of RAM as ZRAM storage on /mnt\n", zramsize); + + ret = chmod("/tmp", 01777); +diff --git a/plug/coldplug.c b/plug/coldplug.c +index c6a89c3..72554c3 100644 +--- a/plug/coldplug.c ++++ b/plug/coldplug.c +@@ -43,13 +43,8 @@ void procd_coldplug(void) + char *argv[] = { "udevtrigger", NULL }; + unsigned int oldumask = umask(0); + +- umount2("/dev/pts", MNT_DETACH); +- umount2("/dev/", MNT_DETACH); +- mount("tmpfs", "/dev", "tmpfs", MS_NOSUID, "mode=0755,size=512K"); + ignore(symlink("/tmp/shm", "/dev/shm")); +- mkdir("/dev/pts", 0755); + umask(oldumask); +- mount("devpts", "/dev/pts", "devpts", MS_NOEXEC | MS_NOSUID, 0); + udevtrigger.cb = udevtrigger_complete; + udevtrigger.pid = fork(); + if (!udevtrigger.pid) { +-- +2.17.1 + diff --git a/patches/procd-openwrt-18.06/0002-lxd-shutdown-on-SIGPWR.patch b/patches/procd-openwrt-18.06/0002-lxd-shutdown-on-SIGPWR.patch new file mode 100644 index 0000000..719dba6 --- /dev/null +++ b/patches/procd-openwrt-18.06/0002-lxd-shutdown-on-SIGPWR.patch @@ -0,0 +1,45 @@ +From 9c252ff0b3fec05f3757362ca044440bfdfa16f4 Mon Sep 17 00:00:00 2001 +From: Mikael Magnusson +Date: Fri, 24 Aug 2018 13:56:12 +0000 +Subject: [PATCH 2/3] lxd: shutdown on SIGPWR + +--- + initd/init.c | 1 + + signal.c | 2 ++ + 2 files changed, 3 insertions(+) + +diff --git a/initd/init.c b/initd/init.c +index 0349e6e..29eee50 100644 +--- a/initd/init.c ++++ b/initd/init.c +@@ -77,6 +77,7 @@ main(int argc, char **argv) + sigaction(SIGTERM, &sa_shutdown, NULL); + sigaction(SIGUSR1, &sa_shutdown, NULL); + sigaction(SIGUSR2, &sa_shutdown, NULL); ++ sigaction(SIGPWR, &sa_shutdown, NULL); + + early(); + cmdline(); +diff --git a/signal.c b/signal.c +index 07dda9a..9974153 100644 +--- a/signal.c ++++ b/signal.c +@@ -44,6 +44,7 @@ static void signal_shutdown(int signal, siginfo_t *siginfo, void *data) + break; + case SIGUSR1: + case SIGUSR2: ++ case SIGPWR: + event = RB_POWER_OFF; + msg = "poweroff"; + break; +@@ -90,6 +91,7 @@ void procd_signal(void) + sigaction(SIGINT, &sa_shutdown, NULL); + sigaction(SIGUSR1, &sa_shutdown, NULL); + sigaction(SIGUSR2, &sa_shutdown, NULL); ++ sigaction(SIGPWR, &sa_shutdown, NULL); + sigaction(SIGSEGV, &sa_crash, NULL); + sigaction(SIGBUS, &sa_crash, NULL); + sigaction(SIGHUP, &sa_dummy, NULL); +-- +2.17.1 + diff --git a/patches/procd-openwrt-18.06/0003-docker-fix-problem-stopping-container.patch b/patches/procd-openwrt-18.06/0003-docker-fix-problem-stopping-container.patch new file mode 100644 index 0000000..394ac26 --- /dev/null +++ b/patches/procd-openwrt-18.06/0003-docker-fix-problem-stopping-container.patch @@ -0,0 +1,36 @@ +From 0aacf0e59985185e7d4a88e3dd72aed62ad87926 Mon Sep 17 00:00:00 2001 +From: Mikael Magnusson +Date: Thu, 29 Nov 2018 22:10:42 +0000 +Subject: [PATCH 3/3] docker: fix problem stopping container + +--- + state.c | 13 +------------ + 1 file changed, 1 insertion(+), 12 deletions(-) + +diff --git a/state.c b/state.c +index ccf4104..bd59d7e 100644 +--- a/state.c ++++ b/state.c +@@ -157,18 +157,7 @@ static void state_enter(void) + else + LOG("- reboot -\n"); + +- /* Allow time for last message to reach serial console, etc */ +- sleep(1); +- +- /* We have to fork here, since the kernel calls do_exit(EXIT_SUCCESS) +- * in linux/kernel/sys.c, which can cause the machine to panic when +- * the init process exits... */ +- if (!vfork( )) { /* child */ +- reboot(reboot_event); +- _exit(EXIT_SUCCESS); +- } +- while (1) +- sleep(1); ++ exit(0); + #else + exit(0); + #endif +-- +2.17.1 + diff --git a/patches/procd-openwrt-18.06/001_lxd_no_mounts.patch b/patches/procd-openwrt-18.06/001_lxd_no_mounts.patch deleted file mode 100644 index e9e5368..0000000 --- a/patches/procd-openwrt-18.06/001_lxd_no_mounts.patch +++ /dev/null @@ -1,69 +0,0 @@ -diff --git a/initd/early.c b/initd/early.c -index 7028ff8..115d8f8 100644 ---- a/initd/early.c -+++ b/initd/early.c -@@ -27,13 +27,6 @@ - #include "../libc-compat.h" - - static void --early_dev(void) --{ -- mkdev("*", 0600); -- mknod("/dev/null", 0666, makedev(1, 3)); --} -- --static void - early_console(const char *dev) - { - struct stat s; -@@ -56,15 +49,6 @@ early_mounts(void) - { - unsigned int oldumask = umask(0); - -- mount("proc", "/proc", "proc", MS_NOATIME | MS_NODEV | MS_NOEXEC | MS_NOSUID, 0); -- mount("sysfs", "/sys", "sysfs", MS_NOATIME | MS_NODEV | MS_NOEXEC | MS_NOSUID, 0); -- mount("cgroup", "/sys/fs/cgroup", "cgroup", MS_NODEV | MS_NOEXEC | MS_NOSUID, 0); -- mount("tmpfs", "/dev", "tmpfs", MS_NOATIME | MS_NOSUID, "mode=0755,size=512K"); -- ignore(symlink("/tmp/shm", "/dev/shm")); -- mkdir("/dev/pts", 0755); -- mount("devpts", "/dev/pts", "devpts", MS_NOATIME | MS_NOEXEC | MS_NOSUID, "mode=600"); -- early_dev(); -- - early_console("/dev/console"); - if (mount_zram_on_tmp()) { - mount("tmpfs", "/tmp", "tmpfs", MS_NOSUID | MS_NODEV | MS_NOATIME, 0); -diff --git a/initd/zram.c b/initd/zram.c -index c730942..8eb38a6 100644 ---- a/initd/zram.c -+++ b/initd/zram.c -@@ -116,12 +116,6 @@ mount_zram_on_tmp(void) - waitpid(pid, NULL, 0); - } - -- ret = mount("/dev/zram0", "/tmp", "ext4", MS_NOSUID | MS_NODEV | MS_NOATIME, "errors=continue,noquota"); -- if (ret < 0) { -- ERROR("Can't mount /dev/zram0 on /tmp: %m\n"); -- return errno; -- } -- - LOG("Using up to %ld kB of RAM as ZRAM storage on /mnt\n", zramsize); - - ret = chmod("/tmp", 01777); -diff --git a/plug/coldplug.c b/plug/coldplug.c -index 5fcb9a3..b846d7f 100644 ---- a/plug/coldplug.c -+++ b/plug/coldplug.c -@@ -43,13 +43,8 @@ void procd_coldplug(void) - char *argv[] = { "udevtrigger", NULL }; - unsigned int oldumask = umask(0); - -- umount2("/dev/pts", MNT_DETACH); -- umount2("/dev/", MNT_DETACH); -- mount("tmpfs", "/dev", "tmpfs", MS_NOSUID, "mode=0755,size=512K"); - ignore(symlink("/tmp/shm", "/dev/shm")); -- mkdir("/dev/pts", 0755); - umask(oldumask); -- mount("devpts", "/dev/pts", "devpts", MS_NOEXEC | MS_NOSUID, 0); - udevtrigger.cb = udevtrigger_complete; - udevtrigger.pid = fork(); - if (!udevtrigger.pid) { diff --git a/patches/procd-openwrt-18.06/002_lxd_signal_halt.patch b/patches/procd-openwrt-18.06/002_lxd_signal_halt.patch deleted file mode 100644 index 306c39b..0000000 --- a/patches/procd-openwrt-18.06/002_lxd_signal_halt.patch +++ /dev/null @@ -1,28 +0,0 @@ ---- a/initd/init.c.orig 2018-07-01 22:24:02.065349814 +0000 -+++ b/initd/init.c 2018-07-01 22:23:02.837917724 +0000 -@@ -77,6 +77,7 @@ - sigaction(SIGTERM, &sa_shutdown, NULL); - sigaction(SIGUSR1, &sa_shutdown, NULL); - sigaction(SIGUSR2, &sa_shutdown, NULL); -+ sigaction(SIGPWR, &sa_shutdown, NULL); - - early(); - cmdline(); ---- a/signal.c.orig 2018-03-28 09:29:49.000000000 +0000 -+++ b/signal.c 2018-07-01 22:23:23.357720944 +0000 -@@ -44,6 +44,7 @@ - break; - case SIGUSR1: - case SIGUSR2: -+ case SIGPWR: - event = RB_POWER_OFF; - msg = "poweroff"; - break; -@@ -90,6 +91,7 @@ - sigaction(SIGINT, &sa_shutdown, NULL); - sigaction(SIGUSR1, &sa_shutdown, NULL); - sigaction(SIGUSR2, &sa_shutdown, NULL); -+ sigaction(SIGPWR, &sa_shutdown, NULL); - sigaction(SIGSEGV, &sa_crash, NULL); - sigaction(SIGBUS, &sa_crash, NULL); - sigaction(SIGHUP, &sa_dummy, NULL); diff --git a/patches/procd-snapshot b/patches/procd-snapshot index 28f9e38..2015f41 120000 --- a/patches/procd-snapshot +++ b/patches/procd-snapshot @@ -1 +1 @@ -procd-openwrt-18.06/ \ No newline at end of file +procd-master \ No newline at end of file -- cgit v1.2.3