From 09229996a1556d7514f0228284ba8daaca6ac542 Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Tue, 17 Sep 2013 10:34:20 +0200 Subject: [PATCH] Enable CAS authentication if smeserver-dovecot is installed --- createlinks | 1 + ipasserelle-groupware.spec | 3 ++ root/etc/e-smith/templates/etc/pam.d/dovecot/05cas | 10 +++++ .../templates/etc/pam.d/dovecot/10SystemAuth | 4 ++ .../templates/etc/pam.d/dovecot/template-begin | 8 ++++ .../var/lib/lemonldap-ng/conf/lmConf/060SOGo | 16 +++++++ .../GNUstep/Defaults/.GNUstepDefaults/55authSource | 10 ++++- .../perl5/site_perl/Apache/FilterChangeLength.pm | 52 ++++++++++++++++++++++ 8 files changed, 103 insertions(+), 1 deletion(-) create mode 100644 root/etc/e-smith/templates/etc/pam.d/dovecot/05cas create mode 100644 root/etc/e-smith/templates/etc/pam.d/dovecot/10SystemAuth create mode 100644 root/etc/e-smith/templates/etc/pam.d/dovecot/template-begin create mode 100644 root/etc/e-smith/templates/var/lib/lemonldap-ng/conf/lmConf/060SOGo create mode 100644 root/usr/lib/perl5/site_perl/Apache/FilterChangeLength.pm diff --git a/createlinks b/createlinks index 13d3a8e..039855e 100755 --- a/createlinks +++ b/createlinks @@ -10,6 +10,7 @@ templates2events("/etc/cron.d/sogo-alarm", qw(email-update bootstrap-console-sav templates2events("/var/lib/sogo/GNUstep/Defaults/.GNUstepDefaults", qw(email-update bootstrap-console-save pre-backup)); templates2events("/etc/sysconfig/sogo", qw(email-update bootstrap-console-save)); templates2events("/etc/logrotate.d/sogo", qw(email-update bootstrap-console-save)); +templates2events("/etc/pam.d/dovecot", qw(email-update bootstrap-console-save)); safe_symlink("restart", "root/etc/e-smith/events/email-update/services2adjust/sogod"); safe_symlink("restart", "root/etc/e-smith/events/email-update/services2adjust/memcached-sogo"); diff --git a/ipasserelle-groupware.spec b/ipasserelle-groupware.spec index dace8d5..4ca5503 100644 --- a/ipasserelle-groupware.spec +++ b/ipasserelle-groupware.spec @@ -23,6 +23,9 @@ Requires: sope49-gdl1-mysql Requires: sogo-ealarms-notify Requires: ipasserelle-base Requires: memcached +Requires: ipasserelle-portal +Requires: smeserver-lemonldap-ng >= 0.2.6 +Requires: smeserver-pam_cas Obsoletes: smeserver-sogo Provides: smeserver-sogo diff --git a/root/etc/e-smith/templates/etc/pam.d/dovecot/05cas b/root/etc/e-smith/templates/etc/pam.d/dovecot/05cas new file mode 100644 index 0000000..668824c --- /dev/null +++ b/root/etc/e-smith/templates/etc/pam.d/dovecot/05cas @@ -0,0 +1,10 @@ +{ +if (-d '/var/service/dovecot'){ + $OUT .=<<"HERE"; +auth sufficient pam_cas.so -simap://localhost -f/etc/pam_cas.conf +HERE +} +else{ + return ""; +} +} diff --git a/root/etc/e-smith/templates/etc/pam.d/dovecot/10SystemAuth b/root/etc/e-smith/templates/etc/pam.d/dovecot/10SystemAuth new file mode 100644 index 0000000..a85aeae --- /dev/null +++ b/root/etc/e-smith/templates/etc/pam.d/dovecot/10SystemAuth @@ -0,0 +1,4 @@ +auth required pam_nologin.so +auth include system-auth +account include system-auth +session include system-auth diff --git a/root/etc/e-smith/templates/etc/pam.d/dovecot/template-begin b/root/etc/e-smith/templates/etc/pam.d/dovecot/template-begin new file mode 100644 index 0000000..292d302 --- /dev/null +++ b/root/etc/e-smith/templates/etc/pam.d/dovecot/template-begin @@ -0,0 +1,8 @@ +{ + $OUT = <{'applicationList'}->{'010apps'}->{'sogo'} = { + 'options' => { + 'logo' => 'mail.png', + 'name' => 'SOGo', + 'description' => 'Mails, agendas, contacts', + 'uri' => "https://$host.$domain/SOGo", + 'display' => 'on' + }, + 'type' => 'application' +} unless ($conf->{'applicationList'}->{'010apps'}->{'sogo'}); + +$OUT = ''; + +} diff --git a/root/etc/e-smith/templates/var/lib/sogo/GNUstep/Defaults/.GNUstepDefaults/55authSource b/root/etc/e-smith/templates/var/lib/sogo/GNUstep/Defaults/.GNUstepDefaults/55authSource index 43e1722..c46a281 100644 --- a/root/etc/e-smith/templates/var/lib/sogo/GNUstep/Defaults/.GNUstepDefaults/55authSource +++ b/root/etc/e-smith/templates/var/lib/sogo/GNUstep/Defaults/.GNUstepDefaults/55authSource @@ -55,4 +55,12 @@ type = ldap; \} ); - +{ + # is smeserver-dovecot installed ? + if (-d '/var/service/dovecot'){ + $OUT .=<<"HERE"; + SOGoAuthenticationType = cas; + SOGoCASServiceURL = "https://auth.$DomainName/cas/"; +HERE + } +} diff --git a/root/usr/lib/perl5/site_perl/Apache/FilterChangeLength.pm b/root/usr/lib/perl5/site_perl/Apache/FilterChangeLength.pm new file mode 100644 index 0000000..b09a1d9 --- /dev/null +++ b/root/usr/lib/perl5/site_perl/Apache/FilterChangeLength.pm @@ -0,0 +1,52 @@ +package Apache::FilterChangeLength; + +use strict; +use warnings FATAL => 'all'; + +use Apache2::RequestRec (); + +use APR::Table (); +use APR::Bucket (); +use APR::Brigade (); + +use base qw(Apache2::Filter); + +use Apache2::Const -compile => qw(OK); +use APR::Const -compile => ':common'; + +sub handler { + my ($filter, $bb) = @_; + my $ctx = $filter->ctx; + my $data = exists $ctx->{data} ? $ctx->{data} : ''; + $ctx->{invoked}++; + my ($bdata, $seen_eos) = flatten_bb($bb); + $data .= $bdata if $bdata; + + if ($seen_eos) { + my $len = length $data; + $filter->r->headers_out->set('Content-Length', $len); + $filter->print($data) if $data; + } + else { + # store context for all but the last invocation + $ctx->{data} = $data; + $filter->ctx($ctx); + } + + return Apache2::Const::OK; +} + +sub flatten_bb { + my ($bb) = shift; + my $seen_eos = 0; + + my @data; + for (my $b = $bb->first; $b; $b = $bb->next($b)) { + $seen_eos++, last if $b->is_eos; + $b->read(my $bdata); + push @data, $bdata; + } + return (join('', @data), $seen_eos); +} + +1;