Skip to content

Conversation

@CarstenGrohmann
Copy link
Contributor

@CarstenGrohmannCarstenGrohmann commented Jun 27, 2023

We need some functionality to query all user names as well as all group names. I implemented in two functions:

  • query all (local and remove) users and groups with getent passwd resp. getent group
  • query local users and groups with cat /etc/passwd resp. cat /etc/group

Small tests of all functions are also part of this pull request.

What do you think about such functionality?

@philpepphilpep added feature enhancement This issue/PR relates to a feature request. and removed feature labels Aug 24, 2023
"""
all_users= [
line.split(":")[0]
forlineinself.check_output("getent passwd").splitlines()
Copy link
Contributor

@martinhoyermartinhoyerJun 12, 2024

Choose a reason for hiding this comment

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

I think we could use pwd?

import pwd all_users = [pw.pw_name for pw in pwd.getpwall()] 

(same with grp for groups)

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Unfortunately, this is not possible because testinfra only executes Unix commands on the remote host.

@philpepphilpep merged commit 4a5fa6e into pytest-dev:mainMar 29, 2025
7 checks passed
@philpep
Copy link
Contributor

Merged, thanks!

@CarstenGrohmannCarstenGrohmann deleted the add_get_all_users branch March 30, 2025 17:19
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancementThis issue/PR relates to a feature request.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@CarstenGrohmann@philpep@martinhoyer