Commit e8022bef authored by Vitaly Kuznetsov's avatar Vitaly Kuznetsov Committed by Iustin Pop
Browse files

Avoid absolute path for privileged commands

Using absolute path for a privileged command is a bad idea as this path may vary.
For example /usr/sbin/brctl in Debian and /sbin/brctl in ALTLinux. Using $PATH is
a better idea.
Signed-off-by: default avatarVitaly Kuznetsov <>
Reviewed-by: default avatarIustin Pop <>
Signed-off-by: default avatarIustin Pop <>
parent b9a6d720
......@@ -183,6 +183,7 @@ class KVMHypervisor(hv_base.BaseHypervisor):
script = StringIO()
script.write("# this is autogenerated by Ganeti, please do not edit\n#\n")
script.write("export INSTANCE=%s\n" %
script.write("export MAC=%s\n" % nic.mac)
if nic.ip:
......@@ -198,21 +199,21 @@ class KVMHypervisor(hv_base.BaseHypervisor):
script.write(" # Execute the user-specific vif file\n")
script.write(" %s\n" % self._KVM_NETWORK_SCRIPT)
script.write(" /sbin/ifconfig $INTERFACE up\n")
script.write(" ifconfig $INTERFACE up\n")
if nic.nicparams[constants.NIC_MODE] == constants.NIC_MODE_BRIDGED:
script.write(" # Connect the interface to the bridge\n")
script.write(" /usr/sbin/brctl addif $BRIDGE $INTERFACE\n")
script.write(" brctl addif $BRIDGE $INTERFACE\n")
elif nic.nicparams[constants.NIC_MODE] == constants.NIC_MODE_ROUTED:
if not nic.ip:
raise errors.HypervisorError("nic/%d is routed, but has no ip." % seq)
script.write(" # Route traffic targeted at the IP to the interface\n")
if nic.nicparams[constants.NIC_LINK]:
script.write(" while /sbin/ip rule del dev $INTERFACE; do :; done\n")
script.write(" /sbin/ip rule add dev $INTERFACE table $LINK\n")
script.write(" /sbin/ip route replace $IP table $LINK proto static"
script.write(" while ip rule del dev $INTERFACE; do :; done\n")
script.write(" ip rule add dev $INTERFACE table $LINK\n")
script.write(" ip route replace $IP table $LINK proto static"
" dev $INTERFACE\n")
script.write(" /sbin/ip route replace $IP proto static"
script.write(" ip route replace $IP proto static"
" dev $INTERFACE\n")
interface_v4_conf = "/proc/sys/net/ipv4/conf/$INTERFACE"
interface_v6_conf = "/proc/sys/net/ipv6/conf/$INTERFACE"
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment