Skip to content

Commit

Permalink
Merge branch 'lmConfigEditorJson' into experimental
Browse files Browse the repository at this point in the history
  • Loading branch information
guimard committed Aug 18, 2024
2 parents a416bf2 + 0017b5d commit 62a5a8c
Show file tree
Hide file tree
Showing 8 changed files with 132 additions and 21 deletions.
32 changes: 16 additions & 16 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ jobs:
with:
context: ./portal
build-args: |
"BASE=yadd/lemonldap-ng-base:experimental"
BASE=yadd/lemonldap-ng-base:experimental
platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6,linux/s390x
push: true
tags: |
Expand Down Expand Up @@ -177,7 +177,7 @@ jobs:
with:
context: ./uwsgi-portal
build-args: |
"BASE=yadd/lemonldap-ng-base:experimental"
BASE=yadd/lemonldap-ng-base:experimental
platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6,linux/s390x
push: true
tags: |
Expand Down Expand Up @@ -211,7 +211,7 @@ jobs:
with:
context: ./cron
build-args: |
"BASE=yadd/lemonldap-ng-base:experimental"
BASE=yadd/lemonldap-ng-base:experimental
platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6,linux/s390x
push: true
tags: |
Expand Down Expand Up @@ -255,7 +255,7 @@ jobs:
with:
context: ./cron-task
build-args: |
"BASE=yadd/lemonldap-ng-base:experimental"
BASE=yadd/lemonldap-ng-base:experimental
platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6,linux/s390x
push: true
tags: |
Expand Down Expand Up @@ -299,7 +299,7 @@ jobs:
with:
context: ./sessions-backup
build-args: |
"BASE=yadd/lemonldap-ng-base:experimental"
BASE=yadd/lemonldap-ng-base:experimental
platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6,linux/s390x
push: true
tags: |
Expand Down Expand Up @@ -343,7 +343,7 @@ jobs:
with:
context: ./manager
build-args: |
"BASE=yadd/lemonldap-ng-base:experimental"
BASE=yadd/lemonldap-ng-base:experimental
platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6,linux/s390x
push: true
tags: |
Expand Down Expand Up @@ -387,7 +387,7 @@ jobs:
with:
context: ./full
build-args: |
"PORTALBASE=yadd/lemonldap-ng-portal:experimental"
PORTALBASE=yadd/lemonldap-ng-portal:experimental
platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6,linux/s390x
push: true
tags: |
Expand Down Expand Up @@ -431,7 +431,7 @@ jobs:
with:
context: ./ssoaas-fastcgi-server
build-args: |
"BASE=yadd/lemonldap-ng-base:experimental"
BASE=yadd/lemonldap-ng-base:experimental
platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6,linux/s390x
push: true
tags: |
Expand Down Expand Up @@ -507,7 +507,7 @@ jobs:
with:
context: ./portal
build-args: |
"BASE=yadd/lemonldap-ng-base:experimental-no-s6"
BASE=yadd/lemonldap-ng-base:experimental-no-s6
platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6,linux/s390x
push: true
tags: |
Expand Down Expand Up @@ -541,7 +541,7 @@ jobs:
with:
context: ./uwsgi-portal
build-args: |
"BASE=yadd/lemonldap-ng-base:experimental-no-s6"
BASE=yadd/lemonldap-ng-base:experimental-no-s6
platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6,linux/s390x
push: true
tags: |
Expand Down Expand Up @@ -575,7 +575,7 @@ jobs:
with:
context: ./cron
build-args: |
"BASE=yadd/lemonldap-ng-base:experimental-no-s6"
BASE=yadd/lemonldap-ng-base:experimental-no-s6
platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6,linux/s390x
push: true
tags: |
Expand Down Expand Up @@ -609,7 +609,7 @@ jobs:
with:
context: ./cron-task
build-args: |
"BASE=yadd/lemonldap-ng-base:experimental-no-s6"
BASE=yadd/lemonldap-ng-base:experimental-no-s6
platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6,linux/s390x
push: true
tags: |
Expand Down Expand Up @@ -643,7 +643,7 @@ jobs:
with:
context: ./sessions-backup
build-args: |
"BASE=yadd/lemonldap-ng-base:experimental-no-s6"
BASE=yadd/lemonldap-ng-base:experimental-no-s6
platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6,linux/s390x
push: true
tags: |
Expand Down Expand Up @@ -677,7 +677,7 @@ jobs:
with:
context: ./manager
build-args: |
"BASE=yadd/lemonldap-ng-base:experimental-no-s6"
BASE=yadd/lemonldap-ng-base:experimental-no-s6
platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6,linux/s390x
push: true
tags: |
Expand Down Expand Up @@ -711,7 +711,7 @@ jobs:
with:
context: ./full
build-args: |
"PORTALBASE=yadd/lemonldap-ng-portal:experimental-no-s6"
PORTALBASE=yadd/lemonldap-ng-portal:experimental-no-s6
platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6,linux/s390x
push: true
tags: |
Expand Down Expand Up @@ -745,7 +745,7 @@ jobs:
with:
context: ./ssoaas-fastcgi-server
build-args: |
"BASE=yadd/lemonldap-ng-base:experimental-no-s6"
BASE=yadd/lemonldap-ng-base:experimental-no-s6
platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6,linux/s390x
push: true
tags: |
Expand Down
7 changes: 4 additions & 3 deletions Changes.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# Changes

* 2024-08-14: add message-broker
* 2024-08-16(v2.19.1-3):
* add `TLS_CERT_FILE` and `TLS_KEY_FILE` variables (v2.19.1-3)
* 2024-08-18: add --json option to lmConfigEditor
* 2024-08-18: add message-broker
* 2024-08-18(v2.19.1-3):
* add `TLS_CERT_FILE` and `TLS_KEY_FILE` variables
* preserve requests in RELAY
* 2024-08-14: add RELAY variable (v2.19.1-2)
* 2024-08-13: add reCaptcha plugin
Expand Down
1 change: 1 addition & 0 deletions full/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ RUN \
echo patch crowdsec.patch && patch -p1 < crowdsec.patch && \
echo patch recaptcha.patch && patch -p1 < recaptcha.patch && \
echo patch msg-broker.patch && patch -p1 < msg-broker.patch && \
echo patch lmConfigEditor.patch && patch -p1 < lmConfigEditor.patch && \
rm -f *.patch && \
LLNG_DEFAULTCONFFILE=/etc/lemonldap-ng/lemonldap-ng.ini \
perl -MLemonldap::NG::Manager::Build -e 'Lemonldap::NG::Manager::Build->run( \
Expand Down
55 changes: 55 additions & 0 deletions full/lmConfigEditor.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
--- a/usr/share/lemonldap-ng/bin/lmConfigEditor
+++ b/usr/share/lemonldap-ng/bin/lmConfigEditor
@@ -18,10 +18,12 @@ my $cli = Lemonldap::NG::Manager::Cli::Lib->new;

our $opt_user = 'www-data';
our $opt_group = 'www-data';
+our $opt_json;

GetOptions(
"user=s" => \$opt_user,
- "group=s" => \$opt_group
+ "group=s" => \$opt_group,
+ "json" => \$opt_json,
) or die("Error in command line arguments\n");

eval {
@@ -45,10 +47,17 @@ delete $refConf->{cfgAuthorIP};
delete $refConf->{cfgDate};
$refConf->{cfgLog} = '';

-# Sort keys
-$Data::Dumper::Sortkeys = 1;
-$Data::Dumper::Useperl = 1;
-my $tmp = Dumper($refConf);
+my $tmp;
+if ($opt_json) {
+ require JSON;
+ $tmp = JSON->new->pretty->canonical->encode($refConf);
+}
+else {
+ # Sort keys
+ $Data::Dumper::Sortkeys = 1;
+ $Data::Dumper::Useperl = 1;
+ $tmp = Dumper($refConf);
+}

my $refFile = File::Temp->new( UNLINK => 1 );
my $editFile = File::Temp->new( UNLINK => 1 );
@@ -73,8 +82,14 @@ if ( $rc == 0 and compare( $refFile->filename, $editFile->filename ) == 1 ) {
my $buf = join( '', <$F1> );
close $F1;

- my $newConf = Safe->new->reval($buf);
- die $EVAL_ERROR if $EVAL_ERROR;
+ my $newConf;
+ if ($opt_json) {
+ $newConf = JSON::from_json($buf);
+ }
+ else {
+ $newConf = Safe->new->reval($buf);
+ die $EVAL_ERROR if $EVAL_ERROR;
+ }

# Update author and date
$newConf->{cfgAuthor} =
1 change: 1 addition & 0 deletions manager/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ RUN \
echo patch crowdsec.patch && patch -p1 < crowdsec.patch && \
echo patch recaptcha.patch && patch -p1 < recaptcha.patch && \
echo patch msg-broker.patch && patch -p1 < msg-broker.patch && \
echo patch lmConfigEditor.patch && patch -p1 < lmConfigEditor.patch && \
rm -f *.patch && \
LLNG_DEFAULTCONFFILE=/etc/lemonldap-ng/lemonldap-ng.ini \
perl -MLemonldap::NG::Manager::Build -e 'Lemonldap::NG::Manager::Build->run( \
Expand Down
55 changes: 55 additions & 0 deletions manager/lmConfigEditor.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
--- a/usr/share/lemonldap-ng/bin/lmConfigEditor
+++ b/usr/share/lemonldap-ng/bin/lmConfigEditor
@@ -18,10 +18,12 @@ my $cli = Lemonldap::NG::Manager::Cli::Lib->new;

our $opt_user = 'www-data';
our $opt_group = 'www-data';
+our $opt_json;

GetOptions(
"user=s" => \$opt_user,
- "group=s" => \$opt_group
+ "group=s" => \$opt_group,
+ "json" => \$opt_json,
) or die("Error in command line arguments\n");

eval {
@@ -45,10 +47,17 @@ delete $refConf->{cfgAuthorIP};
delete $refConf->{cfgDate};
$refConf->{cfgLog} = '';

-# Sort keys
-$Data::Dumper::Sortkeys = 1;
-$Data::Dumper::Useperl = 1;
-my $tmp = Dumper($refConf);
+my $tmp;
+if ($opt_json) {
+ require JSON;
+ $tmp = JSON->new->pretty->canonical->encode($refConf);
+}
+else {
+ # Sort keys
+ $Data::Dumper::Sortkeys = 1;
+ $Data::Dumper::Useperl = 1;
+ $tmp = Dumper($refConf);
+}

my $refFile = File::Temp->new( UNLINK => 1 );
my $editFile = File::Temp->new( UNLINK => 1 );
@@ -73,8 +82,14 @@ if ( $rc == 0 and compare( $refFile->filename, $editFile->filename ) == 1 ) {
my $buf = join( '', <$F1> );
close $F1;

- my $newConf = Safe->new->reval($buf);
- die $EVAL_ERROR if $EVAL_ERROR;
+ my $newConf;
+ if ($opt_json) {
+ $newConf = JSON::from_json($buf);
+ }
+ else {
+ $newConf = Safe->new->reval($buf);
+ die $EVAL_ERROR if $EVAL_ERROR;
+ }

# Update author and date
$newConf->{cfgAuthor} =
1 change: 0 additions & 1 deletion portal/haproxy

This file was deleted.

1 change: 0 additions & 1 deletion uwsgi-portal/haproxy

This file was deleted.

0 comments on commit 62a5a8c

Please sign in to comment.