From 44410535fdd3e2345629cbe7bf94f0caf331cb0d Mon Sep 17 00:00:00 2001 From: Evgeny Poberezkin Date: Thu, 28 Mar 2024 18:16:36 +0000 Subject: [PATCH] do not pass key to control port of xftp server (#1074) --- src/Simplex/FileTransfer/Server.hs | 8 +++----- src/Simplex/FileTransfer/Server/Control.hs | 6 +++--- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/Simplex/FileTransfer/Server.hs b/src/Simplex/FileTransfer/Server.hs index 4874aea1a..2d957a7b2 100644 --- a/src/Simplex/FileTransfer/Server.hs +++ b/src/Simplex/FileTransfer/Server.hs @@ -223,15 +223,13 @@ xftpServer cfg@XFTPServerConfig {xftpPort, transportConfig, inactiveClientExpira | Just auth == user = CPRUser | otherwise = CPRNone CPStatsRTS -> E.tryAny getRTSStats >>= either (hPrint h) (hPrint h) - CPDelete fileId fKey -> withUserRole $ unliftIO u $ do + CPDelete fileId -> withUserRole $ unliftIO u $ do fs <- asks store r <- runExceptT $ do let asSender = ExceptT . atomically $ getFile fs SFSender fileId let asRecipient = ExceptT . atomically $ getFile fs SFRecipient fileId - (fr, fKey') <- asSender `catchError` const asRecipient - if fKey == fKey' - then ExceptT $ deleteServerFile_ fr - else throwError AUTH + (fr, _) <- asSender `catchError` const asRecipient + ExceptT $ deleteServerFile_ fr liftIO . hPutStrLn h $ either (\e -> "error: " <> show e) (\() -> "ok") r CPHelp -> hPutStrLn h "commands: stats-rts, delete, help, quit" CPQuit -> pure () diff --git a/src/Simplex/FileTransfer/Server/Control.hs b/src/Simplex/FileTransfer/Server/Control.hs index d8d0c425f..54d349c3b 100644 --- a/src/Simplex/FileTransfer/Server/Control.hs +++ b/src/Simplex/FileTransfer/Server/Control.hs @@ -14,7 +14,7 @@ data CPClientRole = CPRNone | CPRUser | CPRAdmin data ControlProtocol = CPAuth BasicAuth | CPStatsRTS - | CPDelete ByteString C.APublicAuthKey + | CPDelete ByteString | CPHelp | CPQuit | CPSkip @@ -23,7 +23,7 @@ instance StrEncoding ControlProtocol where strEncode = \case CPAuth tok -> "auth " <> strEncode tok CPStatsRTS -> "stats-rts" - CPDelete fId fKey -> strEncode (Str "delete", fId, fKey) + CPDelete fId -> strEncode (Str "delete", fId) CPHelp -> "help" CPQuit -> "quit" CPSkip -> "" @@ -31,7 +31,7 @@ instance StrEncoding ControlProtocol where A.takeTill (== ' ') >>= \case "auth" -> CPAuth <$> _strP "stats-rts" -> pure CPStatsRTS - "delete" -> CPDelete <$> _strP <*> _strP + "delete" -> CPDelete <$> _strP "help" -> pure CPHelp "quit" -> pure CPQuit "" -> pure CPSkip