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

FR - allow fetching username and password #379

Open
mikegriffin opened this issue Jul 5, 2024 · 1 comment
Open

FR - allow fetching username and password #379

mikegriffin opened this issue Jul 5, 2024 · 1 comment

Comments

@mikegriffin
Copy link
Contributor

It might be useful in some environments, where credentials are not stored locally, to allow arbitrary commands to fetch them, eg:

[mysql:client]
credential-method=fetch
user-fetch-cmd=curl foo1 | base64 --decode
passwd-fetch-cmd=curl foo2 | base64 --decode

These results should probably be stored in a memory, ie not in an environment variable or file

@mikegriffin
Copy link
Contributor Author

If this is to be implemented, it could probably be similar to *-backup-command hooks in commands/backup.py:

def call_hooks(event, entry):
    """
    Rerun pre or post hooks
    """
    hook = event + "-command"

    if entry.config["holland:backup"][hook] is not None:
        cmd = entry.config["holland:backup"][hook]
        try:
            cmd = Template(cmd).safe_substitute(
                hook=hook, backupset=entry.backupset, backupdir=entry.path
            )
            LOG.info(" [%s]> %s", hook, cmd)
            process = Popen(
                cmd,
                shell=True,
                stdin=open("/dev/null", "r"),
                stdout=PIPE,
                stderr=PIPE,
                close_fds=True,
            )
            output, errors = process.communicate()
        except OSError as exc:
            raise BackupError("%s" % exc)

        for line in errors.splitlines():
            LOG.error(" ! %s", line)
        for line in output.splitlines():
            LOG.info(" + %s", line)
        if process.returncode != 0:
            raise BackupError("%s command failed" % hook)
    return 0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant