diff -urN smeserver-manager-0.1.2.old/createlinks smeserver-manager-0.1.2/createlinks --- smeserver-manager-0.1.2.old/createlinks 2020-11-19 11:53:26.000000000 +0400 +++ smeserver-manager-0.1.2/createlinks 2020-11-20 22:49:04.000000000 +0400 @@ -11,36 +11,35 @@ for ( qw( sme_core.css sme_main.css sme_menu.css styles.css ) ) { templates2events("$mngrdir/themes/default/public/css/$_", qw( - bootstrap-console-save smanager-update + bootstrap-console-save smeserver-manager-update )); } templates2events("$mngrdir/conf/srvmngr.conf", - qw( smanager-update smanager-modify bootstrap-console-save )); - -templates2events("/etc/systemd/system/smanager.service", - qw( smanager-update bootstrap-console-save )); + qw( smeserver-manager-update smanager-modify bootstrap-console-save )); templates2events("/etc/httpd/conf/httpd.conf", - qw( smanager-update smanager-modify )); + qw( smeserver-manager-update smanager-modify )); # services to launch on event -for my $event ( qw( smanager-update smanager-modify ) ) +for my $event ( qw( smeserver-manager-update smanager-modify ) ) { safe_symlink("restart", "root/etc/e-smith/events/$event/services2adjust/smanager"); safe_symlink("sigusr1", - "root/etc/e-smith/events/$event/services2adjust/httpd-e-smith"); + "root/etc/e-smith/events/$event/services2adjust/httpd-e-smith"); } safe_symlink("restart", "root/etc/e-smith/events/smanager-refresh/services2adjust/smanager"); # actions to perform -for my $event ( qw( smanager-update smanager-refresh bootstrap-console-save ) ) +for my $event ( qw( smeserver-manager-update smanager-refresh bootstrap-console-save ) ) { event_link('navigation2-conf', "$event", '80'); event_link('routes2-conf', "$event", '80'); event_link('locales2-conf', "$event", '80'); } + +event_link('systemd-reload', "smeserver-manager-update", '85'); diff -urN smeserver-manager-0.1.2.old/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/86SmanagerAlias smeserver-manager-0.1.2/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/86SmanagerAlias --- smeserver-manager-0.1.2.old/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/86SmanagerAlias 2020-11-19 11:53:26.000000000 +0400 +++ smeserver-manager-0.1.2/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/86SmanagerAlias 1970-01-01 04:00:00.000000000 +0400 @@ -1,13 +0,0 @@ -{ - $OUT = ''; - $OUT .= "\n"; - - $OUT .= " AuthName 'SManager Admin'\n"; - $OUT .= " AuthBasicProvider external\n"; - $OUT .= " AuthType Basic\n"; - $OUT .= " AuthExternal pwauth\n"; - $OUT .= " require user admin\n"; - $OUT .= " Satisfy all\n"; - - $OUT .= "\n"; -} diff -urN smeserver-manager-0.1.2.old/root/etc/e-smith/templates/etc/systemd/system/smanager.service/10All smeserver-manager-0.1.2/root/etc/e-smith/templates/etc/systemd/system/smanager.service/10All --- smeserver-manager-0.1.2.old/root/etc/e-smith/templates/etc/systemd/system/smanager.service/10All 2020-11-19 11:53:26.000000000 +0400 +++ smeserver-manager-0.1.2/root/etc/e-smith/templates/etc/systemd/system/smanager.service/10All 1970-01-01 04:00:00.000000000 +0400 @@ -1,24 +0,0 @@ -[Unit] -Description=Server Manager 2 Mojo -Requires=network.target -##Requires= httpd.target slapd.target -##After=network.target slapd.target - -[Service] -Type=simple -SyslogIdentifier=smanager -WorkingDirectory=/usr/share/smanager/script -PIDFile=/var/run/smanager.pid -#EnvironmentFile=-/etc/sysconfig/smanager -ExecStart=/usr/bin/hypnotoad srvmngr -f -ExecStop=/usr/bin/hypnotoad -s srvmngr -ExecReload=/usr/bin/hypnotoad srvmngr -##ExecReload=reload-srvmngr.sh -KillMode=process -Restart=always -RestartSec=5 -User=root -Group=root - -[Install] -WantedBy=multi-user.target diff -urN smeserver-manager-0.1.2.old/root/usr/lib/systemd/system/smanager.service smeserver-manager-0.1.2/root/usr/lib/systemd/system/smanager.service --- smeserver-manager-0.1.2.old/root/usr/lib/systemd/system/smanager.service 1970-01-01 04:00:00.000000000 +0400 +++ smeserver-manager-0.1.2/root/usr/lib/systemd/system/smanager.service 2020-11-21 00:46:19.258000000 +0400 @@ -0,0 +1,21 @@ +[Unit] +Description=Server Manager 2 Mojo +Requires=network.target +# httpd.service slapd.service +After=network.target +# slapd.service + +[Service] +Type=simple +SyslogIdentifier=smanager +WorkingDirectory=/usr/share/smanager/script +PIDFile=/var/run/smanager.pid +ExecStart=/usr/bin/hypnotoad srvmngr -f +ExecStop=/usr/bin/hypnotoad -s srvmngr +ExecReload=/usr/bin/hypnotoad srvmngr +KillMode=process +Restart=always +RestartSec=5 + +[Install] +WantedBy=sme-server.target diff -urN smeserver-manager-0.1.2.old/root/usr/lib/systemd/system-preset/80-koozali-smanager.preset smeserver-manager-0.1.2/root/usr/lib/systemd/system-preset/80-koozali-smanager.preset --- smeserver-manager-0.1.2.old/root/usr/lib/systemd/system-preset/80-koozali-smanager.preset 1970-01-01 04:00:00.000000000 +0400 +++ smeserver-manager-0.1.2/root/usr/lib/systemd/system-preset/80-koozali-smanager.preset 2020-11-20 22:22:04.000000000 +0400 @@ -0,0 +1,2 @@ +enable smanager.service + diff -urN smeserver-manager-0.1.2.old/root/usr/share/smanager/lib/SrvMngr/Controller/Bugreport.pm smeserver-manager-0.1.2/root/usr/share/smanager/lib/SrvMngr/Controller/Bugreport.pm --- smeserver-manager-0.1.2.old/root/usr/share/smanager/lib/SrvMngr/Controller/Bugreport.pm 2020-11-19 11:53:26.000000000 +0400 +++ smeserver-manager-0.1.2/root/usr/share/smanager/lib/SrvMngr/Controller/Bugreport.pm 2020-11-21 00:03:31.041000000 +0400 @@ -19,10 +19,10 @@ use File::Basename; use esmith::FormMagick qw( gen_locale_date_string ); -our $db = esmith::ConfigDB->open or die "Couldn't open ConfigDB\n"; +our $cdb = esmith::ConfigDB->open or die "Couldn't open ConfigDB\n"; # Get some basic info on the current SME install -our $sysconfig = $db->get('sysconfig'); +our $sysconfig = $cdb->get('sysconfig'); our $systemmode = $sysconfig->prop('PreviousSystemMode'); our $releaseversion = $sysconfig->prop('ReleaseVersion'); @@ -73,22 +73,18 @@ my $modul = 'Bug report download'; - #download_config_report(); +# $c->render_file( +# 'filepath' => "$configreportfile", +# 'format' => 'x-download', +# 'content_disposition' => 'attachment', +# 'cleanup' => 1, +# ); - # --> OR <-- - #if ( $params{'output_format'} eq 'txtfile' ) { - $c->res->headers->content_disposition("attachement; filename=" . basename($configreportfile) . ";"); - #$c->res->headers->content_type('text/plain'); - $c->reply->file("$configreportfile"); - #} else { - # $modul .= "\n output_format not compatible with report file"; - #} - # the following in this sub will not be used !!! - $bugr_datas{'trt'} = 'DOWN'; +# $bugr_datas{'trt'} = 'DOWN'; - $c->stash(title => $title, modul => $modul, bugr_datas => \%bugr_datas); - $c->render(template => 'bugreport'); +# $c->stash(title => $title, modul => $modul, bugr_datas => \%bugr_datas); +# $c->render(template => 'bugreport'); } }; @@ -141,6 +137,7 @@ close $cfgrep; } + sub show_config_report { my $c = shift; @@ -159,24 +156,16 @@ } -sub download_config_report { +sub download_config_report { my $c = shift; - my $filesize =-s $configreportfile; - - open (DLFILE, "<$configreportfile") or die "Could not access temporary file for config report!"; - my @fileholder = ; - close (DLFILE) || Error ('close', 'file'); - - print "Content-Type:text/plain\n";#application/x-downloadn"; - print "Content-Disposition:attachment;filename=" . basename($configreportfile) . "\n"; - print "Content-Length:" . $filesize; - print "\n\n"; - print @fileholder ; - - return ""; - + $c->render_file( + 'filepath' => "$configreportfile", + 'format' => 'x-download', + 'content_disposition' => 'attachment', + 'cleanup' => 1, + ); } diff -urN smeserver-manager-0.1.2.old/root/usr/share/smanager/lib/SrvMngr/Controller/Login.pm smeserver-manager-0.1.2/root/usr/share/smanager/lib/SrvMngr/Controller/Login.pm --- smeserver-manager-0.1.2.old/root/usr/share/smanager/lib/SrvMngr/Controller/Login.pm 2020-11-19 11:53:26.000000000 +0400 +++ smeserver-manager-0.1.2/root/usr/share/smanager/lib/SrvMngr/Controller/Login.pm 2020-11-21 00:03:42.223000000 +0400 @@ -64,6 +64,18 @@ return $c->render('login'); } + + my $alias = SrvMngr::Model::Main->check_adminalias( $c ); + if ( $alias ) { + if ( $name eq $alias ) { + $name = 'admin'; + } elsif ( $name eq 'admin' ) { + record_login_attempt($c, 'FAILED'); + $c->stash( error => $c->l('use_SORRY'), trt => 'NORM' ); + return $c->render('login'); + } + } + if (SrvMngr::Model::Main->check_credentials($name, $pass)) { $c->session(logged_in => 1); # set the logged_in flag $c->session(username => $name); # keep a copy of the username diff -urN smeserver-manager-0.1.2.old/root/usr/share/smanager/lib/SrvMngr/Model/Main.pm smeserver-manager-0.1.2/root/usr/share/smanager/lib/SrvMngr/Model/Main.pm --- smeserver-manager-0.1.2.old/root/usr/share/smanager/lib/SrvMngr/Model/Main.pm 2020-11-19 11:53:26.000000000 +0400 +++ smeserver-manager-0.1.2/root/usr/share/smanager/lib/SrvMngr/Model/Main.pm 2020-11-21 00:03:22.385000000 +0400 @@ -5,6 +5,7 @@ use utf8; use esmith::ConfigDB; +use esmith::AccountsDB; use esmith::util; use Net::LDAP qw/LDAP_INVALID_CREDENTIALS/; @@ -70,5 +71,28 @@ } +sub check_adminalias { + + # is an alias required for admin ? return it or undef + my $c = shift; + + my $alias; + my $cdb = esmith::ConfigDB->open_ro() or die("can't open Configuration DB"); + if (defined $cdb->get('AdminAlias')) { + $alias = $cdb->get('AdminAlias')->value; + } + return undef unless $alias; + + my $adb = esmith::AccountsDB->open_ro() or die("can't open Accounts DB"); + my $arec = $adb->get( $alias ); + return undef unless $arec; + + # $alias pseudo exists AND points to admin AND is removable (not known pseudos) => OK + return ( $arec && $arec->prop('type') eq 'pseudonym' && $arec->prop('Account') eq 'admin' + && ($arec->prop('Removable') || 'yes') ne 'no' ) ? $alias : undef; + +} + + 1; diff -urN smeserver-manager-0.1.2.old/root/usr/share/smanager/lib/SrvMngr.pm smeserver-manager-0.1.2/root/usr/share/smanager/lib/SrvMngr.pm --- smeserver-manager-0.1.2.old/root/usr/share/smanager/lib/SrvMngr.pm 2020-11-20 23:53:46.000000000 +0400 +++ smeserver-manager-0.1.2/root/usr/share/smanager/lib/SrvMngr.pm 2020-11-21 00:03:09.872000000 +0400 @@ -23,7 +23,7 @@ use SrvMngr::Model::Main; -our $VERSION = '1.201'; +our $VERSION = '1.202'; $VERSION = eval $VERSION; use Exporter 'import'; @@ -154,6 +154,8 @@ $self->plugin('TagHelpers'); + $self->plugin('RenderFile'); + # CSRF protec if production # $self->plugin('Mojolicious::Plugin::CSRFDefender') if ( $self->mode eq 'production' ); @@ -294,7 +296,7 @@ $if_admin->get('/viewlogfiles')->to('viewlogfiles#main')->name('viewlogfiles'); $if_admin->post('/viewlogfiles')->to('viewlogfiles#do_action')->name('viewlogfiles2'); - $if_admin->get('/viewlogfileR')->to('viewlogfiles#do_action')->name('viewlogfileR'); + $if_admin->get('/viewlogfilesr')->to('viewlogfiles#do_action')->name('viewlogfilesr'); $if_admin->get('/yum')->to('yum#main')->name('yum'); $if_admin->post('/yum')->to('yum#do_display')->name('yumd1'); @@ -607,7 +609,7 @@ } my $lang = ( $c->tx->req->headers->accept_language || ['en_US'] ); - $lang = split(/,/, $lang); + $lang = (split(/,/, $lang))[0]; # my $lang = (split(/,/, $c->tx->req->headers->accept_language))[0]; ## convert xx_XX lang format to xx-xx + delete .UTFxx + lowercase # $lang =~ s/_(.*)\..*$/-${1}/; # just keep 'en-us' diff -urN smeserver-manager-0.1.2.old/root/usr/share/smanager/themes/default/templates/partials/_footer.html.ep smeserver-manager-0.1.2/root/usr/share/smanager/themes/default/templates/partials/_footer.html.ep --- smeserver-manager-0.1.2.old/root/usr/share/smanager/themes/default/templates/partials/_footer.html.ep 2020-11-19 11:53:26.000000000 +0400 +++ smeserver-manager-0.1.2/root/usr/share/smanager/themes/default/templates/partials/_footer.html.ep 2020-11-21 00:02:08.503000000 +0400 @@ -3,6 +3,6 @@ SME Server <%= session 'releaseVersion' %> - Manager <%= $c->app->VERSION %> - <%= session 'lang' %>
Copyright 1999-2006 Mitel Corporation
-<%= session 'copyRight' %> +%= session 'copyRight'
Copyright (c) 2013-2016 Koozali Foundation Inc.
diff -urN smeserver-manager-0.1.2.old/root/usr/share/smanager/themes/default/templates/viewlogfiles2.html.ep smeserver-manager-0.1.2/root/usr/share/smanager/themes/default/templates/viewlogfiles2.html.ep --- smeserver-manager-0.1.2.old/root/usr/share/smanager/themes/default/templates/viewlogfiles2.html.ep 2020-11-19 11:53:26.000000000 +0400 +++ smeserver-manager-0.1.2/root/usr/share/smanager/themes/default/templates/viewlogfiles2.html.ep 2020-11-21 00:02:39.558000000 +0400 @@ -18,7 +18,7 @@

<% my $btn = l('log_REFRESH'); %> - %= form_for 'viewlogfileR' => (method => 'GET') => begin + %= form_for 'viewlogfilesr' => (method => 'GET') => begin %= submit_button "$btn", class => 'action' %= hidden_field 'trt' => $log_datas->{trt} %= hidden_field 'Filename' => $log_datas->{filename}