[pulseaudio-discuss] [PATCH 1/2] core-util: Make pa_make_secure_dir() act like mkdir -p

David Henningsson david.henningsson at canonical.com
Mon Jun 11 01:00:46 PDT 2012


On 06/11/2012 09:48 AM, Arun Raghavan wrote:
> This makes pa_make_secure_dir() create any missing parent directories in
> the given path as well. This is useful, for example, on a pristine
> system with a clean $HOME that needs ~/.config/pulse/ to be created when
> ~/.config does not exist.

Hum, is moving from ~/.pulse to ~/.config/pulse something we've done 
post 2.0? Or is this patch to make it easier for special configurations?

> ---
>   src/pulsecore/core-util.c |    6 ++++++
>   1 files changed, 6 insertions(+), 0 deletions(-)
>
> diff --git a/src/pulsecore/core-util.c b/src/pulsecore/core-util.c
> index 82480c6..5270979 100644
> --- a/src/pulsecore/core-util.c
> +++ b/src/pulsecore/core-util.c
> @@ -230,6 +230,12 @@ int pa_make_secure_dir(const char* dir, mode_t m, uid_t uid, gid_t gid) {
>       mode_t u;
>       u = umask((~m)&  0777);
>       r = mkdir(dir, m);
> +    if (r<  0&&  errno == ENOENT) {
> +        /* If a parent directory in the path doesn't exist, try to create that
> +         * first, then try again. */
> +        pa_make_secure_parent_dir(dir, m, uid, gid);

Hm, is there a possibility to get infinite recursion by specifying 
strange paths such as ./ and ../ here?

> +        r = mkdir(dir, m);
> +    }
>       umask(u);
>   }
>   #endif



-- 
David Henningsson, Canonical Ltd.
https://launchpad.net/~diwic


More information about the pulseaudio-discuss mailing list