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

User - Create parent directories if they do not exist in the specified home path #51043

Merged
merged 3 commits into from
Jul 18, 2019

Conversation

samdoran
Copy link
Contributor

@samdoran samdoran commented Jan 17, 2019

SUMMARY

Fixes #41393

The useradd command line tool does not create parent directories. The PR checks if the specified home path has parents that do not exist. If so, create them prior to running useradd, then set the proper permission on the created directory.

This would fail on the first run because the code it was hitting only checked for missing home directories when the user account existed. The first run code was relying on useradd to create the home directory if it didn't exist, which it usually does. But when parent directories do not exist, useradd simply fails to create the home directory though it does create the account on the system.

Also add integration tests.

Signed-off-by: Sam Doran sdoran@redhat.com

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

user.py

@ansibot
Copy link
Contributor

ansibot commented Jan 17, 2019

cc @sfromm
click here for bot help

@ansibot ansibot added affects_2.8 This issue/PR affects Ansible v2.8 bug This issue/PR relates to a bug. module This issue/PR relates to a module. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. needs_triage Needs a first human triage before being processed. support:community This issue/PR relates to code supported by the Ansible community. support:core This issue/PR relates to code supported by the Ansible Engineering Team. labels Jan 17, 2019
@samdoran samdoran force-pushed the issue/41393-user-home-with-parents branch from e3a4dfa to 95b921a Compare January 21, 2019 17:22
@ansibot ansibot added core_review In order to be merged, this PR must follow the core review workflow. and removed needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. labels Jan 21, 2019
@bcoca bcoca removed the needs_triage Needs a first human triage before being processed. label Jan 21, 2019
@ansibot ansibot added the stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. label Feb 2, 2019
@ansibot ansibot removed the stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. label Feb 10, 2019
@samdoran samdoran force-pushed the issue/41393-user-home-with-parents branch from 95b921a to bcfd5c2 Compare February 13, 2019 20:44
@ansibot ansibot added the system System category label Feb 13, 2019
@ansibot ansibot added the stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. label Feb 22, 2019
@samdoran
Copy link
Contributor Author

bot_status

@ansibot
Copy link
Contributor

ansibot commented Mar 14, 2019

Components

changelogs/fragments/user-home-dir-with-no-parents.yaml
support: community
maintainers:

lib/ansible/modules/system/user.py
support: core
maintainers: samdoran sfromm

test/integration/targets/user/tasks/main.yml
support: core
maintainers: samdoran sfromm

test/integration/targets/user/vars/main.yml
support: core
maintainers: samdoran sfromm

Metadata

waiting_on: ansible
changes_requested_by: null
needs_info: False
needs_revision: False
needs_rebase: False
merge_commits: []
too many files or commits: False
mergeable_state: clean
shippable_status: success
maintainer_shipits (module maintainers): 0
community_shipits (namespace maintainers): 0
ansible_shipits (core team members): 1
shipit_actors (maintainers or core team members): samdoran
shipit_actors_other: []
automerge: automerge shipit test failed

click here for bot help

@ansibot ansibot removed the stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. label Mar 14, 2019
@ansibot ansibot added the stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. label Mar 22, 2019
@samdoran samdoran force-pushed the issue/41393-user-home-with-parents branch from bcfd5c2 to 5c906de Compare April 16, 2019 20:15
@ansibot ansibot removed the stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. label Apr 16, 2019
@ansibot ansibot added the stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. label Apr 25, 2019
The useradd command line tool does not create parent directories. Check if the specified home path has parents that do not exist. If so, create them prior to running useradd, then set the proper permission on the created directory.

Add tests

Signed-off-by: Sam Doran <sdoran@redhat.com>
Signed-off-by: Sam Doran <sdoran@redhat.com>
Signed-off-by: Sam Doran <sdoran@redhat.com>
@samdoran samdoran force-pushed the issue/41393-user-home-with-parents branch from 5c906de to bb53911 Compare May 14, 2019 20:37
@ansibot ansibot removed the stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. label May 14, 2019
@ansibot ansibot added the stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. label May 22, 2019
@samdoran
Copy link
Contributor Author

rebuild_merge

@ansibot ansibot added shipit This PR is ready to be merged by Core and removed core_review In order to be merged, this PR must follow the core review workflow. stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. labels Jul 18, 2019
@ansibot ansibot merged commit d2edf1d into ansible:devel Jul 18, 2019
samdoran added a commit to samdoran/ansible that referenced this pull request Jul 18, 2019
… the specified home path (ansible#51043)

* Create a user home directory if it has parents that do not exist

The useradd command line tool does not create parent directories. Check if the specified home path has parents that do not exist. If so, create them prior to running useradd, then set the proper permission on the created directory.

Add tests

Signed-off-by: Sam Doran <sdoran@redhat.com>

* Use dict for default user group in tests

Signed-off-by: Sam Doran <sdoran@redhat.com>

* Fix tests

Signed-off-by: Sam Doran <sdoran@redhat.com>
(cherry picked from commit d2edf1d)

Co-authored-by: Sam Doran <sdoran@redhat.com>
samdoran pushed a commit to samdoran/ansible that referenced this pull request Aug 12, 2019
Fixes ansible#60307.

This bug was introduced in commit d2edf1d
("User - Create parent directories if they do not exist in the specified
home path (ansible#51043)") and did not make it into any releases.

(cherry picked from commit c71622b)
StephenSorriaux pushed a commit to StephenSorriaux/ansible that referenced this pull request Aug 12, 2019
Fixes ansible#60307.

This bug was introduced in commit d2edf1d
("User - Create parent directories if they do not exist in the specified
home path (ansible#51043)") and did not make it into any releases.
@ansible ansible locked and limited conversation to collaborators Aug 15, 2019
@samdoran samdoran deleted the issue/41393-user-home-with-parents branch July 21, 2020 19:45
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.8 This issue/PR affects Ansible v2.8 bug This issue/PR relates to a bug. module This issue/PR relates to a module. shipit This PR is ready to be merged by Core support:community This issue/PR relates to code supported by the Ansible community. support:core This issue/PR relates to code supported by the Ansible Engineering Team. system System category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[USER] Cannot create home directory when parent directory doesn't exists (only first time)
3 participants