rename config to annex.security.allowed-compute-programs

And require for enable as well as autoenable.

It seemed asking for trouble for `git-annex enable foo` to use whatever
compute program is stored in the git config, without verifying that the
user wants that program to be used.

Note that it would be good to allow `git-annex enable foo program=...`
to be used without the program being in the git config. Not implemented yet
though.
This commit is contained in:
Joey Hess 2025-03-03 16:07:04 -04:00
parent f32d2aecce
commit 52f51d065a
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
5 changed files with 24 additions and 24 deletions

View file

@ -121,21 +121,19 @@ gen r u rc gc rs = case getComputeProgram' rc of
setupInstance :: SetupStage -> Maybe UUID -> Maybe CredPair -> RemoteConfig -> RemoteGitConfig -> Annex (RemoteConfig, UUID) setupInstance :: SetupStage -> Maybe UUID -> Maybe CredPair -> RemoteConfig -> RemoteGitConfig -> Annex (RemoteConfig, UUID)
setupInstance ss mu _ c _ = do setupInstance ss mu _ c _ = do
ComputeProgram program <- either giveup return $ getComputeProgram' c ComputeProgram program <- either giveup return $ getComputeProgram' c
allowedprograms <- maybe [] words . annexAllowedComputePrograms
<$> Annex.getGitConfig
case ss of case ss of
AutoEnable _ -> do Init -> noop
l <- maybe [] words _ -> unless (program `elem` allowedprograms) $ do
. annexAutoEnableComputePrograms let remotename = fromMaybe "(unknown)" (lookupName c)
<$> Annex.getGitConfig giveup $ unwords
unless (program `elem` l) $ do [ "Not enabling compute special remote"
let remotename = fromMaybe "(unknown)" (lookupName c) , remotename
giveup $ unwords , "because its compute program"
[ "Not auto-enabling compute special remote" , program
, remotename , "is not listed in annex.security-allowed-compute-programs"
, "because its compute program" ]
, program
, " is not listed in annex.security.autoenable-compute-programs"
]
_ -> noop
unlessM (liftIO $ inSearchPath program) $ unlessM (liftIO $ inSearchPath program) $
giveup $ "Cannot find " ++ program ++ " in PATH" giveup $ "Cannot find " ++ program ++ " in PATH"
u <- maybe (liftIO genUUID) return mu u <- maybe (liftIO genUUID) return mu

View file

@ -1,3 +1,6 @@
* allow git-annex enableremote with program= explicitly specified,
without checking annex.security.allowed-compute-programs
* need progress bars for computations and implement PROGRESS message * need progress bars for computations and implement PROGRESS message
* get input files for a computation (so `git-annex get .` gets every file, * get input files for a computation (so `git-annex get .` gets every file,

View file

@ -146,7 +146,7 @@ data GitConfig = GitConfig
, annexAllowedUrlSchemes :: S.Set Scheme , annexAllowedUrlSchemes :: S.Set Scheme
, annexAllowedIPAddresses :: String , annexAllowedIPAddresses :: String
, annexAllowUnverifiedDownloads :: Bool , annexAllowUnverifiedDownloads :: Bool
, annexAutoEnableComputePrograms :: Maybe String , annexAllowedComputePrograms :: Maybe String
, annexMaxExtensionLength :: Maybe Int , annexMaxExtensionLength :: Maybe Int
, annexMaxExtensions :: Maybe Int , annexMaxExtensions :: Maybe Int
, annexJobs :: Concurrency , annexJobs :: Concurrency
@ -262,8 +262,8 @@ extractGitConfig configsource r = GitConfig
getmaybe (annexConfig "security.allowed-http-addresses") -- old name getmaybe (annexConfig "security.allowed-http-addresses") -- old name
, annexAllowUnverifiedDownloads = (== Just "ACKTHPPT") $ , annexAllowUnverifiedDownloads = (== Just "ACKTHPPT") $
getmaybe (annexConfig "security.allow-unverified-downloads") getmaybe (annexConfig "security.allow-unverified-downloads")
, annexAutoEnableComputePrograms = , annexAllowedComputePrograms =
getmaybe (annexConfig "security.autoenable-compute-programs") getmaybe (annexConfig "security.allowed-compute-programs")
, annexMaxExtensionLength = getmayberead (annexConfig "maxextensionlength") , annexMaxExtensionLength = getmayberead (annexConfig "maxextensionlength")
, annexMaxExtensions = getmayberead (annexConfig "maxextensions") , annexMaxExtensions = getmayberead (annexConfig "maxextensions")
, annexJobs = fromMaybe NonConcurrent $ , annexJobs = fromMaybe NonConcurrent $

View file

@ -2201,12 +2201,12 @@ Remotes are configured using these settings in `.git/config`.
Per-remote configuration of annex.security.allow-unverified-downloads. Per-remote configuration of annex.security.allow-unverified-downloads.
* `annex.security.autoenable-compute-programs` * `annex.security.allowed-compute-programs`
This is a space separated list of compute programs eg This is a space separated list of compute programs eg
"git-annex-compute-foo git-annex-compute-bar". Listing a compute "git-annex-compute-foo git-annex-compute-bar". Listing a compute
program here allows compute special remotes that use that program to be program here allows compute special remotes that use that program to be
autoenabled. enabled by `git-annex enableremote` or autoenabled.
# CONFIGURATION OF ASSISTANT # CONFIGURATION OF ASSISTANT

View file

@ -15,11 +15,10 @@ program to use to compute the contents of annexed files. It must start with
"git-annex-compute-". The program needs to be installed somewhere in the "git-annex-compute-". The program needs to be installed somewhere in the
`PATH`. `PATH`.
The `autoenable` parameter can be set to "true" like with other special Any program can be passed to `git-annex initremote`. However, when enabling
remotes to make git-annex automatically enable this special remote when a compute special remote later with `git-annex enableremote` or due to
run in a new clone of the repository. However, for security, autoenabling "autoenable=true", the program must be listed in the git config
is only done when the git config `annex.security.autoenable-compute-programs` `annex.security.allowed-compute-programs`.
includes the name of the compute program.
All other "field=value" parameters passed to `initremote` will be passed All other "field=value" parameters passed to `initremote` will be passed
to the program when running [[git-annex-addcomputed]]. Note that when the to the program when running [[git-annex-addcomputed]]. Note that when the