mountd: Preserve special characters in refer and replica path options
Subsystems (2)
[email protected]
maintainerPATCH 1/1 mountd: Preserve special characters in refer and replica path options
From: Lance Shelton <[email protected]>
Allow referral paths to contain special character by adding an escaping mechanism.
Signed-off-by Lance Shelton <[email protected]>
Signed-off-by Trond Myklebust <[email protected]>
--- support/nfs/exports.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-)
support/nfs/exports.c +18 -9
@@ -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 :
Signature · 1 line
2.25.2
Quoted 10 lines · On 4/16/20 5:37 PM, [email protected] wrote:
From: Lance Shelton <[email protected]>
Allow referral paths to contain special character by adding an escaping mechanism.
Signed-off-by Lance Shelton <[email protected]>Signed-off-by Trond Myklebust <[email protected]>--- support/nfs/exports.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-)
Committed... (tag: nfs-utils-2-4-4-rc4)
steved.
Quoted 59 lines
support/nfs/exports.c +18
-9@@ -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 :