Use case: import a Wikidata dump into a MediaWiki Vagrant instance running on a Cloud-VPS machine.
TL;DR: is there a workaround or an alternative import method to avoid doing this manually? :-)
cd /srv/mediawiki-vagrant vagrant import-dump wikidatawiki-latest-pages-articles19.xml-p19072452p19140743.bz2
sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set
Changing the /usr/bin/sudo bits in the Vagrant box, as suggested in:
requires root privileges, of course, and I'm not sure it's a good workaround. Anyway, the default root password is not vagrant, as mentioned in:
Here is some digging that may be useful.
- the actual BASH script run in the Vagrant box is /srv/mediawiki-vagrant/puppet/modules/mediawiki/files/import-mediawiki-dump;
- the script calls mwscript:
/usr/local/bin/mwscript importDump.php --uploads -- "$FILE" /usr/local/bin/mwscript rebuildrecentchanges.php
- mwscript is the one calling sudo, see lines 4 and 5:
# Ensure that the script is run as the www-data user [[ $(whoami) = www-data ]] || exec sudo --preserve-env -u www-data -n -- "$0" "$@"
- directly calling /var/www/w/MWScript.php from inside the Vagrant box also fails:
vagrant ssh php /var/www/w/MWScript.php importDump.php --uploads /vagrant/wikidatawiki-latest-pages-articles19.xml-p19072452p19140743.bz2
Cannot run a MediaWiki script as a user in the group vagrant Maintenance scripts should generally be run using sudo -u www-data which is available to all wikidev users. Running a maintenance script as a privileged user risks compromise of the user account. You should run this script as the www-data user: sudo -u www-data -- <command>
Related to T76041.