Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9fbe92f
commit 9b78014
Showing
4 changed files
with
139 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# A simple makefile to drive everything | ||
dist: | ||
# runhaskell Setup.hs configure --prefix=$(HOME) --user && runhaskell Setup.hs build && runhaskell Setup.hs install && runhaskell Setup.hs sdist | ||
cabal configure --prefix=$(HOME) --user && cabal build && cabal install && cabal sdist | ||
#sipc: Sipc.chs | ||
# c2hs Sipc.chs | ||
# ghc Sipc.hs -lsipc | ||
#ghci: Sipc.hs | ||
# ghci Sipc.hs -lsipc | ||
clean: | ||
rm -rf *.o *.hi *.chi Sipc.chs.h C2HS.hs Sipc.hs a.out dist | ||
find . -type f -name "*.hi" -exec rm -f {} \; | ||
find . -type f -name "*.o" -exec rm -f {} \; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/usr/bin/env runhaskell | ||
import Distribution.Simple | ||
main = defaultMain |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
Name: bindings-sipc | ||
Version: 1.0 | ||
Synopsis: Low level bindings to SIPC. | ||
Description: Low level bindings to the Secure Inter-Process Communications (SIPC) | ||
library for SELinux. | ||
License: LGPL | ||
-- License-file: LICENSE | ||
Author: Justin Ethier | ||
Maintainer: Justin Ethier <github.com/justinethier> | ||
Homepage: http://justinethier.github.com/hs-bindings-sipc | ||
Cabal-Version: >= 1.8 | ||
Build-Tools: c2hs | ||
Build-Type: Simple | ||
Category: FFI | ||
Tested-with: GHC == 6.10.3 | ||
|
||
Library | ||
Build-Depends: base >= 2.0 && < 5 | ||
-- , array, containers, haskeline, transformers, mtl, parsec, directory, ghc, ghc-paths | ||
-- Extensions: ExistentialQuantification CPP CPP | ||
Hs-Source-Dirs: src | ||
Exposed-Modules: Bindings.SELinux.SIPC | ||
Extra-Libraries: sipc | ||
|
||
-- Extra-Source-Files: README.markdown | ||
-- LICENSE | ||
-- Data-Files: stdlib.scm | ||
-- | ||
-- Source-Repository head | ||
-- Type: git | ||
-- Location: git://github.com/justinethier/husk-scheme.git | ||
-- | ||
-- Executable huski | ||
-- Build-Depends: husk-scheme, base >= 2.0 && < 5, array, containers, haskeline, transformers, mtl, parsec, directory, ghc, ghc-paths | ||
-- Extensions: ExistentialQuantification CPP CPP | ||
-- Main-is: shell.hs | ||
-- Hs-Source-Dirs: hs-src/Interpreter | ||
-- | ||
-- Executable huskc | ||
-- Build-Depends: husk-scheme, base >= 2.0 && < 5, array, containers, haskeline, transformers, mtl, parsec, directory, ghc, ghc-paths, process, filepath | ||
-- Extensions: ExistentialQuantification CPP CPP | ||
-- Main-is: huskc.hs | ||
-- Hs-Source-Dirs: hs-src/Compiler | ||
-- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
{-# LANGUAGE ForeignFunctionInterface#-} | ||
|
||
module Bindings.SELinux.SIPC where | ||
|
||
import Foreign | ||
import Foreign.C | ||
|
||
-- The sipc header must be installed on your system | ||
-- in order to compile this module!! | ||
#include <sipc/sipc.h> | ||
|
||
#c | ||
enum SIPCRole { | ||
Sipc_creator = SIPC_CREATOR, | ||
Sipc_sender = SIPC_SENDER, | ||
Sipc_receiver = SIPC_RECEIVER | ||
}; | ||
enum SIPCType { | ||
Sipc_sysv_shm = SIPC_SYSV_SHM, | ||
Sipc_sysv_mqueues = SIPC_SYSV_MQUEUES, | ||
Sipc_num_types = SIPC_NUM_TYPES | ||
}; | ||
enum SIPCIOCtl { | ||
Sipc_block = SIPC_BLOCK, | ||
Sipc_noblock = SIPC_NOBLOCK | ||
}; | ||
#endc | ||
|
||
-- |SIPC Roles | ||
{#enum SIPCRole {} deriving (Eq, Show)#} | ||
-- |SIPC Types | ||
{#enum SIPCType {} deriving (Eq, Show)#} | ||
-- |SIPC behaviors, for sipc_ioctl() | ||
{#enum SIPCIOCtl {} deriving (Eq, Show)#} | ||
|
||
-- TODO: documentation for *everything* once all defs are in place | ||
|
||
--data Sipc = Sipc | ||
--type SipcPtr = Ptr Sipc | ||
type SipcPtr = Ptr () | ||
|
||
-- TODO: should use CSize for last input arg | ||
{#fun unsafe sipc_open {`String', cFromEnum `SIPCRole', cFromEnum `SIPCType', `Int' } -> `SipcPtr' id #} | ||
{#fun unsafe sipc_close {id `SipcPtr'} -> `()' #} | ||
|
||
{#fun unsafe sipc_unlink {`String', cFromEnum `SIPCType'} -> `()' #} | ||
|
||
{#fun unsafe sipc_ioctl {id `SipcPtr', cFromEnum `SIPCIOCtl'} -> `Int' #} | ||
|
||
-- TODO: same issue with CSize as above | ||
--int sipc_send_data(sipc_t *sipc, size_t msg_len); | ||
{#fun unsafe sipc_send_data {id `SipcPtr', `Int'} -> `Int' #} | ||
|
||
-- TODO: is String really the right return type here?? | ||
-- /* Returns a pointer to the data contained within the IPC resource */ | ||
--char *sipc_get_data_ptr(sipc_t *sipc); | ||
{#fun unsafe sipc_get_data_ptr {id `SipcPtr'} -> `String' #} | ||
|
||
{- TODO: | ||
-- data is allocated by C, believe this must be indicated to Haskell | ||
-- TBD: what about len?? | ||
int sipc_recv_data(sipc_t *sipc, char **data, size_t *len); | ||
-- TODO: are variable-length args even supported by the Haskell FFI??? | ||
/* Prints an error message, accepts printf format string */ | ||
void sipc_error(sipc_t *sipc, const char *fmt, ...) | ||
__attribute__ ((format(printf, 2, 3))); | ||
-} | ||
|
||
{#fun unsafe sipc_shm_recv_done {id `SipcPtr'} -> `Int' #} | ||
|
||
-- |Convert a Haskell enumeration to C. | ||
-- | ||
-- This code is from C2HS, but it has been added | ||
-- here since C2HS is deprecated. | ||
cFromEnum :: (Enum e, Integral i) => e -> i | ||
cFromEnum = fromIntegral . fromEnum | ||
|