Commit graph

47105 commits

Author SHA1 Message Date
Joey Hess
314ce317bf
update 2025-09-05 15:48:43 -04:00
Joey Hess
66814d921c
convert withFile and withBinaryFile to close-on-exec safe versions
At this point, every call in git-annex to withFile, openBinaryFile,
withBinaryFile, appendFile, and openTempFile, readFile, and writeFile
have been converted.

Sponsored-by: the NIH-funded NICEMAN (ReproNim TR&D3) project
2025-09-05 15:44:43 -04:00
Joey Hess
6f9a9c81f6
convert all readFile, writeFile, and appendFile to close-on-exec safe versions
Even in the Build system. This allows grepping to make sure that there
are none left un-converted:

git grep "writeFile" |grep -v F\\.| grep -v doc/|grep -v writeFileString | grep -v writeFileProtected |grep -v Utility/FileIO
git grep "readFile" |grep -v F\\.| grep -v doc/|grep -v readFileString |grep -v Utility/FileIO
git grep "appendFile" |grep -v F\\.| grep -v doc/|grep -v appendFileString |grep -v Utility/FileIO

Might be nice to automate that to prevent future mistakes...

Sponsored-by: the NIH-funded NICEMAN (ReproNim TR&D3) project
2025-09-05 15:44:32 -04:00
Joey Hess
867110e9ee
add readFileString, writeFileString, appendFileString
Exported by Common, so they will be available everywhere.
These are the same as readFile, writeFile, appendFile.
But have two benefits:

* They take OsPath, so using them avoids converting back and forth
  unncessarily.
* They use the close-on-exec flag so can't leak FDs to child processes.
  Unlike the standard Haskell versions which unfortunately have that
  wart currently. (I do hope the standard versions get fixed
  eventually.)

Sponsored-by: the NIH-funded NICEMAN (ReproNim TR&D3) project
2025-09-05 14:54:36 -04:00
Joey Hess
171b427eb8
update 2025-09-05 14:07:40 -04:00
Joey Hess
9a2013a2e7
update 2025-09-05 14:06:15 -04:00
Joey Hess
c18581c356
Utility.FileIO: set close-on-exec flag for all functions
Utility.FileIO.CloseOnExec is largely copied from
System.File.OsPath.Internal with the simple modification of
setting the flag.

Unfortunately, openTempFile does not set the flag when
opening the file, but afterwards, leaving it vulnerable to a race.
A lot of code, including posix and windows specific code,
would need to be copied from file-io in order to fix that.
Still, I consider this implementation a placeholder, it doesn't truely
fix all instances of the problem.

I hope that this will be addressed in file-io itself, see
https://github.com/haskell/file-io/issues/44

Utility.FileIO.CloseOnExec could form the basis of a
file-io-closeonexec library, depending on how things go with that
issue.

Sponsored-by: the NIH-funded NICEMAN (ReproNim TR&D3) project
2025-09-05 13:36:50 -04:00
Joey Hess
fe67756197
turn on OsPath build flag by default
It was already default in stack builds, now it is default in cabal
builds as well.

Add build warnings when git-annex is built without the OsPath build flag.

git-annex version: Report on whether it was built with the OsPath build flag.

Having the flag on by default was always the plan, and this is a good time to
make the change. A bit of added urgency comes from the close-on-exec leak
issue. Fixing that is going to need reimplentation of things like openFile.
Needing to reimplenment it twice is not very appealing, especially since the
FilePath version of it has an implementation that cannot be easily copied and
tweaked. If OsPath is on by default, I can start with only implementing
openFile for it, and fix the bug in that build. And perhaps avoid doing the
extra work that will later get thrown away when this transition finishes.

Note that at this point, Debian still needs to package file-io. Hopefully, they
will package it, rather than turning off the OsPath build flag.
2025-09-05 12:44:46 -04:00
Joey Hess
6662b49d35
convert all bytestring readFile/writeFile to use Utility.FileIO
This is groundwork for setting the close-on-exec flag when opening
files, which will be done in Utility.FileIO or a similar module using the same
function names. The bytestring library does not set that flag, even though it
could, and IMHO should.

Note that there are many calls to the Prelude's readFile/writeFile/appendFile
still in git-annex, and this does not address those.

Sponsored-by: the NIH-funded NICEMAN (ReproNim TR&D3) project
2025-09-05 12:13:28 -04:00
Joey Hess
2b3c2d6279
remove dead code 2025-09-05 11:57:08 -04:00
Joey Hess
d8f40288f1
update 2025-09-05 11:21:38 -04:00
Joey Hess
1230ac83e9
copyFile 2025-09-05 11:17:14 -04:00
Joey Hess
cb6f28282a
on libraries 2025-09-04 18:09:57 -04:00
Joey Hess
2b2e76e73f
format 2025-09-04 16:56:19 -04:00
Joey Hess
10fcd61966
fix format 2025-09-04 16:40:59 -04:00
Joey Hess
7b711ffd3b
Revert "try to fix format issue on website"
This reverts commit 764b47d7d4.
2025-09-04 16:40:50 -04:00
Joey Hess
764b47d7d4
try to fix format issue on website 2025-09-04 16:38:55 -04:00
Joey Hess
807ae0ad26
Merge branch 'master' of ssh://git-annex.branchable.com 2025-09-04 16:31:25 -04:00
Joey Hess
eff0c509f7
more 2025-09-04 16:31:09 -04:00
yarikoptic
d67f578049 added project 2025-09-04 20:13:07 +00:00
Joey Hess
033e4b086f
audit all openFd and dupping for close-on-exec
Made all uses of openFd and dup set the close-on-exec flag, with a few
exceptions when starting a git-annex daemon.

