--- rpms/smeserver-php/sme10/smeserver-php-3.0.0-bz11087-webapps.patch 2020/11/09 02:39:26 1.2 +++ rpms/smeserver-php/sme10/smeserver-php-3.0.0-bz11087-webapps.patch 2020/11/09 02:41:37 1.3 @@ -1,4 +1,4 @@ -diff -Nus smeserver-php-3.0.0.old/createlinks smeserver-php-3.0.0/createlinks +diff -Nur smeserver-php-3.0.0.old/createlinks smeserver-php-3.0.0/createlinks --- smeserver-php-3.0.0.old/createlinks 2020-11-08 21:14:58.600000000 -0500 +++ smeserver-php-3.0.0/createlinks 2020-11-08 21:29:38.439000000 -0500 @@ -105,3 +105,9 @@ @@ -11,3 +11,320 @@ diff -Nus smeserver-php-3.0.0.old/create +templates2events("/etc/my.cnf", $event); + +safe_symlink("start", "root/etc/e-smith/events/$event/services2adjust/mysql.init"); +diff -Nur smeserver-php-3.0.0.old/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/81SimpleVHosts smeserver-php-3.0.0/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/81SimpleVHosts +--- smeserver-php-3.0.0.old/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/81SimpleVHosts 1969-12-31 19:00:00.000000000 -0500 ++++ smeserver-php-3.0.0/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/81SimpleVHosts 2020-11-08 21:22:23.367000000 -0500 +@@ -0,0 +1,35 @@ ++{ ++ $OUT = ''; ++ ++ use esmith::DomainsDB; ++ ++ my $db = esmith::DomainsDB->open_ro; ++ unless ($db){ ++ warn "Couldn't open domains DB in VirtualHosts template fragment"; ++ return; ++ } ++ ++ my @vhosts = $db->get_all_by_prop('type' => 'vhost'); ++ foreach my $vhost (@vhosts) { ++ my $templatePath = $vhost->prop('TemplatePath') || 'WebAppVirtualHost'; ++ foreach my $port ($httpPort, $httpsPort){ ++ my %virtualHost = ( ++ ipAddress => '0.0.0.0', ++ port => $port, ++ localAccess => $localAccess, ++ externalSSLAccess => $externalSSLAccess, ++ domain => $vhost, ++ httpPort => $httpPort, ++ httpsPort => $httpsPort ++ ); ++ ++ $OUT .= esmith::templates::processTemplate ( ++ { ++ MORE_DATA => \%virtualHost, ++ TEMPLATE_PATH => ++ "/etc/httpd/conf/httpd.conf/$templatePath", ++ OUTPUT_TYPE => 'string', ++ }); ++ } ++ } ++} +diff -Nur smeserver-php-3.0.0.old/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/WebAppVirtualHost/00Setup smeserver-php-3.0.0/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/WebAppVirtualHost/00Setup +--- smeserver-php-3.0.0.old/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/WebAppVirtualHost/00Setup 1969-12-31 19:00:00.000000000 -0500 ++++ smeserver-php-3.0.0/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/WebAppVirtualHost/00Setup 2017-10-01 09:19:18.000000000 -0400 +@@ -0,0 +1,9 @@ ++{ ++ use esmith::DomainsDB; ++ # Convert the passed hash for the domain object back into an object. ++ $domain = bless \%domain, 'esmith::DB::db::Record'; ++ ++ # Make scalars from some of the properties of the domain ++ $virtualHost = $domain->key; ++ $OUT = ""; ++} +diff -Nur smeserver-php-3.0.0.old/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/WebAppVirtualHost/02ServerName smeserver-php-3.0.0/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/WebAppVirtualHost/02ServerName +--- smeserver-php-3.0.0.old/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/WebAppVirtualHost/02ServerName 1969-12-31 19:00:00.000000000 -0500 ++++ smeserver-php-3.0.0/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/WebAppVirtualHost/02ServerName 2017-10-01 09:19:18.000000000 -0400 +@@ -0,0 +1 @@ ++ ServerName {$virtualHost} +diff -Nur smeserver-php-3.0.0.old/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/WebAppVirtualHost/03ServerAlias smeserver-php-3.0.0/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/WebAppVirtualHost/03ServerAlias +--- smeserver-php-3.0.0.old/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/WebAppVirtualHost/03ServerAlias 1969-12-31 19:00:00.000000000 -0500 ++++ smeserver-php-3.0.0/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/WebAppVirtualHost/03ServerAlias 2017-10-01 09:19:18.000000000 -0400 +@@ -0,0 +1,13 @@ ++ ServerAlias { ++ ++ use esmith::HostsDB; ++ use esmith::DomainsDB; ++ my $hdb = esmith::HostsDB->open_ro(); ++ my %domains = map { $_->key => 1 } esmith::DomainsDB->open_ro->domains; ++ my @hosts = grep { ++ my $h = $_; ++ ($h->prop('HostType') eq 'Self') && !$domains{$h->key} ++ } $hdb->get_hosts_by_domain($virtualHost); ++ $OUT = join " ", map { $_->key } @hosts; ++} ++ +diff -Nur smeserver-php-3.0.0.old/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/WebAppVirtualHost/25SSLDirectives smeserver-php-3.0.0/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/WebAppVirtualHost/25SSLDirectives +--- smeserver-php-3.0.0.old/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/WebAppVirtualHost/25SSLDirectives 1969-12-31 19:00:00.000000000 -0500 ++++ smeserver-php-3.0.0/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/WebAppVirtualHost/25SSLDirectives 2020-11-08 21:23:48.335000000 -0500 +@@ -0,0 +1,28 @@ ++{ ++ my $ssl = $domain->prop('RequireSSL') || 'disabled'; ++ my $auth = $domain->prop('Authentication') || 'none'; ++ ++ if (($httpsPort eq $port){ ++ $OUT .= " SSLEngine on\n"; ++ } ++ elsif (($ssl =~ m/^enabled|yes|on|1$/i) || ($auth =~ /^LemonLDAP/)){ ++ $OUT .=<<'EOF'; ++ RewriteEngine on ++ RewriteCond %{REQUEST_URI} !^/.well-known/acme-challenge/.* ++ RewriteRule ^/(.*|$) https://%{HTTP_HOST}/$1 [L,R] ++ ++EOF ++ } ++ elsif ($ssl =~ m#/#){ ++ $OUT .= " RewriteEngine on\n"; ++ foreach my $loc (split(/[;,]/, $ssl)){ ++ $OUT .= " # Rewriting $loc to use SSL\n"; ++ $loc =~ s#^/##; ++ $OUT .= " RewriteRule ^/$loc(/.*|\$) https://%\{HTTP_HOST\}/$loc\$1 \[L,R\]\n"; ++ } ++ } ++ else{ ++ $OUT .= ''; ++ } ++} ++ +diff -Nur smeserver-php-3.0.0.old/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/WebAppVirtualHost/26RewriteTraceAndTrack smeserver-php-3.0.0/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/WebAppVirtualHost/26RewriteTraceAndTrack +--- smeserver-php-3.0.0.old/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/WebAppVirtualHost/26RewriteTraceAndTrack 1969-12-31 19:00:00.000000000 -0500 ++++ smeserver-php-3.0.0/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/WebAppVirtualHost/26RewriteTraceAndTrack 2017-10-01 09:19:18.000000000 -0400 +@@ -0,0 +1,8 @@ ++{ ++ $OUT =<<'HERE'; ++ RewriteEngine on ++ RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK) ++ RewriteRule .* - [F] ++HERE ++} ++ +diff -Nur smeserver-php-3.0.0.old/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/WebAppVirtualHost/40ApacheIconAlias smeserver-php-3.0.0/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/WebAppVirtualHost/40ApacheIconAlias +--- smeserver-php-3.0.0.old/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/WebAppVirtualHost/40ApacheIconAlias 1969-12-31 19:00:00.000000000 -0500 ++++ smeserver-php-3.0.0/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/WebAppVirtualHost/40ApacheIconAlias 2017-10-01 09:19:18.000000000 -0400 +@@ -0,0 +1,13 @@ ++{ ++my $alias = $domain->prop('IconAlias') || 'enabled'; ++$OUT .= ''; ++ ++unless ($alias =~ m/disabled|off|no|0/i){ ++ $OUT .=<<'EOF'; ++ ++ # alias for Apache icons ++ Alias /icons/ /var/www/icons/ ++ ++EOF ++} ++} +diff -Nur smeserver-php-3.0.0.old/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/WebAppVirtualHost/50Content smeserver-php-3.0.0/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/WebAppVirtualHost/50Content +--- smeserver-php-3.0.0.old/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/WebAppVirtualHost/50Content 1969-12-31 19:00:00.000000000 -0500 ++++ smeserver-php-3.0.0/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/WebAppVirtualHost/50Content 2020-11-08 21:26:33.645000000 -0500 +@@ -0,0 +1,166 @@ ++{ ++ ++use esmith::util; ++my $base = esmith::util::ldapBase($DomainName); ++ ++my $name = $domain->key; ++my $target = $domain->prop('ProxyPassTarget') || ''; ++my $proxy_acme = $domain->prop('ProxyPassACMEChallenges') || 'disabled'; ++my $redirect = $domain->prop('Redirect') || ''; ++my $rewrite = $domain->prop('Rewrite') || ''; ++my $allow = $domain->prop('AllowHosts') || ''; ++my $preserve = $domain->prop('ProxyPreserveHost') || 'no'; ++my $keepalive = $domain->prop('ProxyNoKeepAlive') || 'no'; ++my $timeout = $domain->prop('Timeout') || ''; ++my $index = $domain->prop('DirectoryIndex') || ''; ++my @alias = split /[,;]/, ($domain->prop('Alias') || ''); ++my @env = split(/[;,]/, ($domain->prop('SetEnv') || '')); ++my $auth = $domain->prop('Authentication') || 'none'; ++my @groups = split(/[;,]/, ($domain->prop('AllowGroups') || '')); ++my $ssl_port = $httpsPort; ++my $proto = ($port eq $ssl_port ) ? 'https' : 'http'; ++my $socketio = $domain->prop('ProxySocketIO') || 'disabled'; ++my @proxyrules = split /[,;]/, ($domain->prop('ProxyPassRules') || ''); ++ ++# Custom proxypass rules ++foreach my $rule (@proxyrules){ ++ my ($from, $to) = split /=/, $rule; ++ $OUT .= " ProxyPass $from $to\n"; ++} ++ ++if (@proxyrules > 0 || $target =~ m|https?://[\d\w\.\-/]*|){ ++ $OUT .= " ProxyPreserveHost on\n" if ($preserve eq 'yes'); ++ $OUT .= " RequestHeader set X-Forwarded-Proto \"$proto\"\n"; ++} ++ ++# ProxyPass ? ++if ($target =~ m|https?://[\d\w\.\-/]*|){ ++ $OUT .= " SetEnv proxy-nokeepalive 1\n" if ($keepalive eq 'yes'); ++ if ($proxy_acme eq 'only'){ ++ $OUT .= " ProxyPass /.well-known/acme-challenge/ $target" . ".well-known/acme-challenge/\n"; ++ $OUT .= " ProxyPassReverse / $target" . ".well-known/acme-challenge/\n"; ++ } ++ else{ ++ if ($proxy_acme eq 'disabled'){ ++ $OUT .= " ProxyPass /.well-known/acme-challenge/ !\n"; ++ } ++ if ($socketio eq 'enabled'){ ++ # Try to handle Socket.IO ++ my $wstarget = $target; ++ $wstarget =~ s/^http:/ws:/; ++ $wstarget =~ s/^https:/wss:/; ++ $OUT .=<<"_EOF" ++ ++ ++ RewriteCond %{QUERY_STRING} transport=polling [NC] ++ RewriteRule /socket.io/(.*) ${target}socket.io/\$1 [P,L] ++ ++ ProxyPass /socket.io/socket.io.js ${target}socket.io/socket.io.js ++ ProxyPassReverse /socket.io/socket.io.js ${target}socket.io/socket.io.js ++ ++ ProxyPass /socket.io/ ${wstarget}socket.io/ ++ ProxyPassReverse /socket.io/ ${wstarget}socket.io/ ++ ++ ++_EOF ++ } ++ $OUT .= " ProxyPass / $target\n"; ++ $OUT .= " ProxyPassReverse / $target\n"; ++ } ++} ++# Rewrite ? ++elsif ($rewrite =~ m|https?://[\d\w\.\-/]*|){ ++ $OUT .=<<"HERE"; ++ ++ RewriteCond %{REQUEST_URI} !^/.well-known/acme-challenge/.* ++ RewriteRule /(.*|\$) $rewrite/\$1 [L,R] ++ ++HERE ++} ++# Redirect ? ++elsif ($redirect =~ m|https?://[\d\w\.\-/]*|){ ++ $OUT .=<<"HERE"; ++ ++ RedirectMatch permanent ^/(.*|\$) $redirect/\$1 ++ ++HERE ++} ++else{ ++ my $root = $domain->prop('DocumentRoot') || ++ '/home/e-smith/files/ibays/Primary/html'; ++ ++ $OUT .= " DocumentRoot $root\n"; ++} ++ ++if ($timeout =~ m/^\d+$/){ ++ $OUT .= " Timeout $timeout\n"; ++} ++ ++if ($index ne ''){ ++ $OUT .= " DirectoryIndex $index\n"; ++} ++ ++foreach (@alias){ ++ next unless $_ =~ m/^(\/\w+)=(\/.*)/; ++ my ($al, $targ) = ($1, $2); ++ next unless (-e $2); ++ $OUT .= " Alias $al $targ\n"; ++} ++ ++foreach (@env){ ++ next unless (m/^(.*)=(.*)$/); ++ $OUT .= " SetEnv $1 $2\n"; ++} ++ ++if ($allow ne ''){ ++ if ($allow eq 'local'){ ++ $allow = "$localAccess $externalSSLAccess"; ++ } ++ else{ ++ $allow =~ s/[,;]/ /g; ++ } ++ $OUT .=<<"EOF"; ++ ++ ++ Order deny,allow ++ Deny from all ++ Allow from $allow ++ ++ ++ ++ Allow from all ++ ++ ++EOF ++} ++ ++if ($auth =~ m/^Basic$/i){ ++ my $require = "Require valid-user"; ++ if (scalar(@groups) > 0){ ++ $require = "Require ldap-group "; ++ $require .= "cn=$_,ou=Groups,$base " foreach(@groups); ++ } ++ ++ $OUT .=<<"EOF"; ++ SetEnvIf %{Request_URI} "^/\.well\-known/acme\-challenge" granted=1 ++ ++ ++ Order deny,allow ++ Satisfy any ++ Deny from all ++ Allow from env=granted ++ AuthType basic ++ AuthName "$name" ++ AuthBasicProvider ldap ++ AuthLDAPURL ldap://localhost/ou=Users,$base?uid ++ AuthLDAPGroupAttribute memberUid ++ AuthLDAPGroupAttributeIsDN off ++ $require ++ ++ ++EOF ++ ++} ++ ++} ++ +diff -Nur smeserver-php-3.0.0.old/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/WebAppVirtualHost/template-begin smeserver-php-3.0.0/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/WebAppVirtualHost/template-begin +--- smeserver-php-3.0.0.old/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/WebAppVirtualHost/template-begin 1969-12-31 19:00:00.000000000 -0500 ++++ smeserver-php-3.0.0/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/WebAppVirtualHost/template-begin 2017-10-01 09:19:18.000000000 -0400 +@@ -0,0 +1,2 @@ ++ ++ +diff -Nur smeserver-php-3.0.0.old/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/WebAppVirtualHost/template-end smeserver-php-3.0.0/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/WebAppVirtualHost/template-end +--- smeserver-php-3.0.0.old/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/WebAppVirtualHost/template-end 1969-12-31 19:00:00.000000000 -0500 ++++ smeserver-php-3.0.0/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/WebAppVirtualHost/template-end 2017-10-01 09:19:18.000000000 -0400 +@@ -0,0 +1,2 @@ ++ ++