Portability | unportable |
---|---|
Safe Haskell | None |
Language | Haskell2010 |
Main
Contents
Description
Probably not at all portable. Makes use of functions from the
unistd.h
header file.
TODO:
Tidy this up, shift some of the logic out to another module.
- setresgid_c :: CGid -> CGid -> CGid -> IO CInt
- setresuid_c :: CUid -> CUid -> CUid -> IO CInt
- setResGid :: CGid -> CGid -> CGid -> IO ()
- setResUid :: CUid -> CUid -> CUid -> IO ()
- openIfNExist :: String -> IO Handle
- withMailFile :: String -> (Handle -> IO a) -> IO a
- getUserIDs :: String -> IO (UserID, GroupID)
- getUniqueName :: IO String
- forceEitherMsg :: Either err t -> (err -> String) -> t
- warning :: String -> IO ()
- mkError :: Error a => (t -> String) -> Either t b -> Either a b
- data Config = Config {}
- getConfig :: String -> IO Config
- validateAddr :: Maybe Addr -> Either String (Maybe EmailAddress)
- handleAddr :: (MonadError e m, Error e) => (Addr -> String -> String) -> Maybe Addr -> m (Maybe EmailAddress)
- deliverMail :: FilePath -> String -> AttCmdArgs -> IO ()
- main :: IO ()
- test :: IO AttCmdArgs
C functions and wrappers around them
setresgid_c :: CGid -> CGid -> CGid -> IO CInt Source #
unistd funcs:
#include unistd.h int setresuid(uid_t ruid, uid_t euid, uid_t suid); int setresgid(gid_t rgid, gid_t egid, gid_t sgid);
low-level, Posix-specific functions
openIfNExist :: String -> IO Handle Source #
opens w/ mode 0644, but gives error if exists
i.e. -rw-r--r--
withMailFile :: String -> (Handle -> IO a) -> IO a Source #
opens and closes a file created with openIfNExist, and executes the action f on it in between.
getUniqueName :: IO String Source #
utility functions
forceEitherMsg :: Either err t -> (err -> String) -> t Source #
force either
Program config
Configuration, as read from the config file.
deal with addresses
validateAddr :: Maybe Addr -> Either String (Maybe EmailAddress) Source #
the Addr
type is simply something that _might_ be an address,
this validates it.
handleAddr :: (MonadError e m, Error e) => (Addr -> String -> String) -> Maybe Addr -> m (Maybe EmailAddress) Source #
wrapper around validateAddr. Pass in a func that takes in a (presumably bad) address and an error message, and spits out a string
And then, the Maybe/Either result of validation will get turned into an appropriate MonadError action we can just execute in IO.
whopping big monolithic funcs
deliverMail :: FilePath -> String -> AttCmdArgs -> IO () Source #
deliver mail to the maildir directory mailDir, owned by userName, with command-line args cmdArgs.
Creates a unique file name w/ getUniqueName. If something creates the file in between generating the name and delivering mail, an IOError will get thrown.
AttCmdArgs should never have 0 recipients
process args as for sendmail.
sendmail [flags] [receipients] < message -f = envelop sender address -F = full name of sender -bm = read mail from stdin (default) -bp, -bs = we ignore these
testing
test :: IO AttCmdArgs Source #
here for testing purposes