Skip to content

Lock StateDir#188

Merged
AkihiroSuda merged 2 commits intorootless-containers:masterfrom
HappyTobi:lock_tmp_dir
Nov 4, 2020
Merged

Lock StateDir#188
AkihiroSuda merged 2 commits intorootless-containers:masterfrom
HappyTobi:lock_tmp_dir

Conversation

@HappyTobi
Copy link
Copy Markdown
Contributor

Hi all,

here is the FIX for the created issue #185

Description

If the user don't pass the --state-dir argument the internal StateDirTemp flag will be set.
On running the Parent function a Shared BSD Lock LOCK_SH will be set on the stateDir.

All locks will be removed with the Rootlesskit StateFileLock (/tmp/rootlesskitXXX/lock).

I also added a test to check if the lock was created, but to test that on a real system you have to read the verify part.

Verify Systemd-tmpfiles cleanup resilience

OS: Ubuntu 18.04 LTS

  1. Check tmp settings
    cat /usr/lib/tmpfiles.d/tmp.conf

  2. Change them if no cleanup for "old files" was configured.
    sudo nano /usr/lib/tmpfiles.d/tmp.conf
    See possible configuration settings: tmpfiles.d(5)
    Example: (for testing):
    D /tmp 1777 root root 10s -
    Now all files will be deleted that are older than 10sec.

  3. Run systemd-tmpfiles cleanup manually
    To see whats happen we run the job with debug logs
    sudo env SYSTEMD_LOG_LEVEL=debug systemd-tmpfiles --clean

  4. Check stateDir
    The rootlessXXX stateDir in /tmp/ still exists.

  5. Show Lock
    lsof /tmp/rotlesskitXXXX

Bg
Tobi

@AkihiroSuda
Copy link
Copy Markdown
Member

Thanks, could you sign off the commit? (git commit -a -s --amend)

Signed-off-by: Tobias Schug <happytobi@tscoding.de>
Signed-off-by: Tobias Schug <happytobi@tscoding.de>
Copy link
Copy Markdown
Member

@AkihiroSuda AkihiroSuda left a comment

Choose a reason for hiding this comment

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

Thanks!

@AkihiroSuda AkihiroSuda merged commit 551ab38 into rootless-containers:master Nov 4, 2020
@HappyTobi HappyTobi deleted the lock_tmp_dir branch November 4, 2020 06:55
AkihiroSuda added a commit to AkihiroSuda/docker that referenced this pull request Nov 5, 2020
Important fix: Lock state dir for preventing automatic clean-up by systemd-tmpfiles
(rootless-containers/rootlesskit#188)

Full changes:rootless-containers/rootlesskit@v0.10.0...v0.11.0

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
AkihiroSuda added a commit to AkihiroSuda/docker that referenced this pull request Nov 5, 2020
Important fix: Lock state dir for preventing automatic clean-up by systemd-tmpfiles
(rootless-containers/rootlesskit#188)

Full changes:rootless-containers/rootlesskit@v0.10.0...v0.11.0

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
(cherry picked from commit c6accc6)
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
docker-jenkins pushed a commit to docker-archive/docker-ce that referenced this pull request Nov 5, 2020
Important fix: Lock state dir for preventing automatic clean-up by systemd-tmpfiles
(rootless-containers/rootlesskit#188)

Full changes:rootless-containers/rootlesskit@v0.10.0...v0.11.0

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
Upstream-commit: c6accc67f2e754a6f5a7e43eaddad9580a31cab3
Component: engine
docker-jenkins pushed a commit to docker-archive/docker-ce that referenced this pull request Nov 9, 2020
Important fix: Lock state dir for preventing automatic clean-up by systemd-tmpfiles
(rootless-containers/rootlesskit#188)

Full changes:rootless-containers/rootlesskit@v0.10.0...v0.11.0

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
(cherry picked from commit c6accc67f2e754a6f5a7e43eaddad9580a31cab3)
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
Upstream-commit: 4b181db52b8322dde5e6175bac917a21a49ff160
Component: engine
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants