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

[BUG] Template processing continues although arguments were not provided #404

Open
michael-o opened this issue Jun 14, 2021 · 3 comments
Open
Assignees
Labels
bug Something isn't working

Comments

@michael-o
Copy link
Contributor

[MANDATORY] Describe the bug [MANDATORY]
When a template is applied to a jail and the template contains mandatory args the system just warns and continues. Rendering the process useless.

[MANDATORY] Bastille and FreeBSD version (paste bastille -v && freebsd-version -kru output)
0.8.20210115
12.2-STABLE
12.2-STABLE
12.2-STABLE

[MANDATORY] How did you install bastille? (port/pkg/git)
ports

[optional] Steps to reproduce?
Create a sample Bastillefile

ARG ROOT_FULLNAME
ARG AUTHORIZED_KEYS
ARG K5LOGIN
ARG FORWARD

CMD pw usermod root -c "${ROOT_FULLNAME}"
CMD mkdir /root/.ssh
CP ${AUTHORIZED_KEYS} root/.ssh/authorized_keys
CP ${K5LOGIN} root/.k5login
CP ${FORWARD} root/.forward
CMD openssl rand -base64 15 > /tmp/root.passwd
CMD pw usermod root -h 0 < /tmp/root.passwd
CMD echo "This is the root password: $(cat /tmp/root.passwd)"
CMD rm /tmp/root.passwd

Apply with bastille template mumu lda/root-config and see it fail:

[mumu]:
Applying template: lda/root-config...
No value provided for arg: ROOT_FULLNAME
No value provided for arg: AUTHORIZED_KEYS
No value provided for arg: K5LOGIN
No value provided for arg: FORWARD
[mumu]:

[mumu]:

[mumu]:
/usr/local/bastille/templates/lda/root-config/ -> /usr/local/bastille/jails/mumu/root/root/.ssh
/usr/local/bastille/templates/lda/root-config/Bastillefile -> /usr/local/bastille/jails/mumu/root/root/.ssh/Bastillefile

[mumu]:
cp: /usr/local/bastille/jails/mumu/root/root/.k5login: Not a directory

Failed to execute command: cp

[optional] Expected behavior
I would expect that Bastille for fail if the arg has not been provided and not default value has been set. Since I don't have any IF constructs in this file it does not make sense to continue here.

@michael-o michael-o added the bug Something isn't working label Jun 14, 2021
@michael-o michael-o changed the title [BUG] Template processing continue although arguments are empty [BUG] Template processing continue although arguments were not provided Jun 14, 2021
@michael-o michael-o changed the title [BUG] Template processing continue although arguments were not provided [BUG] Template processing continues although arguments were not provided Jun 14, 2021
@tobiastom
Copy link
Contributor

Just as additional context: we talked about this when the arguments where implemented: #255 (comment).

The reason why it is a warning only is because the feature is inspired by Docker and their documentation says:

If a user specifies a build argument that was not defined in the Dockerfile, the build outputs a warning.

That said, I agree that things could go wrong if the wrong argument is missing…

@michael-o
Copy link
Contributor Author

Just as additional context: we talked about this when the arguments where implemented: #255 (comment).

The reason why it is a warning only is because the feature is inspired by Docker and their documentation says:

If a user specifies a build argument that was not defined in the Dockerfile, the build outputs a warning.

That said, I agree that things could go wrong if the wrong argument is missing…

I see the purpose of consistency, but this inspiration is counterproductive. If your template runs for 30 min and your forget an argument and notice after 28 min, that's a pity. I would appreciate to reconsider arguments to be mandatory. They are arguments, not options after all.

@crypto-scythe
Copy link

crypto-scythe commented Jun 27, 2021

Maybe there is a way to stop the template from further running by failing a CMD?

I tried to realize it with something like this but the template still ran all other commands:
CMD [ "${MYARG}" = "" ] && exit 1

Edit: Just checked and Docker seems to be failing a build if a given command returns > 1. So failing a template with this condition would be even more like Docker 😀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants