fix permissions on initial install

running installer as root allows some file ownership from the archive to be set as a user other than root
This commit is contained in:
Min RK
2018-07-19 00:02:15 -07:00
parent 680206813f
commit bcf31a979c
2 changed files with 18 additions and 7 deletions

View File

@@ -76,6 +76,13 @@ def install_miniconda(installer_path, prefix):
'-u', '-b',
'-p', prefix
], stderr=subprocess.STDOUT)
# fix permissions on initial install
# a few files have the wrong ownership and permissions initially
# when the installer is run as root
subprocess.check_call(
["chown", "-R", "{}:{}".format(os.getuid(), os.getgid()), prefix]
)
subprocess.check_call(["chmod", "-R", "o-w", prefix])
def pip_install(prefix, packages, editable=False):

View File

@@ -1,15 +1,16 @@
import sys
import argparse
import os
import tljh.systemd as systemd
import tljh.conda as conda
import secrets
import subprocess
import sys
import time
from urllib.error import HTTPError
from urllib.request import urlopen, URLError
from tljh import user
import secrets
import argparse
import time
from ruamel.yaml import YAML
from tljh import conda, systemd, user
INSTALL_PREFIX = os.environ.get('TLJH_INSTALL_PREFIX', '/opt/tljh')
HUB_ENV_PREFIX = os.path.join(INSTALL_PREFIX, 'hub')
USER_ENV_PREFIX = os.path.join(INSTALL_PREFIX, 'user')
@@ -193,6 +194,9 @@ def main():
ensure_usergroups()
ensure_user_environment(args.user_requirements_txt_url)
# Weird setuptools issue creates a few world-writable metadata files.
# Fix it:
subprocess.check_call(["chmod", "-R", "o-w", os.path.join(HUB_ENV_PREFIX, "pkgs")])
print("Setting up JupyterHub...")
ensure_jupyterhub_package(HUB_ENV_PREFIX)