Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 697906 - emirrordist: DeletionTask removes only real file but not symlink
Summary: emirrordist: DeletionTask removes only real file but not symlink
Status: RESOLVED FIXED
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Unclassified (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Portage team
URL:
Whiteboard:
Keywords: InVCS
Depends on:
Blocks: 697734
  Show dependency tree
 
Reported: 2019-10-17 04:18 UTC by Michał Górny
Modified: 2020-01-17 22:25 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2019-10-17 04:18:34 UTC
Again, as note to self.  I've investigating why emirrordist keeps trying to remove distfiles that do not exist.

1. _delete_links() assumes it's going to delete layout 1+ while earlier function removes 0.  However, rename() is done on realpath(), so actually it might have removed another layout.  I'm currently testing a change to remove all layouts.

2. DeletionIterator operates based on the result of stat().  However, stat()'s going to fail for stale symlinks.  I think we should special-case that to support stale symlink cleanup.

Will supply patches later today.
Comment 1 Larry the Git Cow gentoo-dev 2019-10-17 18:09:24 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/proj/portage.git/commit/?id=4e9f04a1e11e84a8c513ee334cf2bc1c013d8c11

commit 4e9f04a1e11e84a8c513ee334cf2bc1c013d8c11
Author:     Michał Górny <mgorny@gentoo.org>
AuthorDate: 2019-10-17 12:05:30 +0000
Commit:     Michał Górny <mgorny@gentoo.org>
CommitDate: 2019-10-17 18:08:58 +0000

    emirrordist: Delete potential symlinks for all layouts
    
    Unlink for all distfile layouts rather than for all but primary.  This
    wrongly assumed that the primary layout will always be removed
    as a result of earlier code.  However, the rename() call correctly
    assumes that the primary layout may be an old symlink, and operates
    on realpath().  Therefore, the real file from a secondary layout may
    be renamed, leaving dangling symlink.
    
    Bug: https://bugs.gentoo.org/697906
    Reviewed-by: Zac Medico <zmedico@gentoo.org>
    Signed-off-by: Michał Górny <mgorny@gentoo.org>

 lib/portage/_emirrordist/DeletionTask.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Comment 2 Larry the Git Cow gentoo-dev 2019-10-18 04:16:40 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=6e441cb24d4c4c35fec539158904dd7093e4874d

commit 6e441cb24d4c4c35fec539158904dd7093e4874d
Author:     Zac Medico <zmedico@gentoo.org>
AuthorDate: 2019-10-18 04:13:57 +0000
Commit:     Zac Medico <zmedico@gentoo.org>
CommitDate: 2019-10-18 04:16:33 +0000

    sys-apps/portage: Revbump to 2.3.77-r1 for bug 697906
    
    Closes: https://bugs.gentoo.org/697906
    Package-Manager: Portage-2.3.77, Repoman-2.3.17
    Signed-off-by: Zac Medico <zmedico@gentoo.org>

 sys-apps/portage/{portage-2.3.77.ebuild => portage-2.3.77-r1.ebuild} | 3 +++
 1 file changed, 3 insertions(+)
Comment 3 Zac Medico gentoo-dev 2019-10-18 04:23:13 UTC
(In reply to Michał Górny from comment #0)
> 2. DeletionIterator operates based on the result of stat().  However,
> stat()'s going to fail for stale symlinks.  I think we should special-case
> that to support stale symlink cleanup.

The DeletionTask patch should prevent stale symlinks yes? I suppose we could still change DeletionIterator to handle stale symlinks anyway...
Comment 4 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2019-10-18 05:56:26 UTC
(In reply to Zac Medico from comment #3)
> (In reply to Michał Górny from comment #0)
> > 2. DeletionIterator operates based on the result of stat().  However,
> > stat()'s going to fail for stale symlinks.  I think we should special-case
> > that to support stale symlink cleanup.
> 
> The DeletionTask patch should prevent stale symlinks yes? I suppose we could
> still change DeletionIterator to handle stale symlinks anyway...

Yes, that's why I said it's sufficient for a bugfix release.  But I'd like to fix it fully anyway.
Comment 5 Larry the Git Cow gentoo-dev 2019-10-21 08:09:58 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/proj/portage.git/commit/?id=dc095fc06d323849a6fe47ae3391bc0356439b65

commit dc095fc06d323849a6fe47ae3391bc0356439b65
Author:     Michał Górny <mgorny@gentoo.org>
AuthorDate: 2019-10-20 10:22:11 +0000
Commit:     Michał Górny <mgorny@gentoo.org>
CommitDate: 2019-10-21 08:09:31 +0000

    emirrordist: Clean dangling symlinks up
    
    Bug: https://bugs.gentoo.org/697906
    Reviewed-by: Zac Medico <zmedico@gentoo.org>
    Signed-off-by: Michał Górny <mgorny@gentoo.org>

 lib/portage/_emirrordist/DeletionIterator.py | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
Comment 6 Larry the Git Cow gentoo-dev 2019-10-21 19:16:16 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=ecbfeae408f1bdcfa4241a3f4001d57cf30c3405

commit ecbfeae408f1bdcfa4241a3f4001d57cf30c3405
Author:     Zac Medico <zmedico@gentoo.org>
AuthorDate: 2019-10-21 19:12:06 +0000
Commit:     Zac Medico <zmedico@gentoo.org>
CommitDate: 2019-10-21 19:16:01 +0000

    sys-apps/portage: Bump to version 2.3.78
    
     #697566 fetch: Use FETCHCOMMAND to fetch mirror layout.conf
     #697890 emirrordist: Fix DeletionTask layout assumptions
     #697906 emirrordist: Delete potential symlinks for all layouts
     #698046 make.globals: Change FETCHCOMMAND_RSYNC to --copy-links
    
    Bug: https://bugs.gentoo.org/697734
    Bug: https://bugs.gentoo.org/697566
    Bug: https://bugs.gentoo.org/697890
    Bug: https://bugs.gentoo.org/697906
    Bug: https://bugs.gentoo.org/698046
    Package-Manager: Portage-2.3.78, Repoman-2.3.17
    Signed-off-by: Zac Medico <zmedico@gentoo.org>

 sys-apps/portage/Manifest              |   1 +
 sys-apps/portage/portage-2.3.78.ebuild | 261 +++++++++++++++++++++++++++++++++
 2 files changed, 262 insertions(+)