On Thu, Jul 18, 2013 at 9:53 AM, Michele Tartara <[email protected]>wrote:

> On Thu, Jul 18, 2013 at 9:51 AM, Klaus Aehlig <[email protected]> wrote:
>
>> > One of the haskell tests allocates a Luxi socket. Given that the tests
>> are
>> > run as the local user, setting the owner and group was failing for
>> missing
>> > permissions.
>> >
>> > (Sorry for not noticing this before)
>> >
>> > So, here is the interdiff fixing the problem, by introducing a new
>> boolean
>> > parameter in getServer, determining whether the owner and group of the
>> > socket are actually modified or not.
>> >
>> > diff --git a/src/Ganeti/Luxi.hs b/src/Ganeti/Luxi.hs
>> > index 1042bb7..b75f320 100644
>> > --- a/src/Ganeti/Luxi.hs
>> > +++ b/src/Ganeti/Luxi.hs
>> > @@ -224,11 +224,12 @@ getClient path = do
>> >    return Client { socket=h, rbuf=rf }
>> >
>> >  -- | Creates and returns a server endpoint.
>> > -getServer :: FilePath -> IO S.Socket
>> > -getServer path = do
>> > +getServer :: FilePath -> Bool -> IO S.Socket
>> > +getServer path setOwner = do
>>
>> Generally, it's more usefull to have the extra flags as
>> first arguments. In that way, 'getSever True' could act
>> as a drop-in replacement for the old getServer.
>>
>
> Good point!
> I'll resend it with that modification.
>
>

Here it is. Interdiff:
diff --git a/src/Ganeti/Luxi.hs b/src/Ganeti/Luxi.hs
index b75f320..b0c8b8f 100644
--- a/src/Ganeti/Luxi.hs
+++ b/src/Ganeti/Luxi.hs
@@ -224,8 +224,8 @@ getClient path = do
   return Client { socket=h, rbuf=rf }

 -- | Creates and returns a server endpoint.
-getServer :: FilePath -> Bool -> IO S.Socket
-getServer path setOwner = do
+getServer :: Bool -> FilePath -> IO S.Socket
+getServer setOwner path = do
   s <- S.socket S.AF_UNIX S.Stream S.defaultProtocol
   S.bindSocket s (S.SockAddrUnix path)
   when setOwner . setOwnerAndGroupFromNames path GanetiConfd $
diff --git a/src/Ganeti/Query/Server.hs b/src/Ganeti/Query/Server.hs
index eda019a..3839715 100644
--- a/src/Ganeti/Query/Server.hs
+++ b/src/Ganeti/Query/Server.hs
@@ -249,7 +249,7 @@ prepMain _ _ = do
   socket_path <- Path.defaultQuerySocket
   cleanupSocket socket_path
   s <- describeError "binding to the Luxi socket"
-         Nothing (Just socket_path) $ getServer socket_path True
+         Nothing (Just socket_path) $ getServer True socket_path
   cref <- newIORef (Bad "Configuration not yet loaded")
   return (socket_path, s, cref)

diff --git a/test/hs/Test/Ganeti/Luxi.hs b/test/hs/Test/Ganeti/Luxi.hs
index 2b57ce6..6eb8c12 100644
--- a/test/hs/Test/Ganeti/Luxi.hs
+++ b/test/hs/Test/Ganeti/Luxi.hs
@@ -126,7 +126,7 @@ prop_ClientServer dnschars = monadicIO $ do
   -- we need to create the server first, otherwise (if we do it in the
   -- forked thread) the client could try to connect to it before it's
   -- ready
-  server <- run $ Luxi.getServer fpath False
+  server <- run $ Luxi.getServer False fpath
   -- fork the server responder
   _ <- run . forkIO $
     bracket

Thanks,
Michele

Reply via email to