RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1334881 - systemd-tmpfiles Failed to open directory /tmp: Too many levels of symbolic links
Summary: systemd-tmpfiles Failed to open directory /tmp: Too many levels of symbolic l...
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: systemd
Version: 7.2
Hardware: Unspecified
OS: Linux
unspecified
high
Target Milestone: rc
: ---
Assignee: systemd-maint
QA Contact: qe-baseos-daemons
URL:
Whiteboard:
Depends On:
Blocks: 1420851
TreeView+ depends on / blocked
 
Reported: 2016-05-10 17:39 UTC by John Walter
Modified: 2020-06-11 12:52 UTC (History)
10 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2017-07-24 15:25:12 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
sosreport from affected machine (6.10 MB, application/x-xz)
2016-05-10 17:39 UTC, John Walter
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Red Hat Bugzilla 1290281 0 unspecified CLOSED systemd-tmpfiles Failed to open directory /tmp: Too many levels of symbolic links 2021-02-22 00:41:40 UTC

Description John Walter 2016-05-10 17:39:54 UTC
Created attachment 1155807 [details]
sosreport from affected machine

Description of problem: Currently deploying RHEL7 servers that have /var/tmp -> /tmp symlink in place. After updating to 7.2, 


Version-Release number of selected component (if applicable):
systemd-219-19.el7_2.7.x86_64
kernel-3.10.0-327.13.1.el7.x86_64

How reproducible:
Every time

Steps to Reproduce:
1. On fresh install, remove /var/tmp and symlink to /tmp
2.
3.

Actual results:
/var/tmp -> /tmp

Expected results:
systemd-tmpfiles Failed to open directory /tmp: Too many levels of symbolic links

This behavior did not take place in 7.0 or 7.1.

Additional info:
There is a Fedora bug with the same issue - https://bugzilla.redhat.com/show_bug.cgi?id=1290281

Comment 1 John Walter 2016-05-10 17:40:36 UTC
Edit: Actual and Expected results should be reversed.

Comment 2 Lukáš Nykrýn 2016-05-10 18:26:25 UTC
Can I ask why do you do that? /var/tmp should not be cleaned but /tmp is. This could break  daemons which put stuff to /var and expect that the data stay there.

Comment 8 Andrew J. Schorr 2017-01-04 21:06:03 UTC
We had a similar complaint from systemd-tmpfiles on a system where some of the directories under /var have been moved to a tmpfs to reduce read/write cycles on an SSD. Why is this bothering systemd-tmpfiles?

Comment 9 Andrew J. Schorr 2017-01-04 21:06:30 UTC
Note: this problem persists in 7.3.

Comment 10 Andrew J. Schorr 2017-01-05 18:36:24 UTC
To clarify, this is happening when systemd-tmpfiles-clean runs. I see this in the journalctl output:

Jan 05 12:51:56 ti133 systemd[1]: Starting Cleanup of Temporary Directories...
Jan 05 12:51:56 ti133 systemd-tmpfiles[6031]: Failed to open directory /var/tmp: Too many levels of symbolic link

In my case, /var/tmp is a symbolic link to a directory on tmpfs. I have no idea why it returns ELOOP, since there is only a single symbolic link. Looking in the code, it seems that opendir_nomod is failing with ELOOP. 
The opendir_nomod function calls xopendirat_nomod(AT_FDCWD, path),
and xopendirat_nomod calls xopendirat(dirfd, path, O_NOFOLLOW|O_NOATIME),
and xopendirat finally calls openat(fd, name, O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC|flags, 0);

So the basic problem here is that tmpfiles.c:xopendirat_nomod is passing the O_NOFOLLOW flag down to openat. Why is that flag being passed? The obvious patch is to remove it, but perhaps that would break something else...

Regards,
Andy

Comment 12 Andrew J. Schorr 2017-01-10 17:49:40 UTC
This error occurs every 24 hours when systemd-tmpfiles-clean.timer pops. How do we get this fixed? I think my usage case is legitimate, although I'm not sure about the OP's decision to point /var/tmp to /tmp.

