Page MenuHomePhabricator

mw1017 has outdated broken mwscript
Closed, ResolvedPublic

Description

-rwxr-xr-x 1 root root 654 Aug 8 2014 /usr/local/bin/mwscript
This still tries to sudo as apache, but modern versions use $MEDIAWIKI_WEB_USER to get the correct user (www-data).

Event Timeline

Krenair raised the priority of this task from to Needs Triage.
Krenair updated the task description. (Show Details)
Krenair added a project: acl*sre-team.
Krenair subscribed.

mwscript is provisioned by scap::scripts. That class is applied directly on terbium and indirectly on hosts with role::deployment::server (tin, mira) and role::nova::manager (silver).

If /usr/local/bin/mwscript is on any other hosts it is left over from older puppet rules and likely horribly out of date.

@Krenair I do not fully understand what is the suggested actionable, should the script be removed (because it is unppupetized and not in use) or updated (and/or puppetized) ?

I'd prefer it to be updated by adding scap::scripts to the host directly. mwscript can occasionally be useful there (it's the host we use to test code without affecting users - runs test.wikipedia.org and other requests with the X-Wikimedia-Debug header).

Change 237707 had a related patch set uploaded (by Jcrespo):
Add scap scripts to all canary app servers

https://gerrit.wikimedia.org/r/237707

jcrespo triaged this task as Medium priority.

Change 237707 merged by Dzahn:
Add scap scripts to all canary app servers

https://gerrit.wikimedia.org/r/237707

Sep 14 23:50:10 mw1017 puppet-agent[19262]: (/Stage[main]/Scap::Scripts/File[/usr/local/bin/mwscript]/content) content changed

Notice: /Stage[main]/Scap::Scripts/File[/usr/local/bin/mwscript]/content: 
--- /usr/local/bin/mwscript	2014-08-08 12:12:50.164292436 +0000
+++ /tmp/puppet-file20150914-19262-1hg4dqv	2015-09-14 23:50:10.126281791 +0000
@@ -1,18 +1,23 @@
 #!/bin/bash
 # Shell wrapper for the home version of multiversion/MWScript.php.
 # This script belongs in /usr/local/bin/ and should be in PATH.
-. /usr/local/lib/mw-deployment-vars.sh
+. /etc/profile.d/mediawiki.sh
 
 # Use the source version of the script if the source directory is present.
 # This only matters if the source dir is shared or when run on the deployment server.
-if [ -d "$MW_COMMON_SOURCE" ]; then
-    MW_COMMON_DIR_USE=$MW_COMMON_SOURCE
+if [ -d "$MEDIAWIKI_STAGING_DIR" ]; then
+	MEDIAWIKI_DEPLOYMENT_DIR_DIR_USE=$MEDIAWIKI_STAGING_DIR
 else
-    MW_COMMON_DIR_USE=$MW_COMMON
+	MEDIAWIKI_DEPLOYMENT_DIR_DIR_USE=$MEDIAWIKI_DEPLOYMENT_DIR
 fi
 
-if groups | grep -Ewq 'sudo|wikidev|root'; then
-    sudo -u apache php "$MW_COMMON_DIR_USE/multiversion/MWScript.php" "$@"
+# PHP spits errors on unknown terminals before falling back to "dumb"
+if [ -z "$TERM" ] || [ "$TERM" = unknown ] || [ "$TERM" = dumb ]; then
+	export TERM=dumb
+fi
+
+if [ "`whoami`" != "$MEDIAWIKI_WEB_USER" ] ; then
+	sudo -u "$MEDIAWIKI_WEB_USER" php "$MEDIAWIKI_DEPLOYMENT_DIR_DIR_USE/multiversion/MWScript.php" "$@"
 else
-    php5 "$MW_COMMON_DIR_USE/multiversion/MWScript.php" "$@"
+	php "$MEDIAWIKI_DEPLOYMENT_DIR_DIR_USE/multiversion/MWScript.php" "$@"
 fi
....
Dzahn removed a project: Patch-For-Review.
Dzahn set Security to None.