diff mbox

conffile: ignore empty environment variables.

Message ID 87a89xwr0o.fsf@notabene.neil.brown.name (mailing list archive)
State New, archived
Headers show

Commit Message

NeilBrown Feb. 7, 2017, 10:54 p.m. UTC
conf_set() already refuses to set an empty value, so if
  foo=
appears in the config file, it will be ignored.
This patch extends the policy to environment variables, so empty
environment variables are treated as though they didn't exist.

This means that a separate environment file (e.g. /etc/sysconfig/nfs)
will be treated the same way whether it is:
 - included in the [environment] section of /etc/nfs.conf
 - sourced by the shell before running code
 - sourced by the systemd EnvironmentFile directive.

Signed-off-by: NeilBrown <neilb@suse.com>
---
 support/nfs/conffile.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Steve Dickson Feb. 16, 2017, 10:22 a.m. UTC | #1
On 02/07/2017 05:54 PM, NeilBrown wrote:
> conf_set() already refuses to set an empty value, so if
>   foo=
> appears in the config file, it will be ignored.
> This patch extends the policy to environment variables, so empty
> environment variables are treated as though they didn't exist.
>
> This means that a separate environment file (e.g. /etc/sysconfig/nfs)
> will be treated the same way whether it is:
>  - included in the [environment] section of /etc/nfs.conf
>  - sourced by the shell before running code
>  - sourced by the systemd EnvironmentFile directive.
>
> Signed-off-by: NeilBrown <neilb@suse.com>
Committed...

steved.
> ---
>  support/nfs/conffile.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/support/nfs/conffile.c b/support/nfs/conffile.c
> index e717c1e39bab..203efd2aa602 100644
> --- a/support/nfs/conffile.c
> +++ b/support/nfs/conffile.c
> @@ -533,7 +533,7 @@ retry:
>  				 * or from environment
>  				 */
>  				char *env = getenv(cb->value+1);
> -				if (env)
> +				if (env && *env)
>  					return env;
>  				section = "environment";
>  				tag = cb->value + 1;

--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/support/nfs/conffile.c b/support/nfs/conffile.c
index e717c1e39bab..203efd2aa602 100644
--- a/support/nfs/conffile.c
+++ b/support/nfs/conffile.c
@@ -533,7 +533,7 @@  retry:
 				 * or from environment
 				 */
 				char *env = getenv(cb->value+1);
-				if (env)
+				if (env && *env)
 					return env;
 				section = "environment";
 				tag = cb->value + 1;