Skip to content

Quadlet - new unit type .login #26507

New issue

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

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

Already on GitHub? # to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ygalblum
Copy link
Contributor

Does this PR introduce a user-facing change?

Yes

Quadlet - new unit for podman login
Quadlet - Add support for AuthFile to container and kube units

Copy link
Contributor

openshift-ci bot commented Jun 24, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ygalblum

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 24, 2025
Copy link

[NON-BLOCKING] Packit jobs failed. @containers/packit-build please check. Everyone else, feel free to ignore.

@ygalblum ygalblum force-pushed the quadlet-login branch 2 times, most recently from 004b64f to b0edc68 Compare June 24, 2025 21:38

stringKeys := map[string]string{
KeyCertDir: "--cert-dir",
KeyPassword: "--password",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is insecure so we should not do that as it is not any better than before, it is the same issue as I described in #26484 (comment).

Security relevant stuff should never be passed as on cli argument. I think what this must do is a pass --password-stdin. Then in the systemd unit configure

StandardInput=data
StandardInputText=password

And lastly I am not sure on the perms of current generated files but we should make sure they are 600 so no other user could read the password from there.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is insecure

While I understand your comment, Quadlet already does something similar in .image files: https://docs.podman.io/en/latest/markdown/podman-systemd.unit.5.html#creds.
I don't expect users to use it with real registries. But, do we need to block it? We can add a warning in the man page.

I think what this must do is a pass --password-stdin

I don't see the benefit here. Isn't the password still leaked just under a different key? What am I missing?

And lastly I am not sure on the perms of current generated files but we should make sure they are 600 so no other user could read the password from there.

Currently, all service files are created with 644. Is your comment about permissions specific to the Password key or as a whole to all .login units?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes but again this is horrible security practise so we must discourage it. The login unit should be a solution and not do the exact same error again. The issue is that running podman login --password mypw leaks the password to all users who can view the process list which by default is everyone.

My solution is more secure because the password is never passed via cli argument but rather stdin which is "private". The permissions on the .login file are up to the user who creates them and only something quadlet could warn. But the permissions on the generated -login.service file is up to us so we must ensure the service file is only accessible by the same user because the service also has the password in clear text.

Copy link
Contributor Author

@ygalblum ygalblum Jun 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure I follow why using StandardInputText is better. Doesn't it just mean that instead of:

[Login]
Password=password

The .login unit will have:

[Login]
PasswordSTDIN=yes

[Service]
StandardInput=data
StandardInputText=password

Which also means that it will be copied to the .service file

From what I can see, the actual podman login command does not show in the journal. So, it's not leaked:

Jun 25 08:28:47 lima-default systemd[1001]: Starting image_test_t1-wmsnex2o-login.service...
Jun 25 08:28:47 lima-default image_test_t1-wmsnex2o-login[894538]: Login Succeeded!
Jun 25 08:28:47 lima-default systemd[1001]: Finished image_test_t1-wmsnex2o-login.service.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any user can just run ps auxww and see all the process currently running and does the password is leaked to all users. For a short lived command such as podman login it is hard to actually hit the right window to see it but if you try hard enough and run ps in a loop you might get lucky. Certainly not a secure.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. So, I'll remove the support for Password and replace it with PasswordSTDIN and document the requirement for setting StandardInputText. Quadlet will not verify the existence of StandardInputText when PasswordSTDIN is set because it can be set in a drop-in.

As for permissions, the question is on the generated .service files. Do you think that all .service files generated for .login units should have 600? Only the ones with PasswordSTDIN? Not change the implementation at all and warn the user in the doc?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be clear you don't have to remove support for "Password" as quadlet field. What I try to say here is that we (quadlet) internally map the Password to mean set --password-stdin and

[Service]
StandardInput=data
StandardInputText=<value of Password field>

The user should not need to worry about the implementation details but to me it is very important to not accidentally leak an important secret as cli arg.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've adjusted the code, the tests and the documentation with your recommendations

# Use the same directory for all quadlet files to make sure later steps access previous ones
mkdir $quadlet_tmpdir
# Shutdown the login service to logout and let the dependency kick in
service_cleanup $login_service inactive
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is the podman login --authfile $authfile --get-login $registry command you could run to check if you are logged into the registry. which should fail as the service stop should run logout

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. I added checked around starting and stopping of the login service (directly and indirectly)


Path of the authentication file.

This field is mandatory when linking between an `AuthFile` key of a different unit and the `.login` unit.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would it make sense to instead default to %t/<unit-name>?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question, I'm not sure.
Not setting one, means that the login information is stored in the default file. So, units can depend on on the .login unit (in the Wants and After) without setting AuthKey.
But, maybe it is cleaner

@ygalblum ygalblum force-pushed the quadlet-login branch 3 times, most recently from 110eafe to 84997b1 Compare June 25, 2025 19:26
Implement a new unit for podman login
Add support for AuthFile to container and kube units
Allow linking between AuthFile and a login unit

Signed-off-by: Ygal Blum <ygal.blum@gmail.com>

This field is mandatory when linking between an `AuthFile` key of a different unit and the `.login` unit.

This is equivalent to the `--authfile` option.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
This is equivalent to the `--authfile` option.
This is equivalent to the Podman `--authfile` option.

In some places, you have Podman for a line like this, in others, you do not. I prefer having Podman for each. However, your call, I'd just ask for consistency.


### `LogoutOnStop=` (defaults to `false`)

When set to `true` the logout will be called when the service is stopped
Copy link
Member

@TomSweeneyRedHat TomSweeneyRedHat Jun 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
When set to `true` the logout will be called when the service is stopped
When set to `true`, the logout will be called when the service is stopped.


This key contains a list of arguments passed directly to the end of the `podman login` command
in the generated file. It can be used to access Podman features otherwise unsupported by the generator. Since the generator is unaware
of what unexpected interactions can be caused by these arguments, is not recommended to use
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
of what unexpected interactions can be caused by these arguments, is not recommended to use
of the unexpected interactions that can be caused by these arguments, it is not recommended to use

this option.

The format of this is a space separated list of arguments, which can optionally be individually
escaped to allow inclusion of whitespace and other control characters.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to add some examples at the bottom of this page. Not a necessity.


### `Secret=`

Use a podman secret for the credentials
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Use a podman secret for the credentials
Use a podman secret for the credentials.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. release-note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants