commit - 02dd6ee50e0e52c1581e43fb1910bc44604dcf7f
commit + 1cb49b67c167a14c547143ce621e7573f59c82a3
blob - 82cbd62438015fab107bd4aa25d20bd02e800127
blob + 768dd71c9d5971dd3cc7801fc4692bbe4f2b56d6
--- gotd/gotd.c
+++ gotd/gotd.c
fatal("socketpair");
memset(&ireq, 0, sizeof(ireq));
- ireq.client_id = client->id;
ireq.proc_id = repo_proc->type;
/* Pass repo child pipe to session child process. */
blob - d6d5b413a46c4062f8b7a4a635cd9ffea6d6c49f
blob + f79b125406b4bb07bdc361abda15856360b65719
--- gotd/gotd.h
+++ gotd/gotd.h
int client_is_reading; /* 1 if reading, 0 if writing */
};
-/* Structure for GOTD_IMSG_LIST_REFS_INTERNAL. */
-struct gotd_imsg_list_refs_internal {
- uint32_t client_id;
-};
-
/* Structure for GOTD_IMSG_REFLIST. */
struct gotd_imsg_reflist {
size_t nrefs;
/* Structure for GOTD_IMSG_WANT data. */
struct gotd_imsg_want {
uint8_t object_id[SHA1_DIGEST_LENGTH];
- uint32_t client_id;
} __attribute__((__packed__));
/* Structure for GOTD_IMSG_HAVE data. */
struct gotd_imsg_have {
uint8_t object_id[SHA1_DIGEST_LENGTH];
- uint32_t client_id;
} __attribute__((__packed__));
/* Structure for GOTD_IMSG_ACK data. */
struct gotd_imsg_ack {
uint8_t object_id[SHA1_DIGEST_LENGTH];
- uint32_t client_id;
} __attribute__((__packed__));
/* Structure for GOTD_IMSG_NAK data. */
struct gotd_imsg_nak {
uint8_t object_id[SHA1_DIGEST_LENGTH];
- uint32_t client_id;
} __attribute__((__packed__));
/* Structure for GOTD_IMSG_PACKFILE_STATUS data. */
uint8_t new_id[SHA1_DIGEST_LENGTH];
int ref_is_new;
int delete_ref;
- uint32_t client_id;
size_t name_len;
/* Followed by name_len data bytes. */
/* Structure for GOTD_IMSG_REF_UPDATES_START data. */
struct gotd_imsg_ref_updates_start {
int nref_updates;
- uint32_t client_id;
/* Followed by nref_updates GOT_IMSG_REF_UPDATE_OK/NG messages. */
};
uint8_t old_id[SHA1_DIGEST_LENGTH];
uint8_t new_id[SHA1_DIGEST_LENGTH];
int ref_is_new;
- uint32_t client_id;
size_t name_len;
/* Followed by name_len data bytes. */
struct gotd_imsg_ref_update_ng {
uint8_t old_id[SHA1_DIGEST_LENGTH];
uint8_t new_id[SHA1_DIGEST_LENGTH];
- uint32_t client_id;
size_t name_len;
size_t reason_len;
/* Structure for GOTD_IMSG_SEND_PACKFILE data. */
struct gotd_imsg_send_packfile {
- uint32_t client_id;
int report_progress;
/* delta cache file is sent as a file descriptor */
/* Structure for GOTD_IMSG_RECV_PACKFILE data. */
struct gotd_imsg_recv_packfile {
- uint32_t client_id;
int report_status;
/* pack destination temp file is sent as a file descriptor */
};
-/* Structure for GOTD_IMSG_PACKFILE_PIPE data. */
-struct gotd_imsg_packfile_pipe {
- uint32_t client_id;
-};
-
-/* Structure for GOTD_IMSG_PACKIDX_FILE data. */
-struct gotd_imsg_packidx_file {
- uint32_t client_id;
-};
-
-
/*
* Structure for GOTD_IMSG_PACKFILE_PROGRESS and
* GOTD_IMSG_PACKFILE_READY data.
*/
struct gotd_imsg_packfile_progress {
- uint32_t client_id;
int ncolored;
int nfound;
int ntrees;
/* Structure for GOTD_IMSG_PACKFILE_INSTALL. */
struct gotd_imsg_packfile_install {
- uint32_t client_id;
uint8_t pack_sha1[SHA1_DIGEST_LENGTH];
};
-/* Structure for GOTD_IMSG_PACKFILE_DONE data. */
-struct gotd_imsg_packfile_done {
- uint32_t client_id;
-};
-
/* Structure for GOTD_IMSG_DISCONNECT data. */
struct gotd_imsg_disconnect {
uint32_t client_id;
/* Structure for GOTD_IMSG_CONNECT_REPO_CHILD. */
struct gotd_imsg_connect_repo_child {
- uint32_t client_id;
enum gotd_procid proc_id;
/* repo child imsg pipe is passed via imsg fd */
};
/* IMSG_NOTIFY session <-> repo_write */
struct gotd_imsg_notification_content {
- uint32_t client_id;
enum gotd_notification_action action;
uint8_t old_id[SHA1_DIGEST_LENGTH];
uint8_t new_id[SHA1_DIGEST_LENGTH];
blob - af1549ed25e2702af538cb0dd91835c1faaeca83
blob + f7e53300d55277bab10c4e324bca646100104c8b
--- gotd/repo_read.c
+++ gotd/repo_read.c
int *temp_fds;
int session_fd;
struct gotd_imsgev session_iev;
+ int refs_listed;
} repo_read;
static struct repo_read_client {
struct repo_read_client *client = &repo_read_client;
struct got_reflist_head refs;
struct got_reflist_entry *re;
- struct gotd_imsg_list_refs_internal ireq;
size_t datalen;
struct gotd_imsg_reflist irefs;
struct imsgbuf ibuf;
return got_error(GOT_ERR_PRIVSEP_NO_FD);
datalen = imsg->hdr.len - IMSG_HEADER_SIZE;
- if (datalen != sizeof(ireq))
+ if (datalen != 0)
return got_error(GOT_ERR_PRIVSEP_LEN);
- memcpy(&ireq, imsg->data, sizeof(ireq));
- if (ireq.client_id == 0)
- return got_error(GOT_ERR_CLIENT_ID);
- if (client->id != 0) {
+ if (repo_read.refs_listed) {
return got_error_msg(GOT_ERR_CLIENT_ID,
"duplicate list-refs request");
}
- client->id = ireq.client_id;
+ repo_read.refs_listed = 1;
+
client->fd = client_fd;
imsg_init(&ibuf, client_fd);
receive_pack_pipe(struct imsg *imsg, struct gotd_imsgev *iev)
{
struct repo_read_client *client = &repo_read_client;
- struct gotd_imsg_packfile_pipe ireq;
size_t datalen;
log_debug("receiving pack pipe descriptor");
datalen = imsg->hdr.len - IMSG_HEADER_SIZE;
- if (datalen != sizeof(ireq))
+ if (datalen != 0)
return got_error(GOT_ERR_PRIVSEP_LEN);
- memcpy(&ireq, imsg->data, sizeof(ireq));
if (client->pack_pipe != -1)
return got_error(GOT_ERR_PRIVSEP_MSG);
{
const struct got_error *err = NULL;
struct repo_read_client *client = &repo_read_client;
- struct gotd_imsg_packfile_done idone;
uint8_t packsha1[SHA1_DIGEST_LENGTH];
char hex[SHA1_DIGEST_STRING_LENGTH];
FILE *delta_cache = NULL;
got_sha1_digest_to_str(packsha1, hex, sizeof(hex)))
log_debug("sent pack-%s.pack", hex);
- memset(&idone, 0, sizeof(idone));
- idone.client_id = client->id;
- if (gotd_imsg_compose_event(iev, GOTD_IMSG_PACKFILE_DONE,
- PROC_REPO_READ, -1, &idone, sizeof(idone)) == -1)
+ if (gotd_imsg_compose_event(iev, GOTD_IMSG_PACKFILE_DONE,
+ PROC_REPO_READ, -1, NULL, 0) == -1)
err = got_error_from_errno("imsg compose PACKFILE_DONE");
done:
if (client->delta_cache_fd != -1 &&
break;
if (imsg.hdr.type != GOTD_IMSG_LIST_REFS_INTERNAL &&
- client->id == 0) {
+ !repo_read.refs_listed) {
err = got_error(GOT_ERR_PRIVSEP_MSG);
break;
}
blob - 2ff8767a91c4ae5e858bc0906a5889a4179c3f35
blob + 3bd3f24dbb7a637581477fdf36227426f8b6a00b
--- gotd/repo_write.c
+++ gotd/repo_write.c
int fd1;
int fd2;
} diff;
+ int refs_listed;
} repo_write;
struct gotd_ref_update {
struct repo_write_client *client = &repo_write_client;
struct got_reflist_head refs;
struct got_reflist_entry *re;
- struct gotd_imsg_list_refs_internal ireq;
size_t datalen;
struct gotd_imsg_reflist irefs;
struct imsgbuf ibuf;
return got_error(GOT_ERR_PRIVSEP_NO_FD);
datalen = imsg->hdr.len - IMSG_HEADER_SIZE;
- if (datalen != sizeof(ireq))
+ if (datalen != 0)
return got_error(GOT_ERR_PRIVSEP_LEN);
- memcpy(&ireq, imsg->data, sizeof(ireq));
- if (ireq.client_id == 0)
- return got_error(GOT_ERR_CLIENT_ID);
- if (client->id != 0) {
+ if (repo_write.refs_listed) {
return got_error_msg(GOT_ERR_CLIENT_ID,
"duplicate list-refs request");
}
- client->id = ireq.client_id;
+ repo_write.refs_listed = 1;
+
client->fd = client_fd;
client->nref_updates = 0;
client->nref_del = 0;
int ret;
memset(&inst, 0, sizeof(inst));
- inst.client_id = client->id;
memcpy(inst.pack_sha1, client->pack_sha1, SHA1_DIGEST_LENGTH);
ret = gotd_imsg_compose_event(iev, GOTD_IMSG_PACKFILE_INSTALL,
static const struct got_error *
send_ref_updates_start(int nref_updates, struct gotd_imsgev *iev)
{
- struct repo_write_client *client = &repo_write_client;
struct gotd_imsg_ref_updates_start istart;
int ret;
memset(&istart, 0, sizeof(istart));
istart.nref_updates = nref_updates;
- istart.client_id = client->id;
ret = gotd_imsg_compose_event(iev, GOTD_IMSG_REF_UPDATES_START,
PROC_REPO_WRITE, -1, &istart, sizeof(istart));
static const struct got_error *
send_ref_update(struct gotd_ref_update *ref_update, struct gotd_imsgev *iev)
{
- struct repo_write_client *client = &repo_write_client;
struct gotd_imsg_ref_update iref;
const char *refname = got_ref_get_name(ref_update->ref);
struct ibuf *wbuf;
memcpy(iref.new_id, ref_update->new_id.sha1, SHA1_DIGEST_LENGTH);
iref.ref_is_new = ref_update->ref_is_new;
iref.delete_ref = ref_update->delete_ref;
- iref.client_id = client->id;
iref.name_len = strlen(refname);
len = sizeof(iref) + iref.name_len;
receive_pack_pipe(struct imsg *imsg, struct gotd_imsgev *iev)
{
struct repo_write_client *client = &repo_write_client;
- struct gotd_imsg_packfile_pipe ireq;
size_t datalen;
log_debug("receiving pack pipe descriptor");
datalen = imsg->hdr.len - IMSG_HEADER_SIZE;
- if (datalen != sizeof(ireq))
+ if (datalen != 0)
return got_error(GOT_ERR_PRIVSEP_LEN);
- memcpy(&ireq, imsg->data, sizeof(ireq));
if (client->pack_pipe != -1)
return got_error(GOT_ERR_PRIVSEP_MSG);
receive_pack_idx(struct imsg *imsg, struct gotd_imsgev *iev)
{
struct repo_write_client *client = &repo_write_client;
- struct gotd_imsg_packidx_file ireq;
size_t datalen;
log_debug("receiving pack index output file");
datalen = imsg->hdr.len - IMSG_HEADER_SIZE;
- if (datalen != sizeof(ireq))
+ if (datalen != 0)
return got_error(GOT_ERR_PRIVSEP_LEN);
- memcpy(&ireq, imsg->data, sizeof(ireq));
if (client->packidx_fd != -1)
return got_error(GOT_ERR_PRIVSEP_MSG);
break;
if (imsg.hdr.type != GOTD_IMSG_LIST_REFS_INTERNAL &&
- client->id == 0) {
+ !repo_write.refs_listed) {
err = got_error(GOT_ERR_PRIVSEP_MSG);
break;
}
blob - f452173f6d3d7b1aed664ef373549fedd7933036
blob + 2d25688e104f748188eb06b72e9caa52e4918aa0
--- gotd/session.c
+++ gotd/session.c
}
static const struct got_error *
-recv_packfile_done(uint32_t *client_id, struct imsg *imsg)
+recv_packfile_done(struct imsg *imsg)
{
- struct gotd_imsg_packfile_done idone;
size_t datalen;
log_debug("packfile-done received");
datalen = imsg->hdr.len - IMSG_HEADER_SIZE;
- if (datalen != sizeof(idone))
+ if (datalen != 0)
return got_error(GOT_ERR_PRIVSEP_LEN);
- memcpy(&idone, imsg->data, sizeof(idone));
- *client_id = idone.client_id;
return NULL;
}
static const struct got_error *
-recv_packfile_install(uint32_t *client_id, struct imsg *imsg)
+recv_packfile_install(struct imsg *imsg)
{
struct gotd_imsg_packfile_install inst;
size_t datalen;
return got_error(GOT_ERR_PRIVSEP_LEN);
memcpy(&inst, imsg->data, sizeof(inst));
- *client_id = inst.client_id;
return NULL;
}
static const struct got_error *
-recv_ref_updates_start(uint32_t *client_id, struct imsg *imsg)
+recv_ref_updates_start(struct imsg *imsg)
{
struct gotd_imsg_ref_updates_start istart;
size_t datalen;
return got_error(GOT_ERR_PRIVSEP_LEN);
memcpy(&istart, imsg->data, sizeof(istart));
- *client_id = istart.client_id;
return NULL;
}
static const struct got_error *
-recv_ref_update(uint32_t *client_id, struct imsg *imsg)
+recv_ref_update(struct imsg *imsg)
{
struct gotd_imsg_ref_update iref;
size_t datalen;
return got_error(GOT_ERR_PRIVSEP_LEN);
memcpy(&iref, imsg->data, sizeof(iref));
- *client_id = iref.client_id;
return NULL;
}
size_t len;
memset(&iok, 0, sizeof(iok));
- iok.client_id = client->id;
memcpy(iok.old_id, iref->old_id, SHA1_DIGEST_LENGTH);
memcpy(iok.new_id, iref->new_id, SHA1_DIGEST_LENGTH);
iok.name_len = strlen(refname);
size_t len;
memset(&ing, 0, sizeof(ing));
- ing.client_id = client->id;
memcpy(ing.old_id, iref->old_id, SHA1_DIGEST_LENGTH);
memcpy(ing.new_id, iref->new_id, SHA1_DIGEST_LENGTH);
ing.name_len = strlen(refname);
request_notification(struct gotd_session_notif *notif)
{
const struct got_error *err = NULL;
- struct gotd_session_client *client = &gotd_session_client;
struct gotd_imsgev *iev = &gotd_session.repo_child_iev;
struct gotd_imsg_notification_content icontent;
struct ibuf *wbuf;
return got_error_from_errno("got_opentemp");
memset(&icontent, 0, sizeof(icontent));
- icontent.client_id = client->id;
icontent.action = notif->action;
memcpy(&icontent.old_id, ¬if->old_id, sizeof(notif->old_id));
}
static const struct got_error *
-recv_notification_content(uint32_t *client_id, struct imsg *imsg)
+recv_notification_content(struct imsg *imsg)
{
struct gotd_imsg_notification_content inotif;
size_t datalen;
return got_error(GOT_ERR_PRIVSEP_LEN);
memcpy(&inotif, imsg->data, sizeof(inotif));
- *client_id = inotif.client_id;
return NULL;
}
break;
case GOTD_IMSG_PACKFILE_DONE:
do_disconnect = 1;
- err = recv_packfile_done(&client_id, &imsg);
+ err = recv_packfile_done(&imsg);
break;
case GOTD_IMSG_PACKFILE_INSTALL:
- err = recv_packfile_install(&client_id, &imsg);
+ err = recv_packfile_install(&imsg);
if (err == NULL)
do_packfile_install = 1;
break;
case GOTD_IMSG_REF_UPDATES_START:
- err = recv_ref_updates_start(&client_id, &imsg);
+ err = recv_ref_updates_start(&imsg);
if (err == NULL)
do_ref_updates = 1;
break;
case GOTD_IMSG_REF_UPDATE:
- err = recv_ref_update(&client_id, &imsg);
+ err = recv_ref_update(&imsg);
if (err == NULL)
do_ref_update = 1;
break;
case GOTD_IMSG_NOTIFY:
- err = recv_notification_content(&client_id, &imsg);
+ err = recv_notification_content(&imsg);
if (err == NULL)
do_notify = 1;
break;
memset(&iwant, 0, sizeof(iwant));
memcpy(iwant.object_id, ireq.object_id, SHA1_DIGEST_LENGTH);
- iwant.client_id = client->id;
if (gotd_imsg_compose_event(&gotd_session.repo_child_iev,
GOTD_IMSG_WANT, gotd_session.proc_id, -1,
return got_error_from_errno("malloc");
memcpy(iref, imsg->data, datalen);
- iref->client_id = client->id;
if (gotd_imsg_compose_event(&gotd_session.repo_child_iev,
GOTD_IMSG_REF_UPDATE, gotd_session.proc_id, -1,
iref, datalen) == -1)
memset(&ihave, 0, sizeof(ihave));
memcpy(ihave.object_id, ireq.object_id, SHA1_DIGEST_LENGTH);
- ihave.client_id = client->id;
if (gotd_imsg_compose_event(&gotd_session.repo_child_iev,
GOTD_IMSG_HAVE, gotd_session.proc_id, -1,
{
const struct got_error *err = NULL;
struct gotd_imsg_recv_packfile ipack;
- struct gotd_imsg_packfile_pipe ipipe;
- struct gotd_imsg_packidx_file ifile;
char *basepath = NULL, *pack_path = NULL, *idx_path = NULL;
int packfd = -1, idxfd = -1;
int pipe[2] = { -1, -1 };
if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, pipe) == -1)
return got_error_from_errno("socketpair");
-
- memset(&ipipe, 0, sizeof(ipipe));
- ipipe.client_id = client->id;
/* Send pack pipe end 0 to repo child process. */
if (gotd_imsg_compose_event(&gotd_session.repo_child_iev,
GOTD_IMSG_PACKFILE_PIPE, gotd_session.proc_id, pipe[0],
- &ipipe, sizeof(ipipe)) == -1) {
+ NULL, 0) == -1) {
err = got_error_from_errno("imsg compose PACKFILE_PIPE");
pipe[0] = -1;
goto done;
goto done;
}
- memset(&ifile, 0, sizeof(ifile));
- ifile.client_id = client->id;
if (gotd_imsg_compose_event(&gotd_session.repo_child_iev,
GOTD_IMSG_PACKIDX_FILE, gotd_session.proc_id,
- idxfd, &ifile, sizeof(ifile)) == -1) {
+ idxfd, NULL, 0) == -1) {
err = got_error_from_errno("imsg compose PACKIDX_FILE");
idxfd = -1;
goto done;
idxfd = -1;
memset(&ipack, 0, sizeof(ipack));
- ipack.client_id = client->id;
if (client_has_capability(client, GOT_CAPA_REPORT_STATUS))
ipack.report_status = 1;
{
const struct got_error *err = NULL;
struct gotd_imsg_send_packfile ipack;
- struct gotd_imsg_packfile_pipe ipipe;
int pipe[2];
if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, pipe) == -1)
return got_error_from_errno("socketpair");
memset(&ipack, 0, sizeof(ipack));
- memset(&ipipe, 0, sizeof(ipipe));
- ipack.client_id = client->id;
if (client_has_capability(client, GOT_CAPA_SIDE_BAND_64K))
ipack.report_progress = 1;
return err;
}
- ipipe.client_id = client->id;
-
/* Send pack pipe end 0 to repo child process. */
if (gotd_imsg_compose_event(&gotd_session.repo_child_iev,
- GOTD_IMSG_PACKFILE_PIPE, PROC_GOTD,
- pipe[0], &ipipe, sizeof(ipipe)) == -1) {
+ GOTD_IMSG_PACKFILE_PIPE, PROC_GOTD, pipe[0], NULL, 0) == -1) {
err = got_error_from_errno("imsg compose PACKFILE_PIPE");
close(pipe[1]);
return err;
static const struct got_error *err;
struct gotd_session_client *client = &gotd_session_client;
struct gotd_imsgev *iev = &gotd_session.repo_child_iev;
- struct gotd_imsg_list_refs_internal ilref;
int fd;
if (gotd_session.state != GOTD_STATE_EXPECT_LIST_REFS)
return got_error(GOT_ERR_PRIVSEP_MSG);
- memset(&ilref, 0, sizeof(ilref));
- ilref.client_id = client->id;
-
fd = dup(client->fd);
if (fd == -1)
return got_error_from_errno("dup");
if (gotd_imsg_compose_event(iev, GOTD_IMSG_LIST_REFS_INTERNAL,
- gotd_session.proc_id, fd, &ilref, sizeof(ilref)) == -1) {
+ gotd_session.proc_id, fd, NULL, 0) == -1) {
err = got_error_from_errno("imsg compose LIST_REFS_INTERNAL");
close(fd);
return err;
memcpy(&ichild, imsg->data, sizeof(ichild));
- client->id = ichild.client_id;
if (ichild.proc_id == PROC_REPO_WRITE)
client->is_writing = 1;
else if (ichild.proc_id == PROC_REPO_READ)