From 16e7b5af12e64945a5e88e58e5c1b18787ec5b1e Mon Sep 17 00:00:00 2001 From: Danial Behzadi Date: Sun, 18 Jun 2017 12:42:14 +0000 Subject: [PATCH 1/6] Update INSTALL Step 4 of `Getting it up and running` is not applicable in newer versions. --- INSTALL | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/INSTALL b/INSTALL index f7c2d21caf..06f3a23ee1 100644 --- a/INSTALL +++ b/INSTALL @@ -124,17 +124,7 @@ especially if you've previously installed PHP/MariaDB packages. that user's default group instead. As a last resort, you can create a new group like "gnusocial" and add the Web server's user to the group. -4. You should also take this moment to make your 'avatar' and 'file' sub- - directories writeable by the Web server. The _insecure_ way to do - this is: - - chmod a+w /var/www/gnusocial/avatar - chmod a+w /var/www/gnusocial/file - - You can also make the avatar, and file directories just writable by - the Web server group, as noted above. - -5. Create a database to hold your site data. Something like this +4. Create a database to hold your site data. Something like this should work (you will be prompted for your database password): mysqladmin -u "root" -p create social @@ -147,7 +137,7 @@ especially if you've previously installed PHP/MariaDB packages. a tool like phpMyAdmin to create a database. Check your hosting service's documentation for how to create a new MariaDB database.) -6. Create a new database account that GNU Social will use to access the +5. Create a new database account that GNU Social will use to access the database. If you have shell access, this will probably work from the MariaDB shell: @@ -159,7 +149,7 @@ especially if you've previously installed PHP/MariaDB packages. to your preferred new database username and password. You may want to test logging in to MariaDB as this new user. -7. In a browser, navigate to the GNU Social install script; something like: +6. In a browser, navigate to the GNU Social install script; something like: https://social.example.net/install.php @@ -167,7 +157,7 @@ especially if you've previously installed PHP/MariaDB packages. install program will configure your site and install the initial, almost-empty database. -8. You should now be able to navigate to your social site's main directory +7. You should now be able to navigate to your social site's main directory and see the "Public Timeline", which will probably be empty. You can now register new user, post some notices, edit your profile, etc. From e6150323317fb5c37e54a1ac3637b0dfa87038c6 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Sat, 19 Aug 2017 17:55:47 +0200 Subject: [PATCH 2/6] Fix PHP incompatibilities in XMPPHP This fixes the following to errors in XMPPHP: Stack trace: 0 [internal function]: XMPPHP_XMLStream->endXML(Resource id 150, 'STREAM:FEATURES') 1 /var/vhosts/example.org/plugins/Xmpp/extlib/XMPPHP/XMLStream.php(420): xml_parse(Resource id 150, '__process() 3 /var/vhosts/example.org/plugins/Xmpp/lib/xmppmanager.php(165): XMPPHP_XMLStream->processUntil(Array) 4 /var/vhosts/example.org/plugins/Xmpp/lib/xmppmanager.php(49): XmppManager->connect() 5 /var/vhosts/example.org/lib/iomaster.php(248): XmppManager->start(Object(ImMaster)) 6 /var/vhosts/example.org/lib/iomaster.php(111): IoMaster->start() 7 /var/vhosts/example.org/scripts/imdaemon.php(58): IoMaster->service() 8 /var/vhosts/example.org/lib/spawningdaemon.php(189): ImDaemon->runThread() in /var/vhosts/example.org/plugins/Xmpp/extlib/XMPPHP/XMLStream.php on line 567 PHP Fatal error: Uncaught Error: Function name must be a string in /var/vhosts/example.org/plugins/Xmpp/extlib/XMPPHP/XMLStream.php:567 PHP Fatal error: Uncaught Error: Call to undefined function split() in /var/vhosts/example.org/plugins/Xmpp/extlib/XMPPHP/XMLStream.php:266 Stack trace: 0 /var/vhosts/example.org/plugins/Xmpp/extlib/XMPPHP/XMPP.php(129): XMPPHP_XMLStream->addXPathHandler('{http://etherx....', 'features_handle...') 1 /var/vhosts/example.org/plugins/Xmpp/lib/xmppmanager.php(145): XMPPHP_XMPP->__construct('geekplace.eu', 5222, 'gnusocial', 'U^k&l5fV53duGy', 'gnusocial', 'geekplace.eu', false, NULL) 2 /var/vhosts/example.org/plugins/Xmpp/lib/xmppmanager.php(49): XmppManager->connect() 3 /var/vhosts/example.org/lib/iomaster.php(248): XmppManager->start(Object(ImMaster)) 4 /var/vhosts/example.org/lib/iomaster.php(111): IoMaster->start() 5 /var/vhosts/example.org/scripts/imdaemon.php(58): IoMaster->service() 6 /var/vhosts/example.org/lib/spawningdaemon.php(189): ImDaemon->runThread() 7 /var/vhosts/example.org/lib/spawningdaemon.php(118): SpawningDaemon->initAndRunChild(1 in /var/vhosts/example.org/plugins/Xmpp/extlib/XMPPHP/XMLStream.php on line 266 --- plugins/Xmpp/extlib/XMPPHP/Roster.php | 4 ++-- plugins/Xmpp/extlib/XMPPHP/XMLStream.php | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/plugins/Xmpp/extlib/XMPPHP/Roster.php b/plugins/Xmpp/extlib/XMPPHP/Roster.php index 2e459e2a2f..69457b22a1 100644 --- a/plugins/Xmpp/extlib/XMPPHP/Roster.php +++ b/plugins/Xmpp/extlib/XMPPHP/Roster.php @@ -118,7 +118,7 @@ class Roster { * @param string $status */ public function setPresence($presence, $priority, $show, $status) { - list($jid, $resource) = split("/", $presence); + list($jid, $resource) = explode("/", $presence); if ($show != 'unavailable') { if (!$this->isContact($jid)) { $this->addContact($jid, 'not-in-roster'); @@ -137,7 +137,7 @@ class Roster { * @param string $jid */ public function getPresence($jid) { - $split = split("/", $jid); + $split = explode("/", $jid); $jid = $split[0]; if($this->isContact($jid)) { $current = array('resource' => '', 'active' => '', 'priority' => -129, 'show' => '', 'status' => ''); //Priorities can only be -128 = 127 diff --git a/plugins/Xmpp/extlib/XMPPHP/XMLStream.php b/plugins/Xmpp/extlib/XMPPHP/XMLStream.php index d33411ec54..eefa84531c 100644 --- a/plugins/Xmpp/extlib/XMPPHP/XMLStream.php +++ b/plugins/Xmpp/extlib/XMPPHP/XMLStream.php @@ -263,7 +263,7 @@ class XMPPHP_XMLStream { $ns_tags = array($xpath); } foreach($ns_tags as $ns_tag) { - list($l, $r) = split("}", $ns_tag); + list($l, $r) = explode("}", $ns_tag); if ($r != null) { $xpart = array(substr($l, 1), $r); } else { @@ -564,7 +564,7 @@ class XMPPHP_XMLStream { if ($searchxml !== null) { if($handler[2] === null) $handler[2] = $this; $this->log->log("Calling {$handler[1]}", XMPPHP_Log::LEVEL_DEBUG); - $handler[2]->$handler[1]($this->xmlobj[2]); + $handler[2]->{$handler[1]}($this->xmlobj[2]); } } } @@ -584,7 +584,7 @@ class XMPPHP_XMLStream { foreach($this->idhandlers as $id => $handler) { if(array_key_exists('id', $this->xmlobj[2]->attrs) and $this->xmlobj[2]->attrs['id'] == $id) { if($handler[1] === null) $handler[1] = $this; - $handler[1]->$handler[0]($this->xmlobj[2]); + $handler[1]->{$handler[0]}($this->xmlobj[2]); #id handlers are only used once unset($this->idhandlers[$id]); break; @@ -640,7 +640,7 @@ class XMPPHP_XMLStream { if($handler[2] === null) { $handler[2] = $this; } - $handler[2]->$handler[1]($payload); + $handler[2]->{$handler[1]}($payload); } } foreach($this->until as $key => $until) { From a6e33bdd6a9c44e5fd06af3c3973c0112792d743 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Fri, 25 Aug 2017 11:35:02 +0000 Subject: [PATCH 3/6] Fixed code so that GNU social can receive Mastodon boosts (from GNU social nightly commit: https://git.gnu.io/gnu/gnu-social/commit/c741d1a52a8256336632d090fa5ffd7d2cf549a9) --- lib/activity.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/activity.php b/lib/activity.php index 49f7603d80..a52f29e9ca 100644 --- a/lib/activity.php +++ b/lib/activity.php @@ -180,7 +180,7 @@ class Activity foreach ($objectEls as $objectEl) { // Special case for embedded activities $objectType = ActivityUtils::childContent($objectEl, self::OBJECTTYPE, self::SPEC); - if (!empty($objectType) && $objectType == ActivityObject::ACTIVITY) { + if ((!empty($objectType) && $objectType == ActivityObject::ACTIVITY) || $this->verb == ActivityVerb::SHARE) { $this->objects[] = new Activity($objectEl); } else { $this->objects[] = new ActivityObject($objectEl); From fdd3d63098f6411b2bec99fbca96543866374de7 Mon Sep 17 00:00:00 2001 From: nee Date: Sun, 26 Nov 2017 22:14:30 +0100 Subject: [PATCH 4/6] Don't write the config file when --skip-config flag is given to the installer. * scripts/installer_cli.php: Read the arguments list before checking if the config file is writeable. --- lib/installer.php | 14 ++++++++------ scripts/install_cli.php | 2 +- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/installer.php b/lib/installer.php index 346c706d61..e73216f18d 100644 --- a/lib/installer.php +++ b/lib/installer.php @@ -85,7 +85,7 @@ abstract class Installer $pass = true; $config = INSTALLDIR.'/config.php'; - if (file_exists($config)) { + if (!$this->skipConfig && file_exists($config)) { if (!is_writable($config) || filesize($config) > 0) { if (filesize($config) == 0) { $this->warning('Config file "config.php" already exists and is empty, but is not writable.'); @@ -126,14 +126,16 @@ abstract class Installer } // @fixme this check seems to be insufficient with Windows ACLs - if (!is_writable(INSTALLDIR)) { + if (!$this->skipConfig && !is_writable(INSTALLDIR)) { $this->warning(sprintf('Cannot write config file to: %s

