From c852833d2eccf543233a72080ef59d5d9791a7eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arnau=20V=C3=A0zquez=20Palma?= Date: Wed, 21 Oct 2020 15:56:45 +0200 Subject: [PATCH 01/10] =?UTF-8?q?It=20gets=20worse=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitlab-ci.yml | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 .gitlab-ci.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 00000000..d05a95f2 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,30 @@ + +# This file is a template, and might need editing before it works on your project. +docker-build-master: + # Official docker image. + image: docker:latest + stage: build + services: + - docker:dind + before_script: + - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY + script: + - docker build --pull -t "$CI_REGISTRY_IMAGE" . + - docker push "$CI_REGISTRY_IMAGE" + only: + - master + +docker-build: + # Official docker image. + image: docker:latest + stage: build + services: + - docker:dind + before_script: + - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY + script: + - docker build --pull -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" . + - docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" + except: + - master + -- GitLab From 1c09b8dd873cd7c2d18867534e9ceb22db2df1f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arnau=20V=C3=A0zquez=20Palma?= Date: Wed, 21 Oct 2020 16:06:07 +0200 Subject: [PATCH 02/10] hello world --- Dockerfile | 3 +++ files/helloworld.txt | 1 + 2 files changed, 4 insertions(+) create mode 100644 Dockerfile create mode 100644 files/helloworld.txt diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..ef9f482a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,3 @@ +FROM nextcloud:18-fpm +RUN mkdir -p /var/www/skeleton/{Documents,Images} +COPY files/helloworld.txt /var/www/skeleton/Documents/ diff --git a/files/helloworld.txt b/files/helloworld.txt new file mode 100644 index 00000000..1385f264 --- /dev/null +++ b/files/helloworld.txt @@ -0,0 +1 @@ +hey -- GitLab From 6d4bb115441f1fe73e7a711f206cb08759b0bb32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arnau=20V=C3=A0zquez=20Palma?= Date: Wed, 21 Oct 2020 16:15:18 +0200 Subject: [PATCH 03/10] Closer to what we use so far --- .gitlab-ci.yml | 29 ++++++++--------------------- 1 file changed, 8 insertions(+), 21 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d05a95f2..6aa4d39b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,30 +1,17 @@ +docker-build: + image: docker:stable + + # When using dind, it's wise to use the overlayfs driver for + # improved performance. + variables: + DOCKER_DRIVER: overlay2 -# This file is a template, and might need editing before it works on your project. -docker-build-master: - # Official docker image. - image: docker:latest - stage: build services: - docker:dind before_script: - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY - script: - - docker build --pull -t "$CI_REGISTRY_IMAGE" . - - docker push "$CI_REGISTRY_IMAGE" - only: - - master -docker-build: - # Official docker image. - image: docker:latest stage: build - services: - - docker:dind - before_script: - - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY script: - docker build --pull -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" . - - docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" - except: - - master - + - docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" \ No newline at end of file -- GitLab From 5385503650324263f1573c3902524033c7513efc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arnau=20V=C3=A0zquez?= Date: Wed, 21 Oct 2020 15:14:19 +0000 Subject: [PATCH 04/10] Use privileged runners --- .gitlab-ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6aa4d39b..6546d51a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -10,8 +10,9 @@ docker-build: - docker:dind before_script: - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY - stage: build + tags: + - generic_privileged script: - docker build --pull -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" . - docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" \ No newline at end of file -- GitLab From 57aab7c0fcc10254bc85d769f3071d3bb9e71b1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arnau=20V=C3=A0zquez=20Palma?= Date: Wed, 21 Oct 2020 18:06:14 +0200 Subject: [PATCH 05/10] First patch --- .gitignore | 1 + Dockerfile | 5 +++-- files/helloworld.txt | 1 - patches/001-login-without-domain.patch | 14 ++++++++++++++ 4 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 .gitignore delete mode 100644 files/helloworld.txt create mode 100644 patches/001-login-without-domain.patch diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..723ef36f --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index ef9f482a..9997549b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,3 +1,4 @@ FROM nextcloud:18-fpm -RUN mkdir -p /var/www/skeleton/{Documents,Images} -COPY files/helloworld.txt /var/www/skeleton/Documents/ +RUN mkdir -p /var/www/skeleton/Documents && mkdir -p /var/www/skeleton/Images +COPY patches/ /tmp/build_patches/ +RUN patch -u /usr/src/nextcloud/core/Controller/LoginController.php -i /tmp/build_patches/001-login-without-domain.patch \ No newline at end of file diff --git a/files/helloworld.txt b/files/helloworld.txt deleted file mode 100644 index 1385f264..00000000 --- a/files/helloworld.txt +++ /dev/null @@ -1 +0,0 @@ -hey diff --git a/patches/001-login-without-domain.patch b/patches/001-login-without-domain.patch new file mode 100644 index 00000000..71157f73 --- /dev/null +++ b/patches/001-login-without-domain.patch @@ -0,0 +1,14 @@ +--- LoginController.original.php 2020-10-21 17:32:18.000000000 +0200 ++++ LoginController.php 2020-10-21 18:03:51.000000000 +0200 +@@ -289,6 +289,11 @@ + return $this->generateRedirect($redirect_url); + } + ++ $user = trim($user); ++ if (stristr($user, '@eeo.one') === FALSE) { ++ $user = $user . '@eeo.one'; ++ } ++ + $data = new LoginData( + $this->request, + trim($user), -- GitLab From b0a199c073c365718e32b19e3f30b805e1acb793 Mon Sep 17 00:00:00 2001 From: akhil Date: Thu, 3 Dec 2020 18:12:50 +0530 Subject: [PATCH 06/10] Replaced 'eeo.one' with DOMAIN env variable --- patches/001-login-without-domain.patch | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/patches/001-login-without-domain.patch b/patches/001-login-without-domain.patch index 71157f73..8cd9a801 100644 --- a/patches/001-login-without-domain.patch +++ b/patches/001-login-without-domain.patch @@ -5,8 +5,10 @@ } + $user = trim($user); -+ if (stristr($user, '@eeo.one') === FALSE) { -+ $user = $user . '@eeo.one'; ++ $domain = $_ENV["DOMAIN"]; ++ $domain_suffix = "@$domain"; ++ if (stristr($user, $domain_suffix) === FALSE) { ++ $user = $user . $domain_suffix; + } + $data = new LoginData( -- GitLab From 9f95a394dbb7381e5069eb34d55316fd8054b333 Mon Sep 17 00:00:00 2001 From: akhil Date: Thu, 3 Dec 2020 18:15:24 +0530 Subject: [PATCH 07/10] Indentation fix --- patches/001-login-without-domain.patch | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/patches/001-login-without-domain.patch b/patches/001-login-without-domain.patch index 8cd9a801..09705ffe 100644 --- a/patches/001-login-without-domain.patch +++ b/patches/001-login-without-domain.patch @@ -5,8 +5,8 @@ } + $user = trim($user); -+ $domain = $_ENV["DOMAIN"]; -+ $domain_suffix = "@$domain"; ++ $domain = $_ENV["DOMAIN"]; ++ $domain_suffix = "@$domain"; + if (stristr($user, $domain_suffix) === FALSE) { + $user = $user . $domain_suffix; + } -- GitLab From bb38506246d4ad1eab6f7a2d2b2c669ad756d1df Mon Sep 17 00:00:00 2001 From: akhil Date: Thu, 3 Dec 2020 18:43:14 +0530 Subject: [PATCH 08/10] added correct line coordinate --- patches/001-login-without-domain.patch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/patches/001-login-without-domain.patch b/patches/001-login-without-domain.patch index 09705ffe..bd09f509 100644 --- a/patches/001-login-without-domain.patch +++ b/patches/001-login-without-domain.patch @@ -1,6 +1,6 @@ --- LoginController.original.php 2020-10-21 17:32:18.000000000 +0200 +++ LoginController.php 2020-10-21 18:03:51.000000000 +0200 -@@ -289,6 +289,11 @@ +@@ -289,6 +289,13 @@ return $this->generateRedirect($redirect_url); } -- GitLab From 7548180aae4ca193aa63a2b583e44cf800399354 Mon Sep 17 00:00:00 2001 From: akhil Date: Fri, 4 Dec 2020 12:23:37 +0530 Subject: [PATCH 09/10] Patch modified to check email suffix from config --- patches/001-login-without-domain.patch | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/patches/001-login-without-domain.patch b/patches/001-login-without-domain.patch index bd09f509..bd0619a5 100644 --- a/patches/001-login-without-domain.patch +++ b/patches/001-login-without-domain.patch @@ -1,13 +1,14 @@ --- LoginController.original.php 2020-10-21 17:32:18.000000000 +0200 +++ LoginController.php 2020-10-21 18:03:51.000000000 +0200 -@@ -289,6 +289,13 @@ +@@ -289,6 +289,14 @@ return $this->generateRedirect($redirect_url); } + $user = trim($user); -+ $domain = $_ENV["DOMAIN"]; ++ $domain = $this->config->getSystemValue("mail_domain"); + $domain_suffix = "@$domain"; -+ if (stristr($user, $domain_suffix) === FALSE) { ++ $admin_username = $_ENV["NEXTCLOUD_ADMIN_USER"]; ++ if (stristr($user, $domain_suffix) === FALSE && strcmp($user, $admin_username) != 0) { + $user = $user . $domain_suffix; + } + -- GitLab From 903b12a9534c2bba98d3a3f53d78e7c72eb10c63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arnau=20V=C3=A0zquez=20Palma?= Date: Fri, 4 Dec 2020 11:05:01 +0100 Subject: [PATCH 10/10] Bump version to force copying our changes --- .gitignore | 3 ++- Dockerfile | 3 ++- patches/001-version-bump.patch | 9 +++++++++ ...thout-domain.patch => 002-login-without-domain.patch} | 0 4 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 patches/001-version-bump.patch rename patches/{001-login-without-domain.patch => 002-login-without-domain.patch} (100%) diff --git a/.gitignore b/.gitignore index 723ef36f..d6588b0e 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -.idea \ No newline at end of file +.idea +files diff --git a/Dockerfile b/Dockerfile index 9997549b..3702a477 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,5 @@ FROM nextcloud:18-fpm RUN mkdir -p /var/www/skeleton/Documents && mkdir -p /var/www/skeleton/Images COPY patches/ /tmp/build_patches/ -RUN patch -u /usr/src/nextcloud/core/Controller/LoginController.php -i /tmp/build_patches/001-login-without-domain.patch \ No newline at end of file +RUN patch -u /usr/src/nextcloud/version.php -i /tmp/build_patches/001-version-bump.patch && \ + patch -u /usr/src/nextcloud/core/Controller/LoginController.php -i /tmp/build_patches/002-login-without-domain.patch diff --git a/patches/001-version-bump.patch b/patches/001-version-bump.patch new file mode 100644 index 00000000..412ab435 --- /dev/null +++ b/patches/001-version-bump.patch @@ -0,0 +1,9 @@ +--- version.original.php 2020-12-04 10:55:45.000000000 +0100 ++++ version.php 2020-12-04 10:56:09.000000000 +0100 +@@ -1,5 +1,5 @@ +