Re: [Tiki-devel] SF.net SVN: tikiwiki:[58593] trim

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Re: [Tiki-devel] SF.net SVN: tikiwiki:[58593] trim

Cloutier, Philippe (RESSOURCE EXTERNE)

Hi,

r58593 changes the technique used to enable TRIM Web administration, from creating a symlink from Apache’s document root, to configuring an Apache alias, which requires root privileges.

The commit message claims to fix something, but is most vague and I do not see what was broken. Since the new technique brings a functional regression (requirement of root privileges), I would like to understand the point of this change.

 

If no one explains at least what this change supposedly fixed, I may revert it.

 

De : Cloutier, Philippe (RESSOURCE EXTERNE)
Envoyé : 7 mars 2017 14:27
À : '[hidden email]' <[hidden email]>
Cc : [hidden email]
Objet : Re: SF.net SVN: tikiwiki:[58593] trim

 

Hi dlucio,
I am not sure it is a good idea to require root privileges, but if so, should enablewww not stop prompting about sudo?
 
Revision: 58593
          http://sourceforge.net/p/tikiwiki/code/58593
Author:   dlucio
Date:     2016-05-13 03:34:53 +0000 (Fri, 13 May 2016)
Log Message:
-----------
[FIX] WEBTrim is back
 
Modified Paths:
--------------
    trim/scripts/enablewww.php
    trim/www/.htaccess
 
Modified: trim/scripts/enablewww.php
===================================================================
--- trim/scripts/enablewww.php 2016-05-12 21:07:30 UTC (rev 58592)
+++ trim/scripts/enablewww.php 2016-05-13 03:34:53 UTC (rev 58593)
@@ -1,4 +1,18 @@
 <?php
+if (function_exists(posix_getuid)){
+       if (posix_getuid() == 0){
+              echo "Good! This is root!\n";
+       } 
+       else {
+               echo "This is non-root";
+              echo "You need to execute this script as root, it will write some configuration files";
+              exit(1);
+       }
+}
+else {
+       echo "PHP POSIX functions are not installed, install them and try again\n";
+       exit(1);
+}
 
 include_once dirname(__FILE__) . "/../src/env_setup.php";
 
@@ -25,11 +39,31 @@
 if( 'confirm' != readline( "Type 'confirm' to continue: " ) )
        exit;
 
-$d_folder = "/var/www/webtrim";
-$folder = readline( "TRIM location : [$d_folder] " );
-if( empty( $folder ) )
-       $folder = $d_folder;
+$ret_var = -1;
+$out = '/etc/httpd/';
+$cmd = 'dirname $(find /etc/httpd -name httpd.conf )';
+exec ($cmd, $out, $ret_var);
+$out2 = $out[0];
 
+$d_httpd = readline( "Apache httpd.conf directory : [$out2] " );
+if( empty( $d_httpd ) )
+       $d_httpd = $out2;
+
+$base = dirname($d_httpd);
+$precmd = 'dirname $(find '.$base.' -name httpd.conf -exec grep ^Include {} \; | cut -d'."' '".' -f2)|sort|head -n1';
+$cmd = $precmd;
+exec ($cmd, $out, $ret_var);
+
+$out2 = $base.'/'.$out[1];
+$d_httpd_optional = readline( "Apache httpd.conf IncludeOptional directory : [$out2] " );
+if( empty( $d_httpd_optional ) )
+       $d_httpd_optional = $out2;
+
+//$d_folder = "/var/www/webtrim";
+//$folder = readline( "TRIM location : [$d_folder] " );
+//if( empty( $folder ) )
+//     $folder = $d_folder;
+
 $user = $pass = '';
 while( empty( $user ) )
        $user = readline( "Desired username : " );
@@ -39,7 +73,7 @@
        $pass = getPassword(true); print "\n";
 }
 
-$d_restrict = 'yes';
+$d_restrict = 'no';
 $restrict = readline( "Restrict use to localhost : [$d_restrict] " );
 if( empty( $restrict ) )
        $restrict = $d_restrict;
@@ -62,10 +96,36 @@
 define( 'RESTRICT', $restrict );
 CONFIG
 );
+
 $web = realpath( dirname(__FILE__) . '/../www' );
 
+file_put_contents ( $d_httpd_optional.'/webtrim.conf', <<<CONFIG
+Alias /webtrim $web
+
+<Directory $web/>
+LogLevel alert rewrite:trace6
+
+AllowOverride All
+<IfModule mod_authz_core.c>
+        # Apache 2.4
+       Require all granted
+</IfModule>
+<IfModule !mod_authz_core.c>
+        # Apache 2.2
+        order deny,allow
+        allow from all
+</IfModule>
+</Directory>
+CONFIG
+);
+
 $db = DB_FILE;
 $data = dirname( DB_FILE );
-`$prefix ln -sf $web $folder`;
+#`$prefix ln -sf $web $folder`;
 `$prefix chmod 0666 $db`;
 `$prefix chmod 0777 $data`;
+
+echo "Please restart your apache before continuing\n";
+echo "WWW Trim is now enabled\n";
+echo "Go to your browser and do http://server_ip/webtrim/\n";;
+echo "Enjoy!\n";

 


------------------------------------------------------------------------------
Announcing the Oxford Dictionaries API! The API offers world-renowned
dictionary content that is easy and intuitive to access. Sign up for an
account today to start using our lexical data to power your apps and
projects. Get started today and enter our developer competition.
http://sdm.link/oxford
_______________________________________________
TikiWiki-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/tikiwiki-devel