archivematica / Issues

Issues repository for the Archivematica project
GNU Affero General Public License v3.0
16 stars 1 forks source link

Problem: manage.py scripts fail when using rsync space/locations #1591

Open mamedin opened 1 year ago

mamedin commented 1 year ago

Version of the documentation

The rsync space will be added to SS 0.20, so it is for AM >= 1.14.

Page (and section, if applicable) where the issue occurs

All the scripts starting with:

sudo -u archivematica bash -c " \
                        set -a -e

Description of the issue

When a manage.py command on SS (like import_aip or create_aip_replicas) needs to work with rclone, it tries to find the rclone.conf on root config dir:

locations.models.StorageException: Error running rclone command. Command called: ['rclone', 'listremotes']. Details: ('rclone returned non-zero return code: %s. stderr: %s', 1, '2023/02/21 09:24:11 Failed to load config file "/root/.rclone.conf": open /root/.rclone.conf: permission denied\n')
You have mail in /var/mail/root

Suggested fix

Using the -H option with the sudo command fixes the issue. From sudo man page:

     -H, --set-home
                 Request that the security policy set the HOME environment variable to the home directory specified by the target user's password database entry.  Depending on the
                 policy, this may be the default behavior.

So we need to change all the scripts from:

sudo -u archivematica bash -c " \
                        set -a -e

To:

sudo -H -u archivematica bash -c " \
                        set -a -e

We can safely apply the same to all the dashboard manage.py commands as well.


For Artefactual use:

Before you close this issue, you must check off the following:

replaceafill commented 1 year ago

We plan to add a note in the Management commands section of the Storage Service documentation explaining the relevance of the sudo -H flag in RClone configurations.