Skip to content

Commit

Permalink
linux: libshare: smb: fix more than one smb_is_share_active() call
Browse files Browse the repository at this point in the history
This also fixes zfs_unshare_006_pos, which exposed this

Fixes: 2f71caf ("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 openzfs#13259
  • Loading branch information
nabijaczleweli authored and andrewc12 committed Sep 23, 2022
1 parent b5cf63a commit 4594ddd
Showing 1 changed file with 5 additions and 15 deletions.
20 changes: 5 additions & 15 deletions lib/libshare/os/linux/smb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
}
Expand All @@ -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);
}

Expand Down

0 comments on commit 4594ddd

Please sign in to comment.