Control: tag -1 + moreinfo

Hi,

On Mon, 21 Oct 2024 13:25:33 +0200 Niels Thykier <ni...@thykier.net> wrote:
> The sbuild code assumes that the directory hosting the 

> UNSHARE_TMPDIR_TEMPLATE is mode 4777 (--chroot-mode=unshare). When it is 

> not, the following rm failure will appear under cleanup

> 

> > +------------------------------------------------------------------------------+

> > | Cleanup                                                                   
> >    |

> > +------------------------------------------------------------------------------+

> > 

> > Purging /<<BUILDDIR>>

> > Not cleaning session: cloned chroot in use

> > rm: cannot remove '/home/user/debian/sbuild-test/tmp.sbuild.4Gf6tS2': 
> > Permission denied

> > [...]

> 

> This happens for both successful and failed builds. The temporary 

> directory is properly cleaned regardless of this error (I guess there is 

> rm code both on the host and "inside" the chroot).

> 

> In my case, I changed UNSHARE_TMPDIR_TEMPLATE into a directory under my 

> user's HOME folder that I just created with mkdir -p. On my system, /tmp 

> is mounted with "noexec" and therefore the default could not be used.


yes, in the code there is this comment right after the "rm -rf" runs:

# we ignore the exit status, because the command will fail to remove the
# unpack directory itself because of insufficient permissions

It would be nice if there were an easy way to instruct rm to remove a directory
recursively *except* for the root directory. What do you suggest should sbuild
do instead? I see several options:

 * implement our own recursive removal which ignores the parent
 * redirect the rm -rf output to /dev/null to not confuse the user
 * if rm -rf fails, print a message saying that the failure is not fatal
   because there will be a rmdir on the outside which will clean the root

Thanks!

cheers, josch

Attachment: signature.asc
Description: signature

Reply via email to