diff options
author | наб <[email protected]> | 2022-03-22 15:50:46 +0100 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2022-04-01 18:02:24 -0700 |
commit | 56692e77e2178e9af977ca8bbf99a664df002f3f (patch) | |
tree | 6c7b0b3fcc63c0e78bdeeb6d8ba6785dbae17152 /lib | |
parent | 34abca3e2c51f34f94ec4b4b91974792951e863a (diff) |
linux: libshare: smb: fix more than one smb_is_share_active() call
This also fixes zfs_unshare_006_pos, which exposed this
Fixes: 2f71caf2d926249920d1b9162550c56715cc6461 ("Allow zfs unshare
<protocol> -a")
Reviewed-by: Brian Behlendorf <[email protected]>
Reviewed-by: John Kennedy <[email protected]>
Reviewed-by: Ryan Moeller <[email protected]>
Signed-off-by: Ahelenia Ziemiańska <[email protected]>
Closes #13259
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libshare/os/linux/smb.c | 20 |
1 files changed, 5 insertions, 15 deletions
diff --git a/lib/libshare/os/linux/smb.c b/lib/libshare/os/linux/smb.c index bcb9b4270..47d1aa776 100644 --- a/lib/libshare/os/linux/smb.c +++ b/lib/libshare/os/linux/smb.c @@ -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); } |