2 * Copyright (c) 2018 Stefan Sperling <stsp@openbsd.org>
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 * All code runs under the same UID but sensitive code paths are
19 * run in a separate process with tighter pledge(2) promises.
20 * Data is communicated between processes via imsg_read(3)/imsg_compose(3).
21 * This behaviour is transparent to users of the library.
23 * File descriptor passing is used in cases where sizes exceed MAX_IMSGSIZE.
25 * We currently do not exec(2) after a fork(2).
26 * To achieve fork+exec, relevant parts of our library functionality could
27 * be made accessible via separate executables in a libexec directory.
32 * Messages concerned with read access to objects in a repository.
33 * Object and pack files are opened by the main process, where
34 * data may be read as a byte string but without any interpretation.
35 * Decompression and parsing of object and pack files occurs in a
36 * separate process which runs under pledge("stdio").
37 * This sandboxes our own repository parsing code, as well as zlib.
39 GOT_IMSG_READ_LOOSE_OBJECT_HEADER_REQUEST,
40 GOT_IMSG_READ_LOOSE_OBJECT_HEADER_REPLY,
42 GOT_IMSG_READ_LOOSE_BLOB_OBJECT_REQUEST,
43 GOT_IMSG_READ_LOOSE_BLOB_OBJECT_REPLY,
44 GOT_IMSG_READ_LOOSE_TREE_OBJECT_REQUEST,
45 GOT_IMSG_READ_LOOSE_TREE_OBJECT_REPLY,
46 GOT_IMSG_READ_LOOSE_COMMIT_OBJECT_REQUEST,
47 GOT_IMSG_READ_LOOSE_COMMIT_OBJECT_REPLY,
48 GOT_IMSG_READ_PACKED_BLOB_OBJECT_REQUEST,
49 GOT_IMSG_READ_PACKED_BLOB_OBJECT_REPLY,
50 GOT_IMSG_READ_PACKED_TREE_OBJECT_REQUEST,
51 GOT_IMSG_READ_PACKED_TREE_OBJECT_REPLY,
52 GOT_IMSG_READ_PACKED_COMMIT_OBJECT_REQUEST,
53 GOT_IMSG_READ_PACKED_COMMIT_OBJECT_REPLY
56 /* Structure for GOT_IMSG_READ_LOOSE_OBJECT_HEADER_REQUEST data. */
57 struct got_imsg_read_loose_object_header_request {
59 * Empty since the following is implied: If imsg fd == -1 then
60 * read raw object data from imsg buffer, else read from fd.
64 /* Structure for GOT_IMSG_READ_LOOSE_OBJECT_HEADER_REPLY data. */
65 struct got_imsg_read_loose_object_header_reply {
66 /* These fields are the same as in struct got_object. */
71 struct got_object_id id;
73 int ndeltas; /* this many GOT_IMSG_DELTA messages follow */
76 /* Structure for GOT_IMSG_DELTA data. */
77 struct got_imsg_delta {
78 /* These fields are the same as in struct got_delta. */
87 * Followed by raw delta data: If imsg fd == -1 then read
88 * delta data from imsg buffer, else read from fd.
92 /* TODO: Implement the above, and then add more message data types here. */