Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configuration permission issues - unable to access rclone config file #122

Open
n-hass opened this issue Aug 23, 2023 · 6 comments
Open
Labels
troubleshooting There might be bug or it could be user error, more info needed type: config

Comments

@n-hass
Copy link

n-hass commented Aug 23, 2023

Hello

I am encountering some strange issues with permissions. Whether I use my userns keep-id or as root 0:0, I can create and view a config with podman run but cannot run the backup script.

IE, this reveals my valid config:

podman run --user 0:0 -v /etc/localtime:/etc/localtime:ro -v /home/servhost/vw-server/vw-data:/bitwarden/data -v /home/servhost/vw-server/backups/backup-service-config:/config/ -v /tank/vaultwarden-backups:/tank-backup-repo --env-file /home/servhost/vw-server/.env.backup-service -it docker.io/ttionya/vaultwarden-backup:latest rclone config

and then the same command dropping the -it and rclone config, fails with config not found:

podman run --user 0:0 -v /etc/localtime:/etc/localtime:ro -v /home/servhost/vw-server/vw-data:/bitwarden/data -v /home/servhost/vw-server/backups/backup-service-config:/config/ -v /tank/vaultwarden-backups:/tank-backup-repo --env-file /home/servhost/vw-server/.env.backup-service docker.io/ttionya/vaultwarden-backup:latest

If I also do -it —entrypoint sh, i can go to the config dir and access the rclone.conf file.

Why might the backup script be the only thing not able to access the rclone config?

@n-hass
Copy link
Author

n-hass commented Aug 23, 2023

For some reason not using an environment file and using direct env values in the podman run command fixes this and it runs like normal… confusing :/

Worth noting there must be something fragile about the way env files are handled.

@ttionya
Copy link
Owner

ttionya commented Aug 23, 2023

I attempted to reproduce the issue but wasn't successful. Could you provide the environment variables starting with RCLONE_ from the env file? Additionally, it would be helpful if you could provide the error log.

Furthermore, if your error message is rclone configuration information not found, it's related only to RCLONE_REMOTE_NAME. You can enter the container to confirm the value of the RCLONE_REMOTE_NAME environment variable. By default, it's BitwardenBackup. You can also use the command rclone config show "${RCLONE_REMOTE_NAME:-"BitwardenBackup"}" to ensure that the rclone configuration is correctly retrieved.

@ttionya ttionya added troubleshooting There might be bug or it could be user error, more info needed type: config labels Aug 23, 2023
@Fiestaman
Copy link

I also had the same issue as @n-hass. However, instead of using direct env values like he did, I directly mounted the .env file to /.env and removed the --env-file flag. Then, everything loaded as it should. Something isn't getting read correctly when using the --env-file flag.

@ttionya
Copy link
Owner

ttionya commented Sep 4, 2023

I compared the differences between using --env-file and mounting the .env file to /.env.

When the environment variable values in the .env file include quotes (' and ", example A='xxx'), using --env-file results in the program getting the value as 'xxx', whereas when mounted to /.env, the program retrieves the value as xxx. (This is the conclusion I've reached on my Windows computer. I need to further validate if it's the same on Linux. I obtained the same result on both Windows and Linux.)

I would like to get more information, especially the output of environment variables, to help troubleshoot the issue.

@Fiestaman
Copy link

I compared the differences between using --env-file and mounting the .env file to /.env.

When the environment variable values in the .env file include quotes (' and ", example A='xxx'), using --env-file results in the program getting the value as 'xxx', whereas when mounted to /.env, the program retrieves the value as xxx. (This is the conclusion I've reached on my Windows computer. I need to further validate if it's the same on Linux. I obtained the same result on both Windows and Linux.)

After you mentioned this, I did go back and try loading the .env as --env-file and can replicate your findings. I had some single quote entries that were read in with the quotes.

I would like to get more information, especially the output of environment variables, to help troubleshoot the issue.

What information are you seeking and how can I help provide it to help you with further troubleshooting?

@ttionya
Copy link
Owner

ttionya commented Sep 4, 2023

@Fiestaman ,

I need to confirm if the problem is caused by the improper removal of quotation marks around the environment variable values when using --env-file.

If possible, please provide the log information related to environment variables. They should be separated by yellow ============= and look like key-value pairs, for example: RCLONE_REMOTE: BitwardenBackup:/BitwardenBackup.

Unfortunately, even if we have confirmed that the issue is caused by quotation marks, there are limited actions this tool can take. I believe the best course of action would be to include a reminder in the README, advising users not to use the --env-file method for importing environment variables when quotation marks are present in the environment variable values.

While it might be tempting to simply remove leading and trailing quotation marks from the values of environment variables, what should the tool do if a user's environment variable is ENV='"ABC"'? Handling such cases could introduce complexity and potential errors. Therefore, avoiding the use of --env-file when quotation marks are involved appears to be the safest option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
troubleshooting There might be bug or it could be user error, more info needed type: config
Projects
None yet
Development

No branches or pull requests

3 participants