packages feed

gssapi 0.1.0.0 → 0.2.0.0

raw patch · 3 files changed

+16/−10 lines, 3 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

- Network.Security.GssApi: GssException :: Word -> ByteString -> GssException
+ Network.Security.GssApi: GssException :: Word -> ByteString -> Word -> ByteString -> GssException

Files

+ ChangeLog.md view
@@ -0,0 +1,3 @@+## 0.2.0.0++Better exception handling. `GssException` now contains both major and minor code and description for both.
gssapi.cabal view
@@ -1,5 +1,5 @@ name:                gssapi-version:             0.1.0.0+version:             0.2.0.0 synopsis:            libgssapi and libkrb5 bindings for haskell description:         Simple bindings for libgssapi(SSO) and libkrb5(user/password) library. license:             BSD3@@ -10,7 +10,7 @@ copyright:           Ondrej Palkovsky category:            Network build-type:          Simple-extra-source-files:  clib/hkrb5.h README.md+extra-source-files:  clib/hkrb5.h README.md ChangeLog.md cabal-version:       >=1.10  source-repository head
src/Network/Security/GssApi.hs view
@@ -28,7 +28,7 @@ import           Network.Security.GssTypes  -- | Exception that can be thrown by functions from this module-data GssException = GssException Word BS.ByteString+data GssException = GssException Word BS.ByteString Word BS.ByteString   deriving (Show) instance Exception GssException @@ -60,6 +60,7 @@ foreign import capi "gssapi/gssapi.h value GSS_C_NO_BUFFER" gssCNoBuffer :: Ptr BufferDesc  foreign import capi "gssapi/gssapi.h value GSS_C_MECH_CODE" gssCMechCode :: CUInt+foreign import capi "gssapi/gssapi.h value GSS_C_GSS_CODE" gssCGSSCode :: CUInt  foreign import capi "gssapi/gssapi.h GSS_ERROR" _gssError :: CUInt -> CUInt foreign import capi "gssapi/gssapi.h value GSS_S_CONTINUE_NEEDED" _gssSContinueNeeded :: CUInt@@ -132,19 +133,21 @@   | otherwise = code   where     throwGssException status = do-      errtxt <- gssDisplayStatus status-      throwIO $ GssException (fromIntegral status) errtxt+      majorTxt <- gssDisplayStatus gssCGSSCode major+      minorTxt <- gssDisplayStatus gssCMechCode status+      throwIO $ GssException (fromIntegral major) majorTxt (fromIntegral status) minorTxt -gssDisplayStatus :: CUInt -> IO BS.ByteString-gssDisplayStatus rstatus =+gssDisplayStatus :: CUInt -> CUInt -> IO BS.ByteString+gssDisplayStatus statusType rstatus =   alloca $ \minor ->       alloca $ \msgctx -> do           poke msgctx 0           withBufferDesc "" $ \bdesc -> do               -- TODO: This could produce more than 1 line, we should fetch all of them               poke bdesc (BufferDesc 0 nullPtr)-              major <- _gss_display_status minor rstatus gssCMechCode gssCNoOid msgctx bdesc-              whenGssOk major minor $ peekBuffer bdesc+              major <- _gss_display_status minor rstatus statusType gssCNoOid msgctx bdesc+              if | gssError major -> return ""+                 | otherwise -> peekBuffer bdesc  foreign import ccall safe "gssapi/gssapi.h gss_acquire_cred"   _gss_acquire_cred :: Ptr CUInt -> GssNameT -> CUInt -> GssOIDSet -> GssCredUsageT -> Ptr GssCredIdT -> Ptr GssOIDSet -> Ptr CUInt -> IO CUInt@@ -204,7 +207,7 @@                     when (gssContinueNeeded major) $ do                         void $ _gss_delete_sec_context minor sContext gssCNoBuffer                         gssReleaseName clname-                        throwIO (GssException 0 "Only one auth interaction allowed.")+                        throwIO (GssException 0 "Only one auth interaction allowed." 0 "")                     sClientName <- gssDisplayName clname `finally` gssReleaseName clname                     sOutputToken <- peekBuffer boutput                     return SecContextResult{..}