diff options
author | Joey Hess <joeyh@joeyh.name> | 2017-02-13 17:30:28 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2017-02-13 17:39:16 -0400 |
commit | ab15aba7e4eb7fcc6d1e1423622a0e1bc04c567e (patch) | |
tree | 859c5098a50217580cb803dd99e166ad76b9e814 /Utility | |
parent | 6e5180c8d52cabffff00fda0682b6cb280e95b36 (diff) |
Work around sqlite's incorrect handling of umask when creating databases.
Refactored some common code into initDb.
This only deals with the problem when creating new databases. If a repo
got bad permissions into it, it's up to the user to deal with it.
This commit was sponsored by Ole-Morten Duesund on Patreon.
Diffstat (limited to 'Utility')
-rw-r--r-- | Utility/FileMode.hs | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/Utility/FileMode.hs b/Utility/FileMode.hs index bb3780c6e..fe9cbf56a 100644 --- a/Utility/FileMode.hs +++ b/Utility/FileMode.hs @@ -1,6 +1,6 @@ {- File mode utilities. - - - Copyright 2010-2012 Joey Hess <id@joeyh.name> + - Copyright 2010-2017 Joey Hess <id@joeyh.name> - - License: BSD-2-clause -} @@ -130,6 +130,21 @@ withUmask umask a = bracket setup cleanup go withUmask _ a = a #endif +getUmask :: IO FileMode +#ifndef mingw32_HOST_OS +getUmask = bracket setup cleanup return + where + setup = setFileCreationMask nullFileMode + cleanup = setFileCreationMask +#else +getUmask = return nullFileMode +#endif + +defaultFileMode :: IO FileMode +defaultFileMode = do + umask <- getUmask + return $ intersectFileModes (complement umask) stdFileMode + combineModes :: [FileMode] -> FileMode combineModes [] = 0 combineModes [m] = m |