Note: This is a beta release of Red Hat Bugzilla 5.0. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Also email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback here.
Bug 454987 - getcap should not follow symlinks to directories in recursive mode
Summary: getcap should not follow symlinks to directories in recursive mode
Keywords:
Status: CLOSED UPSTREAM
Alias: None
Product: Fedora
Classification: Fedora
Component: libcap
Version: rawhide
Hardware: All
OS: Linux
low
low
Target Milestone: ---
Assignee: Karsten Hopp
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
: 449986 (view as bug list)
Depends On:
Blocks: 449984
TreeView+ depends on / blocked
 
Reported: 2008-07-11 10:26 UTC by Lukas Kuklinek
Modified: 2008-11-21 15:55 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2008-11-21 15:55:32 UTC


Attachments (Terms of Use)
patch (fix candidate) (deleted)
2008-07-15 14:06 UTC, Lukas Kuklinek
no flags Details | Diff

Description Lukas Kuklinek 2008-07-11 10:26:13 UTC
Description of problem:

getcap utility should not follow symlinks to directories in recursive mode.
This can cause output redudant information or drive getcap into endless loop 
if symlinks pointing to parent directories are present in a directory subtree 
being walked by getcap.

Steps to Reproduce (example):

# ln -s . link1
# ln -s link1 link2
# ls -l
lrwxrwxrwx 1 ilja ilja 1 2008-07-11 11:50 link1 -> .
lrwxrwxrwx 1 ilja ilja 5 2008-07-11 11:52 link2 -> link1
# getcap -r link1
Failed to get capabilities of file 
`link1/link2/link2/link2/link2/link2/link2/link2/link2/link2/link2/link2/link1/link2/link1/link2/link2/link2/link1/link1/link1/link1/link1/link1/link1/link1' 
(Too many levels of symbolic links)
Failed to get attribute of file 
`link1/link2/link2/link2/link2/link2/link2/link2/link2/link2/link2/link2/link1/link2/link1/link2/link2/link2/link1/link1/link1/link1/link1/link1/link1/link1' 
(Too many levels of symbolic links)
<getcap keeps printing these error messages in endless loop>

Expected results: empty output

Comment 1 Lukas Kuklinek 2008-07-11 10:31:27 UTC
Heve a look at stat() function... there is version that does not follow 
symlinks named lstat(), but manpage says it is availible only for
_BSD_SOURCE || _XOPEN_SOURCE >= 500

Comment 2 Lukas Kuklinek 2008-07-15 14:06:42 UTC
Created attachment 311829 [details]
patch (fix candidate)

This patch is an fix candidate for this bug.
It replaces all the code for managing recursive walking through directory tree
by nftw() system library call. With this patch, getcap does not follow symlinks
at all (like find utility).
Fixes also bug #449986.

Comment 3 Christopher D. Stover 2008-10-25 16:50:58 UTC
*** Bug 449986 has been marked as a duplicate of this bug. ***

Comment 4 Christopher D. Stover 2008-10-25 17:04:11 UTC
It looks like libcap-2.13.tar.gz is released here, http://www.kernel.org/pub/linux/libs/security/linux-privs/kernel-2.6/, so this should probably be repackaged at some point.  I'm not sure if the new version fixes this problem because I couldn't find anything in the change log.  However, I would recommend you submit your patch upstream as well.

Comment 5 Lukas Kuklinek 2008-11-21 11:03:17 UTC
Patch was sent to upstream and is already applied in git.

Comment 6 Christopher D. Stover 2008-11-21 15:55:32 UTC
Thanks for the update and nice work!


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