Warn about unsupported core.sharedRepository=0xxx when set
This spams the user with a lot of messages, but it seems like busywork to avoid that and only warn once, since this warning will go away when it gets implemented. Also fix parsing of the octal value. Sponsored-by: Kevin Mueller on Patreon
This commit is contained in:
parent
4881bc5a53
commit
7af75a59be
4 changed files with 57 additions and 18 deletions
|
@ -1,6 +1,6 @@
|
||||||
{- git-annex file permissions
|
{- git-annex file permissions
|
||||||
-
|
-
|
||||||
- Copyright 2012-2022 Joey Hess <id@joeyh.name>
|
- Copyright 2012-2023 Joey Hess <id@joeyh.name>
|
||||||
-
|
-
|
||||||
- Licensed under the GNU AGPL version 3 or higher.
|
- Licensed under the GNU AGPL version 3 or higher.
|
||||||
-}
|
-}
|
||||||
|
@ -45,6 +45,7 @@ import Utility.Directory.Create
|
||||||
import qualified Utility.RawFilePath as R
|
import qualified Utility.RawFilePath as R
|
||||||
|
|
||||||
import System.PosixCompat.Files (fileMode, intersectFileModes, nullFileMode, groupWriteMode, ownerWriteMode, ownerReadMode, groupReadMode, stdFileMode, ownerExecuteMode, groupExecuteMode)
|
import System.PosixCompat.Files (fileMode, intersectFileModes, nullFileMode, groupWriteMode, ownerWriteMode, ownerReadMode, groupReadMode, stdFileMode, ownerExecuteMode, groupExecuteMode)
|
||||||
|
import Numeric
|
||||||
|
|
||||||
withShared :: (SharedRepository -> Annex a) -> Annex a
|
withShared :: (SharedRepository -> Annex a) -> Annex a
|
||||||
withShared a = a =<< coreSharedRepository <$> Annex.getGitConfig
|
withShared a = a =<< coreSharedRepository <$> Annex.getGitConfig
|
||||||
|
@ -64,21 +65,28 @@ setAnnexPerm = setAnnexPerm' Nothing
|
||||||
|
|
||||||
setAnnexPerm' :: Maybe ([FileMode] -> FileMode -> FileMode) -> Bool -> RawFilePath -> Annex ()
|
setAnnexPerm' :: Maybe ([FileMode] -> FileMode -> FileMode) -> Bool -> RawFilePath -> Annex ()
|
||||||
setAnnexPerm' modef isdir file = unlessM crippledFileSystem $
|
setAnnexPerm' modef isdir file = unlessM crippledFileSystem $
|
||||||
withShared $ liftIO . go
|
withShared go
|
||||||
where
|
where
|
||||||
go GroupShared = void $ tryIO $ modifyFileMode file $ modef' $
|
go GroupShared = void $ liftIO $ tryIO $ modifyFileMode file $ modef' $
|
||||||
groupSharedModes ++
|
groupSharedModes ++
|
||||||
if isdir then [ ownerExecuteMode, groupExecuteMode ] else []
|
if isdir then [ ownerExecuteMode, groupExecuteMode ] else []
|
||||||
go AllShared = void $ tryIO $ modifyFileMode file $ modef' $
|
go AllShared = void $ liftIO $ tryIO $ modifyFileMode file $ modef' $
|
||||||
readModes ++
|
readModes ++
|
||||||
[ ownerWriteMode, groupWriteMode ] ++
|
[ ownerWriteMode, groupWriteMode ] ++
|
||||||
if isdir then executeModes else []
|
if isdir then executeModes else []
|
||||||
go _ = case modef of
|
go UnShared = case modef of
|
||||||
Nothing -> noop
|
Nothing -> noop
|
||||||
Just f -> void $ tryIO $
|
Just f -> void $ liftIO $ tryIO $
|
||||||
modifyFileMode file $ f []
|
modifyFileMode file $ f []
|
||||||
|
go (UmaskShared n) = do
|
||||||
|
warnUmaskSharedUnsupported n
|
||||||
|
go UnShared
|
||||||
modef' = fromMaybe addModes modef
|
modef' = fromMaybe addModes modef
|
||||||
|
|
||||||
|
warnUmaskSharedUnsupported :: Int -> Annex ()
|
||||||
|
warnUmaskSharedUnsupported n = warning $ UnquotedString $
|
||||||
|
"core.sharedRepository set to a umask override (0" ++ showOct n "" ++ ") is not supported by git-annex; ignoring that configuration"
|
||||||
|
|
||||||
resetAnnexFilePerm :: RawFilePath -> Annex ()
|
resetAnnexFilePerm :: RawFilePath -> Annex ()
|
||||||
resetAnnexFilePerm = resetAnnexPerm False
|
resetAnnexFilePerm = resetAnnexPerm False
|
||||||
|
|
||||||
|
@ -101,11 +109,14 @@ resetAnnexPerm isdir file = unlessM crippledFileSystem $ do
|
||||||
- taken into account; this is for use with actions that create the file
|
- taken into account; this is for use with actions that create the file
|
||||||
- and apply the umask automatically. -}
|
- and apply the umask automatically. -}
|
||||||
annexFileMode :: Annex FileMode
|
annexFileMode :: Annex FileMode
|
||||||
annexFileMode = withShared $ return . go
|
annexFileMode = withShared go
|
||||||
where
|
where
|
||||||
go GroupShared = sharedmode
|
go GroupShared = return sharedmode
|
||||||
go AllShared = combineModes (sharedmode:readModes)
|
go AllShared = return $ combineModes (sharedmode:readModes)
|
||||||
go _ = stdFileMode
|
go UnShared = return stdFileMode
|
||||||
|
go (UmaskShared n) = do
|
||||||
|
warnUmaskSharedUnsupported n
|
||||||
|
go UnShared
|
||||||
sharedmode = combineModes groupSharedModes
|
sharedmode = combineModes groupSharedModes
|
||||||
|
|
||||||
{- Creates a directory inside the gitAnnexDir (or possibly the dbdir),
|
{- Creates a directory inside the gitAnnexDir (or possibly the dbdir),
|
||||||
|
@ -178,7 +189,10 @@ freezeContent'' sr file rv = do
|
||||||
(readModes ++ writeModes)
|
(readModes ++ writeModes)
|
||||||
else liftIO $ ignoresharederr $
|
else liftIO $ ignoresharederr $
|
||||||
nowriteadd readModes
|
nowriteadd readModes
|
||||||
go _ = liftIO $ nowriteadd [ownerReadMode]
|
go UnShared = liftIO $ nowriteadd [ownerReadMode]
|
||||||
|
go (UmaskShared n) = do
|
||||||
|
warnUmaskSharedUnsupported n
|
||||||
|
go UnShared
|
||||||
|
|
||||||
ignoresharederr = void . tryIO
|
ignoresharederr = void . tryIO
|
||||||
|
|
||||||
|
@ -206,8 +220,8 @@ checkContentWritePerm file = ifM crippledFileSystem
|
||||||
, do
|
, do
|
||||||
rv <- getVersion
|
rv <- getVersion
|
||||||
hasfreezehook <- hasFreezeHook
|
hasfreezehook <- hasFreezeHook
|
||||||
withShared $ \sr -> liftIO $
|
withShared $ \sr ->
|
||||||
checkContentWritePerm' sr file rv hasfreezehook
|
liftIO $ checkContentWritePerm' sr file rv hasfreezehook
|
||||||
)
|
)
|
||||||
|
|
||||||
checkContentWritePerm' :: SharedRepository -> RawFilePath -> Maybe RepoVersion -> Bool -> IO (Maybe Bool)
|
checkContentWritePerm' :: SharedRepository -> RawFilePath -> Maybe RepoVersion -> Bool -> IO (Maybe Bool)
|
||||||
|
@ -222,7 +236,9 @@ checkContentWritePerm' sr file rv hasfreezehook
|
||||||
| versionNeedsWritableContentFiles rv ->
|
| versionNeedsWritableContentFiles rv ->
|
||||||
want sharedret (includemodes writeModes)
|
want sharedret (includemodes writeModes)
|
||||||
| otherwise -> want sharedret (excludemodes writeModes)
|
| otherwise -> want sharedret (excludemodes writeModes)
|
||||||
_ -> want Just (excludemodes writeModes)
|
UnShared -> want Just (excludemodes writeModes)
|
||||||
|
UmaskShared _ ->
|
||||||
|
checkContentWritePerm' UnShared file rv hasfreezehook
|
||||||
where
|
where
|
||||||
want mk f = catchMaybeIO (fileMode <$> R.getFileStatus file)
|
want mk f = catchMaybeIO (fileMode <$> R.getFileStatus file)
|
||||||
>>= return . \case
|
>>= return . \case
|
||||||
|
@ -247,7 +263,10 @@ thawContent' sr file = do
|
||||||
where
|
where
|
||||||
go GroupShared = liftIO $ void $ tryIO $ groupWriteRead file
|
go GroupShared = liftIO $ void $ tryIO $ groupWriteRead file
|
||||||
go AllShared = liftIO $ void $ tryIO $ groupWriteRead file
|
go AllShared = liftIO $ void $ tryIO $ groupWriteRead file
|
||||||
go _ = liftIO $ allowWrite file
|
go UnShared = liftIO $ allowWrite file
|
||||||
|
go (UmaskShared n) = do
|
||||||
|
warnUmaskSharedUnsupported n
|
||||||
|
go UnShared
|
||||||
|
|
||||||
{- Runs an action that thaws a file's permissions. This will probably
|
{- Runs an action that thaws a file's permissions. This will probably
|
||||||
- fail on a crippled filesystem. But, if file modes are supported on a
|
- fail on a crippled filesystem. But, if file modes are supported on a
|
||||||
|
@ -273,7 +292,10 @@ freezeContentDir file = do
|
||||||
dir = parentDir file
|
dir = parentDir file
|
||||||
go GroupShared = liftIO $ void $ tryIO $ groupWriteRead dir
|
go GroupShared = liftIO $ void $ tryIO $ groupWriteRead dir
|
||||||
go AllShared = liftIO $ void $ tryIO $ groupWriteRead dir
|
go AllShared = liftIO $ void $ tryIO $ groupWriteRead dir
|
||||||
go _ = liftIO $ preventWrite dir
|
go UnShared = liftIO $ preventWrite dir
|
||||||
|
go (UmaskShared n) = do
|
||||||
|
warnUmaskSharedUnsupported n
|
||||||
|
go UnShared
|
||||||
|
|
||||||
thawContentDir :: RawFilePath -> Annex ()
|
thawContentDir :: RawFilePath -> Annex ()
|
||||||
thawContentDir file = do
|
thawContentDir file = do
|
||||||
|
|
|
@ -29,6 +29,7 @@ git-annex (10.20230408) UNRELEASED; urgency=medium
|
||||||
--json-error-messages is enabled, output a JSON object indicating the
|
--json-error-messages is enabled, output a JSON object indicating the
|
||||||
problem. (But git ls-files --error-unmatch still displays errors about
|
problem. (But git ls-files --error-unmatch still displays errors about
|
||||||
such files in some situations.)
|
such files in some situations.)
|
||||||
|
* Warn about unsupported core.sharedRepository=0xxx when set.
|
||||||
|
|
||||||
-- Joey Hess <id@joeyh.name> Sat, 08 Apr 2023 13:57:18 -0400
|
-- Joey Hess <id@joeyh.name> Sat, 08 Apr 2023 13:57:18 -0400
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{- git config types
|
{- git config types
|
||||||
-
|
-
|
||||||
- Copyright 2012, 2017 Joey Hess <id@joeyh.name>
|
- Copyright 2012-2023 Joey Hess <id@joeyh.name>
|
||||||
-
|
-
|
||||||
- Licensed under the GNU AGPL version 3 or higher.
|
- Licensed under the GNU AGPL version 3 or higher.
|
||||||
-}
|
-}
|
||||||
|
@ -10,6 +10,7 @@
|
||||||
module Git.ConfigTypes where
|
module Git.ConfigTypes where
|
||||||
|
|
||||||
import Data.Char
|
import Data.Char
|
||||||
|
import Numeric
|
||||||
import qualified Data.ByteString.Char8 as S8
|
import qualified Data.ByteString.Char8 as S8
|
||||||
|
|
||||||
import Common
|
import Common
|
||||||
|
@ -31,7 +32,8 @@ getSharedRepository r =
|
||||||
"all" -> AllShared
|
"all" -> AllShared
|
||||||
"world" -> AllShared
|
"world" -> AllShared
|
||||||
"everybody" -> AllShared
|
"everybody" -> AllShared
|
||||||
_ -> maybe UnShared UmaskShared (readish (decodeBS v))
|
_ -> maybe UnShared UmaskShared
|
||||||
|
(fmap fst $ headMaybe $ readOct $ decodeBS v)
|
||||||
Just NoConfigValue -> UnShared
|
Just NoConfigValue -> UnShared
|
||||||
Nothing -> UnShared
|
Nothing -> UnShared
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
[[!comment format=mdwn
|
||||||
|
username="joey"
|
||||||
|
subject="""comment 2"""
|
||||||
|
date="2023-04-26T16:50:23Z"
|
||||||
|
content="""
|
||||||
|
I don't think it would be that hard to implement, I count 6 places, all in
|
||||||
|
Annex.Perms that don't handle UmaskShared.
|
||||||
|
|
||||||
|
For now I've made all of them display a warning.
|
||||||
|
|
||||||
|
(Note that your warning patch to datalad is probably buggy,
|
||||||
|
since core.sharedrepository=1 and =2 are supported by git-annex.
|
||||||
|
(As legacy alternatives to "group" and "everybody".))
|
||||||
|
"""]]
|
Loading…
Reference in a new issue