Skip to content

Commit

Permalink
Add smb_available() sanity checks
Browse files Browse the repository at this point in the history
Do basic sanity checks in smb_available() to verify that the 'net'
command and the usershare directory exists.

Signed-off-by: Brian Behlendorf <[email protected]>
Closes openzfs#1124
  • Loading branch information
FransUrbo authored and behlendorf committed Apr 2, 2013
1 parent b5d8c5f commit be8bc8c
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/libshare/smb.c
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,15 @@ static const sa_share_ops_t smb_shareops = {
static boolean_t
smb_available(void)
{
/* TODO: Sanity check NET_CMD_PATH and SHARE_DIR */
struct stat statbuf;

if (lstat(SHARE_DIR, &statbuf) != 0 ||
!S_ISDIR(statbuf.st_mode))
return B_FALSE;

if (access(NET_CMD_PATH, F_OK) != 0)
return B_FALSE;

return B_TRUE;
}

Expand Down

0 comments on commit be8bc8c

Please sign in to comment.