#722280 schroot fails if $CHROOT/etc/passwd is a symbolic link

Package:
schroot
Source:
schroot
Description:
Execute commands in a chroot environment
Submitter:
Ilya L
Date:
2013-09-09 19:21:06 UTC
Severity:
normal
#722280#5
Date:
2013-09-09 19:20:16 UTC
From:
To:
If chroot filesystem contains /etc/passwd and it is symbolic link, schroot
fails with

E: 20nssdatabases: /etc/schroot/setup.d/20nssdatabases: 32:
/etc/schroot/setup.d/20nssdatabases: cannot create
/var/lib/schroot/mount/ZZZ-d2fb7e61-a09a-49d3-8ce1-d1e8c172dbeb/etc/passwd:
Directory nonexistent

This is because copy operation in dup_nss() tries to follow the symbolic
link. Changing dup_nss() function to the following fixed the problem for me:

dup_nss()
{
    info "Copying $1 database to $2"
    rm -f "$2"
    getent "$1" > "$2"
}