commit ee0b2e502f3be1d01835e96bdcd38afed67429f7 from: Stefan Sperling date: Tue Jan 10 14:22:25 2023 UTC remove support for showing client capabilities in 'gotctl info' The gotd parent process has lost access to client capabilities. Take the easy way out and remove related code. If needed, client capabilities can still be found in the debug log with 'gotd -v'. ok op, jamsek commit - 2e6043e87514d1a49e1c8a037d7c4e20869b07ad commit + ee0b2e502f3be1d01835e96bdcd38afed67429f7 blob - 447c95850f26e58bc93149f6531707c99bf1691b blob + dbb09cd4673bf340a19e12a3607758538bfefff2 --- gotctl/gotctl.c +++ gotctl/gotctl.c @@ -160,54 +160,6 @@ show_client_info(struct imsg *imsg) } static const struct got_error * -show_capability(struct imsg *imsg) -{ - struct gotd_imsg_capability icapa; - size_t datalen; - char *key, *value = NULL; - - memset(&icapa, 0, sizeof(icapa)); - - datalen = imsg->hdr.len - IMSG_HEADER_SIZE; - if (datalen < sizeof(icapa)) - return got_error(GOT_ERR_PRIVSEP_LEN); - memcpy(&icapa, imsg->data, sizeof(icapa)); - - if (datalen != sizeof(icapa) + icapa.key_len + icapa.value_len) - return got_error(GOT_ERR_PRIVSEP_LEN); - - key = malloc(icapa.key_len + 1); - if (key == NULL) - return got_error_from_errno("malloc"); - if (icapa.value_len > 0) { - value = malloc(icapa.value_len + 1); - if (value == NULL) { - free(key); - return got_error_from_errno("malloc"); - } - } - - memcpy(key, imsg->data + sizeof(icapa), icapa.key_len); - key[icapa.key_len] = '\0'; - if (value) { - memcpy(value, imsg->data + sizeof(icapa) + icapa.key_len, - icapa.value_len); - value[icapa.value_len] = '\0'; - } - - if (strcmp(key, GOT_CAPA_AGENT) == 0) - printf(" client user agent: %s\n", value); - else if (value) - printf(" client supports %s=%s\n", key, value); - else - printf(" client supports %s\n", key); - - free(key); - free(value); - return NULL; -} - -static const struct got_error * cmd_info(int argc, char *argv[], int gotd_sock) { const struct got_error *err; @@ -241,9 +193,6 @@ cmd_info(int argc, char *argv[], int gotd_sock) case GOTD_IMSG_INFO_CLIENT: err = show_client_info(&imsg); break; - case GOTD_IMSG_CAPABILITY: - err = show_capability(&imsg); - break; default: err = got_error(GOT_ERR_PRIVSEP_MSG); break; blob - 5859cd2493349eb8310f838afc2f0b11cdbc6f14 blob + 56c227fb60619b289a5e2680330bf0651400bac8 --- gotd/gotd.c +++ gotd/gotd.c @@ -70,9 +70,6 @@ struct gotd_client { STAILQ_ENTRY(gotd_client) entry; enum gotd_client_state state; - struct gotd_client_capability *capabilities; - size_t ncapa_alloc; - size_t ncapabilities; uint32_t id; int fd; struct gotd_imsgev iev; @@ -381,7 +378,6 @@ disconnect(struct gotd_client *client) close(client->fd); else if (client->iev.ibuf.fd != -1) close(client->iev.ibuf.fd); - free(client->capabilities); free(client); client_cnt--; } @@ -420,48 +416,8 @@ send_repo_info(struct gotd_imsgev *iev, struct gotd_re err = got_error_from_errno("imsg compose INFO_REPO"); if (err) return err; - } - - return NULL; -} - -static const struct got_error * -send_capability(struct gotd_client_capability *capa, struct gotd_imsgev* iev) -{ - const struct got_error *err = NULL; - struct gotd_imsg_capability icapa; - size_t len; - struct ibuf *wbuf; - - memset(&icapa, 0, sizeof(icapa)); - - icapa.key_len = strlen(capa->key); - len = sizeof(icapa) + icapa.key_len; - if (capa->value) { - icapa.value_len = strlen(capa->value); - len += icapa.value_len; - } - - wbuf = imsg_create(&iev->ibuf, GOTD_IMSG_CAPABILITY, 0, 0, len); - if (wbuf == NULL) { - err = got_error_from_errno("imsg_create CAPABILITY"); - return err; } - - if (imsg_add(wbuf, &icapa, sizeof(icapa)) == -1) - return got_error_from_errno("imsg_add CAPABILITY"); - if (imsg_add(wbuf, capa->key, icapa.key_len) == -1) - return got_error_from_errno("imsg_add CAPABILITY"); - if (capa->value) { - if (imsg_add(wbuf, capa->value, icapa.value_len) == -1) - return got_error_from_errno("imsg_add CAPABILITY"); - } - - wbuf->fd = -1; - imsg_close(&iev->ibuf, wbuf); - gotd_imsg_event_add(iev); - return NULL; } @@ -471,7 +427,6 @@ send_client_info(struct gotd_imsgev *iev, struct gotd_ const struct got_error *err = NULL; struct gotd_imsg_info_client iclient; struct gotd_child_proc *proc; - size_t i; memset(&iclient, 0, sizeof(iclient)); iclient.euid = client->euid; @@ -493,19 +448,10 @@ send_client_info(struct gotd_imsgev *iev, struct gotd_ iclient.state = client->state; if (client->session) iclient.session_child_pid = client->session->pid; - iclient.ncapabilities = client->ncapabilities; if (gotd_imsg_compose_event(iev, GOTD_IMSG_INFO_CLIENT, PROC_GOTD, -1, &iclient, sizeof(iclient)) == -1) { err = got_error_from_errno("imsg compose INFO_CLIENT"); - if (err) - return err; - } - - for (i = 0; i < client->ncapabilities; i++) { - struct gotd_client_capability *capa; - capa = &client->capabilities[i]; - err = send_capability(capa, iev); if (err) return err; } blob - 3f6ddfc81056dd0933a199322c90fe6b5e8296b0 blob + 3c7194f856798d1eab7423b732b4dad29644e13e --- gotd/gotd.h +++ gotd/gotd.h @@ -232,9 +232,6 @@ struct gotd_imsg_info_client { enum gotd_client_state state; pid_t session_child_pid; pid_t repo_child_pid; - size_t ncapabilities; - - /* Followed by ncapabilities GOTD_IMSG_CAPABILITY. */ }; /* Structure for GOTD_IMSG_LIST_REFS. */