blob: 23404da627b9f2385d6b1a26c2f5991061745756 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
Index: wa-new/waagent
===================================================================
--- wa-new.orig/waagent 2012-11-14 11:06:12.227371000 -0700
+++ wa-new/waagent 2012-11-14 11:07:53.093401274 -0700
@@ -2262,7 +2262,26 @@
Run("rm -f " + a + "/*")
# Clear LibDir, remove nameserver and root bash history
- for f in os.listdir(LibDir) + ["/etc/resolv.conf", "/root/.bash_history", "/var/log/waagent.log"]:
+ fileBlackList = [ "/root/.bash_history", "/var/log/waagent.log" ]
+
+ if IsUbuntu():
+ # Ubuntu uses resolv.conf by default, so removing /etc/resolv.conf will
+ # break resolvconf. Therefore, we check to see if resolvconf is in use,
+ # and if so, we remove the resolvconf artifacts.
+
+ if os.path.realpath('/etc/resolv.conf') != '/run/resolvconf/resolv.conf':
+ Log("resolvconf is not configured. Removing /etc/resolv.conf")
+ fileBlackList.append('/etc/resolv.conf')
+ else:
+ Log("resolvconf is enabled; leaving /etc/resolv.conf intact")
+ resolvConfD = '/etc/resolvconf/resolv.conf.d/'
+ fileBlackList.extend([resolvConfD + 'tail', resolvConfD + 'originial' ])
+ else:
+ fileBlackList.append(os.listdir(LibDir) + '/etc/resolv.conf')
+
+
+ # Clear LibDir, remove nameserver and root bash history
+ for f in os.listdir(LibDir) + fileBlackList:
try:
os.remove(f)
except:
|