Bug 198515 - mock -r distro clean does not clean /var/lib/mock/distro
mock -r distro clean does not clean /var/lib/mock/distro
Status: CLOSED CURRENTRELEASE
Product: Fedora Hosted Projects
Classification: Retired
Component: mock (Show other bugs)
unspecified
All Linux
medium Severity medium
: ---
: ---
Assigned To: Clark Williams
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2006-07-11 12:07 EDT by Ralf Corsepius
Modified: 2013-01-09 22:59 EST (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2008-10-24 15:11:45 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Ralf Corsepius 2006-07-11 12:07:22 EDT
Description of problem:

mock -r distro clean
doesn't clean up /var/lib/mock/distro

It leaves directories behind below /var/lib/mock/distro.


Version-Release number of selected component (if applicable):
mock-0.6-4.fc5

How reproducible:
deterministic


Steps to Reproduce:
1. login as user1
2. mock -r <distro> init
=> Creates /var/lib/mock/<distro> directory hierarchy

3. mock -r <distro> clean
=> Largely empties /var/lib/mock/<distro> directory hierarchy
but leave directories and files behind:

/var/lib/mock/distro/
/var/lib/mock/distro/result
/var/lib/mock/distro/result/root.log
/var/lib/mock/distro/result/mockconfig.log
/var/lib/mock/distro/result/build.log
/var/lib/mock/distro/state
/var/lib/mock/distro/state/status
/var/lib/mock/distro/root

4. login as user2
5. mock -r <distro> init
  
Actual results:
Step 5. fails.

# mock -r distro init
Traceback (most recent call last):
  File "/usr/bin/mock", line 985, in ?
    main()
  File "/usr/bin/mock", line 956, in main
    do_clean(config_opts, init=1)
  File "/usr/bin/mock", line 826, in do_clean
    my = Root(config_opts)
  File "/usr/bin/mock", line 129, in __init__
    self.state("init")
  File "/usr/bin/mock", line 202, in state
    sfo = open(sf, 'w')
IOError: [Errno 13] Permission denied: '/var/lib/mock/distro/state/status'


Expected results:
Step 5. to succeed.

Additional info:

A simple "rm -rf /var/lib/mock/<distro>" after "mock -r <distro> clean" resolves
this issue, i.e. an analogous operation at the end of "mock clean" would likely
resolve this issue, too.
Comment 1 Clark Williams 2006-08-11 13:39:02 EDT
The directories and files that you're seeing are created *after* a clean
operation to ensure that the hierarchy is correct.  This is because the internal
cleanup function is called as part of an "init" operation as well as a "clean"
operation. 

Changing this behavior will require some re-architecting in how the Root object
handles init versus clean ops. Either that or changing permission/ownership of
those files so your "user2" can nuke them.
Comment 2 Ralf Corsepius 2006-08-12 23:45:58 EDT
(In reply to comment #1)
> The directories and files that you're seeing are created *after* a clean
> operation to ensure that the hierarchy is correct.  This is because the
> internal
> cleanup function is called as part of an "init" operation as well as a "clean"
> operation. 

Well - what shall I say - your problem ;)

'mock clean' is documented (man mock) as:
...
clean - purge the chroot tree
...

Apparently mock doesn't do this.


Also, I think I need to emphasize the severity of this bug: It classifies mock
as "not multiuser-capabile", i.e. as unusable in a multiuser environment.
Comment 3 Clark Williams 2008-10-24 15:11:45 EDT
This behavior got cleaned up in the Great Re-Write that happened over the last year.

mock -r distro clean

now deletes /var/lib/mock/<distro>

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