Re: [PATCH] mountd: Preserve special characters in refer and replica path options

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

 




On 4/16/20 5:37 PM, trondmy@xxxxxxxxxx wrote:
> From: Lance Shelton <lance.shelton@xxxxxxxxxxxxxxx>
> 
> Allow referral paths to contain special character by adding an
> escaping mechanism.
> 
> Signed-off-by: Lance Shelton <lance.shelton@xxxxxxxxxxxxxxx>
> Signed-off-by: Trond Myklebust <trond.myklebust@xxxxxxxxxxxxxxx>
> ---
>  support/nfs/exports.c | 27 ++++++++++++++++++---------
>  1 file changed, 18 insertions(+), 9 deletions(-)
Committed... (tag: nfs-utils-2-4-4-rc4)

steved.

> 
> diff --git a/support/nfs/exports.c b/support/nfs/exports.c
> index 8fbb6b15c299..97eb31837816 100644
> --- a/support/nfs/exports.c
> +++ b/support/nfs/exports.c
> @@ -247,23 +247,28 @@ void secinfo_show(FILE *fp, struct exportent *ep)
>  	}
>  }
>  
> +static void
> +fprintpath(FILE *fp, const char *path)
> +{
> +	int i;
> +	for (i=0; path[i]; i++)
> +		if (iscntrl(path[i]) || path[i] == '"' || path[i] == '\\' || path[i] == '#' || isspace(path[i]))
> +			fprintf(fp, "\\%03o", path[i]);
> +		else
> +			fprintf(fp, "%c", path[i]);
> +}
> +
>  void
>  putexportent(struct exportent *ep)
>  {
>  	FILE	*fp;
>  	int	*id, i;
> -	char	*esc=ep->e_path;
>  
>  	if (!efp)
>  		return;
>  
>  	fp = efp->x_fp;
> -	for (i=0; esc[i]; i++)
> -	        if (iscntrl(esc[i]) || esc[i] == '"' || esc[i] == '\\' || esc[i] == '#' || isspace(esc[i]))
> -			fprintf(fp, "\\%03o", esc[i]);
> -		else
> -			fprintf(fp, "%c", esc[i]);
> -
> +	fprintpath(fp, ep->e_path);
>  	fprintf(fp, "\t%s(", ep->e_hostname);
>  	fprintf(fp, "%s,", (ep->e_flags & NFSEXP_READONLY)? "ro" : "rw");
>  	fprintf(fp, "%ssync,", (ep->e_flags & NFSEXP_ASYNC)? "a" : "");
> @@ -302,10 +307,14 @@ putexportent(struct exportent *ep)
>  	case FSLOC_NONE:
>  		break;
>  	case FSLOC_REFER:
> -		fprintf(fp, "refer=%s,", ep->e_fslocdata);
> +		fprintf(fp, "refer=");
> +		fprintpath(fp, ep->e_fslocdata);
> +		fprintf(fp, ",");
>  		break;
>  	case FSLOC_REPLICA:
> -		fprintf(fp, "replicas=%s,", ep->e_fslocdata);
> +		fprintf(fp, "replicas=");
> +		fprintpath(fp, ep->e_fslocdata);
> +		fprintf(fp, ",");
>  		break;
>  #ifdef DEBUG
>  	case FSLOC_STUB:
> 




[Index of Archives]     [Linux Filesystem Development]     [Linux USB Development]     [Linux Media Development]     [Video for Linux]     [Linux NILFS]     [Linux Audio Users]     [Yosemite Info]     [Linux SCSI]

  Powered by Linux