Исправлено определение dhcp.

master3.3
Mike Hiretsky 11 years ago
parent 5e7782d26e
commit 928033c111

@ -15,7 +15,7 @@
# limitations under the License.
from files import ( process, checkUtils, readFile, listDirectory,readLinesFile,
getRunCommands )
getRunCommands, getProgPath )
import sys,os
import re
import struct,fcntl,socket,math,ctypes
@ -158,11 +158,23 @@ def isIpInNet(checkip,*ipnets):
def isDhcpIp(interface="eth0"):
"""Get ip by dhcp or static"""
# dhclients (dhcpcd, dhclient (dhcp), udhcpc (busybox)
commands = getRunCommands()
dhcpProgs = ("dhcpcd","dhclient","udhcpc")
if filter(lambda x:interface in x and any(prog in x for prog in dhcpProgs),
getRunCommands()):
commands):
return True
else:
# если запущен демон dhcpcd
if filter(lambda x:"dhcpcd\x00-q" in x,commands):
curIp = getIp(interface)
dhcpcd = getProgPath('/sbin/dhcpcd')
leaseIp = \
map(lambda x:x.group(1),
filter(None,
map(re.compile('^ip_address=(.*)$').search,
process(dhcpcd,'-U',interface))))
if not curIp or leaseIp and leaseIp[0] == curIp:
return True
return False
def getRouteTable(onlyIface=[]):

Loading…
Cancel
Save