fix 'make PROFILE=1' build
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223
diff --git a/lib/object.c b/lib/object.c
index 7c7fdf3..e0a3cb4 100644
--- a/lib/object.c
+++ b/lib/object.c
@@ -56,24 +56,6 @@
#define MIN(_a,_b) ((_a) < (_b) ? (_a) : (_b))
#endif
-const struct got_error *
-got_object_id_str(char **outbuf, struct got_object_id *id)
-{
- static const size_t len = SHA1_DIGEST_STRING_LENGTH;
-
- *outbuf = malloc(len);
- if (*outbuf == NULL)
- return got_error_from_errno();
-
- if (got_sha1_digest_to_str(id->sha1, *outbuf, len) == NULL) {
- free(*outbuf);
- *outbuf = NULL;
- return got_error(GOT_ERR_BAD_OBJ_ID_STR);
- }
-
- return NULL;
-}
-
int
got_object_id_cmp(struct got_object_id *id1, struct got_object_id *id2)
{
diff --git a/lib/object_parse.c b/lib/object_parse.c
index bab79fa..2ff896a 100644
--- a/lib/object_parse.c
+++ b/lib/object_parse.c
@@ -62,6 +62,24 @@
#define GOT_COMMIT_TAG_AUTHOR "author "
#define GOT_COMMIT_TAG_COMMITTER "committer "
+const struct got_error *
+got_object_id_str(char **outbuf, struct got_object_id *id)
+{
+ static const size_t len = SHA1_DIGEST_STRING_LENGTH;
+
+ *outbuf = malloc(len);
+ if (*outbuf == NULL)
+ return got_error_from_errno();
+
+ if (got_sha1_digest_to_str(id->sha1, *outbuf, len) == NULL) {
+ free(*outbuf);
+ *outbuf = NULL;
+ return got_error(GOT_ERR_BAD_OBJ_ID_STR);
+ }
+
+ return NULL;
+}
+
void
got_object_close(struct got_object *obj)
{
diff --git a/libexec/got-read-blob/got-read-blob.c b/libexec/got-read-blob/got-read-blob.c
index 24a3577..0713310 100644
--- a/libexec/got-read-blob/got-read-blob.c
+++ b/libexec/got-read-blob/got-read-blob.c
@@ -47,12 +47,14 @@ main(int argc, char *argv[])
imsg_init(&ibuf, GOT_IMSG_FD_CHILD);
+#ifndef PROFILE
/* revoke access to most system calls */
if (pledge("stdio recvfd", NULL) == -1) {
err = got_error_from_errno();
got_privsep_send_error(&ibuf, err);
return 1;
}
+#endif
while (1) {
struct imsg imsg, imsg_outfd;
diff --git a/libexec/got-read-commit/got-read-commit.c b/libexec/got-read-commit/got-read-commit.c
index 7936f1a..f6b5435 100644
--- a/libexec/got-read-commit/got-read-commit.c
+++ b/libexec/got-read-commit/got-read-commit.c
@@ -76,12 +76,14 @@ main(int argc, char *argv[])
imsg_init(&ibuf, GOT_IMSG_FD_CHILD);
+#ifndef PROFILE
/* revoke access to most system calls */
if (pledge("stdio recvfd", NULL) == -1) {
err = got_error_from_errno();
got_privsep_send_error(&ibuf, err);
return 1;
}
+#endif
while (1) {
struct imsg imsg;
diff --git a/libexec/got-read-object/got-read-object.c b/libexec/got-read-object/got-read-object.c
index 8a78746..baca773 100644
--- a/libexec/got-read-object/got-read-object.c
+++ b/libexec/got-read-object/got-read-object.c
@@ -156,12 +156,14 @@ main(int argc, char *argv[])
imsg_init(&ibuf, GOT_IMSG_FD_CHILD);
+#ifndef PROFILE
/* revoke access to most system calls */
if (pledge("stdio recvfd", NULL) == -1) {
err = got_error_from_errno();
got_privsep_send_error(&ibuf, err);
return 1;
}
+#endif
while (1) {
err = got_privsep_recv_imsg(&imsg, &ibuf, 0);
diff --git a/libexec/got-read-pack/got-read-pack.c b/libexec/got-read-pack/got-read-pack.c
index 51e3ea5..2238e3a 100644
--- a/libexec/got-read-pack/got-read-pack.c
+++ b/libexec/got-read-pack/got-read-pack.c
@@ -411,12 +411,14 @@ main(int argc, char *argv[])
return 1;
}
+#ifndef PROFILE
/* revoke access to most system calls */
if (pledge("stdio recvfd", NULL) == -1) {
err = got_error_from_errno();
got_privsep_send_error(&ibuf, err);
return 1;
}
+#endif
err = receive_packidx(&packidx, &ibuf);
if (err) {
diff --git a/libexec/got-read-tree/got-read-tree.c b/libexec/got-read-tree/got-read-tree.c
index cb003bb..5abd564 100644
--- a/libexec/got-read-tree/got-read-tree.c
+++ b/libexec/got-read-tree/got-read-tree.c
@@ -75,12 +75,14 @@ main(int argc, char *argv[])
imsg_init(&ibuf, GOT_IMSG_FD_CHILD);
+#ifndef PROFILE
/* revoke access to most system calls */
if (pledge("stdio recvfd", NULL) == -1) {
err = got_error_from_errno();
got_privsep_send_error(&ibuf, err);
return 1;
}
+#endif
while (1) {
struct imsg imsg;
diff --git a/regress/delta/delta_test.c b/regress/delta/delta_test.c
index f8b0bfa..09019b9 100644
--- a/regress/delta/delta_test.c
+++ b/regress/delta/delta_test.c
@@ -47,7 +47,7 @@ struct delta_test {
};
static int
-delta_apply()
+delta_apply(void)
{
const struct got_error *err = NULL;
int i;
@@ -115,8 +115,10 @@ main(int argc, const char *argv[])
return 1;
}
+#ifndef PROFILE
if (pledge("stdio rpath wpath cpath", NULL) == -1)
err(1, "pledge");
+#endif
RUN_TEST(delta_apply(), "delta_apply");
diff --git a/regress/idset/idset_test.c b/regress/idset/idset_test.c
index ebadf49..7d0f1de 100644
--- a/regress/idset/idset_test.c
+++ b/regress/idset/idset_test.c
@@ -206,8 +206,10 @@ main(int argc, char *argv[])
int test_ok = 0, failure = 0;
int ch;
+#ifndef PROFILE
if (pledge("stdio", NULL) == -1)
err(1, "pledge");
+#endif
while ((ch = getopt(argc, argv, "v")) != -1) {
switch (ch) {
diff --git a/regress/repository/repository_test.c b/regress/repository/repository_test.c
index 9b48c7f..7d05f1a 100644
--- a/regress/repository/repository_test.c
+++ b/regress/repository/repository_test.c
@@ -458,8 +458,10 @@ main(int argc, char *argv[])
const char *repo_path;
int ch;
+#ifndef PROFILE
if (pledge("stdio rpath wpath cpath proc exec sendfd", NULL) == -1)
err(1, "pledge");
+#endif
while ((ch = getopt(argc, argv, "v")) != -1) {
switch (ch) {
diff --git a/regress/worktree/worktree_test.c b/regress/worktree/worktree_test.c
index c6ece3a..1b97298 100644
--- a/regress/worktree/worktree_test.c
+++ b/regress/worktree/worktree_test.c
@@ -390,9 +390,11 @@ main(int argc, char *argv[])
const char *repo_path;
int ch;
+#ifndef PROFILE
if (pledge("stdio rpath wpath cpath flock proc exec sendfd", NULL)
== -1)
err(1, "pledge");
+#endif
while ((ch = getopt(argc, argv, "v")) != -1) {
switch (ch) {