.gear/rules | 2 + .../tags/cd2272e4cfb943e89b1628c3af34b74caee04493 | 6 + .gear/tags/list | 1 + dists/Makefile.am | 4 + dists/alt.conf | 36 +++ dists/scripts/alt-add_ip.sh | 186 +++++++++++ dists/scripts/alt-add_netif.sh | 259 +++++++++++++++ dists/scripts/alt-del_ip.sh | 94 ++++++ dists/scripts/alt-del_netif.sh | 57 ++++ dists/scripts/set_dns.sh | 51 +-- include/libvzctl.h | 4 +- lib/bindmount.c | 2 + lib/disk_configure.c | 2 +- lib/env.c | 2 +- lib/env_configure.c | 2 +- lib/exec.c | 4 +- lib/net.c | 2 +- lib/util.c | 6 +- lib/vztypes.h | 3 +- libvzctl.spec | 356 +++++++++++++++++++++ paths.am | 9 +- scripts/vz-announce_ips.in | 2 +- scripts/vz-cpt.in | 4 +- scripts/vz-functions.in | 16 +- scripts/vz-rst.in | 4 +- scripts/vz-setrate.in | 2 +- scripts/vz-stop.in | 2 +- scripts/vznetcfg.in | 9 +- 28 files changed, 1068 insertions(+), 59 deletions(-) diff --git a/.gear/rules b/.gear/rules new file mode 100644 index 0000000..26340af --- /dev/null +++ b/.gear/rules @@ -0,0 +1,2 @@ +tar: v@version@:. +diff: v@version@:. . name=@name@-@version@.patch diff --git a/.gear/tags/cd2272e4cfb943e89b1628c3af34b74caee04493 b/.gear/tags/cd2272e4cfb943e89b1628c3af34b74caee04493 new file mode 100644 index 0000000..a7de1fc --- /dev/null +++ b/.gear/tags/cd2272e4cfb943e89b1628c3af34b74caee04493 @@ -0,0 +1,6 @@ +object aea5242a32d9cccc3cd170d1eef4b7008b8f58d0 +type commit +tag v7.0.730 +tagger Apache 1678297753 +0300 + +AUTO v7.0.730 tag diff --git a/.gear/tags/list b/.gear/tags/list new file mode 100644 index 0000000..ef9b2b3 --- /dev/null +++ b/.gear/tags/list @@ -0,0 +1 @@ +cd2272e4cfb943e89b1628c3af34b74caee04493 v7.0.730 diff --git a/dists/Makefile.am b/dists/Makefile.am index 2c599ed..be9b268 100644 --- a/dists/Makefile.am +++ b/dists/Makefile.am @@ -47,6 +47,9 @@ SLACK_9x_VER = 9.0 9.1 SLACK_VER = 10.0 10.1 SLES_VER = 9 10 11 +alt: + $(INSTALL_DATA) $(srcdir)/alt.conf \ + $(DESTDIR)$(distconfdir)/alt.conf centos: $(INSTALL_DATA) $(srcdir)/redhat.conf \ $(DESTDIR)$(distconfdir)/centos.conf @@ -145,6 +148,7 @@ ubuntu: $(DESTDIR)$(distconfdir)/ubuntu.conf install-data-hook:\ + alt \ centos \ debian \ fedora \ diff --git a/dists/alt.conf b/dists/alt.conf new file mode 100644 index 0000000..8a103a0 --- /dev/null +++ b/dists/alt.conf @@ -0,0 +1,36 @@ +# This configuration file is meant to be used with +# the CentOS distribution kit. +# +# Copyright (c) 1999-2017, Parallels International GmbH +# Copyright (c) 2018, vt@altlinux.org +# +# This file is part of OpenVZ libraries. OpenVZ is free software; you can +# redistribute it and/or modify it under the terms of the GNU Lesser General +# Public License as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. +# +# Our contact details: Parallels International GmbH, Vordergasse 59, 8200 +# Schaffhausen, Switzerland. + +ADD_IP=alt-add_ip.sh +DEL_IP=alt-del_ip.sh +NETIF_ADD=alt-add_netif.sh +NETIF_DEL=alt-del_netif.sh +SET_HOSTNAME=redhat-set_hostname.sh +SET_DNS=set_dns.sh +SET_USERPASS=set_userpass.sh +SET_UGID_QUOTA=set_ugid_quota.sh +POST_CREATE=postcreate.sh +POST_MIGRATE=redhat-post_migrate.sh +GET_V2PMIGRATE_EXCLUDES=redhat-v2pmigrate-excludes.sh +SET_CONSOLE=set_console.sh diff --git a/dists/scripts/alt-add_ip.sh b/dists/scripts/alt-add_ip.sh new file mode 100755 index 0000000..a4dab1c --- /dev/null +++ b/dists/scripts/alt-add_ip.sh @@ -0,0 +1,186 @@ +#!/bin/bash +# Copyright (c) 1999-2017, Parallels International GmbH +# Copyright (c) 2018, vt@altlinux.org +# +# This file is part of OpenVZ libraries. OpenVZ is free software; you can +# redistribute it and/or modify it under the terms of the GNU Lesser General +# Public License as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. +# +# Our contact details: Parallels International GmbH, Vordergasse 59, 8200 +# Schaffhausen, Switzerland. +# +# This script configure IP alias(es) inside RedHat like VPS. +# +# Parameters are passed in environment variables. +# Required parameters: +# IP_ADDR - IP address(es) to add +# (several addresses should be divided by space) +# Optional parameters: +# VE_STATE - state of VPS; could be one of: +# starting | stopping | running | stopped +# IPDELALL - delete all old interfaces +# +VENET_DEV=venet0 +IFCFG=/etc/net/ifaces/$VENET_DEV +NETFILE=/etc/sysconfig/network +HOSTFILE=/etc/hosts +IFCFG_NETWORKD=/etc/systemd/network + +function setup_network() +{ + rm -rf $IFCFG >/dev/null 2>&1 + put_param $NETFILE NETWORKING yes + if [ ! -f $HOSTFILE ]; then + echo "127.0.0.1 localhost.localdomain localhost" > $HOSTFILE + fi +} + +function setup_network_networkd() +{ + if [ ! -f $HOSTFILE ]; then + echo "127.0.0.1 localhost.localdomain localhost" > $HOSTFILE + fi + echo "[Match] +Name=${VENET_DEV} + +[Network] +IPv6AcceptRA=no +LinkLocalAddressing=no +DefaultRouteOnDevice=yes" > $IFCFG_NETWORKD/${VENET_DEV}.network || \ + error "Can't write to file $IFCFG_NETWORKD/${VENET_DEV}.network" $VZ_FS_NO_DISK_SPACE +} + +function init_config() +{ + mkdir -p $IFCFG + echo "TYPE=eth +DEVICE=$VENET_DEV +BOOTPROTO=static +ONBOOT=yes" > $IFCFG/options || \ + error "Can't write to file $IFCFG/options" $VZ_FS_NO_DISK_SPACE +} + +function add_ip6() +{ + local ip=$1 + local mask=$2 + + put_param $IFCFG/options CONFIG_IPV6 yes + echo "$ip/${mask:-128}" >> $IFCFG/ipv6address || \ + error "Can't write to file $IFCFG/ipv6address" ${VZ_FS_NO_DISK_SPACE} +} + +function add_ip6_networkd() +{ + local ip=$1 + local mask=$2 + local ipe + local cfg=$IFCFG_NETWORKD/${VENET_DEV}.network + + ipe=$(echo $ip | sed -e 's/[]\/$*.^[]/\\&/g') + if grep -E "^Address=$ip/${mask:-128}" $cfg >/dev/null 2>&1; then + echo "$ip/${mask:-128} already exists" + else + echo "Address=$ip/${mask:-128}" >> $cfg || \ + error "Can't write to file $cfg" ${VZ_FS_NO_DISK_SPACE} + fi +} + +function add_ip4() +{ + local ip=$1 + local mask=$2 + + echo "$ip/${mask:-32}" >> $IFCFG/ipv4address || \ + error "Can't write to file $IFCFG/ipv4address" ${VZ_FS_NO_DISK_SPACE} + echo "default dev $VENET_DEV" >"$IFCFG/ipv4route" || \ + error "Can't write to file $IFCFG/ipv4route" $VZ_FS_NO_DISK_SPACE + echo net.ipv4.conf.$VENET_DEV.promote_secondaries=1 > ${IFCFG}/sysctl.conf || \ + error "Can't write to file $IFCFG/sysctl.conf" $VZ_FS_NO_DISK_SPACE +} + +function add_ip4_networkd() +{ + local ip=$1 + local mask=$2 + local ipe + local cfg=$IFCFG_NETWORKD/${VENET_DEV}.network + + ipe=$(echo $ip | sed -e 's/[]\/$*.^[]/\\&/g') + if grep -E "^Address=$ip/${mask:-32}" $cfg >/dev/null 2>&1; then + echo "$ip/${mask:-32} already exists" + else + echo "Address=$ip/${mask:-32}" >> $cfg || \ + error "Can't write to file $cfg" ${VZ_FS_NO_DISK_SPACE} + ip addr add $ip/${mask:-32} dev $VENET_DEV + fi +} + +function add_ip() +{ + local ipm ip mask + + if [ "$VE_STATE" = "starting" ]; then + setup_network + fi + if [ ! -d $IFCFG ]; then + init_config + fi + for ipm in $IP_ADDR; do + ip=${ipm%%/*} + mask= + if [[ "$ipm" =~ / ]]; then + mask=${ipm##*/} + fi + if is_ipv6 $ip; then + add_ip6 "$ip" "$mask" + else + add_ip4 "$ip" "$mask" + fi + done + ifdown $VENET_DEV 2>/dev/null + ifup $VENET_DEV 2>/dev/null +} + +function add_ip_networkd() +{ + local ipm ip mask + + if [ "$VE_STATE" = "starting" ]; then + setup_network_networkd + fi + for ipm in $IP_ADDR; do + ip=${ipm%%/*} + mask= + if [[ "$ipm" =~ / ]]; then + mask=${ipm##*/} + fi + if is_ipv6 $ip; then + add_ip6_networkd "$ip" "$mask" + else + add_ip4_networkd "$ip" "$mask" + fi + done + ip link set $VENET_DEV up + ip route add default dev $VENET_DEV +} + +if [ -e /etc/systemd/system/dbus-org.freedesktop.network1.service -o \ + -e /etc/systemd/system/multi-user.target.wants/systemd-networkd.service -o \ + -e /lib/systemd/system/multi-user.target.wants/systemd-networkd.service ]; then + add_ip_networkd +else + add_ip +fi +exit 0 diff --git a/dists/scripts/alt-add_netif.sh b/dists/scripts/alt-add_netif.sh new file mode 100755 index 0000000..7dddd85 --- /dev/null +++ b/dists/scripts/alt-add_netif.sh @@ -0,0 +1,259 @@ +#!/bin/bash +# Copyright (C) 1999-2015 Parallels IP Holdings GmbH +# Copyright (C) 2018 vt@altlinux.org +# +# This file is part of OpenVZ libraries. OpenVZ is free software; you can +# redistribute it and/or modify it under the terms of the GNU Lesser General +# Public License as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. +# +# Our contact details: Parallels IP Holdings GmbH, Vordergasse 59, 8200 +# Schaffhausen, Switzerland. +# +# This script configure IP alias(es) inside RedHat like VE. +# +# Parameters are passed in environment variables. +# Required parameters: +# IP_ADDR - IP address(es) to add +# (several addresses should be divided by space) +# Optional parameters: +# VE_STATE - state of VPS; could be one of: +# starting | stopping | running | stopped +# DEVICE - device name +# IPADD - list of ip addresses in format +# IPDEL - list of ip addresses in format +# GW - gateway ip +# + +DEVICE=$(basename $DEVICE) +IFCFG=/etc/net/ifaces/$DEVICE +NETFILE=/etc/sysconfig/network +IFCFG_NETWORKD=/etc/systemd/network + +function setup_network() # OK +{ + rm -rf $IFCFG >/dev/null 2>&1 + put_param $NETFILE NETWORKING yes + if [ ! -f ${HOSTFILE} ]; then + echo "127.0.0.1 localhost.localdomain localhost" > $HOSTFILE + fi +} + +function setup_network_networkd() +{ + if [ ! -f ${HOSTFILE} ]; then + echo "127.0.0.1 localhost.localdomain localhost" > $HOSTFILE + fi +} + +function init_config() +{ + mkdir -p $IFCFG + echo "TYPE=eth +DEVICE=$DEVICE +BOOTPROTO=static +ONBOOT=yes" > $IFCFG/options || \ + error "Can't write to file $IFCFG/options" $VZ_FS_NO_DISK_SPACE +} + +# Function to delete IP address for RedHat like systems +function del_ips() +{ + local ips="$1" + local ip ipm mask + local file + + [ -z "$ips" ] && return 0 + [ -d $IFCFG ] || return 0 + + for ipm in ${ips}; do + ip=${ipm%%/*} + if [ "$ip" = "all" ]; then + rm -f $IFCFG/ipv4address + rm -f $IFCFG/ipv6address + else + ipe=$(echo $ip | sed -e 's/[]\/$*.^[]/\\&/g') + if is_ipv6 "$ip"; then + [ -e $IFCFG/ipv6address ] && sed -i "/^$ipe\//d" $IFCFG/ipv6address + else + [ -e $IFCFG/ipv4address ] && sed -i "/^$ipe\//d" $IFCFG/ipv4address + fi + fi + if [ ! -s $IFCFG/ipv4address ]; then + rm -f $IFCFG/ipv4address + rm -f $IFCFG/ipv4route + fi + if [ ! -s $IFCFG/ipv6address ]; then + rm -f $IFCFG/ipv6address + rm -f $IFCFG/ipv6route + del_param $IFCFG/options CONFIG_IPV6 + fi + done +} + +function add_ip6() +{ + local ip=$1 + local mask=$2 + local ipe + + put_param $IFCFG/options CONFIG_IPV6 yes + ipe=$(echo $ip | sed -e 's/[]\/$*.^[]/\\&/g') + sed -i "/^$ipe\//d" $IFCFG/ipv6address + echo "$ip/${mask:-128}" >> $IFCFG/ipv6address || \ + error "Can't write to file $IFCFG/ipv6address" ${VZ_FS_NO_DISK_SPACE} +} + +function add_ip4() +{ + local ip=$1 + local mask=$2 + local ipe + + ipe=$(echo $ip | sed -e 's/[]\/$*.^[]/\\&/g') + [ -e $IFCFG/ipv4address ] && sed -i "/^$ipe\//d" $IFCFG/ipv4address + echo "$ip/${mask:-32}" >> $IFCFG/ipv4address || \ + error "Can't write to file $IFCFG/ipv4address" ${VZ_FS_NO_DISK_SPACE} + echo net.ipv4.conf.$DEVICE.promote_secondaries=1 > $IFCFG/sysctl.conf || \ + error "Can't write to file $IFCFG/sysctl.conf" $VZ_FS_NO_DISK_SPACE +} + +function add_ip4_networkd() +{ + local ip=$1 + local mask=$2 + local ipe + + ipe=$(echo $ip | sed -e 's/[]\/$*.^[]/\\&/g') + echo "Address=$ip/${mask:-32}" >> $IFCFG_NETWORKD/${DEVICE}.network || \ + error "Can't write to file $IFCFG_NETWORKD/${DEVICE}.network" ${VZ_FS_NO_DISK_SPACE} + ip addr add $ip/${mask:-32} dev $DEVICE +} + +function update_dev() +{ + local ips="$1" + local ipm ip mask + + put_param $IFCFG/options BOOTPROTO "static" + if [ "$DHCP4" = "yes" ]; then + check_dhcp + put_param $IFCFG/options BOOTPROTO "dhcp" + rm -f $IFCFG/ipv4address + rm -f $IFCFG/ipv4route + fi + if [ "$DHCP6" = "yes" ]; then + check_dhcp_ipv6 + put_param $IFCFG/options BOOTPROTO "dhcp6" + put_param $IFCFG/options CONFIG_IPV6 "yes" + rm -f $IFCFG/ipv6address + rm -f $IFCFG/ipv6route + fi + for ipm in $ips; do + ip=${ipm%%/*} + if [[ "$ipm" =~ / ]]; then + mask=${ipm##*/} + else + mask= + fi + if is_ipv6 "$ip"; then + add_ip6 "$ip" "$mask" + else + add_ip4 "$ip" "$mask" + fi + done + if [ -n "$IPV6" ]; then + put_param $IFCFG/options CONFIG_IPV6 yes + fi +} + +function update_dev_systemd() +{ + local ips="$1" + local ipm ip mask + + for ipm in $ips; do + ip=${ipm%%/*} + if [[ "$ipm" =~ / ]]; then + mask=${ipm##*/} + else + mask= + fi + add_ip4_networkd "$ip" "$mask" + done +} + +function setup_gw() +{ + if [ -n "$GWDEL" ]; then + rm -f $IFCFG/ipv4route + fi + if [ -n "$GW6DEL" ]; then + rm -f $IFCFG/ipv6route + fi + if [ -n "$GW" ]; then + echo "default dev $DEVICE via $GW" > $IFCFG/ipv4route + fi + if [ -n "$GW6" ]; then + echo "default dev $DEVICE via $GW6" > $IFCFG/ipv6route + fi +} + +function setup() +{ + if [ "$VE_STATE" = "starting" ]; then + setup_network + fi + if [ ! -d $IFCFG ]; then + init_config + fi + [ -z "$DEVICE" ] && return + ifdown $DEVICE 2>/dev/null + del_ips "$IPDEL" + update_dev "$IPADD" + setup_gw + ifup $DEVICE 2>/dev/null +} + +function setup_networkd() +{ + if [ "$VE_STATE" = "starting" ]; then + setup_network_networkd + fi + [ -z "$DEVICE" ] && return + ip link set $DEVICE down + + echo "[Match] +Name=${DEVICE} + +[Network] +IPv6AcceptRA=no +LinkLocalAddressing=no +DefaultRouteOnDevice=yes" > $IFCFG_NETWORKD/${DEVICE}.network || \ + error "Can't write to file $IFCFG_NETWORKD/${DEVICE}.network" $VZ_FS_NO_DISK_SPACE + +#TODO del_ips_networkd "$IPDEL" + update_dev_networkd "$IPADD" + + ip link set $DEVICE up + ip route add default dev $DEVICE +} + +if [ -e /etc/systemd/system/dbus-org.freedesktop.network1.service -o \ + -e /etc/systemd/system/multi-user.target.wants/systemd-networkd.service -o \ + -e /lib/systemd/system/multi-user.target.wants/systemd-networkd.service ]; then + setup_networkd +else + setup +fi +exit 0 diff --git a/dists/scripts/alt-del_ip.sh b/dists/scripts/alt-del_ip.sh new file mode 100755 index 0000000..800c0d0 --- /dev/null +++ b/dists/scripts/alt-del_ip.sh @@ -0,0 +1,94 @@ +#!/bin/bash +# Copyright (C) 1999-2015 Parallels IP Holdings GmbH +# Copyright (c) 2018, vt@altlinux.org +# +# This file is part of OpenVZ libraries. OpenVZ is free software; you can +# redistribute it and/or modify it under the terms of the GNU Lesser General +# Public License as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. +# +# Our contact details: Parallels IP Holdings GmbH, Vordergasse 59, 8200 +# Schaffhausen, Switzerland. +# +# This script deletes IP alias(es) inside VPS for RedHat like systems. +# +# Parameters are passed in environment variables. +# Required parameters: +# IP_ADDR - IPs to delete, several addresses should be divided by space +# Optional parameters: +# IPDELALL - delete all ip addresses +VENET_DEV=venet0 +IFCFG=/etc/net/ifaces/${VENET_DEV} +NETFILE=/etc/sysconfig/network +HOSTFILE=/etc/hosts +IFCFG_NETWORKD=/etc/systemd/network + +# Function to delete IP address for RedHat like systems +function del_ip() +{ + local ipm ip mask + + [ -d ${IFCFG} ] || return 0 + for ipm in ${IP_ADDR}; do + ip=${ipm%%/*} + mask= + if [[ "${ipm}" =~ / ]]; then + mask=${ipm##*/} + fi + ipe=$(echo $ip | sed -e 's/[]\/$*.^[]/\\&/g') + if is_ipv6 "${ip}"; then + sed -i "/^$ipe\//d" ${IFCFG}/ipv6address + else + sed -i "/^$ipe\//d" ${IFCFG}/ipv4address + fi + if [ ! -s ${IFCFG}/ipv6address ]; then + rm -f ${IFCFG}/ipv6address + rm -f ${IFCFG}/ipv6route + del_param ${IFCFG}/options CONFIG_IPV6 + fi + done + + ifdown ${VENET_DEV} 2>/dev/null + ifup ${VENET_DEV} 2>/dev/null +} + +# Function to delete IP for Networkd service of Systemd +function del_ip_systemd() +{ + local ipm ip mask + local cfg=$IFCFG_NETWORKD/${VENET_DEV}.network + + [ -d ${IFCFG_NETWORKD} ] || return 0 + for ipm in ${IP_ADDR}; do + ip=${ipm%%/*} + mask= + if [[ "${ipm}" =~ / ]]; then + mask=${ipm##*/} + fi + ipe=$(echo $ip | sed -e 's/[]\/$*.^[]/\\&/g') + sed -i "/^$ipe\//d" ${cfg} + /sbin/ip a d ${ipe} + done + + ifdown ${VENET_DEV} 2>/dev/null + ifup ${VENET_DEV} 2>/dev/null +} + +if [ -e /etc/systemd/system/dbus-org.freedesktop.network1.service -o \ + -e /etc/systemd/system/multi-user.target.wants/systemd-networkd.service -o \ + -e /lib/systemd/system/multi-user.target.wants/systemd-networkd.service ]; then + del_ip_networkd +else + del_ip +fi +exit 0 diff --git a/dists/scripts/alt-del_netif.sh b/dists/scripts/alt-del_netif.sh new file mode 100755 index 0000000..fcab7df --- /dev/null +++ b/dists/scripts/alt-del_netif.sh @@ -0,0 +1,57 @@ +#!/bin/bash +# Copyright (C) 1999-2015 Parallels IP Holdings GmbH +# Copyright (C) 2018 vt@altlinux.org +# +# This file is part of OpenVZ libraries. OpenVZ is free software; you can +# redistribute it and/or modify it under the terms of the GNU Lesser General +# Public License as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. +# +# Our contact details: Parallels IP Holdings GmbH, Vordergasse 59, 8200 +# Schaffhausen, Switzerland. +# +# This script deletes IP alias(es) inside VPS for RedHat like systems. +# +# Parameters are passed in environment variables. +# Required parameters: +# DEVICE - device name + +DEVICE=$(basename $DEVICE) +IFCFG=/etc/net/ifaces/${DEVICE} +NETFILE=/etc/sysconfig/network +IFCFG_NETWORKD=/etc/systemd/network + +function del_dev() +{ + [ -d ${IFCFG} ] || exit 1 + ifdown ${DEVICE} 2>/dev/null + if [ -f ${IFCFG}/options ]; then + rm -rf -- "${IFCFG}" + fi +} + +function del_dev_systemd() +{ + [ -d ${IFCFG_NETWORKD} ] || exit 1 + ifdown ${DEVICE} 2>/dev/null + rm -rf -- "${IFCFG_NETWORKD}/${DEVICE}.network" +} + +if [ -e /etc/systemd/system/dbus-org.freedesktop.network1.service -o \ + -e /etc/systemd/system/multi-user.target.wants/systemd-networkd.service -o \ + -e /lib/systemd/system/multi-user.target.wants/systemd-networkd.service ]; then + del_dev_systemd +else + del_dev +fi +exit 0 diff --git a/dists/scripts/set_dns.sh b/dists/scripts/set_dns.sh index 2b42aec..2070b7c 100755 --- a/dists/scripts/set_dns.sh +++ b/dists/scripts/set_dns.sh @@ -29,15 +29,18 @@ # Sets search domain(s). Modifies /etc/resolv.conf # NAMESERVER # Sets name server(s). Modifies /etc/resolv.conf -RESOLVCONF=/etc/resolvconf/resolv.conf.d/base + +# shellcheck disable=SC2181,SC2166,SC2086 +#RESOLVCONF=/etc/resolvconf/resolv.conf.d/base +RESOLVCONF=/etc/net/ifaces/venet0/resolv.conf set_resolvconf() { - local cfgfile=/etc/resolv.conf - local server="$1" - local search="$2" + local cfgfile="$1" + local server="$2" + local search="$3" local post_configure_cmd= - local srv fname + local srv # Use resolvconf static storage if which resolvconf >/dev/null 2>&1; then @@ -45,8 +48,8 @@ set_resolvconf() cfgfile=$RESOLVCONF [ "${VE_STATE}" = "running" ] && post_configure_cmd='resolvconf -u' if [ "${VE_STATE}" = "starting" ] && - [ -e /etc/systemd/system/systemd-resolved.service ] && - [ $(readlink /etc/systemd/system/systemd-resolved.service) == '/dev/null' ]; then + [ -e /lib/systemd/system/systemd-resolved.service ] && + [ "$(readlink /lib/systemd/system/systemd-resolved.service)" == "/dev/null" ]; then grep -qF -- "resolvconf -u" "/etc/rc.local" || echo "resolvconf -u" >> "/etc/rc.local" fi fi @@ -57,7 +60,7 @@ set_resolvconf() sed "/search.*/d" < ${cfgfile} > ${cfgfile}.$$ && \ if [ $? -ne 0 ]; then rm -f ${cfgfile}.$$ - error "Can't change file ${cfgfile}" ${VZ_FS_NO_DISK_SPACE} + error "Can't change file ${cfgfile}" "${VZ_FS_NO_DISK_SPACE}" fi mv -f ${cfgfile}.$$ ${cfgfile} || rm -f ${cfgfile}.$$ else @@ -66,17 +69,17 @@ set_resolvconf() fi if [ -n "${server}" -a ! -L "${cfgfile}" ]; then [ -f "${cfgfile}" ] || touch "${cfgfile}" - ${CP} ${cfgfile} ${cfgfile}.$$ || error "Can't copy file $cfgfile" $VZ_FS_NO_DISK_SPACE + ${CP} ${cfgfile} ${cfgfile}.$$ || error "Can't copy file $cfgfile" "$VZ_FS_NO_DISK_SPACE" sed "/nameserver.*/d" ${cfgfile} > ${cfgfile}.$$ if [ $? -ne 0 ]; then rm -f ${cfgfile}.$$ - error "Can't change file ${cfgfile}" ${VZ_FS_NO_DISK_SPACE} + error "Can't change file ${cfgfile}" "${VZ_FS_NO_DISK_SPACE}" fi if [ "${server}" != '#' ]; then for srv in ${server}; do echo "nameserver ${srv}" >> ${cfgfile}.$$ || \ - error "Can't change file ${cfgfile}" ${VZ_FS_NO_DISK_SPACE} + error "Can't change file ${cfgfile}" "${VZ_FS_NO_DISK_SPACE}" done fi @@ -88,9 +91,9 @@ set_resolvconf() set_resolved() { - local cfg=/etc/systemd/resolved.conf - local server="$1" - local search="$2" + local cfg="$1" + local server="$2" + local search="$3" if [ "${server}" = '#' ]; then sed "/DNS=.*/d" < ${cfg} > ${cfg}.$$ && \ @@ -134,14 +137,18 @@ set_network_config() [ -n "$NAMESERVER" -o -n "$SEARCHDOMAIN" ] && netconfig -v update -m dns-resolver } -if [ -e /etc/systemd/system/dbus-org.freedesktop.resolve1.service ] && - [ -e /etc/systemd/system/systemd-resolved.service ] && - [ $(readlink /etc/systemd/system/systemd-resolved.service) != '/dev/null' ]; then - set_resolved "${NAMESERVER}" "${SEARCHDOMAIN}" -elif [ -e /sbin/netconfig -a -e /etc/sysconfig/network/config ]; then - set_network_config -else - set_resolvconf "${NAMESERVER}" "${SEARCHDOMAIN}" +if [ -e /etc/systemd/system/dbus-org.freedesktop.network1.service ]; then # systemd-networkd + set_resolved "/etc/systemd/network/venet0.network" "${NAMESERVER}" "${SEARCHDOMAIN}" +fi +if [ -e /etc/systemd/system/dbus-org.freedesktop.resolve1.service ] && + [ -e /lib/systemd/system/systemd-resolved.service ] && + [ "$(readlink /etc/systemd/system/dbus-org.freedesktop.resolve1.service)" != "/dev/null" ] && + [ "$(readlink /lib/systemd/system/systemd-resolved.service)" != "/dev/null" ]; then # systemd-resolved + set_resolved "/etc/systemd/resolved.conf" "${NAMESERVER}" "${SEARCHDOMAIN}" +elif [ -e /sbin/netconfig -a -e /etc/sysconfig/network/config ]; then # SLES netconfig + set_network_config +else # openresolv or any other resolver + set_resolvconf "/etc/resolv.conf" "${NAMESERVER}" "${SEARCHDOMAIN}" fi exit 0 diff --git a/include/libvzctl.h b/include/libvzctl.h index 71282d0..141a82c 100644 --- a/include/libvzctl.h +++ b/include/libvzctl.h @@ -31,7 +31,7 @@ #define VZ_DIR "/etc/vz/" #define VZ_GLOBAL_CFG VZ_DIR "vz.conf" #define VZ_ENV_CONF_DIR VZ_DIR "conf/" -#define VZ_ENV_CONF_LOCK_DIR "/var/vz/" +#define VZ_ENV_CONF_LOCK_DIR "/var/lib/vz/" #define VZ_SAMPLE_CONF_PATTERN "ve-%s.conf-sample" #define VZ_ENV_CONF_SAMPLE VZ_ENV_CONF_DIR VZ_SAMPLE_CONF_PATTERN #define VZCTL_VE_ROOTHDD_DIR "root.hdd" @@ -762,7 +762,7 @@ int vzctl2_clear_all_ve_netstat(void); vzctl_env_handle_ptr vzctl2_alloc_env_handle(); vzctl_env_handle_ptr vzctl2_env_open(const char *ctid, int flags, int *err); -vzctl_env_handle_ptr vzctl2_env_open_conf(const char *ctid, const char *fname, int flags, int *err); +vzctl_env_handle_ptr vzctl2_env_open_conf(const ctid_t ctid, const char *fname, int flags, int *err); void vzctl2_env_close(vzctl_env_handle_ptr h); int vzctl2_apply_param(vzctl_env_handle_ptr h, vzctl_env_param_ptr param, int flags); int vzctl2_env_save(vzctl_env_handle_ptr h); diff --git a/lib/bindmount.c b/lib/bindmount.c index 8b5281e..fabb214 100644 --- a/lib/bindmount.c +++ b/lib/bindmount.c @@ -365,6 +365,7 @@ static int get_mount_flags(const char *dir, int *flags) return 0; } +#if __GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 37) static int open_tree(int dirfd, const char *pathname, unsigned int flags) { return syscall(428, dirfd, pathname, flags); } @@ -373,6 +374,7 @@ static int move_mount(int from_dirfd, const char *from_pathname, int to_dirfd, const char *to_pathname, unsigned int flags) { return syscall(429, from_dirfd, from_pathname, to_dirfd, to_pathname, flags); } +#endif static int set_mount_flags(const char *mnt, int flags) { diff --git a/lib/disk_configure.c b/lib/disk_configure.c index 382d7df..9fea838 100644 --- a/lib/disk_configure.c +++ b/lib/disk_configure.c @@ -57,7 +57,7 @@ int get_fs_uuid(const char *device, struct vzctl_disk *disk) struct stat st; FILE *fp; char *argv[] = { - "/usr/sbin/blkid", + "/sbin/blkid", (char *)device, NULL, }; diff --git a/lib/env.c b/lib/env.c index 4cd7e6f..62daa97 100644 --- a/lib/env.c +++ b/lib/env.c @@ -901,7 +901,7 @@ int exec_init(const struct start_param *param) { char cid[STR_SIZE]; char *argv[] = {"init", "-z", " ", NULL}; - char *envp[] = {"HOME=/", "TERM=linux", cid, NULL}; + char *envp[] = {"HOME=/root", "TERM=linux", cid, NULL}; char **env; int errcode = 0; logger(1, 0, "Starting init"); diff --git a/lib/env_configure.c b/lib/env_configure.c index fcace24..da4ca72 100644 --- a/lib/env_configure.c +++ b/lib/env_configure.c @@ -46,7 +46,7 @@ static char *envp_s[] = { - "HOME=/", + "HOME=/root", "TERM=linux", ENV_PATH, NULL diff --git a/lib/exec.c b/lib/exec.c index af7a081..e24e819 100644 --- a/lib/exec.c +++ b/lib/exec.c @@ -85,7 +85,7 @@ static __thread int s_timeout_pid; static char _proc_title[PATH_MAX]; static int _proc_title_len = sizeof(_proc_title); -static char *envp_bash[] = {"HOME=/", +static char *envp_bash[] = {"HOME=/root", ENV_PATH, "SHELL=/bin/bash", NULL, NULL}; @@ -147,7 +147,7 @@ static void exec_handler(int sig) int execvep(const char *path, char *const argv[], char *const envp[]) { if (!strchr(path, '/')) { - char *p = DEF_PATH; + char *p = DEF_PATH "/usr/local/bin"; for (; p && *p;) { char partial[FILENAME_MAX]; char *p2; diff --git a/lib/net.c b/lib/net.c index 30764ba..f9777ad 100644 --- a/lib/net.c +++ b/lib/net.c @@ -746,7 +746,7 @@ static int get_net_info(ctid_t ctid, const char *ifname, char ip[STR_SIZE]; char buf[STR_SIZE]; LIST_HEAD(ips); - char *arg[] = {"/usr/sbin/ip", "-n", ctid, "a", "l", + char *arg[] = {"/sbin/ip", "-n", ctid, "a", "l", ifname ? "dev" : NULL, (char *) ifname, NULL}; fp = vzctl_popen(arg, NULL, 0); diff --git a/lib/util.c b/lib/util.c index 9d68770..a8f5011 100644 --- a/lib/util.c +++ b/lib/util.c @@ -72,8 +72,8 @@ #define NR_OPEN 1024 #endif -static char *envp_bash[] = {"HOME=/", "TERM=linux", - ENV_PATH ".", NULL}; +static char *envp_bash[] = {"HOME=/root", "TERM=linux", + ENV_PATH, NULL}; void *xmalloc(size_t size) { @@ -1120,7 +1120,7 @@ static int vzctl_env_convert_layout4(struct vzctl_env_handle *h) unlink(buf); } /* Remove quota file */ - snprintf(buf, sizeof(buf), "/var/vzquota/quota.%d", ctid); + snprintf(buf, sizeof(buf), "/var/lib/vzquota/quota.%d", ctid); unlink(buf); logger(0, 0, "Container was successfully converted to the 4 layout"); return 0; diff --git a/lib/vztypes.h b/lib/vztypes.h index d58dee2..0133ce5 100644 --- a/lib/vztypes.h +++ b/lib/vztypes.h @@ -101,8 +101,7 @@ #define VZCTL_SCRIPT_EXEC_TIMEOUT 600 /* Default enviroment variable PATH */ -#define DEF_PATH "/usr/local/sbin:/usr/local/bin:" \ - "/bin:/sbin:/usr/bin:/usr/sbin:" +#define DEF_PATH "/sbin:/usr/sbin:/bin:/usr/bin:" #define ENV_PATH "PATH=" DEF_PATH #define MAX_ARGS 255 diff --git a/libvzctl.spec b/libvzctl.spec new file mode 100644 index 0000000..ada1c4a --- /dev/null +++ b/libvzctl.spec @@ -0,0 +1,356 @@ + +# %%define _without_vcmmd yes +%{?_without_vcmmd:%global _without_vcmmd --without-vcmmd} + +Name: libvzctl +Summary: OpenVZ Containers API library +Version: 7.0.730 +Release: alt2 +License: LGPLv2.1 +Group: System/Libraries +Url: https://openvz.org/ +Vcs: https://src.openvz.org/scm/ovzl/libvzctl.git + +Source: %name-%version.tar +Patch: %name-%version.patch + +ExclusiveArch: x86_64 + +Requires: libvzevent >= 7.0.0 +Requires: libploop >= 7.0.199 +Requires: cgroup +Requires: crtools-ovz >= 3.15.0.9 +Requires: e2fsprogs gdisk iputils iproute2 +BuildRequires: kernel-headers-ovz-el7 >= 3.10.0 +BuildRequires: libvzevent-devel >= 5.0.0 +BuildRequires: libploop-devel >= 7.0.199 +BuildRequires: libe2fs-devel +BuildRequires: libxml2-devel >= 2.6.16 +BuildRequires: libuuid-devel +BuildRequires: libdbus-devel + +%if 0%{!?_without_vcmmd:1} +Requires: libvcmmd >= 7.0.22 +BuildRequires: libvcmmd-devel >= 7.0.22 +%endif + +%add_findreq_skiplist %_datadir/%name/dists/scripts/* +%filter_from_requires /^\/etc\/vz\/vz.conf/d +%define _pkglibdir %_libdir/%name + +%description +OpenVZ Containers API library + +%package devel +Summary: OpenVZ Containers API development library +Group: Development/C +License: LGPLv2.1 +Requires: %name = %version-%release + +%description devel +OpenVZ Containers API development library + +%prep +%setup -q +%patch -p1 + +%build +%autoreconf +export CFLAGS="%optflags -Wno-error=format-truncation -Wno-error=stringop-truncation -Wno-error=format-overflow -Wno-error=stringop-overflow" +%configure %{?_without_vcmmd} +%make_build + +%install +%makeinstall_std + +%files +%_libdir/*.so.* +%_pkglibdir +%_datadir/%name + +%files devel +%_libdir/*.so +%_includedir/vzctl + +%changelog +* Fri Jul 14 2023 Andrew A. Vasilyev 7.0.730-alt2 +- fix build with glibc 2.37 + +* Tue Mar 14 2023 Andrew A. Vasilyev 7.0.730-alt1 +- 7.0.730 + +* Tue Mar 07 2023 Andrew A. Vasilyev 7.0.729-alt1 +- 7.0.729 + +* Wed Feb 22 2023 Andrew A. Vasilyev 7.0.726-alt2 +- set_dns.sh: restore previous resolver choice + +* Tue Feb 21 2023 Andrew A. Vasilyev 7.0.726-alt1 +- 7.0.726 +- set_dns.sh: optimize and clear syntax + +* Sat Dec 10 2022 Andrew A. Vasilyev 7.0.723-alt1 +- 7.0.723 + +* Mon Nov 14 2022 Andrew A. Vasilyev 7.0.719-alt1 +- 7.0.719 + +* Wed Oct 26 2022 Andrew A. Vasilyev 7.0.717-alt1 +- 7.0.717 + +* Tue Jun 28 2022 Andrew A. Vasilyev 7.0.714-alt1 +- 7.0.714 + +* Wed Jun 01 2022 Andrew A. Vasilyev 7.0.713-alt1 +- 7.0.713 + +* Thu May 12 2022 Andrew A. Vasilyev 7.0.711-alt1 +- 7.0.711 + +* Sat Nov 13 2021 Andrew A. Vasilyev 7.0.707-alt1 +- 7.0.707 + +* Tue Oct 05 2021 Andrew A. Vasilyev 7.0.700-alt1 +- 7.0.700 + +* Wed Sep 22 2021 Andrew A. Vasilyev 7.0.698-alt1 +- 7.0.698 +- move all ALT CFLAGS to spec +- fix -Warray-parameter in vzctl2_env_open_conf() declaration (gcc11) + +* Fri Sep 10 2021 Andrew A. Vasilyev 7.0.697-alt1 +- 7.0.697 + +* Wed Sep 01 2021 Andrew A. Vasilyev 7.0.689-alt1 +- 7.0.689 +- fix openvswitch dependency + +* Thu Aug 05 2021 Andrew A. Vasilyev 7.0.678-alt1 +- 7.0.678 + +* Wed Jul 28 2021 Andrew A. Vasilyev 7.0.674-alt1 +- 7.0.674 + +* Thu Jul 15 2021 Andrew A. Vasilyev 7.0.671-alt1 +- 7.0.671 + +* Tue Jul 13 2021 Andrew A. Vasilyev 7.0.664-alt2 +- use "ip link" instead of brctl, no deps on bridge-utils now + +* Thu Jul 08 2021 Andrew A. Vasilyev 7.0.664-alt1 +- 7.0.664 + +* Wed Jun 09 2021 Andrew A. Vasilyev 7.0.659-alt1 +- 7.0.659 + +* Mon Apr 19 2021 Andrew A. Vasilyev 7.0.651-alt1 +- 7.0.651 + +* Fri Mar 26 2021 Andrew A. Vasilyev 7.0.648-alt1 +- 7.0.648 + +* Fri Mar 19 2021 Andrew A. Vasilyev 7.0.647-alt1 +- 7.0.647 + +* Mon Mar 08 2021 Andrew A. Vasilyev 7.0.645-alt1 +- 7.0.645 + +* Wed Feb 10 2021 Andrew A. Vasilyev 7.0.641-alt1 +- 7.0.641 + +* Thu Feb 04 2021 Andrew A. Vasilyev 7.0.640-alt1 +- 7.0.640 + +* Sun Jan 31 2021 Andrew A. Vasilyev 7.0.639-alt2 +- change resolver configuration for systemd +- remove default NS from systemd-networkd config +- change route command to "ip route" call + +* Tue Jan 26 2021 Andrew A. Vasilyev 7.0.639-alt1 +- 7.0.639 + +* Tue Dec 08 2020 Andrew A. Vasilyev 7.0.633-alt1 +- 7.0.633 + +* Thu Dec 03 2020 Andrew A. Vasilyev 7.0.632-alt1 +- 7.0.632 + +* Thu Nov 19 2020 Andrew A. Vasilyev 7.0.629-alt1 +- 7.0.629 + +* Sat Oct 24 2020 Andrew A. Vasilyev 7.0.628-alt1 +- 7.0.628 + +* Tue Oct 06 2020 Andrew A. Vasilyev 7.0.625-alt1 +- 7.0.625 + +* Fri Oct 02 2020 Andrew A. Vasilyev 7.0.623-alt1 +- 7.0.623 +- add explicit requirements on e2fsprogs, gdisk and iputils packages + +* Wed Sep 30 2020 Andrew A. Vasilyev 7.0.619-alt2 +- change criu to criu-ovz in scripts + +* Thu Sep 24 2020 Andrew A. Vasilyev 7.0.619-alt1 +- 7.0.619 + +* Fri Sep 18 2020 Andrew A. Vasilyev 7.0.618-alt1 +- 7.0.618 + +* Mon Sep 14 2020 Andrew A. Vasilyev 7.0.617-alt1 +- 7.0.617 +- R: crtools-ovz + +* Thu Sep 10 2020 Andrew A. Vasilyev 7.0.616-alt1 +- 7.0.616 + +* Fri Sep 04 2020 Andrew A. Vasilyev 7.0.614-alt1 +- 7.0.614 + +* Fri Aug 28 2020 Andrew A. Vasilyev 7.0.605-alt1 +- 7.0.605 + +* Tue Aug 25 2020 Andrew A. Vasilyev 7.0.604-alt1 +- 7.0.604 + +* Mon Aug 03 2020 Andrew A. Vasilyev 7.0.601-alt1 +- 7.0.601 + +* Fri Jul 24 2020 Andrew A. Vasilyev 7.0.598-alt1 +- 7.0.598 + +* Tue Jul 21 2020 Andrew A. Vasilyev 7.0.596-alt1 +- 7.0.596 + +* Tue Jul 14 2020 Andrew A. Vasilyev 7.0.592-alt1 +- 7.0.592 +- ability to build without vcmmd + +* Wed Jun 24 2020 Andrew A. Vasilyev 7.0.590-alt1 +- 7.0.590 + +* Wed Jun 17 2020 Andrew A. Vasilyev 7.0.588-alt1 +- 7.0.588 + +* Wed May 27 2020 Andrew A. Vasilyev 7.0.583-alt1 +- 7.0.583 + +* Wed May 20 2020 Andrew A. Vasilyev 7.0.580-alt1 +- 7.0.580 + +* Sat Apr 25 2020 Andrew A. Vasilyev 7.0.578-alt1 +- 7.0.578 + +* Mon Apr 20 2020 Andrew A. Vasilyev 7.0.574-alt1 +- 7.0.574 + +* Wed Apr 08 2020 Andrew A. Vasilyev 7.0.571-alt1 +- 7.0.571 + +* Tue Mar 31 2020 Andrew A. Vasilyev 7.0.568-alt1 +- 7.0.568 +- remove with_ub due to autodetect of UB + +* Tue Mar 24 2020 Andrew A. Vasilyev 7.0.567-alt1 +- 7.0.567 + +* Thu Mar 19 2020 Andrew A. Vasilyev 7.0.566-alt1 +- 7.0.566 + +* Wed Mar 11 2020 Andrew A. Vasilyev 7.0.564-alt1 +- 7.0.564 + +* Tue Mar 10 2020 Andrew A. Vasilyev 7.0.563-alt1 +- 7.0.563 + +* Thu Feb 27 2020 Andrew A. Vasilyev 7.0.561-alt1 +- 7.0.561 + +* Wed Feb 12 2020 Andrew A. Vasilyev 7.0.560-alt1 +- 7.0.560 + +* Mon Feb 03 2020 Andrew A. Vasilyev 7.0.558-alt1 +- 7.0.558 + +* Fri Jan 31 2020 Andrew A. Vasilyev 7.0.556-alt1 +- 7.0.556 + +* Tue Jan 28 2020 Andrew A. Vasilyev 7.0.555-alt1 +- 7.0.555 + +* Wed Jan 22 2020 Andrew A. Vasilyev 7.0.553-alt1 +- 7.0.553 + +* Wed Jan 22 2020 Andrew A. Vasilyev 7.0.552-alt2 +- modify scripts for networkd + +* Tue Dec 17 2019 Andrew A. Vasilyev 7.0.552-alt1 +- 7.0.552 + +* Tue Dec 10 2019 Andrew A. Vasilyev 7.0.551-alt1 +- 7.0.551 + +* Mon Dec 09 2019 Andrew A. Vasilyev 7.0.550-alt1 +- 7.0.550 + +* Fri Dec 06 2019 Andrew A. Vasilyev 7.0.548-alt1 +- 7.0.548 + +* Thu Nov 14 2019 Andrew A. Vasilyev 7.0.545-alt5 +- fix criu scripts path +- spec cleanup + +* Fri Nov 08 2019 Andrew A. Vasilyev 7.0.545-alt4 +- fix broken Requires + +* Wed Nov 06 2019 Andrew A. Vasilyev 7.0.545-alt3 +- revert 1d53de2b265fe21c7df7bc to lower diff with upstream + +* Wed Nov 06 2019 Andrew A. Vasilyev 7.0.545-alt2 +- fix USE_UB absence + +* Tue Nov 05 2019 Andrew A. Vasilyev 7.0.545-alt1 +- 7.0.545 + +* Fri Nov 01 2019 Andrew A. Vasilyev 7.0.544-alt1 +- 7.0.544 +- fix /sbin/blkid path + +* Fri Oct 25 2019 Andrew A. Vasilyev 7.0.540-alt1 +- 7.0.540 + +* Wed Oct 16 2019 Andrew A. Vasilyev 7.0.539-alt1 +- 7.0.539 + +* Wed Oct 16 2019 Andrew A. Vasilyev 7.0.538-alt2 +- add/remove device for systemd/networkd service + +* Mon Oct 14 2019 Andrew A. Vasilyev 7.0.538-alt1 +- 7.0.538 +- fix /sbin/ip path + +* Mon Oct 07 2019 Andrew A. Vasilyev 7.0.537-alt1 +- 7.0.537 + +* Thu Sep 12 2019 Andrew A. Vasilyev 7.0.536-alt3 +- fix systemd-networkd discovery + +* Tue Sep 03 2019 Andrew A. Vasilyev 7.0.536-alt2 +- add interface and IPs for networkd + +* Mon Aug 26 2019 Andrew A. Vasilyev 7.0.536-alt1 +- 7.0.536 + +* Fri Aug 23 2019 Andrew A. Vasilyev 7.0.535-alt2 +- fixed alt scripts +- fixed arping full path +- fixed awk regexp warning + +* Mon Aug 19 2019 Andrew A. Vasilyev 7.0.535-alt1 +- 7.0.535 + +* Sun Nov 04 2018 Alexey Shabalin 7.0.499-alt1 +- 7.0.499 + +* Mon Feb 19 2018 Alexey Shabalin 7.0.463-alt1 +- Initial build diff --git a/paths.am b/paths.am index 4553b07..13a86a7 100644 --- a/paths.am +++ b/paths.am @@ -21,16 +21,15 @@ pkglibdir=$(libdir)/libvzctl initddir = $(sysconfdir)/init.d +etcnetdir = $(sysconfdir)/net netsdir = $(sysconfdir)/sysconfig/network-scripts pkgconfdir = $(sysconfdir)/vz vpsconfdir = $(pkgconfdir)/conf namesdir = $(pkgconfdir)/names -# automake < 1.10.2 does not set pkglibexecdir -pkglibexecdir = $(libexecdir)/libvzctl -distconfdir = $(pkglibexecdir)/dists -scriptdir = $(pkglibexecdir)/scripts -scriptddir = $(pkglibexecdir)/script.d +distconfdir = $(pkgdatadir)/dists +scriptdir = $(pkgdatadir)/scripts +scriptddir = $(pkgdatadir)/script.d pkgincludedir = $(includedir)/vzctl diff --git a/scripts/vz-announce_ips.in b/scripts/vz-announce_ips.in index 3851c3e..8a590e8 100755 --- a/scripts/vz-announce_ips.in +++ b/scripts/vz-announce_ips.in @@ -35,7 +35,7 @@ if [ ! -d "${VEROOT}/sys/class/net" ]; then exit 1 fi -ARPING_CMD=/sbin/arping +ARPING_CMD=/usr/sbin/arping ARPING_ARGS="-f -c 1 -w 1" IP_CMD=/sbin/ip NDSEND_CMD=/usr/sbin/ndsend diff --git a/scripts/vz-cpt.in b/scripts/vz-cpt.in index 12cf950..cbcafdd 100755 --- a/scripts/vz-cpt.in +++ b/scripts/vz-cpt.in @@ -83,7 +83,7 @@ function cg_dump_props { } # NFS actions -nfs_actions_path=/usr/libexec/criu/scripts/nfs-ports-allow.sh +nfs_actions_path=/usr/lib/criu/scripts/nfs-ports-allow.sh if [ -f "$nfs_actions_path" ]; then nfs_actions="--action-script $nfs_actions_path" fi @@ -111,7 +111,7 @@ cg_controllers="--cgroup-dump-controller hugetlb \ --cgroup-dump-controller blkio" CRIU_LOGLEVEL=4 -criu dump -v$CRIU_LOGLEVEL -o dump.log \ +criu-ovz dump -v$CRIU_LOGLEVEL -o dump.log \ --ve $VEID \ --skip-freezer-state \ --skip-in-flight \ diff --git a/scripts/vz-functions.in b/scripts/vz-functions.in index 3e0e157..86c9c08 100755 --- a/scripts/vz-functions.in +++ b/scripts/vz-functions.in @@ -39,7 +39,7 @@ VZ_SET_RATE=80 VZ_SET_ACCOUNT=81 # iptables parameters -VE_STATE_DIR="/var/vz/veip/" +VE_STATE_DIR="/var/lib/vz/veip/" CONF_DIR=@VPSCONFDIR@ VZ_IP_CLASSES="${CONF_DIR}/networks_classes" SUSPEND_CONF_DIR="/etc/vz/vzreboot" @@ -50,7 +50,7 @@ PRAM_MOUNT_POINT="/mnt/pram" TC_CMD=tc IP_CMD=ip MAX_FORKS=100 -ARPING_CMD="/sbin/arping" +ARPING_CMD="/usr/sbin/arping" ARPING_ARGS="-f -c 1 -q" NDSEND_CMD="/usr/sbin/ndsend" OVSCTL_CMD="/usr/bin/ovs-vsctl" @@ -232,14 +232,14 @@ vzadjustmacs() vzconfbridge() { if [ "x$BRIDGE" = "xvenet0" ]; then - if [ $(brctl show venet0 2>/dev/null | tail -n+2 | wc -l) -eq 0 ]; then - brctl addbr venet0 + if [ $(${IP_CMD} -br link show venet0 2>/dev/null | wc -l) -eq 0 ]; then + ${IP_CMD} link add venet0 type bridge ${IP_CMD} link set venet0 up fi fi if [ "x$BRIDGE" != "x" ]; then - brctl addif $BRIDGE $HNAME >/dev/null 2>&1 + ${IP_CMD} link set "$HNAME" master "$BRIDGE" >/dev/null 2>&1 fi } @@ -275,7 +275,7 @@ function vzgetnetdev() continue fi local tmp=`${IP_CMD} a l $dev | awk -v dev=$dev \ - '/^^[\ \t]+inet6? / && !/scope link/ { print(dev); exit; }'` + '/^^[ \t]+inet6? / && !/scope link/ { print(dev); exit; }'` [ -n "$tmp" ] && tmp_list="$tmp_list $tmp" done NETDEVICES="$tmp_list" @@ -365,7 +365,7 @@ function vzarpipdetect() done done # Duplicate address detection mode (DAD). Returns 0, if DAD succeeded i.e. no replies are received - parallel_execution 1000000 "${ARPING_CMD} ${ARPING_ARGS} -w 1 -D -I" ipv4_pairs[@] + parallel_execution 1000000 "${ARPING_CMD} ${ARPING_ARGS} -w 1 -D -I" ipv4_pairs[@] >/dev/null 2>&1 } # Send ARP request to update neighbour ARP caches @@ -403,7 +403,7 @@ function vzarpipset() lockfile ${VZ_ARP_ANNOUNCE_LOCK} nonlocal_bind_prev=$(cat /proc/sys/net/ipv4/ip_nonlocal_bind) echo "1" > /proc/sys/net/ipv4/ip_nonlocal_bind - parallel_execution 100000 "${ARPING_CMD} ${ARPING_ARGS} -A -I" ipv4_pairs[@] + parallel_execution 100000 "${ARPING_CMD} ${ARPING_ARGS} -A -I" ipv4_pairs[@] >/dev/null 2>&1 echo "${nonlocal_bind_prev}" > /proc/sys/net/ipv4/ip_nonlocal_bind rm -rf ${VZ_ARP_ANNOUNCE_LOCK} > /dev/null 2>&1 parallel_execution 100000 "${NDSEND_CMD}" ipv6_pairs[@] diff --git a/scripts/vz-rst.in b/scripts/vz-rst.in index 3360ecf..452fd0f 100755 --- a/scripts/vz-rst.in +++ b/scripts/vz-rst.in @@ -105,7 +105,7 @@ fi [ -z "$VE_RESTORE_LOG_PATH" ] && VE_RESTORE_LOG_PATH="restore.log" # AutoFS actions -autofs_actions_path=/usr/libexec/criu/scripts/systemd-autofs-restart.sh +autofs_actions_path=/usr/lib/criu/scripts/systemd-autofs-restart.sh if [ -f "$autofs_actions_path" ]; then autofs_actions="--action-script $autofs_actions_path" fi @@ -113,7 +113,7 @@ fi eval $(. /etc/vz/vz.conf && echo RESTORE_EXTRA_OPT=\"$RESTORE_EXTRA_OPT\") CRIU_LOGLEVEL=4 [ -n "$VE_CRIU_PIDFILE" ] && echo $$ > $VE_CRIU_PIDFILE -exec criu restore -v$CRIU_LOGLEVEL $RESTORE_EXTRA_OPT \ +exec criu-ovz restore -v$CRIU_LOGLEVEL $RESTORE_EXTRA_OPT \ --ve $VEID \ --skip-freezer-state \ --file-locks \ diff --git a/scripts/vz-setrate.in b/scripts/vz-setrate.in index 7f56bd9..9226dbf 100755 --- a/scripts/vz-setrate.in +++ b/scripts/vz-setrate.in @@ -314,7 +314,7 @@ fill_configured_dev() check_BANDWIDTH() { [ -n "$BANDWIDTH" ] && return - dev=`/usr/sbin/ip r l | awk '/^default/ {print $5; exit(0)}'` + dev=`/sbin/ip r l | awk '/^default/ {print $5; exit(0)}'` [ -z "$dev" ] && return if [ -e "/sys/class/net/$dev/device" ]; then BANDWIDTH="$dev" diff --git a/scripts/vz-stop.in b/scripts/vz-stop.in index b64d4d7..9755ea5 100755 --- a/scripts/vz-stop.in +++ b/scripts/vz-stop.in @@ -47,7 +47,7 @@ fi [ "${TRAFFIC_SHAPING}" == "yes" ] && @SCRIPTDIR@/vz-setrate del for v in $VETH; do - [ -x /usr/bin/ovs-vsctl ] && ovs-vsctl --if-exists del-port "$v" 2>/dev/null + [ -x ${OVSCTL_CMD} ] && ${OVSCTL_CMD} --if-exists del-port "$v" 2>/dev/null ip link set $v down >/dev/null 2>&1 && \ ip link set $v name "${v}M$(( $$ % 100 ))" >/dev/null 2>&1 done diff --git a/scripts/vznetcfg.in b/scripts/vznetcfg.in index 526aece..dbb5d0b 100755 --- a/scripts/vznetcfg.in +++ b/scripts/vznetcfg.in @@ -20,6 +20,7 @@ # Our contact details: Virtuozzo International GmbH, Vordergasse 59, 8200 # Schaffhausen, Switzerland. VZNETCFG='/etc/vz/vznet.conf' +OVSCTL='ovs-vsctl' [ -f "$VZNETCFG" ] && . "$VZNETCFG" @@ -74,9 +75,9 @@ addif() set Interface $iface external-ids:iface-id=$IFACEID -- \ set Interface $iface external-ids:attached-mac=${MAC} -- \ set Interface $iface external-ids:vm-id=${VEID}" - ovs-vsctl $args + ${OVSCTL} $args else - brctl addif "$br" "$iface" + ip link set "$iface" master "$br" fi if [ $? -ne 0 ]; then echo "Unable to attach $iface to bridge $br/$2" @@ -92,11 +93,11 @@ delif() local br if [ "$VPORT_TYPE" = "ovs" ]; then - ovs-vsctl --if-exists del-port "$iface" + ${OVSCTL} --if-exists del-port "$iface" fi for br in `ls -1 /sys/class/net`; do [ -d /sys/class/net/$br/bridge ] || continue - brctl show $br | grep -w $iface && brctl delif $br $iface + ip -br link show master "$br" | grep -w "$iface" && ip link set "$iface" nomaster done }