Compare commits
10 Commits
0e97a910a6
...
7a182f1034
Author | SHA1 | Date |
---|---|---|
Yu Watanabe | 7a182f1034 | |
Lennart Poettering | 983ffdb0bf | |
Yu Watanabe | 6b50cb5ca9 | |
Yu Watanabe | b6cea5496a | |
Lennart Poettering | 67861acdf3 | |
Lennart Poettering | a2a64d3ac9 | |
Yu Watanabe | 25454a0c34 | |
Yu Watanabe | 735ea55f5c | |
Daan De Meyer | 2436ea761b | |
Daan De Meyer | bbd407ea2b |
|
@ -342,12 +342,11 @@ const char *special_glyph(SpecialGlyph code) {
|
||||||
[SPECIAL_GLYPH_TRIANGULAR_BULLET] = ">",
|
[SPECIAL_GLYPH_TRIANGULAR_BULLET] = ">",
|
||||||
[SPECIAL_GLYPH_BLACK_CIRCLE] = "*",
|
[SPECIAL_GLYPH_BLACK_CIRCLE] = "*",
|
||||||
[SPECIAL_GLYPH_BULLET] = "*",
|
[SPECIAL_GLYPH_BULLET] = "*",
|
||||||
[SPECIAL_GLYPH_ARROW] = "->",
|
|
||||||
[SPECIAL_GLYPH_MDASH] = "-",
|
|
||||||
[SPECIAL_GLYPH_ELLIPSIS] = "...",
|
|
||||||
[SPECIAL_GLYPH_MU] = "u",
|
[SPECIAL_GLYPH_MU] = "u",
|
||||||
[SPECIAL_GLYPH_CHECK_MARK] = "+",
|
[SPECIAL_GLYPH_CHECK_MARK] = "+",
|
||||||
[SPECIAL_GLYPH_CROSS_MARK] = "-",
|
[SPECIAL_GLYPH_CROSS_MARK] = "-",
|
||||||
|
[SPECIAL_GLYPH_ARROW] = "->",
|
||||||
|
[SPECIAL_GLYPH_ELLIPSIS] = "...",
|
||||||
[SPECIAL_GLYPH_ECSTATIC_SMILEY] = ":-]",
|
[SPECIAL_GLYPH_ECSTATIC_SMILEY] = ":-]",
|
||||||
[SPECIAL_GLYPH_HAPPY_SMILEY] = ":-}",
|
[SPECIAL_GLYPH_HAPPY_SMILEY] = ":-}",
|
||||||
[SPECIAL_GLYPH_SLIGHTLY_HAPPY_SMILEY] = ":-)",
|
[SPECIAL_GLYPH_SLIGHTLY_HAPPY_SMILEY] = ":-)",
|
||||||
|
@ -359,26 +358,34 @@ const char *special_glyph(SpecialGlyph code) {
|
||||||
|
|
||||||
/* UTF-8 */
|
/* UTF-8 */
|
||||||
[true] = {
|
[true] = {
|
||||||
|
/* The following are multiple glyphs in both ASCII and in UNICODE */
|
||||||
[SPECIAL_GLYPH_TREE_VERTICAL] = "\342\224\202 ", /* │ */
|
[SPECIAL_GLYPH_TREE_VERTICAL] = "\342\224\202 ", /* │ */
|
||||||
[SPECIAL_GLYPH_TREE_BRANCH] = "\342\224\234\342\224\200", /* ├─ */
|
[SPECIAL_GLYPH_TREE_BRANCH] = "\342\224\234\342\224\200", /* ├─ */
|
||||||
[SPECIAL_GLYPH_TREE_RIGHT] = "\342\224\224\342\224\200", /* └─ */
|
[SPECIAL_GLYPH_TREE_RIGHT] = "\342\224\224\342\224\200", /* └─ */
|
||||||
[SPECIAL_GLYPH_TREE_SPACE] = " ", /* */
|
[SPECIAL_GLYPH_TREE_SPACE] = " ", /* */
|
||||||
|
|
||||||
|
/* Single glyphs in both cases */
|
||||||
[SPECIAL_GLYPH_TRIANGULAR_BULLET] = "\342\200\243", /* ‣ */
|
[SPECIAL_GLYPH_TRIANGULAR_BULLET] = "\342\200\243", /* ‣ */
|
||||||
[SPECIAL_GLYPH_BLACK_CIRCLE] = "\342\227\217", /* ● */
|
[SPECIAL_GLYPH_BLACK_CIRCLE] = "\342\227\217", /* ● */
|
||||||
[SPECIAL_GLYPH_BULLET] = "\342\200\242", /* • */
|
[SPECIAL_GLYPH_BULLET] = "\342\200\242", /* • */
|
||||||
[SPECIAL_GLYPH_ARROW] = "\342\206\222", /* → */
|
[SPECIAL_GLYPH_MU] = "\316\274", /* μ (actually called: GREEK SMALL LETTER MU) */
|
||||||
[SPECIAL_GLYPH_MDASH] = "\342\200\223", /* – */
|
|
||||||
[SPECIAL_GLYPH_ELLIPSIS] = "\342\200\246", /* … */
|
|
||||||
[SPECIAL_GLYPH_MU] = "\316\274", /* μ */
|
|
||||||
[SPECIAL_GLYPH_CHECK_MARK] = "\342\234\223", /* ✓ */
|
[SPECIAL_GLYPH_CHECK_MARK] = "\342\234\223", /* ✓ */
|
||||||
[SPECIAL_GLYPH_CROSS_MARK] = "\342\234\227", /* ✗ */
|
[SPECIAL_GLYPH_CROSS_MARK] = "\342\234\227", /* ✗ (actually called: BALLOT X) */
|
||||||
[SPECIAL_GLYPH_ECSTATIC_SMILEY] = "\360\237\230\207", /* 😇 */
|
|
||||||
[SPECIAL_GLYPH_HAPPY_SMILEY] = "\360\237\230\200", /* 😀 */
|
/* Single glyph in Unicode, two in ASCII */
|
||||||
[SPECIAL_GLYPH_SLIGHTLY_HAPPY_SMILEY] = "\360\237\231\202", /* 🙂 */
|
[SPECIAL_GLYPH_ARROW] = "\342\206\222", /* → (actually called: RIGHTWARDS ARROW) */
|
||||||
[SPECIAL_GLYPH_NEUTRAL_SMILEY] = "\360\237\230\220", /* 😐 */
|
|
||||||
[SPECIAL_GLYPH_SLIGHTLY_UNHAPPY_SMILEY] = "\360\237\231\201", /* 🙁 */
|
/* Single glyph in Unicode, three in ASCII */
|
||||||
[SPECIAL_GLYPH_UNHAPPY_SMILEY] = "\360\237\230\250", /* 😨 */
|
[SPECIAL_GLYPH_ELLIPSIS] = "\342\200\246", /* … (actually called: HORIZONTAL ELLIPSIS) */
|
||||||
[SPECIAL_GLYPH_DEPRESSED_SMILEY] = "\360\237\244\242", /* 🤢 */
|
|
||||||
|
/* These smileys are a single glyph in Unicode, and three in ASCII */
|
||||||
|
[SPECIAL_GLYPH_ECSTATIC_SMILEY] = "\360\237\230\207", /* 😇 (actually called: SMILING FACE WITH HALO) */
|
||||||
|
[SPECIAL_GLYPH_HAPPY_SMILEY] = "\360\237\230\200", /* 😀 (actually called: GRINNING FACE) */
|
||||||
|
[SPECIAL_GLYPH_SLIGHTLY_HAPPY_SMILEY] = "\360\237\231\202", /* 🙂 (actually called: SLIGHTLY SMILING FACE) */
|
||||||
|
[SPECIAL_GLYPH_NEUTRAL_SMILEY] = "\360\237\230\220", /* 😐 (actually called: NEUTRAL FACE) */
|
||||||
|
[SPECIAL_GLYPH_SLIGHTLY_UNHAPPY_SMILEY] = "\360\237\231\201", /* 🙁 (actually called: SLIGHTLY FROWNING FACE) */
|
||||||
|
[SPECIAL_GLYPH_UNHAPPY_SMILEY] = "\360\237\230\250", /* 😨 (actually called: FEARFUL FACE) */
|
||||||
|
[SPECIAL_GLYPH_DEPRESSED_SMILEY] = "\360\237\244\242", /* 🤢 (actually called: NAUSEATED FACE) */
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -46,12 +46,11 @@ typedef enum {
|
||||||
SPECIAL_GLYPH_TRIANGULAR_BULLET,
|
SPECIAL_GLYPH_TRIANGULAR_BULLET,
|
||||||
SPECIAL_GLYPH_BLACK_CIRCLE,
|
SPECIAL_GLYPH_BLACK_CIRCLE,
|
||||||
SPECIAL_GLYPH_BULLET,
|
SPECIAL_GLYPH_BULLET,
|
||||||
SPECIAL_GLYPH_ARROW,
|
|
||||||
SPECIAL_GLYPH_MDASH,
|
|
||||||
SPECIAL_GLYPH_ELLIPSIS,
|
|
||||||
SPECIAL_GLYPH_MU,
|
SPECIAL_GLYPH_MU,
|
||||||
SPECIAL_GLYPH_CHECK_MARK,
|
SPECIAL_GLYPH_CHECK_MARK,
|
||||||
SPECIAL_GLYPH_CROSS_MARK,
|
SPECIAL_GLYPH_CROSS_MARK,
|
||||||
|
SPECIAL_GLYPH_ARROW,
|
||||||
|
SPECIAL_GLYPH_ELLIPSIS,
|
||||||
_SPECIAL_GLYPH_FIRST_SMILEY,
|
_SPECIAL_GLYPH_FIRST_SMILEY,
|
||||||
SPECIAL_GLYPH_ECSTATIC_SMILEY = _SPECIAL_GLYPH_FIRST_SMILEY,
|
SPECIAL_GLYPH_ECSTATIC_SMILEY = _SPECIAL_GLYPH_FIRST_SMILEY,
|
||||||
SPECIAL_GLYPH_HAPPY_SMILEY,
|
SPECIAL_GLYPH_HAPPY_SMILEY,
|
||||||
|
|
|
@ -20,29 +20,28 @@
|
||||||
#include "string-util.h"
|
#include "string-util.h"
|
||||||
#include "virt.h"
|
#include "virt.h"
|
||||||
|
|
||||||
|
static const char *const vm_table[_VIRTUALIZATION_MAX] = {
|
||||||
|
[VIRTUALIZATION_XEN] = "XenVMMXenVMM",
|
||||||
|
[VIRTUALIZATION_KVM] = "KVMKVMKVM",
|
||||||
|
[VIRTUALIZATION_QEMU] = "TCGTCGTCGTCG",
|
||||||
|
/* http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1009458 */
|
||||||
|
[VIRTUALIZATION_VMWARE] = "VMwareVMware",
|
||||||
|
/* https://docs.microsoft.com/en-us/virtualization/hyper-v-on-windows/reference/tlfs */
|
||||||
|
[VIRTUALIZATION_MICROSOFT] = "Microsoft Hv",
|
||||||
|
/* https://wiki.freebsd.org/bhyve */
|
||||||
|
[VIRTUALIZATION_BHYVE] = "bhyve bhyve ",
|
||||||
|
[VIRTUALIZATION_QNX] = "QNXQVMBSQG",
|
||||||
|
/* https://projectacrn.org */
|
||||||
|
[VIRTUALIZATION_ACRN] = "ACRNACRNACRN",
|
||||||
|
};
|
||||||
|
|
||||||
|
DEFINE_PRIVATE_STRING_TABLE_LOOKUP_FROM_STRING(vm, int);
|
||||||
|
|
||||||
static int detect_vm_cpuid(void) {
|
static int detect_vm_cpuid(void) {
|
||||||
|
|
||||||
/* CPUID is an x86 specific interface. */
|
/* CPUID is an x86 specific interface. */
|
||||||
#if defined(__i386__) || defined(__x86_64__)
|
#if defined(__i386__) || defined(__x86_64__)
|
||||||
|
|
||||||
static const struct {
|
|
||||||
const char *cpuid;
|
|
||||||
int id;
|
|
||||||
} cpuid_vendor_table[] = {
|
|
||||||
{ "XenVMMXenVMM", VIRTUALIZATION_XEN },
|
|
||||||
{ "KVMKVMKVM", VIRTUALIZATION_KVM },
|
|
||||||
{ "TCGTCGTCGTCG", VIRTUALIZATION_QEMU },
|
|
||||||
/* http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1009458 */
|
|
||||||
{ "VMwareVMware", VIRTUALIZATION_VMWARE },
|
|
||||||
/* https://docs.microsoft.com/en-us/virtualization/hyper-v-on-windows/reference/tlfs */
|
|
||||||
{ "Microsoft Hv", VIRTUALIZATION_MICROSOFT },
|
|
||||||
/* https://wiki.freebsd.org/bhyve */
|
|
||||||
{ "bhyve bhyve ", VIRTUALIZATION_BHYVE },
|
|
||||||
{ "QNXQVMBSQG", VIRTUALIZATION_QNX },
|
|
||||||
/* https://projectacrn.org */
|
|
||||||
{ "ACRNACRNACRN", VIRTUALIZATION_ACRN },
|
|
||||||
};
|
|
||||||
|
|
||||||
uint32_t eax, ebx, ecx, edx;
|
uint32_t eax, ebx, ecx, edx;
|
||||||
bool hypervisor;
|
bool hypervisor;
|
||||||
|
|
||||||
|
@ -59,7 +58,7 @@ static int detect_vm_cpuid(void) {
|
||||||
uint32_t sig32[3];
|
uint32_t sig32[3];
|
||||||
char text[13];
|
char text[13];
|
||||||
} sig = {};
|
} sig = {};
|
||||||
unsigned j;
|
int v;
|
||||||
|
|
||||||
/* There is a hypervisor, see what it is */
|
/* There is a hypervisor, see what it is */
|
||||||
__cpuid(0x40000000U, eax, ebx, ecx, edx);
|
__cpuid(0x40000000U, eax, ebx, ecx, edx);
|
||||||
|
@ -70,11 +69,11 @@ static int detect_vm_cpuid(void) {
|
||||||
|
|
||||||
log_debug("Virtualization found, CPUID=%s", sig.text);
|
log_debug("Virtualization found, CPUID=%s", sig.text);
|
||||||
|
|
||||||
for (j = 0; j < ELEMENTSOF(cpuid_vendor_table); j ++)
|
v = vm_from_string(sig.text);
|
||||||
if (streq(sig.text, cpuid_vendor_table[j].cpuid))
|
if (v < 0)
|
||||||
return cpuid_vendor_table[j].id;
|
|
||||||
|
|
||||||
return VIRTUALIZATION_VM_OTHER;
|
return VIRTUALIZATION_VM_OTHER;
|
||||||
|
|
||||||
|
return v;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
log_debug("No virtualization found in CPUID");
|
log_debug("No virtualization found in CPUID");
|
||||||
|
@ -432,25 +431,23 @@ finish:
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
int detect_container(void) {
|
static const char *const container_table[_VIRTUALIZATION_MAX] = {
|
||||||
static const struct {
|
[VIRTUALIZATION_LXC] = "lxc",
|
||||||
const char *value;
|
[VIRTUALIZATION_LXC_LIBVIRT] = "lxc-libvirt",
|
||||||
int id;
|
[VIRTUALIZATION_SYSTEMD_NSPAWN] = "systemd-nspawn",
|
||||||
} value_table[] = {
|
[VIRTUALIZATION_DOCKER] = "docker",
|
||||||
{ "lxc", VIRTUALIZATION_LXC },
|
[VIRTUALIZATION_PODMAN] = "podman",
|
||||||
{ "lxc-libvirt", VIRTUALIZATION_LXC_LIBVIRT },
|
[VIRTUALIZATION_RKT] = "rkt",
|
||||||
{ "systemd-nspawn", VIRTUALIZATION_SYSTEMD_NSPAWN },
|
[VIRTUALIZATION_WSL] = "wsl",
|
||||||
{ "docker", VIRTUALIZATION_DOCKER },
|
|
||||||
{ "podman", VIRTUALIZATION_PODMAN },
|
|
||||||
{ "rkt", VIRTUALIZATION_RKT },
|
|
||||||
{ "wsl", VIRTUALIZATION_WSL },
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
DEFINE_PRIVATE_STRING_TABLE_LOOKUP_FROM_STRING(container, int);
|
||||||
|
|
||||||
|
int detect_container(void) {
|
||||||
static thread_local int cached_found = _VIRTUALIZATION_INVALID;
|
static thread_local int cached_found = _VIRTUALIZATION_INVALID;
|
||||||
_cleanup_free_ char *m = NULL;
|
_cleanup_free_ char *m = NULL;
|
||||||
_cleanup_free_ char *o = NULL;
|
_cleanup_free_ char *o = NULL;
|
||||||
const char *e = NULL;
|
const char *e = NULL;
|
||||||
unsigned j;
|
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
if (cached_found >= 0)
|
if (cached_found >= 0)
|
||||||
|
@ -532,12 +529,8 @@ int detect_container(void) {
|
||||||
goto finish;
|
goto finish;
|
||||||
|
|
||||||
translate_name:
|
translate_name:
|
||||||
for (j = 0; j < ELEMENTSOF(value_table); j++)
|
r = container_from_string(e);
|
||||||
if (streq(e, value_table[j].value)) {
|
if (r < 0)
|
||||||
r = value_table[j].id;
|
|
||||||
goto finish;
|
|
||||||
}
|
|
||||||
|
|
||||||
r = VIRTUALIZATION_CONTAINER_OTHER;
|
r = VIRTUALIZATION_CONTAINER_OTHER;
|
||||||
|
|
||||||
finish:
|
finish:
|
||||||
|
|
|
@ -124,6 +124,49 @@ int rtnl_set_link_alternative_names(sd_netlink **rtnl, int ifindex, char * const
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int rtnl_set_link_alternative_names_by_ifname(sd_netlink **rtnl, const char *ifname, char * const *alternative_names) {
|
||||||
|
_cleanup_(sd_netlink_message_unrefp) sd_netlink_message *message = NULL;
|
||||||
|
int r;
|
||||||
|
|
||||||
|
assert(rtnl);
|
||||||
|
assert(ifname);
|
||||||
|
|
||||||
|
if (strv_isempty(alternative_names))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (!*rtnl) {
|
||||||
|
r = sd_netlink_open(rtnl);
|
||||||
|
if (r < 0)
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
r = sd_rtnl_message_new_link(*rtnl, &message, RTM_NEWLINKPROP, 0);
|
||||||
|
if (r < 0)
|
||||||
|
return r;
|
||||||
|
|
||||||
|
r = sd_netlink_message_append_string(message, IFLA_IFNAME, ifname);
|
||||||
|
if (r < 0)
|
||||||
|
return r;
|
||||||
|
|
||||||
|
r = sd_netlink_message_open_container(message, IFLA_PROP_LIST);
|
||||||
|
if (r < 0)
|
||||||
|
return r;
|
||||||
|
|
||||||
|
r = sd_netlink_message_append_strv(message, IFLA_ALT_IFNAME, alternative_names);
|
||||||
|
if (r < 0)
|
||||||
|
return r;
|
||||||
|
|
||||||
|
r = sd_netlink_message_close_container(message);
|
||||||
|
if (r < 0)
|
||||||
|
return r;
|
||||||
|
|
||||||
|
r = sd_netlink_call(*rtnl, message, 0, NULL);
|
||||||
|
if (r < 0)
|
||||||
|
return r;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int rtnl_resolve_link_alternative_name(sd_netlink **rtnl, const char *name, int *ret) {
|
int rtnl_resolve_link_alternative_name(sd_netlink **rtnl, const char *name, int *ret) {
|
||||||
_cleanup_(sd_netlink_message_unrefp) sd_netlink_message *message = NULL, *reply = NULL;
|
_cleanup_(sd_netlink_message_unrefp) sd_netlink_message *message = NULL, *reply = NULL;
|
||||||
int r;
|
int r;
|
||||||
|
|
|
@ -50,6 +50,7 @@ static inline bool rtnl_message_type_is_qdisc(uint16_t type) {
|
||||||
int rtnl_set_link_name(sd_netlink **rtnl, int ifindex, const char *name);
|
int rtnl_set_link_name(sd_netlink **rtnl, int ifindex, const char *name);
|
||||||
int rtnl_set_link_properties(sd_netlink **rtnl, int ifindex, const char *alias, const struct ether_addr *mac, uint32_t mtu);
|
int rtnl_set_link_properties(sd_netlink **rtnl, int ifindex, const char *alias, const struct ether_addr *mac, uint32_t mtu);
|
||||||
int rtnl_set_link_alternative_names(sd_netlink **rtnl, int ifindex, char * const *alternative_names);
|
int rtnl_set_link_alternative_names(sd_netlink **rtnl, int ifindex, char * const *alternative_names);
|
||||||
|
int rtnl_set_link_alternative_names_by_ifname(sd_netlink **rtnl, const char *ifname, char * const *alternative_names);
|
||||||
int rtnl_resolve_link_alternative_name(sd_netlink **rtnl, const char *name, int *ret);
|
int rtnl_resolve_link_alternative_name(sd_netlink **rtnl, const char *name, int *ret);
|
||||||
|
|
||||||
int rtnl_log_parse_error(int r);
|
int rtnl_log_parse_error(int r);
|
||||||
|
|
|
@ -989,6 +989,19 @@ int mount_custom(
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool has_custom_root_mount(const CustomMount *mounts, size_t n) {
|
||||||
|
size_t i;
|
||||||
|
|
||||||
|
for (i = 0; i < n; i++) {
|
||||||
|
const CustomMount *m = mounts + i;
|
||||||
|
|
||||||
|
if (path_equal(m->destination, "/"))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
static int setup_volatile_state(const char *directory, uid_t uid_shift, const char *selinux_apifs_context) {
|
static int setup_volatile_state(const char *directory, uid_t uid_shift, const char *selinux_apifs_context) {
|
||||||
|
|
||||||
_cleanup_free_ char *buf = NULL;
|
_cleanup_free_ char *buf = NULL;
|
||||||
|
|
|
@ -55,6 +55,7 @@ int mount_all(const char *dest, MountSettingsMask mount_settings, uid_t uid_shif
|
||||||
int mount_sysfs(const char *dest, MountSettingsMask mount_settings);
|
int mount_sysfs(const char *dest, MountSettingsMask mount_settings);
|
||||||
|
|
||||||
int mount_custom(const char *dest, CustomMount *mounts, size_t n, uid_t uid_shift, const char *selinux_apifs_context, MountSettingsMask mount_settings);
|
int mount_custom(const char *dest, CustomMount *mounts, size_t n, uid_t uid_shift, const char *selinux_apifs_context, MountSettingsMask mount_settings);
|
||||||
|
bool has_custom_root_mount(const CustomMount *mounts, size_t n);
|
||||||
|
|
||||||
int setup_volatile_mode(const char *directory, VolatileMode mode, uid_t uid_shift, const char *selinux_apifs_context);
|
int setup_volatile_mode(const char *directory, VolatileMode mode, uid_t uid_shift, const char *selinux_apifs_context);
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||||
|
|
||||||
|
#include <net/if.h>
|
||||||
|
#include <linux/if.h>
|
||||||
#include <linux/veth.h>
|
#include <linux/veth.h>
|
||||||
#include <sys/file.h>
|
#include <sys/file.h>
|
||||||
|
|
||||||
|
@ -99,10 +101,34 @@ static int generate_mac(
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int set_alternative_ifname(sd_netlink *rtnl, const char *ifname, const char *altifname) {
|
||||||
|
int r;
|
||||||
|
|
||||||
|
assert(rtnl);
|
||||||
|
assert(ifname);
|
||||||
|
|
||||||
|
if (!altifname)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (strlen(altifname) >= ALTIFNAMSIZ)
|
||||||
|
return log_warning_errno(SYNTHETIC_ERRNO(ERANGE),
|
||||||
|
"Alternative interface name '%s' for '%s' is too long, ignoring",
|
||||||
|
altifname, ifname);
|
||||||
|
|
||||||
|
r = rtnl_set_link_alternative_names_by_ifname(&rtnl, ifname, STRV_MAKE(altifname));
|
||||||
|
if (r < 0)
|
||||||
|
return log_warning_errno(r,
|
||||||
|
"Failed to set alternative interface name '%s' to '%s', ignoring: %m",
|
||||||
|
altifname, ifname);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int add_veth(
|
static int add_veth(
|
||||||
sd_netlink *rtnl,
|
sd_netlink *rtnl,
|
||||||
pid_t pid,
|
pid_t pid,
|
||||||
const char *ifname_host,
|
const char *ifname_host,
|
||||||
|
const char *altifname_host,
|
||||||
const struct ether_addr *mac_host,
|
const struct ether_addr *mac_host,
|
||||||
const char *ifname_container,
|
const char *ifname_container,
|
||||||
const struct ether_addr *mac_container) {
|
const struct ether_addr *mac_container) {
|
||||||
|
@ -168,6 +194,8 @@ static int add_veth(
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return log_error_errno(r, "Failed to add new veth interfaces (%s:%s): %m", ifname_host, ifname_container);
|
return log_error_errno(r, "Failed to add new veth interfaces (%s:%s): %m", ifname_host, ifname_container);
|
||||||
|
|
||||||
|
(void) set_alternative_ifname(rtnl, ifname_host, altifname_host);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -181,13 +209,13 @@ static char urlsafe_base64char(int x) {
|
||||||
return table[x & 63];
|
return table[x & 63];
|
||||||
}
|
}
|
||||||
|
|
||||||
static void shorten_ifname(char *ifname) {
|
static int shorten_ifname(char *ifname) {
|
||||||
char new_ifname[IFNAMSIZ];
|
char new_ifname[IFNAMSIZ];
|
||||||
|
|
||||||
assert(ifname);
|
assert(ifname);
|
||||||
|
|
||||||
if (strlen(ifname) < IFNAMSIZ) /* Name is short enough */
|
if (strlen(ifname) < IFNAMSIZ) /* Name is short enough */
|
||||||
return;
|
return 0;
|
||||||
|
|
||||||
if (naming_scheme_has(NAMING_NSPAWN_LONG_HASH)) {
|
if (naming_scheme_has(NAMING_NSPAWN_LONG_HASH)) {
|
||||||
uint64_t h;
|
uint64_t h;
|
||||||
|
@ -211,6 +239,7 @@ static void shorten_ifname(char *ifname) {
|
||||||
log_warning("Network interface name '%s' has been changed to '%s' to fit length constraints.", ifname, new_ifname);
|
log_warning("Network interface name '%s' has been changed to '%s' to fit length constraints.", ifname, new_ifname);
|
||||||
|
|
||||||
strcpy(ifname, new_ifname);
|
strcpy(ifname, new_ifname);
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int setup_veth(const char *machine_name,
|
int setup_veth(const char *machine_name,
|
||||||
|
@ -221,7 +250,7 @@ int setup_veth(const char *machine_name,
|
||||||
_cleanup_(sd_netlink_unrefp) sd_netlink *rtnl = NULL;
|
_cleanup_(sd_netlink_unrefp) sd_netlink *rtnl = NULL;
|
||||||
struct ether_addr mac_host, mac_container;
|
struct ether_addr mac_host, mac_container;
|
||||||
unsigned u;
|
unsigned u;
|
||||||
char *n;
|
char *n, *a = NULL;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
assert(machine_name);
|
assert(machine_name);
|
||||||
|
@ -231,7 +260,9 @@ int setup_veth(const char *machine_name,
|
||||||
/* Use two different interface name prefixes depending whether
|
/* Use two different interface name prefixes depending whether
|
||||||
* we are in bridge mode or not. */
|
* we are in bridge mode or not. */
|
||||||
n = strjoina(bridge ? "vb-" : "ve-", machine_name);
|
n = strjoina(bridge ? "vb-" : "ve-", machine_name);
|
||||||
shorten_ifname(n);
|
r = shorten_ifname(n);
|
||||||
|
if (r > 0)
|
||||||
|
a = strjoina(bridge ? "vb-" : "ve-", machine_name);
|
||||||
|
|
||||||
r = generate_mac(machine_name, &mac_container, CONTAINER_HASH_KEY, 0);
|
r = generate_mac(machine_name, &mac_container, CONTAINER_HASH_KEY, 0);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
|
@ -245,7 +276,7 @@ int setup_veth(const char *machine_name,
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return log_error_errno(r, "Failed to connect to netlink: %m");
|
return log_error_errno(r, "Failed to connect to netlink: %m");
|
||||||
|
|
||||||
r = add_veth(rtnl, pid, n, &mac_host, "host0", &mac_container);
|
r = add_veth(rtnl, pid, n, a, &mac_host, "host0", &mac_container);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
|
@ -288,7 +319,7 @@ int setup_veth_extra(
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return log_error_errno(r, "Failed to generate predictable MAC address for container side of extra veth link: %m");
|
return log_error_errno(r, "Failed to generate predictable MAC address for container side of extra veth link: %m");
|
||||||
|
|
||||||
r = add_veth(rtnl, pid, *a, &mac_host, *b, &mac_container);
|
r = add_veth(rtnl, pid, *a, NULL, &mac_host, *b, &mac_container);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
|
@ -536,7 +567,7 @@ int setup_macvlan(const char *machine_name, pid_t pid, char **ifaces) {
|
||||||
|
|
||||||
STRV_FOREACH(i, ifaces) {
|
STRV_FOREACH(i, ifaces) {
|
||||||
_cleanup_(sd_netlink_message_unrefp) sd_netlink_message *m = NULL;
|
_cleanup_(sd_netlink_message_unrefp) sd_netlink_message *m = NULL;
|
||||||
_cleanup_free_ char *n = NULL;
|
_cleanup_free_ char *n = NULL, *a = NULL;
|
||||||
struct ether_addr mac;
|
struct ether_addr mac;
|
||||||
int ifi;
|
int ifi;
|
||||||
|
|
||||||
|
@ -560,7 +591,12 @@ int setup_macvlan(const char *machine_name, pid_t pid, char **ifaces) {
|
||||||
if (!n)
|
if (!n)
|
||||||
return log_oom();
|
return log_oom();
|
||||||
|
|
||||||
shorten_ifname(n);
|
r = shorten_ifname(n);
|
||||||
|
if (r > 0) {
|
||||||
|
a = strjoin("mv-", *i);
|
||||||
|
if (!a)
|
||||||
|
return log_oom();
|
||||||
|
}
|
||||||
|
|
||||||
r = sd_netlink_message_append_string(m, IFLA_IFNAME, n);
|
r = sd_netlink_message_append_string(m, IFLA_IFNAME, n);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
|
@ -597,6 +633,8 @@ int setup_macvlan(const char *machine_name, pid_t pid, char **ifaces) {
|
||||||
r = sd_netlink_call(rtnl, m, 0, NULL);
|
r = sd_netlink_call(rtnl, m, 0, NULL);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return log_error_errno(r, "Failed to add new macvlan interfaces: %m");
|
return log_error_errno(r, "Failed to add new macvlan interfaces: %m");
|
||||||
|
|
||||||
|
(void) set_alternative_ifname(rtnl, n, a);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -616,7 +654,7 @@ int setup_ipvlan(const char *machine_name, pid_t pid, char **ifaces) {
|
||||||
|
|
||||||
STRV_FOREACH(i, ifaces) {
|
STRV_FOREACH(i, ifaces) {
|
||||||
_cleanup_(sd_netlink_message_unrefp) sd_netlink_message *m = NULL;
|
_cleanup_(sd_netlink_message_unrefp) sd_netlink_message *m = NULL;
|
||||||
_cleanup_free_ char *n = NULL;
|
_cleanup_free_ char *n = NULL, *a = NULL;
|
||||||
int ifi;
|
int ifi;
|
||||||
|
|
||||||
ifi = parse_interface(*i);
|
ifi = parse_interface(*i);
|
||||||
|
@ -635,7 +673,12 @@ int setup_ipvlan(const char *machine_name, pid_t pid, char **ifaces) {
|
||||||
if (!n)
|
if (!n)
|
||||||
return log_oom();
|
return log_oom();
|
||||||
|
|
||||||
shorten_ifname(n);
|
r = shorten_ifname(n);
|
||||||
|
if (r > 0) {
|
||||||
|
a = strjoin("iv-", *i);
|
||||||
|
if (!a)
|
||||||
|
return log_oom();
|
||||||
|
}
|
||||||
|
|
||||||
r = sd_netlink_message_append_string(m, IFLA_IFNAME, n);
|
r = sd_netlink_message_append_string(m, IFLA_IFNAME, n);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
|
@ -668,6 +711,8 @@ int setup_ipvlan(const char *machine_name, pid_t pid, char **ifaces) {
|
||||||
r = sd_netlink_call(rtnl, m, 0, NULL);
|
r = sd_netlink_call(rtnl, m, 0, NULL);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return log_error_errno(r, "Failed to add new ipvlan interfaces: %m");
|
return log_error_errno(r, "Failed to add new ipvlan interfaces: %m");
|
||||||
|
|
||||||
|
(void) set_alternative_ifname(rtnl, n, a);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -1541,6 +1541,9 @@ static int verify_arguments(void) {
|
||||||
if (arg_volatile_mode != VOLATILE_NO) /* Make sure all file systems contained in the image are mounted read-only if we are in volatile mode */
|
if (arg_volatile_mode != VOLATILE_NO) /* Make sure all file systems contained in the image are mounted read-only if we are in volatile mode */
|
||||||
arg_read_only = true;
|
arg_read_only = true;
|
||||||
|
|
||||||
|
if (has_custom_root_mount(arg_custom_mounts, arg_n_custom_mounts))
|
||||||
|
arg_read_only = true;
|
||||||
|
|
||||||
if (arg_keep_unit && arg_register && cg_pid_get_owner_uid(0, NULL) >= 0)
|
if (arg_keep_unit && arg_register && cg_pid_get_owner_uid(0, NULL) >= 0)
|
||||||
/* Save the user from accidentally registering either user-$SESSION.scope or user@.service.
|
/* Save the user from accidentally registering either user-$SESSION.scope or user@.service.
|
||||||
* The latter is not technically a user session, but we don't need to labour the point. */
|
* The latter is not technically a user session, but we don't need to labour the point. */
|
||||||
|
@ -3438,7 +3441,8 @@ static int outer_child(
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
if (arg_read_only && arg_volatile_mode == VOLATILE_NO) {
|
if (arg_read_only && arg_volatile_mode == VOLATILE_NO &&
|
||||||
|
!has_custom_root_mount(arg_custom_mounts, arg_n_custom_mounts)) {
|
||||||
r = bind_remount_recursive(directory, MS_RDONLY, MS_RDONLY, NULL);
|
r = bind_remount_recursive(directory, MS_RDONLY, MS_RDONLY, NULL);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return log_error_errno(r, "Failed to make tree read-only: %m");
|
return log_error_errno(r, "Failed to make tree read-only: %m");
|
||||||
|
|
|
@ -81,7 +81,6 @@ static void dump_special_glyphs(void) {
|
||||||
dump_glyph(SPECIAL_GLYPH_BLACK_CIRCLE);
|
dump_glyph(SPECIAL_GLYPH_BLACK_CIRCLE);
|
||||||
dump_glyph(SPECIAL_GLYPH_BULLET);
|
dump_glyph(SPECIAL_GLYPH_BULLET);
|
||||||
dump_glyph(SPECIAL_GLYPH_ARROW);
|
dump_glyph(SPECIAL_GLYPH_ARROW);
|
||||||
dump_glyph(SPECIAL_GLYPH_MDASH);
|
|
||||||
dump_glyph(SPECIAL_GLYPH_ELLIPSIS);
|
dump_glyph(SPECIAL_GLYPH_ELLIPSIS);
|
||||||
dump_glyph(SPECIAL_GLYPH_MU);
|
dump_glyph(SPECIAL_GLYPH_MU);
|
||||||
dump_glyph(SPECIAL_GLYPH_CHECK_MARK);
|
dump_glyph(SPECIAL_GLYPH_CHECK_MARK);
|
||||||
|
|
|
@ -1654,7 +1654,7 @@ static int udev_rule_apply_token_to_event(
|
||||||
if (mode == MODE_INVALID)
|
if (mode == MODE_INVALID)
|
||||||
return token->op == OP_MATCH;
|
return token->op == OP_MATCH;
|
||||||
|
|
||||||
match = (((statbuf.st_mode ^ mode) & 07777) == 0);
|
match = (statbuf.st_mode & mode) > 0;
|
||||||
return token->op == (match ? OP_MATCH : OP_NOMATCH);
|
return token->op == (match ? OP_MATCH : OP_NOMATCH);
|
||||||
}
|
}
|
||||||
case TK_M_PROGRAM: {
|
case TK_M_PROGRAM: {
|
||||||
|
|
Loading…
Reference in New Issue