diff options
author | Turbo Fredriksson <[email protected]> | 2013-04-02 09:27:52 -0700 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2013-04-02 09:27:52 -0700 |
commit | be8bc8c0d3ff16888f046e8523051b514ad285e0 (patch) | |
tree | 7e7e8889b2f37c7dfbe1452f5e7129a9dfaf1376 /lib | |
parent | b5d8c5fb08d596d598d86afce479be7e8b9bc700 (diff) |
Add smb_available() sanity checks
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 #1124
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libshare/smb.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/libshare/smb.c b/lib/libshare/smb.c index e34d14259..a545bfb0f 100644 --- a/lib/libshare/smb.c +++ b/lib/libshare/smb.c @@ -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; } |