Commit Briefs
remove unneded wbuf->fd = -1
There's no need to set the fd to -1 on ibufs created with imsg_create(3), and it was probably never needed.
convert to use imsg_get_fd()
While here also fix a fd leak in got-read-pack. We were dup'ing imsg.fd without closing imsg.fd later; instead just use imsg_get_fd() to extract the file descriptor. Tested by falsifian and Kyle Ackerman, thanks! 'go ahead' stsp@
portable: gotd/gitwrapper: update for libs
Bring gotd and gitwrapper closer to how libraries are detected.
portable: gotd: listen
Include listen.c; make it portable.
portable: enable compiling gotd
This enables gotd -- for now, this is opt-in at compile-time, via: ./configure --enable-gotd
portable: configure: split out dependencies
Rather than assume all dependencies are required for all programs, split them out. This will make packaging easier, as well as splitting the code to use subprojects. Note that due to the use of config.h semantics, in most cases the got_compat.h header file is now at the top of the .c file it is included in, so that it can handle the system header inclusion properly.
gotd: Fix more double process names
Patch by Josiah Frentsos, thanks!
add some helper functions to compute hashes
This adds a set of functions to abstract over SHA1Init, SHA1Update, SHA1Final, their respective SHA256 variants and how to compare digests. Replace all the SHA1*() usage with the new APIs. It's a preparatory step for sha256 handling. ok stsp@
portable: rework SHA detection
Simply the SHA detection by not predicating on libcrypto, but instead checking individual header files.
portable: remove sha1.h; found portably
Remove sha1.h as this is found portably across systems.
rename lib/sha1.c to lib/hash.c
It will soon grow functions to deal with sha256 too. stsp@ agrees.
include sha2.h too where sha1.h is included
In preparation for wide sha256 support; stsp@ agrees. Change done mechanically with find . -iname \*.[cy] -exec sam {} + X ,x/<sha1\.h>/i/\n#include <sha2.h>
do not expect to see a DISCONNECT message in repo processes
The parent no longer sends this message. Perform related cleanup in the shutdown path instead. ok op@
gotd: implement the delete-refs capability
Allow clients to run "got send -d" against gotd. Clients will send a zero-id as new id for a reference and, in the special but more common case of just deleting and not updating, no pack file will be sent. ok and tweaks by stsp@
gotd: fix "bad packfile with zero objects" error while creating branches
Clients will send an empty pack file if they are only creating new references and have no objects to upload. Make gotd handle this and add a regression test which triggers the bug. Problem found by op@. The new regression test caught an unrelated issue where the client connection was left lingering after references had been updated, which made 'got send' followed by 'got clone -l' fail with the connection limit configured for the test suite (just one connection is allowed at a time). Fix this as well. ok op@
add a gotd session process, split off from the parent process
The new session process is able to manipulate files in the repository and keeps track of the read/write client session state. The parent process now restricts its view of the filesystem to the absolute path stored in argv[0], and combines this with unveil "x" on this path. As a result the parent process can only re-exec itself. small tweaks + ok op@
convert gotd repo_read.c and repo_write.c to single-client
Because these processes are now started on demand per client connection there is no need to keep track of multiple clients anymore. Also, these processes can now exit when a disconnect event is received. ok op, jamsek