Merge tag 'v2.3.5' into testing v2.1.3
authorMathieu Baudier <mbaudier@argeo.org>
Tue, 19 Dec 2023 06:10:34 +0000 (07:10 +0100)
committerMathieu Baudier <mbaudier@argeo.org>
Tue, 19 Dec 2023 06:10:34 +0000 (07:10 +0100)
27 files changed:
argeo-freed.spec
debian/changelog
debian/control
etc/freed/init/config.ini [deleted file]
etc/freed/init/jvm.args [deleted file]
etc/freed/init/system.properties [deleted file]
etc/freed/pid1/config.ini [new file with mode: 0644]
etc/freed/pid1/jvm.args [new file with mode: 0644]
etc/freed/pid1/system.properties [new file with mode: 0644]
local.mk [new file with mode: 0644]
sjbin/.classpath [new file with mode: 0644]
sjbin/.gitignore [new file with mode: 0644]
sjbin/.project [new file with mode: 0644]
sjbin/META-INF/MANIFEST.MF [new file with mode: 0644]
sjbin/Makefile [new file with mode: 0644]
sjbin/build.properties [new file with mode: 0644]
sjbin/src/freed-pid1.java [new file with mode: 0644]
usr/jbin/.classpath [deleted file]
usr/jbin/.gitignore [deleted file]
usr/jbin/.project [deleted file]
usr/jbin/META-INF/MANIFEST.MF [deleted file]
usr/jbin/Makefile [deleted file]
usr/jbin/build.properties [deleted file]
usr/jbin/src/freed-init.java [deleted file]
usr/lib/systemd/system/argeo@.service
usr/lib/systemd/system/freed-ipsec-roaming@.service
usr/lib/systemd/user/argeo@.service

index 18a09e25e2e3aadbc8a98ac3708b68c02fed06b8..3535875b64f6f5a18e328d768744097fbb026906 100644 (file)
@@ -1,5 +1,5 @@
 Name:           argeo-freed
-Version:        2.1.2
+Version:        2.1.3
 Release:        1%{?dist}
 Summary:        Utilities for a FREEd compatible domain
 
@@ -33,7 +33,7 @@ Requires:       libreswan
 
 %package roaming-client
 Summary:        FREEd roaming client
-Requires:       argeo-freed-libreswan unbound
+Requires:       argeo-freed-libreswan
 
 %description roaming-client
 
index fac7e6f9f8038e0606d3ebc78e03013bb4feeb6c..a4e47ce2bd6c8f903a1dd68c1713a348bb8ae7ca 100644 (file)
@@ -1,5 +1,5 @@
-argeo-freed (2.1.2) testing; urgency=medium
+argeo-freed (2.1.3) testing; urgency=medium
 
-  * Fix launch scripts
+  * Adapt to changes in Argeo TP
 
- -- Mathieu Baudier <mbaudier@argeo.org>  Sat, 03 Jun 2023 06:21:21 +0200
+ -- Mathieu Baudier <mbaudier@argeo.org>  Thu, 14 Dec 2023 05:48:41 +0000
index 808dc5eab68daf9c1d191253ae6dad8b787b4f50..6c4b9d30eafac5b22ff66aa92523536a13e893aa 100644 (file)
@@ -28,7 +28,7 @@ Description: FREEd extensions to libreswan
 
 Package: argeo-freed-roaming-client
 Architecture: all
-Depends: ${misc:Depends}, argeo-freed-libreswan, unbound
+Depends: ${misc:Depends}, argeo-freed-libreswan
 Description: FREEd roaming client
  Argeo FREEd roaming client
 
