git-annex/Command/RemoteDaemon.hs
Joey Hess cd544e548b
filter out control characters in error messages
giveup changed to filter out control characters. (It is too low level to
make it use StringContainingQuotedPath.)

error still does not, but it should only be used for internal errors,
where the message is not attacker-controlled.

Changed a lot of existing error to giveup when it is not strictly an
internal error.

Of course, other exceptions can still be thrown, either by code in
git-annex, or a library, that include some attacker-controlled value.
This does not guard against those.

Sponsored-by: Noam Kremen on Patreon
2023-04-10 13:50:51 -04:00

37 lines
950 B
Haskell

{- git-annex command
-
- Copyright 2014-2016 Joey Hess <id@joeyh.name>
-
- Licensed under the GNU AGPL version 3 or higher.
-}
{-# LANGUAGE CPP #-}
module Command.RemoteDaemon where
import Command
import RemoteDaemon.Core
import Utility.Daemon
#ifndef mingw32_HOST_OS
import Annex.Path
#endif
cmd :: Command
cmd = noCommit $
command "remotedaemon" SectionCommon
"persistent communication with remotes"
paramNothing (run <$$> const (parseDaemonOptions False))
run :: DaemonOptions -> CommandSeek
run o
| stopDaemonOption o = giveup "--stop not implemented for remotedaemon"
| foregroundDaemonOption o = liftIO runInteractive
| otherwise = do
#ifndef mingw32_HOST_OS
git_annex <- liftIO programPath
ps <- gitAnnexDaemonizeParams
let logfd = openFd "/dev/null" ReadOnly Nothing defaultFileFlags
liftIO $ daemonize git_annex ps logfd Nothing False runNonInteractive
#else
liftIO $ foreground Nothing runNonInteractive
#endif