sys-auth-smbclient 1.0.0.0 → 2.0.0.0
raw patch · 2 files changed
+17/−10 lines, 2 files
Files
src/System/Authenticate/SmbClient.hs view
@@ -1,7 +1,8 @@ {-# LANGUAGE OverloadedStrings #-} module System.Authenticate.SmbClient (- loginSmbClient+ loginSmbClient,+ SmbClientResult ) where import Control.Applicative@@ -15,9 +16,14 @@ commandName = "smbclient" +-- |The login result type.+--+-- If success, return Right with actual username.+type SmbClientResult = Either () Text+ -- |Authenticate with @smbclient@ command. ----- Return True if login success, False otherwise.+-- Return Right if login success, Left otherwise. -- -- This does not accept empty username or password, -- because those has always been success as Guest login.@@ -25,12 +31,12 @@ -> Text -- ^ Domain -> Text -- ^ Username -> Text -- ^ Password- -> IO Bool+ -> IO SmbClientResult loginSmbClient server domain username password = do timedResult <- timeout (10 * 1000000) process case timedResult of Just result -> return result- Nothing -> return False+ Nothing -> return $ Left () where domain' = checkedText domain username' = checkedText username@@ -45,17 +51,18 @@ process = case authInfo' of Just a -> validate commandName server a- _ -> return False+ $ Right (fromJust username')+ _ -> return $ Left () -validate command server authInfo = do+validate command server authInfo successInfo = do (exitCode, _, _) <- readProcessWithExitCode command [ "-L", unpack server, "-A", "/dev/stdin"] authInfo case exitCode of- ExitSuccess -> return True- _ -> return False+ ExitSuccess -> return successInfo+ _ -> return $ Left () -- |Returns valid words or Nothing. --
sys-auth-smbclient.cabal view
@@ -10,7 +10,7 @@ -- PVP summary: +-+------- breaking API changes -- | | +----- non-breaking API additions -- | | | +--- code changes with no API change-version: 1.0.0.0+version: 2.0.0.0 -- A short (one-line) description of the package. synopsis: Auth with smbclient command@@ -78,4 +78,4 @@ source-repository this type: git location: https://github.com/kkazuo/sys-auth-smbclient.git- tag: 1.0.0.0+ tag: 2.0.0.0