Made openFdWithMode be used everywhere, rather than openFd.
Adding a new parameter to it ensures I checked everything.
And will help to make sure this gets considered in the future when
opening fds.

In lockPidFile, the only thing that keeps the pid file locked, once
daemonize re-runs the command in a new session, is that the fd is
inherited.

In Utility.LogFile.redir, the new fd it dups to does not have the
close-on-exec flag set, because this is used to set up the stdout and
stderr fds, which need to be inherited by child processes.

Same in Assistant.startDaemon where the browser gets started with the
original stdout and stderr.

This does nothing about uses of openFile and similar!

Sponsored-By: mycroft
2025-09-04 16:01:41 -04:00
Joey Hess
6ba848d275
avoid overhead of fcntl when setting close-on-exec
unix-2.8.0 adds cloexec to OpenFileFlags, rather than needing to call
setFdOption after opening.

This also might avoid a race, if another thread started a process at
just the wrong time, before the flag got set, it could inherit the FD.

Unfortunately, the arm64-ancient build needs support for older versions
of unix than that, so had to ifdef. That build is still needed to
support using git-annex in termux on phones like mine, I have confirmed
today.

Sponsored-by: Luke T. Shumaker
2025-09-04 15:04:03 -04:00
Joey Hess
e1dcf98b78
analysis 2025-09-04 14:46:44 -04:00
Joey Hess
b2b055a634
analysis 2025-09-04 14:23:13 -04:00
Joey Hess
d44fd44c92
comment 2025-09-04 13:32:12 -04:00
Joey Hess
50e0106af5
comment 2025-09-04 13:13:54 -04:00
Joey Hess
ed397b21de
improve changelog
That bug fix also affects unlock, and it might also affect other
commands.
2025-09-04 13:06:12 -04:00
Joey Hess
67f00027d1
avoid relatedTemplate ever returning ""
add: Fix crash adding filenames that are exactly 21 bytes long and begin
with a utf-8 character.

Also longer filenames that start with "....." would cause the same crash.

I also audited for other calls to truncateFilePath that could truncate it
to "". Most use pathmax so are not a problem. Backend.Utilities.genKeyName
could possibly truncate it like that, but appends the md5 so would not be a
problem either.

Sponsored-by: Kevin Mueller
2025-09-04 13:02:46 -04:00
yarikoptic
4b037dda81 Added a comment 2025-09-04 02:06:22 +00:00
frederik@ffbea6a549cb3f460d110386c0f634c1ddc6a68a
5f14c2e50c 2025-09-03 14:56:19 +00:00
yarikoptic
5347627025 Added a comment: odd odd filesystem 2025-09-02 15:06:43 +00:00
guardcat
da4237182e 2025-09-02 10:42:04 +00:00
guardcat
25834e7c79 2025-09-02 10:21:27 +00:00
guardcat
8e032545d8 2025-09-02 10:02:44 +00:00
guardcat
4654097a97 2025-09-02 09:32:38 +00:00
guardcat
bb0690a254 2025-09-02 09:30:30 +00:00
guardcat
9a32b46103 2025-09-02 08:32:27 +00:00
Joey Hess
146d224c63
drop: --fast support when dropping from a remote
This is the same as --not --in $remote, but easier to type. And the
documentation of --fast helps also document that drop can do extra work
when used without --fast.

Sponsored-by: Nicholas Golder-Manning
2025-08-29 12:45:33 -04:00
Joey Hess
9ccb2dd1a3
add news item for git-annex 10.20250828 2025-08-29 11:43:46 -04:00
Joey Hess
18e1efc69d
releasing package git-annex version 10.20250828 2025-08-29 11:43:26 -04:00
Joey Hess
1d51a0b0ad
comments 2025-08-29 11:42:33 -04:00
Joey Hess
06a44093d6
Merge branch 'master' of ssh://git-annex.branchable.com 2025-08-29 11:13:35 -04:00
Joey Hess
3788c48b32
todo 2025-08-29 11:13:29 -04:00
yarikoptic
5771a4c83a initial report from ducky 2025-08-29 14:35:04 +00:00
Joey Hess
fe7ecf5051
prep release 2025-08-28 12:33:44 -04:00
Joey Hess
6b2af3db9e
remove dead code 2025-08-28 12:32:16 -04:00
Joey Hess
68c900f954
remove para about conflicts
That was only ever relevant for the v1 upgrade!
2025-08-27 12:37:07 -04:00
Joey Hess
83edb2cede
reword 2025-08-27 12:33:53 -04:00
Joey Hess
a82d531433
fix test suite breakage
640bc43c38 broke a test. Change that test
to not use encryption=shared. Which required some refactoring.

Sponsored-by: Joshua Antonishen
2025-08-27 12:26:50 -04:00
Joey Hess
63d134300f
Merge branch 'master' of ssh://git-annex.branchable.com 2025-08-27 09:47:19 -04:00