mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-24 11:18:52 +03:00
libshare/nfs: escape mount points when needed
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz> Closes #13165 Closes #13153
This commit is contained in:
@@ -109,15 +109,24 @@ nfs_enable_share_impl(sa_share_impl_t impl_share, FILE *tmpfile)
|
||||
if (strcmp(shareopts, "on") == 0)
|
||||
shareopts = "";
|
||||
|
||||
if (fputs(impl_share->sa_mountpoint, tmpfile) == EOF ||
|
||||
boolean_t need_free;
|
||||
char *mp;
|
||||
int rc = nfs_escape_mountpoint(impl_share->sa_mountpoint, &mp,
|
||||
&need_free);
|
||||
if (rc != SA_OK)
|
||||
return (rc);
|
||||
|
||||
if (fputs(mp, tmpfile) == EOF ||
|
||||
fputc('\t', tmpfile) == EOF ||
|
||||
translate_opts(shareopts, tmpfile) == EOF ||
|
||||
fputc('\n', tmpfile) == EOF) {
|
||||
fprintf(stderr, "failed to write to temporary file\n");
|
||||
return (SA_SYSTEM_ERR);
|
||||
rc = SA_SYSTEM_ERR;
|
||||
}
|
||||
|
||||
return (SA_OK);
|
||||
if (need_free)
|
||||
free(mp);
|
||||
return (rc);
|
||||
}
|
||||
|
||||
static int
|
||||
|
||||
@@ -387,14 +387,21 @@ nfs_add_entry(FILE *tmpfile, const char *sharepath,
|
||||
if (linux_opts == NULL)
|
||||
linux_opts = "";
|
||||
|
||||
if (fprintf(tmpfile, "%s %s(sec=%s,%s,%s)\n", sharepath,
|
||||
boolean_t need_free;
|
||||
char *mp;
|
||||
int rc = nfs_escape_mountpoint(sharepath, &mp, &need_free);
|
||||
if (rc != SA_OK)
|
||||
return (rc);
|
||||
if (fprintf(tmpfile, "%s %s(sec=%s,%s,%s)\n", mp,
|
||||
get_linux_hostspec(host), security, access_opts,
|
||||
linux_opts) < 0) {
|
||||
fprintf(stderr, "failed to write to temporary file\n");
|
||||
return (SA_SYSTEM_ERR);
|
||||
rc = SA_SYSTEM_ERR;
|
||||
}
|
||||
|
||||
return (SA_OK);
|
||||
if (need_free)
|
||||
free(mp);
|
||||
return (rc);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user