← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/lp-codeimport:charm-storage-home-dir-ownership into lp-codeimport:master

 

Colin Watson has proposed merging ~cjwatson/lp-codeimport:charm-storage-home-dir-ownership into lp-codeimport:master.

Commit message:
charm/lp-codeimport-storage: Fix ownership of /home/importd

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/lp-codeimport/+git/lp-codeimport/+merge/439954
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/lp-codeimport:charm-storage-home-dir-ownership into lp-codeimport:master.
diff --git a/charm/lp-codeimport-storage/reactive/lp-codeimport-storage.py b/charm/lp-codeimport-storage/reactive/lp-codeimport-storage.py
index 5be4349..99ceb26 100644
--- a/charm/lp-codeimport-storage/reactive/lp-codeimport-storage.py
+++ b/charm/lp-codeimport-storage/reactive/lp-codeimport-storage.py
@@ -46,13 +46,11 @@ def configure():
     host.add_group("importd")
     host.adduser("importd", primary_group="importd")
     for directory in ("/srv/importd/sources", "/srv/importd/www"):
-        if not os.path.exists(directory):
-            host.mkdir(
-                directory, owner="importd", group="importd", perms=0o755
-            )
-    ssh_dir = "/home/importd/.ssh"
-    if not os.path.exists(ssh_dir):
-        host.mkdir(ssh_dir, owner="importd", group="importd", perms=0o700)
+        host.mkdir(directory, owner="importd", group="importd", perms=0o755)
+    home_dir = "/home/importd"
+    host.mkdir(home_dir, owner="importd", group="importd", perms=0o755)
+    ssh_dir = os.path.join(home_dir, ".ssh")
+    host.mkdir(ssh_dir, owner="importd", group="importd", perms=0o700)
     config = dict(hookenv.config())
     config["codeimport_subnets"] = codeimport_storage.get_codeimport_subnets()
     config["public_ssh_key"] = base64.b64decode(