From c5c562bc6c720675714000ab1fa4e6fc748ff564 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Apr 29 2020 20:30:41 +0000 Subject: [PATCH 1/2] Use symlink instead of pip3 install which isn't always working as desired Basically pip3 install doesn't like being run as root but if it's not run as root it doesn't quite work because it runs into permission error. So instead, let's just have a symlink that will make pagure available in the python path. We're also creating a symlink to ensure /usr/bin/python exists (and it will be python3) since hooks are relying on it. Signed-off-by: Pierre-Yves Chibon --- diff --git a/dev/ansible/roles/pagure-dev/tasks/main.yml b/dev/ansible/roles/pagure-dev/tasks/main.yml index 91bbf2c..103d73e 100644 --- a/dev/ansible/roles/pagure-dev/tasks/main.yml +++ b/dev/ansible/roles/pagure-dev/tasks/main.yml @@ -58,10 +58,17 @@ - redhat-rpm-config state: latest -- name: Install pagure for dev - command: pip3 install -e . - args: - chdir: "/srv/pagure/" +- name: Create symbolic link for pagure to be in the python path + file: + src: /srv/pagure + dest: /usr/local/lib/python3.7/site-packages/pagure + state: link + +- name: Create symbolic link for python to be py3 by default + file: + src: /usr/bin/python3 + dest: /usr/bin/python + state: link # Add various helpful configuration files - name: Install a custom bashrc From 6b4f67d44b20d040eaa4f6a90fe2b131fd9b737e Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Apr 29 2020 20:30:41 +0000 Subject: [PATCH 2/2] Ensure aclchecker and keyhelper can work with APP_URL having a trailing slash And for the sake of it, adjust the default pagure configuration file in the vagrant environment. Signed-off-by: Pierre-Yves Chibon --- diff --git a/dev/ansible/roles/pagure-dev/files/pagure.cfg b/dev/ansible/roles/pagure-dev/files/pagure.cfg index 00cca58..3ca257d 100644 --- a/dev/ansible/roles/pagure-dev/files/pagure.cfg +++ b/dev/ansible/roles/pagure-dev/files/pagure.cfg @@ -30,7 +30,7 @@ ADMIN_GROUP = ['sysadmin-main'] PAGURE_ADMIN_USERS = [] ### The URL at which the project is available. -APP_URL = 'http://127.0.0.1:5000/' +APP_URL = 'http://127.0.0.1:5000' ### The URL at which the documentation of projects will be available ## This should be in a different domain to avoid XSS issues since we want ## to allow raw html to be displayed (different domain, ie not a sub-domain). diff --git a/files/aclchecker.py b/files/aclchecker.py index ee5cb01..9592845 100644 --- a/files/aclchecker.py +++ b/files/aclchecker.py @@ -64,8 +64,8 @@ if gitdir[0] == "/": if not gitdir.endswith(".git"): gitdir = gitdir + ".git" - -url = "%s/pv/ssh/checkaccess/" % pagure_config["APP_URL"] +pagure_url = pagure_config["APP_URL"].rstrip("/") +url = "%s/pv/ssh/checkaccess/" % pagure_url data = {"gitdir": gitdir, "username": remoteuser} headers = {} if pagure_config.get("SSH_ADMIN_TOKEN"): diff --git a/files/keyhelper.py b/files/keyhelper.py index c949c10..67e244e 100644 --- a/files/keyhelper.py +++ b/files/keyhelper.py @@ -61,7 +61,8 @@ if not username_lookup: sys.exit(0) -url = "%s/pv/ssh/lookupkey/" % pagure_config["APP_URL"] +pagure_url = pagure_config["APP_URL"].rstrip("/") +url = "%s/pv/ssh/lookupkey/" % pagure_url data = {"search_key": fingerprint} if username_lookup: data["username"] = username