Commit 8ebb5e45 authored by jan.koester's avatar jan.koester
Browse files

test

parent d6ade1de
Loading
Loading
Loading
Loading
+2 −15
Changes for src/containers.cpp: 2 added lines, 15 removed lines.
Original line number Diff line number Diff line
@@ -235,23 +235,10 @@ std::string prepare(const Settings &s) {
    // with DHCP the supervisor writes the leased address in later
    std::string ip = s.network == "bridge" && !s.address.empty() && !isDhcp(s) ? s.address.substr(0, s.address.find('/')) : "127.0.1.1";
    std::vector<std::string> servers = nameservers(s);
    
    bool fenrir = isFenrirOS();

    // Unter FenrirOS: host.yaml, hostname.yaml und resolv.yaml
    // Sonst: hosts, hostname und resolv.conf
    if (fenrir) {
        if (!writeFile(dir + "/host.yaml", hostYaml(host, ip)) ||
            !writeFile(dir + "/hostname.yaml", host + "\n") ||
    if (!writeFile(dir + "/hosts", hostsText(host, ip)) || !writeFile(dir + "/hostname", host + "\n") ||
        !writeFile(dir + "/resolv.conf", resolvConfText(servers)) || !writeFile(dir + "/host.yaml", hostYaml(host, ip)) ||
        !writeFile(dir + "/resolv.yaml", resolvYaml(servers)))
        return sysErr(dir, errno);
    } else {
        if (!writeFile(dir + "/hosts", hostsText(host, ip)) ||
            !writeFile(dir + "/hostname", host + "\n") ||
            !writeFile(dir + "/resolv.conf", resolvConfText(servers)))
            return sysErr(dir, errno);
    }

    return "";
}

+1 −7
Changes for src/runtime.cpp: 1 added line, 7 removed lines.
Original line number Diff line number Diff line
@@ -248,12 +248,7 @@ struct Pid1 {
            if (stat(host.c_str(), &st) != 0) fail(sysErr(tr("bind mount %1", "Bind-Mount %1", {host}), errno));
            binds.push_back({openTree(host, ro), where, !S_ISDIR(st.st_mode), ro});
        };

if(isFenrirOS())
            for (const char *f : {"hosts.yaml", "hostname.yaml", "resolv.yaml"}) source(l.dir + "/" + f, std::string("/etc/") + f, false);
        else
        for (const char *f : {"hosts", "hostname", "resolv.conf"}) source(l.dir + "/" + f, std::string("/etc/") + f, false);
        
        // systempp's: only mounted in a FenrirOS image, which is known
        // after pivoting (its os-release resolved inside the container)
        size_t yamlBinds = binds.size();
@@ -300,12 +295,11 @@ if(isFenrirOS())
        symlink("/proc/self/fd/2", "/dev/stderr");
        symlink("/proc/kcore", "/dev/core");

        bool fenriros = isFenrirOS(); // Korrigiert von fenrirOs() auf isFenrirOS()
        bool fenriros = fenrirOs();
        for (auto &b : yaml) {
            if (fenriros) attach(b.fd, b.where, b.file);
            close(b.fd);
        }

        for (auto &b : binds) {
            attach(b.fd, b.where, b.file);
            close(b.fd);
+0 −17
Changes for src/runtime.h: 0 added lines, 17 removed lines.
Original line number Diff line number Diff line
@@ -64,7 +64,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#include "images.h"
#include "settings.h"
#include "util.h"

namespace containerd {

@@ -75,22 +74,6 @@ struct Launch {
    int logFd = -1;                  // the log file, appending
};

inline bool isFenrirOS() {
    std::string text;
    if (readFile("/etc/os-release", text)) {
        for (auto &line : split(text, '\n')) {
            std::string l = trim(line);
            if (startsWith(l, "ID=")) {
                std::string val = trim(l.substr(3));
                if (val >= "2" && (val[0] == '"' || val[0] == '\''))
                    val = val.substr(1, val.size() - 2);
                if (val == "fenriros") return true;
            }
        }
    }
    return exists("/etc/resolv.yaml");
}

// starts the supervisor; *status gets the read end of a pipe on which it
// reports "running <pid>" or "failed <why>", later "exit <code>"
pid_t launch(const Launch &l, int *status, std::string &err);