linux: libshare: smb: fix more than one smb_is_share_active() call

This also fixes zfs_unshare_006_pos, which exposed this

Fixes: 2f71caf2d9 ("Allow zfs unshare
 <protocol> -a")

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: John Kennedy <john.kennedy@delphix.com>
Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #13259
This commit is contained in:
наб 2022-03-22 15:50:46 +01:00 committed by Brian Behlendorf
parent 34abca3e2c
commit 56692e77e2

View File

@ -323,8 +323,6 @@ smb_disable_share_one(const char *sharename)
static int
smb_disable_share(sa_share_impl_t impl_share)
{
smb_share_t *shares = smb_shares;
if (!smb_available()) {
/*
* The share can't possibly be active, so nothing
@ -333,12 +331,9 @@ smb_disable_share(sa_share_impl_t impl_share)
return (SA_OK);
}
while (shares != NULL) {
if (strcmp(impl_share->sa_mountpoint, shares->path) == 0)
return (smb_disable_share_one(shares->name));
shares = shares->next;
}
for (const smb_share_t *i = smb_shares; i != NULL; i = i->next)
if (strcmp(impl_share->sa_mountpoint, i->path) == 0)
return (smb_disable_share_one(i->name));
return (SA_OK);
}
@ -362,21 +357,16 @@ smb_validate_shareopts(const char *shareopts)
static boolean_t
smb_is_share_active(sa_share_impl_t impl_share)
{
smb_share_t *iter = smb_shares;
if (!smb_available())
return (B_FALSE);
/* Retrieve the list of (possible) active shares */
smb_retrieve_shares();
while (iter != NULL) {
if (strcmp(impl_share->sa_mountpoint, iter->path) == 0)
for (const smb_share_t *i = smb_shares; i != NULL; i = i->next)
if (strcmp(impl_share->sa_mountpoint, i->path) == 0)
return (B_TRUE);
iter = iter->next;
}
return (B_FALSE);
}