277
277
old_profile.delete()
279
279
raw_lxc_config = [
280
("lxc.aa_profile", "unconfined"),
281
280
("lxc.cap.drop", ""),
282
281
("lxc.cap.drop", "sys_time sys_module"),
283
282
("lxc.cgroup.devices.deny", ""),
284
283
("lxc.cgroup.devices.allow", ""),
285
284
("lxc.mount.auto", ""),
286
285
("lxc.mount.auto", "proc:rw sys:rw"),
287
("lxc.network.0.ipv4", ipv4_address),
288
("lxc.network.0.ipv4.gateway", self.ipv4_network.ip),
288
lxc_version = self._client.host_info["environment"]["driver_version"]
289
major, minor = [int(v) for v in lxc_version.split(".")[0:2]]
292
raw_lxc_config.extend([
293
("lxc.apparmor.profile", "unconfined"),
294
("lxc.net.0.ipv4.address", ipv4_address),
295
("lxc.net.0.ipv4.gateway", self.ipv4_network.ip),
298
raw_lxc_config.extend([
299
("lxc.aa_profile", "unconfined"),
300
("lxc.network.0.ipv4", ipv4_address),
301
("lxc.network.0.ipv4.gateway", self.ipv4_network.ip),
290
304
# Linux 4.4 on powerpc doesn't support all the seccomp bits that LXD
292
306
if self.arch == "powerpc":
296
310
"security.nesting": "true",
297
311
"raw.lxc": "".join(
298
312
"{key}={value}\n".format(key=key, value=value)
299
for key, value in raw_lxc_config),
313
for key, value in sorted(raw_lxc_config)),
341
361
hostname_file.flush()
342
362
os.fchmod(hostname_file.fileno(), 0o644)
343
363
self.copy_in(hostname_file.name, "/etc/hostname")
344
self.copy_in("/etc/resolv.conf", "/etc/resolv.conf")
365
resolv_conf = "/etc/resolv.conf"
367
if os.path.islink(resolv_conf):
368
resolv_conf = os.path.realpath(resolv_conf)
369
if (resolv_conf == "/run/systemd/resolve/stub-resolv.conf" and
370
os.path.isfile("/run/systemd/resolve/resolv.conf")):
371
resolv_conf = "/run/systemd/resolve/resolv.conf"
373
self.copy_in(resolv_conf, "/etc/resolv.conf")
345
375
with tempfile.NamedTemporaryFile(mode="w+") as policy_rc_d_file:
346
376
policy_rc_d_file.write(policy_rc_d)
347
377
policy_rc_d_file.flush()