Re: [PATCH] config: fix several access(NULL) calls

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Junio C Hamano <gitster@xxxxxxxxx> writes:

> I would think that it is plausible that the user wanted to write
> into XDG one and used "unset HOME" as a way to signal that wish. 

I didn't think of this case, but it makes sense.

Anyway, I don't really care either way, so I leave it up to you (either
your patch below, or the fixup in pu).

> -		if (user_config && access(user_config, R_OK) &&
> +		if (!user_config)
> +			/*
> +			 * We do not know HOME/.gitconfig exists or
> +			 * not, hence we do not know if we should
> +			 * write to XDG location, so we error out even
> +			 * if XDG_CONFIG_HOME is set and points at a
> +			 * sane location.
> +			 *
> +			 * In other words, we forbid the user from
> +			 * telling us to write to XDG location,
> +			 * pretending that $HOME/.gitconfig does not
> +			 * exist, by temporarily unsetting HOME.
> +			 */
> +			die("$HOME not set");
> +
> +		if (access(user_config, R_OK) &&
>  		    xdg_config && !access(xdg_config, R_OK))
>  			given_config_file = xdg_config;
> -		else if (user_config)
> -			given_config_file = user_config;
>  		else
> -			die("$HOME not set");
> +			given_config_file = user_config;

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]