diff --git a/etc/freed/init/config.ini b/etc/freed/init/config.ini
deleted file mode 100644 (file)
index bdb2a9a..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-osgi.clean=true
-osgi.console=true
-
-argeo.osgi.start.2=\
-org.eclipse.equinox.http.servlet,\
-org.apache.felix.scr,\
-org.eclipse.rap.rwt.osgi,\
-org.apache.tika.parsers,\
-org.argeo.init
-
-argeo.osgi.start.3=\
-org.argeo.cms,\
-org.argeo.cms.swt.rap,\
-org.argeo.cms.swt.rcp,\
-org.argeo.cms.ee,\
-org.argeo.cms.lib.sshd,\
-org.argeo.cms.lib.equinox,\
-org.argeo.cms.lib.jetty,\
-org.argeo.cms.jshell,\
-
-argeo.http.port=80
-argeo.sshd.port=22
-
-argeo.osgi.sources=\
-a2:///?\
-osgi=equinox&\
-log=syslogger&\
-crypto=fips&\
diff --git a/etc/freed/init/jvm.args b/etc/freed/init/jvm.args
deleted file mode 100644 (file)
index 6e7d6a6..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
--Dosgi.configuration.cascaded=true
--Dosgi.sharedConfiguration.area=/etc/freed/init
--Dosgi.sharedConfiguration.area.readOnly=true
--Dosgi.configuration.area=/var/lib/freed/init/state/
--Dosgi.instance.area=/var/lib/freed/init/data/
-
--Dorg.osgi.framework.system.packages.extra=sun.security.internal.spec,sun.security.provider,com.sun.net.httpserver,com.sun.jndi.ldap,com.sun.jndi.ldap.sasl,com.sun.jndi.dns,com.sun.security.jgss,com.sun.nio.file,com.sun.nio.sctp
--Dorg.eclipse.equinox.http.jetty.autostart=false
-
--cp /usr/local/share/a2/osgi/equinox/org.argeo.tp.osgi/org.eclipse.osgi.3.18.jar:/usr/local/share/a2/org.argeo.cms/org.argeo.init.2.3.jar
\ No newline at end of file
diff --git a/etc/freed/init/system.properties b/etc/freed/init/system.properties
deleted file mode 100644 (file)
index 5ee8524..0000000
+++ /dev/null
@@ -1 +0,0 @@
-log.org.argeo=DEBUG
\ No newline at end of file
diff --git a/etc/freed/pid1/config.ini b/etc/freed/pid1/config.ini
new file mode 100644 (file)
index 0000000..3fd167d
--- /dev/null
@@ -0,0 +1,28 @@
+osgi.clean=true
+#osgi.console=true
+
+argeo.osgi.start.2=\
+org.eclipse.equinox.http.servlet,\
+org.apache.felix.scr,\
+org.eclipse.rap.rwt.osgi,\
+org.apache.tika.parsers,\
+org.argeo.init
+
+argeo.osgi.start.3=\
+org.argeo.cms,\
+org.argeo.cms.swt.rap,\
+org.argeo.cms.swt.rcp,\
+org.argeo.cms.ee,\
+org.argeo.cms.lib.sshd,\
+org.argeo.cms.lib.equinox,\
+org.argeo.cms.lib.jetty,\
+org.argeo.cms.jshell,\
+
+argeo.http.port=80
+#argeo.sshd.port=22
+
+argeo.osgi.sources=\
+a2:///?\
+osgi=equinox&\
+log=syslogger&\
+crypto=fips&\
diff --git a/etc/freed/pid1/jvm.args b/etc/freed/pid1/jvm.args
new file mode 100644 (file)
index 0000000..708fab1
--- /dev/null
@@ -0,0 +1,23 @@
+#-Xmx64m
+#-Xshareclasses:name=pid1
+#-XX:+IdleTuningGcOnIdle
+
+-Dargeo.logging.file=/var/log/freed-pid1.log
+-Dlog.FreedPid1=DEBUG
+
+-Dosgi.configuration.cascaded=true
+-Dosgi.sharedConfiguration.area=/usr/local/etc/freed/pid1
+-Dosgi.sharedConfiguration.area.readOnly=true
+-Dosgi.configuration.area=/var/lib/freed/pid1/state/
+-Dosgi.instance.area=/var/lib/freed/pid1/data/
+
+-Dorg.osgi.framework.system.packages.extra=sun.security.utils,sun.security.internal.spec,sun.security.provider,com.sun.net.httpserver,com.sun.jndi.ldap,com.sun.jndi.ldap.sasl,com.sun.jndi.dns,com.sun.security.jgss,com.sun.nio.file,com.sun.nio.sctp
+-Dorg.eclipse.equinox.http.jetty.autostart=false
+
+-Dfile.encoding=UTF-8
+-Dnative.encoding=UTF-8
+-Dsun.stdout.encoding=UTF-8
+-Dsun.stderr.encoding=UTF-8
+-Dsun.jnu.encoding=UTF-8
+
+-cp /usr/local/share/a2/osgi/equinox/org.argeo.tp.osgi/org.eclipse.osgi.3.18.jar:/usr/local/share/a2/org.argeo.cms/org.argeo.init.2.3.jar
\ No newline at end of file
diff --git a/etc/freed/pid1/system.properties b/etc/freed/pid1/system.properties
new file mode 100644 (file)
index 0000000..5ee8524
--- /dev/null
@@ -0,0 +1 @@
+log.org.argeo=DEBUG
\ No newline at end of file
diff --git a/local.mk b/local.mk
new file mode 100644 (file)
index 0000000..7095276
--- /dev/null
+++ b/local.mk
@@ -0,0 +1,26 @@
+# GNU coding standards
+prefix ?= /usr/local
+exec_prefix ?= $(prefix)
+bindir ?= $(exec_prefix)/bin
+sbindir ?= $(exec_prefix)/sbin
+libdir ?= $(exec_prefix)/lib
+libexecdir ?= $(exec_prefix)/libexec
+sysconfdir ?= $(prefix)/etc
+srcdir ?= src
+datarootdir ?= $(prefix)/share
+
+COPY=cp --reflink=auto
+
+all:
+       $(MAKE) -C sjbin all
+
+clean:
+       $(MAKE) -C sjbin clean
+
+install:
+       $(COPY) -r --no-clobber etc/* $(DESTDIR)$(sysconfdir)
+       $(COPY) -r usr/bin/* $(DESTDIR)$(bindir)
+       $(COPY) -r usr/share/* $(DESTDIR)$(datarootdir)
+       $(COPY) -r usr/lib/* $(DESTDIR)$(libdir)
+       $(COPY) -r usr/libexec/* $(DESTDIR)$(libexecdir)
+       $(MAKE) -C sjbin install
diff --git a/sjbin/.classpath b/sjbin/.classpath
new file mode 100644 (file)
index 0000000..81fe078
--- /dev/null
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17"/>
+       <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+       <classpathentry kind="src" path="src"/>
+       <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/sjbin/.gitignore b/sjbin/.gitignore
new file mode 100644 (file)
index 0000000..01c3b51
--- /dev/null
@@ -0,0 +1,4 @@
+/bin/
+/src/*
+!/src/*.java
+/freed-pid1
diff --git a/sjbin/.project b/sjbin/.project
new file mode 100644 (file)
index 0000000..295adf7
--- /dev/null
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>freed-sjbin</name>
+       <comment></comment>
+       <projects>
+       </projects>
+       <buildSpec>
+               <buildCommand>
+                       <name>org.eclipse.jdt.core.javabuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.pde.ManifestBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.pde.SchemaBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+       </buildSpec>
+       <natures>
+               <nature>org.eclipse.pde.PluginNature</nature>
+               <nature>org.eclipse.jdt.core.javanature</nature>
+       </natures>
+</projectDescription>
diff --git a/sjbin/META-INF/MANIFEST.MF b/sjbin/META-INF/MANIFEST.MF
new file mode 100644 (file)
index 0000000..8b35d9a
--- /dev/null
@@ -0,0 +1,7 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Freed-jbin
+Bundle-SymbolicName: freed-jbin
+Bundle-Version: 1.0.0.qualifier
+Automatic-Module-Name: freed.jbin
+Bundle-RequiredExecutionEnvironment: JavaSE-17
diff --git a/sjbin/Makefile b/sjbin/Makefile
new file mode 100644 (file)
index 0000000..959f751
--- /dev/null
@@ -0,0 +1,25 @@
+# GNU coding standards
+prefix ?= /usr/local
+exec_prefix ?= $(prefix)
+sbindir ?= $(exec_prefix)/sbin
+sysconfdir = $(prefix)/etc
+srcdir ?= src
+
+EXECUTABLES=$(notdir $(patsubst %.java,%,$(wildcard $(srcdir)/*.java)))
+
+all: $(EXECUTABLES)
+
+%: $(srcdir)/%.java
+       cp $< $@
+       sed -i '1!b;s|//#!|#!|' $@
+       chmod a+x $@
+
+clean:
+       $(RM) $(EXECUTABLES)
+
+install:
+# TODO generalise
+       cp -v --preserve=mode freed-pid1 $(DESTDIR)$(sbindir)
+       sed -i 's|/usr/local|$(prefix)|' $(DESTDIR)$(sbindir)/freed-pid1
+       sed -i 's|/usr/local|$(prefix)|' $(DESTDIR)$(sysconfdir)/freed/pid1/jvm.args
+#      cp -v ../../etc/freed/init/* $(DESTDIR)$(sysconfdir)/freed/init
diff --git a/sjbin/build.properties b/sjbin/build.properties
new file mode 100644 (file)
index 0000000..5d082ea
--- /dev/null
@@ -0,0 +1,5 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+               .
+additional.bundles = org.argeo.init
diff --git a/sjbin/src/freed-pid1.java b/sjbin/src/freed-pid1.java
new file mode 100644 (file)
index 0000000..446cc0e
--- /dev/null
@@ -0,0 +1,309 @@
+//#! /usr/bin/java --source 17 @/usr/local/etc/freed/pid1/jvm.args
+
+import static java.lang.System.Logger.Level.DEBUG;
+import static java.lang.System.Logger.Level.ERROR;
+import static java.lang.System.Logger.Level.INFO;
+import static java.lang.System.Logger.Level.WARNING;
+
+import java.io.Console;
+import java.io.IOException;
+import java.lang.System.Logger;
+import java.lang.management.ManagementFactory;
+import java.net.InetAddress;
+import java.net.InterfaceAddress;
+import java.net.NetworkInterface;
+import java.net.SocketException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.List;
+import java.util.TreeMap;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.argeo.init.Service;
+
+import sun.misc.Signal;
+
+/** A minimalistic Linux init process. */
+class FreedPid1 {
+       final static AtomicInteger runLevel = new AtomicInteger(-1);
+
+       private final static Logger logger = System.getLogger(FreedPid1.class.getName());
+
+       private final static List<String> initDServices = Collections.synchronizedList(new ArrayList<>());
+
+       public static void main(String... args) {
+               try {
+                       final long pid = ProcessHandle.current().pid();
+                       Signal.handle(new Signal("TERM"), (signal) -> {
+                               System.out.println("SIGTERM caught");
+                               System.exit(0);
+                       });
+                       Signal.handle(new Signal("INT"), (signal) -> {
+                               System.out.println("SIGINT caught");
+                               System.exit(0);
+                       });
+                       Signal.handle(new Signal("HUP"), (signal) -> {
+                               System.out.println("SIGHUP caught");
+                               System.exit(0);
+                       });
+
+                       boolean isSystemInit = pid == 1 || pid == 2;
+
+                       if (isSystemInit && args.length > 0 && ("1".equals(args[0]) //
+                                       || "single".equals(args[0]) //
+                                       || "emergency".equals(args[0]))) {
+                               runLevel.set(1);
+                               for (Object key : new TreeMap<>(System.getProperties()).keySet()) {
+                                       System.out.println(key + "=" + System.getProperty(key.toString()));
+                               }
+                               System.out.println("Single user mode");
+                               System.out.flush();
+                               ProcessBuilder pb = new ProcessBuilder("/bin/bash");
+                               pb.redirectError(ProcessBuilder.Redirect.INHERIT);
+                               pb.redirectOutput(ProcessBuilder.Redirect.INHERIT);
+                               pb.redirectInput(ProcessBuilder.Redirect.INHERIT);
+                               Process singleUserShell = pb.start();
+                               singleUserShell.waitFor();
+                       } else {
+                               if (args.length == 0)
+                                       runLevel.set(5);
+                               else
+                                       runLevel.set(Integer.parseInt(args[0]));
+
+                               if (runLevel.get() == 0) {// shutting down the whole system
+                                       if (!isSystemInit) {
+                                               logger.log(INFO, "Shutting down system...");
+                                               shutdown(false);
+                                               System.exit(0);
+                                       } else {
+                                               logger.log(ERROR, "Cannot start at run level " + runLevel.get());
+                                               System.exit(1);
+                                       }
+                               } else if (runLevel.get() == 6) {// reboot the whole system
+                                       if (!isSystemInit) {
+                                               logger.log(INFO, "Rebooting the system...");
+                                               shutdown(true);
+                                       } else {
+                                               logger.log(ERROR, "Cannot start at run level " + runLevel.get());
+                                               System.exit(1);
+                                       }
+                               }
+
+                               logger.log(INFO, "FREEd Init daemon starting with pid " + pid + " after "
+                                               + ManagementFactory.getRuntimeMXBean().getUptime() + " ms");
+                               // hostname
+                               String hostname = Files.readString(Paths.get("/etc/hostname"));
+                               new ProcessBuilder("/usr/bin/hostname", hostname).start();
+                               logger.log(DEBUG, "Set hostname to " + hostname);
+                               // networking
+                               initSysctl();
+                               startInitDService("networking", true);
+//                             Thread.sleep(3000);// leave some time for network to start up
+                               if (!waitForNetwork(10 * 1000))
+                                       logger.log(ERROR, "No network available");
+
+                               // OpenSSH
+                               // TODO make it coherent with Java sshd
+                               startInitDService("ssh", true);
+
+                               // NSS services
+                               startInitDService("nslcd", false);// Note: nslcd fails to stop
+
+                               // login prompt
+                               Service.addPostStart(() -> new LoginThread().start());
+
+                               // init Argeo CMS
+                               logger.log(INFO, "FREEd Init daemon starting Argeo Init after "
+                                               + ManagementFactory.getRuntimeMXBean().getUptime() + " ms");
+                               Service.main(args);
+                       }
+               } catch (Throwable e) {
+                       logger.log(ERROR, "Unexpected exception in free-pid1 init, shutting down... ", e);
+                       System.exit(1);
+               } finally {
+                       stopInitDServices();
+               }
+       }
+
+       static void initSysctl() {
+               try {
+                       Path sysctlD = Paths.get("/etc/sysctl.d/");
+                       for (Path conf : Files.newDirectoryStream(sysctlD, "*.conf")) {
+                               try {
+                                       new ProcessBuilder("/usr/sbin/sysctl", "-p", conf.toString()).start();
+                               } catch (IOException e) {
+                                       e.printStackTrace();
+                               }
+                       }
+               } catch (IOException e) {
+                       e.printStackTrace();
+               }
+       }
+
+       static void startInitDService(String serviceName, boolean stopOnShutdown) {
+               Path serviceInit = Paths.get("/etc/init.d/", serviceName);
+               if (Files.exists(serviceInit))
+                       try {
+                               int exitCode = new ProcessBuilder(serviceInit.toString(), "start").start().waitFor();
+                               if (exitCode != 0)
+                                       logger.log(ERROR, "Service " + serviceName + " dit not stop properly");
+                               else
+                                       logger.log(DEBUG, "Service " + serviceName + " started");
+                               if (stopOnShutdown)
+                                       initDServices.add(serviceName);
+//                                     Runtime.getRuntime().addShutdownHook(new Thread(() -> {
+//                                             try {
+//                                                     new ProcessBuilder(serviceInit.toString(), "stop").start().waitFor();
+//                                             } catch (IOException | InterruptedException e) {
+//                                                     e.printStackTrace();
+//                                             }
+//                                     }, "FREEd stop service " + serviceName));
+                       } catch (IOException | InterruptedException e) {
+                               e.printStackTrace();
+                       }
+               else
+                       logger.log(WARNING, "Service " + serviceName + " not found and therefore not started");
+       }
+
+       static boolean waitForNetwork(long timeout) {
+               long begin = System.currentTimeMillis();
+               long duration = 0;
+               boolean networkAvailable = false;
+               try {
+                       networkAvailable: while (!networkAvailable) {
+                               duration = System.currentTimeMillis() - begin;
+                               if (duration > timeout)
+                                       break networkAvailable;
+                               Enumeration<NetworkInterface> netInterfaces = null;
+                               try {
+                                       netInterfaces = NetworkInterface.getNetworkInterfaces();
+                               } catch (SocketException e) {
+                                       throw new IllegalStateException("Cannot list network interfaces", e);
+                               }
+                               if (netInterfaces != null) {
+                                       while (netInterfaces.hasMoreElements()) {
+                                               NetworkInterface netInterface = netInterfaces.nextElement();
+                                               logger.log(DEBUG, "Interface:" + netInterface);
+                                               for (InterfaceAddress addr : netInterface.getInterfaceAddresses()) {
+                                                       InetAddress inetAddr = addr.getAddress();
+                                                       logger.log(DEBUG, "  addr: " + inetAddr);
+                                                       if (!inetAddr.isLoopbackAddress() && !inetAddr.isLinkLocalAddress()) {
+                                                               try {
+                                                                       if (inetAddr.isReachable((int) timeout)) {
+                                                                               networkAvailable = true;
+                                                                               duration = System.currentTimeMillis() - begin;
+                                                                               logger.log(DEBUG,
+                                                                                               "Network available after " + duration + " ms. IP: " + inetAddr);
+                                                                               break networkAvailable;
+                                                                       }
+                                                               } catch (IOException e) {
+                                                                       logger.log(ERROR, "Cannot check whether " + inetAddr + " is reachable", e);
+                                                               }
+                                                       }
+                                               }
+                                       }
+                               } else {
+                                       throw new IllegalStateException("No network interface has been found");
+                               }
+                               try {
+                                       Thread.sleep(1000);
+                               } catch (InterruptedException e) {
+                                       // silent
+                               }
+                       }
+               } catch (Exception e) {
+                       logger.log(ERROR, "Cannot check whether network is available", e);
+               }
+               return networkAvailable;
+       }
+
+       static void shutdown(boolean reboot) {
+               try {
+                       stopInitDServices();
+                       Path sysrqP = Paths.get("/proc/sys/kernel/sysrq");
+                       Files.writeString(sysrqP, "1");
+                       Path sysrqTriggerP = Paths.get("/proc/sysrq-trigger");
+                       Files.writeString(sysrqTriggerP, "e");// send SIGTERM to all processes
+                       // Files.writeString(sysrqTriggerP, "i");// send SIGKILL to all processes
+                       Files.writeString(sysrqTriggerP, "e");// flush data to disk
+                       Files.writeString(sysrqTriggerP, "u");// unmount
+                       if (reboot)
+                               Files.writeString(sysrqTriggerP, "b");
+                       else
+                               Files.writeString(sysrqTriggerP, "o");
+               } catch (IOException e) {
+                       logger.log(ERROR, "Cannot shut down system", e);
+               }
+       }
+
+       static void stopInitDServices() {
+               for (int i = initDServices.size() - 1; i >= 0; i--) {
+                       String serviceName = initDServices.get(i);
+                       Path serviceInit = Paths.get("/etc/init.d/", serviceName);
+                       try {
+                               int exitCode = new ProcessBuilder(serviceInit.toString(), "stop").start().waitFor();
+                               if (exitCode != 0)
+                                       logger.log(ERROR, "Service " + serviceName + " dit not stop properly");
+                       } catch (InterruptedException | IOException e) {
+                               logger.log(ERROR, "Cannot stop service " + serviceName, e);
+                       }
+               }
+       }
+
+       /** A thread watching the login prompt. */
+       static class LoginThread extends Thread {
+               private boolean systemShuttingDown = false;
+               private Process process = null;
+
+               public LoginThread() {
+                       super("FREEd login prompt");
+                       setDaemon(true);
+                       Runtime.getRuntime().addShutdownHook(new Thread(() -> {
+                               systemShuttingDown = true;
+                               if (process != null)
+                                       process.destroy();
+                       }));
+               }
+
+               @Override
+               public void run() {
+                       boolean getty = true;
+                       prompt: while (!systemShuttingDown) {
+                               try {
+                                       if (getty) {
+                                               ProcessBuilder pb = new ProcessBuilder("/usr/sbin/getty", "38400", "tty2");
+                                               process = pb.start();
+                                       } else {
+                                               Console console = System.console();
+                                               console.readLine(); // type return once to activate login prompt
+                                               console.printf("login: ");
+                                               String username = console.readLine();
+                                               username = username.trim();
+                                               if ("".equals(username))
+                                                       continue prompt;
+                                               ProcessBuilder pb = new ProcessBuilder("su", "--login", username);
+                                               pb.redirectError(ProcessBuilder.Redirect.INHERIT);
+                                               pb.redirectOutput(ProcessBuilder.Redirect.INHERIT);
+                                               pb.redirectInput(ProcessBuilder.Redirect.INHERIT);
+                                               process = pb.start();
+                                       }
+                                       Runtime.getRuntime().addShutdownHook(new Thread(() -> process.destroy()));
+                                       try {
+                                               process.waitFor();
+                                       } catch (InterruptedException e) {
+                                               process.destroy();
+                                       }
+                               } catch (Exception e) {
+                                       e.printStackTrace();
+                               } finally {
+                                       process = null;
+                               }
+                       }
+               }
+
+       }
+}
diff --git a/usr/jbin/.classpath b/usr/jbin/.classpath
deleted file mode 100644 (file)
index 81fe078..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
-       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17"/>
-       <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
-       <classpathentry kind="src" path="src"/>
-       <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/usr/jbin/.gitignore b/usr/jbin/.gitignore
deleted file mode 100644 (file)
index 8c068ec..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-/bin/
-/src/*
-!/src/*.java
-/freed-init
diff --git a/usr/jbin/.project b/usr/jbin/.project
deleted file mode 100644 (file)
index dfb0678..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
-       <name>freed-jbin</name>
-       <comment></comment>
-       <projects>
-       </projects>
-       <buildSpec>
-               <buildCommand>
-                       <name>org.eclipse.jdt.core.javabuilder</name>
-                       <arguments>
-                       </arguments>
-               </buildCommand>
-               <buildCommand>
-                       <name>org.eclipse.pde.ManifestBuilder</name>
-                       <arguments>
-                       </arguments>
-               </buildCommand>
-               <buildCommand>
-                       <name>org.eclipse.pde.SchemaBuilder</name>
-                       <arguments>
-                       </arguments>
-               </buildCommand>
-       </buildSpec>
-       <natures>
-               <nature>org.eclipse.pde.PluginNature</nature>
-               <nature>org.eclipse.jdt.core.javanature</nature>
-       </natures>
-</projectDescription>
diff --git a/usr/jbin/META-INF/MANIFEST.MF b/usr/jbin/META-INF/MANIFEST.MF
deleted file mode 100644 (file)
index 8b35d9a..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-Manifest-Version: 1.0
-Bundle-ManifestVersion: 2
-Bundle-Name: Freed-jbin
-Bundle-SymbolicName: freed-jbin
-Bundle-Version: 1.0.0.qualifier
-Automatic-Module-Name: freed.jbin
-Bundle-RequiredExecutionEnvironment: JavaSE-17
diff --git a/usr/jbin/Makefile b/usr/jbin/Makefile
deleted file mode 100644 (file)
index 94f73a1..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-# GNU coding standards
-prefix ?= /usr/local
-exec_prefix ?= $(prefix)
-sbindir ?= $(exec_prefix)/sbin
-sysconfdir = $(prefix)/etc
-srcdir ?= src
-
-EXECUTABLES=$(notdir $(patsubst %.java,%,$(wildcard $(srcdir)/*.java)))
-#EXECUTABLES=$(FILE:src/%.java=%)
-
-all: $(EXECUTABLES)
-
-%: $(srcdir)/%.java
-       cp $< $@
-       sed -i '1!b;s|//#!|#!|' $@
-       chmod a+x $@
-
-clean:
-       $(RM) $(EXECUTABLES)
-
-install:
-       cp -v --preserve=mode  freed-init $(DESTDIR)$(sbindir)
-       cp -v ../../etc/freed/init/* $(DESTDIR)$(sysconfdir)/freed/init
diff --git a/usr/jbin/build.properties b/usr/jbin/build.properties
deleted file mode 100644 (file)
index 5d082ea..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-source.. = src/
-output.. = bin/
-bin.includes = META-INF/,\
-               .
-additional.bundles = org.argeo.init
diff --git a/usr/jbin/src/freed-init.java b/usr/jbin/src/freed-init.java
deleted file mode 100644 (file)
index f9e9cb8..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-//#! /usr/bin/java --source 17 @/etc/freed/init/jvm.args
-
-import java.lang.management.ManagementFactory;
-import java.util.TreeMap;
-
-import org.argeo.init.Service;
-
-import jdk.jshell.tool.JavaShellToolBuilder;
-import sun.misc.Signal;
-
-class FreedInit {
-       public static void main(String... args) {
-               final long pid = ProcessHandle.current().pid();
-               System.out.println("FREEd Init daemon starting with pid " + pid + "...");
-//             System.out.println(System.getProperty("user.dir"));
-//             System.out.println(System.getProperty("user.name"));
-//             System.out.println(System.getProperty("user.home"));
-               
-               // System.setProperty("user.dir", "/tmp");
-               for (Object key : new TreeMap<>(System.getProperties()).keySet()) {
-                       System.out.println(key + "=" + System.getProperty(key.toString()));
-               }
-
-               System.out.flush();
-
-               Signal.handle(new Signal("TERM"), (signal) -> {
-                       System.out.println("SIGTERM caught");
-                       System.exit(0);
-               });
-               Signal.handle(new Signal("INT"), (signal) -> {
-                       System.out.println("SIGINT caught");
-                       System.exit(0);
-               });
-               Signal.handle(new Signal("HUP"), (signal) -> {
-                       System.out.println("SIGHUP caught");
-                       System.exit(0);
-               });
-
-               if (args.length > 0 && ("1".equals(args[0]) //
-                               || "single".equals(args[0]) //
-                               || "emergency".equals(args[0]))) {
-                       // TODO check if we can remove dependency to management
-                       String classpath = ManagementFactory.getRuntimeMXBean().getClassPath();
-                       String feedbackMode = "concise";
-                       // TODO --startup script
-                       JavaShellToolBuilder builder = JavaShellToolBuilder.builder();
-                       try {
-                               builder.start("--execution", "direct", "--class-path", classpath, "--feedback", feedbackMode);
-                       } catch (Exception e) {
-                               e.printStackTrace();
-                               System.err.flush();
-                               System.exit(1);
-                               return;
-                       }
-
-               } else {
-                       Service.main(args);
-               }
-       }
-}
index a4ccef7f9fbf8e3af0e8eb0344bbcc0d2e91f86a..f3654cd1798798a09856868701916500e083e6d4 100644 (file)
@@ -16,13 +16,14 @@ CacheDirectory=argeo.d/%I
 WorkingDirectory=/var/lib/argeo.d/%I
 
 ExecStart=java \
+-Dfile.encoding=UTF-8 \
 -Dosgi.configuration.cascaded=true \
 -Dosgi.sharedConfiguration.area=/etc/argeo.d/%I/ \
 -Dosgi.sharedConfiguration.area.readOnly=true \
 -Dosgi.configuration.area=${STATE_DIRECTORY}/state/ \
 -Dosgi.instance.area=${STATE_DIRECTORY}/data/ \
 -Dargeo.node.repo.indexesBase=${CACHE_DIRECTORY}/indexes \
--Dorg.osgi.framework.system.packages.extra=sun.security.internal.spec,sun.security.provider,com.sun.net.httpserver,com.sun.jndi.ldap,com.sun.jndi.ldap.sasl,com.sun.jndi.dns,com.sun.security.jgss,com.sun.nio.file,com.sun.nio.sctp \
+-Dorg.osgi.framework.system.packages.extra=sun.security.util,sun.security.internal.spec,sun.security.provider,com.sun.net.httpserver,com.sun.jndi.ldap,com.sun.jndi.ldap.sasl,com.sun.jndi.dns,com.sun.security.jgss,com.sun.nio.file,com.sun.nio.sctp \
 -Declipse.ignoreApp=true \
 -Dosgi.noShutdown=true \
 -Dorg.eclipse.equinox.http.jetty.autostart=false \
index 374004bd358dbe4655f6d04ee3ced83c73f0fe07..4318528cfaeef1dde74ed81b14d827deb71192e6 100644 (file)
@@ -3,9 +3,6 @@ Description=Roaming IPSec to '%i'
 After=network-online.target
 Wants=network-online.target
 
-After=unbound.service
-Requires=unbound.service
-
 After=ipsec.service
 PartOf=ipsec.service
 Requires=ipsec.service
index ec73e42fe7f5f88c291c8fbf0273996d84948b05..6704c8fe0b74f6a7b0e368c9c9fd1a07353031f3 100644 (file)
@@ -10,13 +10,14 @@ CacheDirectory=argeo.d/%I
 #WorkingDirectory=
 
 ExecStart=java \
+-Dfile.encoding=UTF-8 \
 -Dosgi.configuration.cascaded=true \
 -Dosgi.sharedConfiguration.area=/etc/argeo.user.d/%I/ \
 -Dosgi.sharedConfiguration.area.readOnly=true \
 -Dosgi.configuration.area=${STATE_DIRECTORY}/state/ \
 -Dosgi.instance.area=${STATE_DIRECTORY}/data/ \
 -Dargeo.node.repo.indexesBase=${CACHE_DIRECTORY}/indexes \
--Dorg.osgi.framework.system.packages.extra=sun.security.internal.spec,sun.security.provider,com.sun.net.httpserver,com.sun.jndi.ldap,com.sun.jndi.ldap.sasl,com.sun.jndi.dns,com.sun.security.jgss,com.sun.nio.file,com.sun.nio.sctp \
+-Dorg.osgi.framework.system.packages.extra=sun.security.util,sun.security.internal.spec,sun.security.provider,com.sun.net.httpserver,com.sun.jndi.ldap,com.sun.jndi.ldap.sasl,com.sun.jndi.dns,com.sun.security.jgss,com.sun.nio.file,com.sun.nio.sctp \
 -Declipse.ignoreApp=true \
 -Dosgi.noShutdown=true \
 -Dorg.eclipse.equinox.http.jetty.autostart=false \