Jan 08 11:14:37 ti133 systemd-tmpfiles[2092]: Failed to open directory /var/tmp: Too many levels of symbolic links
Jan 09 11:15:37 ti133 systemd-tmpfiles[4719]: Failed to open directory /var/tmp: Too many levels of symbolic links
Jan 10 11:16:37 ti133 systemd-tmpfiles[15367]: Failed to open directory /var/tmp: Too many levels of symbolic links

sh-4.2$ ls -ld /var/tmp
lrwxrwxrwx. 1 root root 19 Jan  5 12:08 /var/tmp -> impermanent/var/tmp

sh-4.2$ df /var/tmp
Filesystem     1K-blocks  Used Available Use% Mounted on
tmpfs            1535268 49624   1485644   4% /var/impermanent

Do I need to open a separate bug report for this, since my situation is slightly different? In my case, /var/impermanent is a tmpfs that is saved on system shutdown and repopulated at bootup. So I achieve persistence with fewer read/write cycles on my SSD.

Thanks,
Andy

Comment 13 Andrew Sanders 2017-01-20 17:57:19 UTC
(In reply to Andrew J. Schorr from comment #12)
> Do I need to open a separate bug report for this, since my situation is
> slightly different? In my case, /var/impermanent is a tmpfs that is saved on
> system shutdown and repopulated at bootup. So I achieve persistence with
> fewer read/write cycles on my SSD.
> 
> Thanks,
> Andy

Hi Andy,
  I wanted to drop you a quick update on this and thank you for the data you've submitted to this bugzilla.  It's great to see the analysis you've done and know your use case and requirements for making a change like this - it helps a lot, thank you!  For what it's worth, I'm also working with a large strategic Red Hat customer who is seeing this same issue under a different use case, so know that you're not the only one hitting this.  I'm working on getting engineering's assistance with identifying the root cause and then a patch that would resolve this.  Until I hear back from engineering let's keep any additional updates in this bugzilla and not open a new one until we know can confirm that this is the same issue or if you're seeing a new unique issue.  Once there's more progress to report we'll update this publicly so you'll have an idea of what we find and what our next steps are.

Andrew Sanders
Red Hat Inc.
Senior Technical Account Manager

Comment 15 Kyle Walker 2017-04-25 15:13:08 UTC
Good morning,

The reason for the O_NOFOLLOW flag is due to the following upstream commit:

	commit a247755d5221411ffe7780677b270963682dadd1
	Author: Lennart Poettering <lennart>
	Date:   Tue Dec 28 14:20:21 2010 +0100

	    tmpfiles: ensure we do no follow symlinks when cleaning up dirs
	    
	    Patch suggested by Miloslav Trmac.


This is likely to avoid conditions where tmpfiles cleans up unexpected directories due to a stray symlink.

Such as:

    d /var/tmp/dir 0755 root root 1d

Where:

    /var/tmp/dir -> /application/data/


In the above instance, the administrator creating the tmpfiles cleanup rule would likely be unaware that the cleanup location would be /application/data.

That being said, I believe the issue can be avoided for the tmpfs use-case simply by setting the tmpfs mount point to the /var/tmp directory itself.

    # grep var\/tmp /etc/fstab 
    nodev /var/tmp tmpfs defaults 0 0


Is there a characteristic of the environment that renders the above solution infeasible?

- Kyle Walker

Comment 16 Andrew J. Schorr 2017-04-27 19:52:15 UTC
Hi,

Thanks for the further info. I think such a solution is possible, although it will require reworking a number of system administration scripts related to this
configuration scenario.

Regards,
Andy

Comment 17 Kyle Walker 2017-07-24 15:25:12 UTC
Based on the feedback given from impacted users, I am currently closing this as NOTABUG. The issue can be avoided in a number of ways, and the alternative of allowing tmpfiles to follow symlinks introduces a number of possible unexpected results.

- Kyle Walker

Comment 18 troy.engel 2017-07-24 15:33:54 UTC
Hello Kyle, I believe this should be closed as WONTFIX, not NOTABUG. It's a bug and a conscious choice is being made to not fix it (no arguments) due to impact and available workarounds. The symlink action is technically viable and against no "rules" of Linux or UNIX in general, it's introduced by the systemd code design not being able to handle the symlink correctly.


Note You need to log in before you can comment on or make changes to this bug.