Commit d6ade1de authored by jan.koester's avatar jan.koester
Browse files

test

parent 8b86b258
Loading
Loading
Loading
Loading
+0 −16
Changes for src/containers.cpp: 0 added lines, 16 removed lines.
Original line number Diff line number Diff line
@@ -227,22 +227,6 @@ std::vector<std::string> nameservers(const Settings &s) {
    return servers;
}

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");
}

std::string prepare(const Settings &s) {
    std::string dir = containerDir(s.name);
    for (const char *d : {"upper", "work", "root"})
+7 −1
Changes for src/runtime.cpp: 7 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -248,7 +248,12 @@ 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();
@@ -295,11 +300,12 @@ struct Pid1 {
        symlink("/proc/self/fd/2", "/dev/stderr");
        symlink("/proc/kcore", "/dev/core");

        bool fenriros = fenrirOs();
        bool fenriros = isFenrirOS(); // Korrigiert von fenrirOs() auf isFenrirOS()
        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);
+17 −0
Changes for src/runtime.h: 17 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -64,6 +64,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

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

namespace containerd {

@@ -74,6 +75,22 @@ 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);