Comment 4 for bug 224754

Revision history for this message
Colin Ian King (colin-king) wrote :

stracing the installation of sudo package, trips the bug on a chown() call. From the strace'd code I've got a stripped down minimal C program below reliably breaks it the same way. Definitely due to the hard linked file and chown32 system call on the file on unionfs. Got some hard evidence now. C code below:

#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

void main(void)
{
        int fd;

        fd = open("/usr/bin/sudoedit.dpkg-new", O_WRONLY|O_CREAT|O_EXCL, 0);
        fchown(fd, 0, 0);
        fchmod(fd, 04755);
        close(fd);
        link("/usr/bin/sudoedit", "/usr/bin/sudoedit.dpkg-tmp");
        rename("/usr/bin/sudoedit.dpkg-new", "/usr/bin/sudoedit");
        link("/./usr/bin/sudoedit", "/usr/bin/sudo.dpkg-new");
        chown("/usr/bin/sudo.dpkg-new", 0, 0);
}

Incidentally, removing the fchown and fchmod from above and the bug goes away.