', INSTALLDIR), sprintf('On your server, try this command: chmod a+w %s', INSTALLDIR)); $pass = false; } // Check the subdirs used for file uploads - $fileSubdirs = array('avatar', 'file'); + // TODO get another flag for this --skipFileSubdirCreation + if (!$this->skipConfig) { + $fileSubdirs = array($this->avatarDir, $this->fileDir); foreach ($fileSubdirs as $fileSubdir) { $fileFullPath = INSTALLDIR."/$fileSubdir"; if (!file_exists($fileFullPath)) { @@ -148,7 +150,7 @@ abstract class Installer $pass = false; } } - + } return $pass; } @@ -580,10 +582,10 @@ abstract class Installer return false; } + if (!$this->skipConfig) { // Make sure we can write to the file twice $oldUmask = umask(000); - if (!$this->skipConfig) { $this->updateStatus("Writing config file..."); $res = $this->writeConf(); @@ -616,12 +618,12 @@ abstract class Installer $this->updateStatus("Can't write to config file.", true); return false; } - } // Restore original umask umask($oldUmask); // Set permissions back to something decent chmod(INSTALLDIR.'/config.php', 0644); + } $scheme = $this->ssl === 'always' ? 'https' : 'http'; $link = "{$scheme}://{$this->server}/{$this->path}"; diff --git a/scripts/install_cli.php b/scripts/install_cli.php index 815418aaab..da5f0f4b0c 100755 --- a/scripts/install_cli.php +++ b/scripts/install_cli.php @@ -47,10 +47,10 @@ class CliInstaller extends Installer */ function main() { + if ($this->prepare()) { if (!$this->checkPrereqs()) { return false; } - if ($this->prepare()) { return $this->handle(); } else { $this->showHelp(); From 3b5fabbe97b333a7d1137ce5910e340c8444e509 Mon Sep 17 00:00:00 2001 From: nee Date: Wed, 6 Dec 2017 01:50:22 +0100 Subject: [PATCH 5/6] set the html sanitizer cache directory to ['cache']['dir'] from the config file; --- CONFIGURE | 7 +++++++ lib/util.php | 3 +++ 2 files changed, 10 insertions(+) diff --git a/CONFIGURE b/CONFIGURE index 25af381332..4a7926f8c9 100644 --- a/CONFIGURE +++ b/CONFIGURE @@ -773,6 +773,13 @@ high: if you need high performance, or if you're seeing bad performance, set this to true. It will turn off some high-intensity code from the site. +cache +----- + +dir: A string path to a writable directory that will be used as temporary cache + for some functions (currently just the HtmlSanitizer). + If it is not set, the GNU social installation directory will be used. + oldschool --------- diff --git a/lib/util.php b/lib/util.php index 62db64d828..9c32d74433 100644 --- a/lib/util.php +++ b/lib/util.php @@ -597,6 +597,9 @@ function common_purify($html) $cfg->set('Attr.AllowedRel', ['bookmark', 'directory', 'enclosure', 'home', 'license', 'nofollow', 'payment', 'tag']); // http://microformats.org/wiki/rel $cfg->set('HTML.ForbiddenAttributes', array('style')); // id, on* etc. are already filtered by default $cfg->set('URI.AllowedSchemes', array_fill_keys(common_url_schemes(), true)); + if (common_config('cache', 'dir')) { + $cfg->set('Cache.SerializerPath', common_config('cache', 'dir')); + } // Remove more elements than what the default filter removes, default in GNU social are remotely // linked resources such as img, video, audio From 0b9a2fdf3ad19942e85a66b94d08501ce9c927dd Mon Sep 17 00:00:00 2001 From: nee Date: Sun, 17 Dec 2017 17:52:24 +0100 Subject: [PATCH 6/6] allow the cmd installer to load the config file from '/etc/gnusocial/config.d/'.$_server.'.php' using the commandline argument as $_server (passed through lib/common.php to lib/gnusocial.php) --- lib/installer.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/installer.php b/lib/installer.php index e73216f18d..5f44812b23 100644 --- a/lib/installer.php +++ b/lib/installer.php @@ -517,6 +517,9 @@ abstract class Installer */ function registerInitialUser() { + // initalize hostname from install arguments, so it can be used to find + // the /etc config file from the commandline installer + $server = $this->server; require_once INSTALLDIR . '/lib/common.php'; $data = array('nickname' => $this->adminNick,