Browse code

Basic check for homedir permissions

Several guides suggest using data directories under your homedir,
rather than the default /opt area. This is fine, but on RHEL6 and
similar distros homedirs are very restrictive 0700 permissions which
doesn't allow things like httpd to pass through to serve up files.

Even though stack.sh is taking over the host, changing permissions
automatically is not a nice idea. So we just warn when it looks like
this is happening.

Change-Id: I9cd70e7fe90638a2a5c3b8fd94756afacac7c7be

Ian Wienand authored on 2013/04/11 11:04:36
Showing 2 changed files
... ...
@@ -1411,6 +1411,35 @@ function get_pip_command() {
1411 1411
     fi
1412 1412
 }
1413 1413
 
1414
+# Path permissions sanity check
1415
+# check_path_perm_sanity path
1416
+function check_path_perm_sanity() {
1417
+    # Ensure no element of the path has 0700 permissions, which is very
1418
+    # likely to cause issues for daemons.  Inspired by default 0700
1419
+    # homedir permissions on RHEL and common practice of making DEST in
1420
+    # the stack user's homedir.
1421
+
1422
+    local real_path=$(readlink -f $1)
1423
+    local rebuilt_path=""
1424
+    for i in $(echo ${real_path} | tr "/" " "); do
1425
+        rebuilt_path=$rebuilt_path"/"$i
1426
+
1427
+        if [[ $(stat -c '%a' ${rebuilt_path}) = 700 ]]; then
1428
+            echo "*** DEST path element"
1429
+            echo "***    ${rebuilt_path}"
1430
+            echo "*** appears to have 0700 permissions."
1431
+            echo "*** This is very likely to cause fatal issues for devstack daemons."
1432
+
1433
+            if [[ -n "$SKIP_PATH_SANITY" ]]; then
1434
+                return
1435
+            else
1436
+                echo "*** Set SKIP_PATH_SANITY to skip this check"
1437
+                die $LINENO "Invalid path permissions"
1438
+            fi
1439
+        fi
1440
+    done
1441
+}
1442
+
1414 1443
 # Restore xtrace
1415 1444
 $XTRACE
1416 1445
 
... ...
@@ -199,6 +199,9 @@ fi
199 199
 sudo mkdir -p $DEST
200 200
 sudo chown -R $STACK_USER $DEST
201 201
 
202
+# a basic test for $DEST path permissions (fatal on error unless skipped)
203
+check_path_perm_sanity ${DEST}
204
+
202 205
 # Set ``OFFLINE`` to ``True`` to configure ``stack.sh`` to run cleanly without
203 206
 # Internet access. ``stack.sh`` must have been previously run with Internet
204 207
 # access to install prerequisites and fetch repositories.