Comment 8 for bug 330766

Revision history for this message
Mario Schwalbe (schwalbe) wrote :

This is no duplicate and no race condition, at all. In addition to points 1-2 by Josh Smith, I'd like to add:
3) if ~/.pulse is a symlink, pulseaudio fails to start although the target directory's permissions are correct

# ls -ld .pulse ../mario-sync/.pulse/
lrwxrwxrwx 1 mario mario 20 2008-10-10 16:53 .pulse -> ../mario-sync/.pulse
drwx------ 2 mario mario 4096 2008-10-10 16:53 /home/mario-sync/.pulse

the problem lies in pulsecore/core-util.c, function pa_make_secure_dir line 206 and following:

#ifdef HAVE_LSTAT
    if (lstat(dir, &st) < 0)
#else
    if (stat(dir, &st) < 0)
#endif
        goto fail;

#ifndef OS_IS_WIN32
    if (!S_ISDIR(st.st_mode) ||
        (st.st_uid != uid) ||
        (st.st_gid != gid) ||
        ((st.st_mode & 0777) != m)) {
        errno = EACCES;
        goto fail;
    }
#else
    pa_log_warn("Secure directory creation not supported on Win32.");
#endif

Since we are compiling for linux, 'lstat' is available. But pulseaudio should have used 'stat' instead, because in contrast to 'stat', 'lstat' returns the symlink's permissions (lrwxrwxrwx), not those of the target directory (drwx------).