commit - 8652e5612d19bb8c006bbb4efcbb3554c67888b1
commit + 7b1db75e88420c57858703ddfec2851107c6577d
blob - dbb09cd4673bf340a19e12a3607758538bfefff2
blob + c325f57c4de7b7c6a9487f451080651916364add
--- gotctl/gotctl.c
+++ gotctl/gotctl.c
printf("repository \"%s\", path %s\n", info.repo_name, info.repo_path);
return NULL;
-}
-
-static const char *
-get_state_name(enum gotd_client_state state)
-{
- static char unknown_state[64];
-
- switch (state) {
- case GOTD_STATE_EXPECT_LIST_REFS:
- return "list-refs";
- case GOTD_STATE_EXPECT_CAPABILITIES:
- return "expect-capabilities";
- case GOTD_STATE_EXPECT_WANT:
- return "expect-want";
- case GOTD_STATE_EXPECT_REF_UPDATE:
- return "expect-ref-update";
- case GOTD_STATE_EXPECT_MORE_REF_UPDATES:
- return "expect-more-ref-updates";
- case GOTD_STATE_EXPECT_HAVE:
- return "expect-have";
- case GOTD_STATE_EXPECT_PACKFILE:
- return "expect-packfile";
- case GOTD_STATE_EXPECT_DONE:
- return "expect-done";
- case GOTD_STATE_DONE:
- return "done";
- }
-
- snprintf(unknown_state, sizeof(unknown_state),
- "unknown state %d", state);
- return unknown_state;
}
static const struct got_error *
return got_error(GOT_ERR_PRIVSEP_LEN);
memcpy(&info, imsg->data, sizeof(info));
- printf("client UID %d, GID %d, protocol state '%s', ",
- info.euid, info.egid, get_state_name(info.state));
+ printf("client UID %d, GID %d, ", info.euid, info.egid);
if (info.session_child_pid)
printf("session PID %ld, ", (long)info.session_child_pid);
if (info.repo_child_pid)
blob - 56c227fb60619b289a5e2680330bf0651400bac8
blob + 390d403cdcb5e59c2799c5ebfea7918257bbfa92
--- gotd/gotd.c
+++ gotd/gotd.c
#define nitems(_a) (sizeof((_a)) / sizeof((_a)[0]))
#endif
+enum gotd_client_state {
+ GOTD_CLIENT_STATE_NEW,
+ GOTD_CLIENT_STATE_ACCESS_GRANTED,
+};
+
struct gotd_client {
STAILQ_ENTRY(gotd_client) entry;
enum gotd_client_state state;
iclient.repo_child_pid = proc->pid;
}
- iclient.state = client->state;
if (client->session)
iclient.session_child_pid = client->session->pid;
log_debug("list-refs request from uid %d", client->euid);
- if (client->state != GOTD_STATE_EXPECT_LIST_REFS)
+ if (client->state != GOTD_CLIENT_STATE_NEW)
return got_error_msg(GOT_ERR_BAD_REQUEST,
"unexpected list-refs request received");
}
if (err) {
- if (err->code != GOT_ERR_EOF ||
- client->state != GOTD_STATE_EXPECT_PACKFILE)
+ if (err->code != GOT_ERR_EOF)
disconnect_on_error(client, err);
} else {
gotd_imsg_event_add(&client->iev);
*client_id = iconnect.client_id;
- client->state = GOTD_STATE_EXPECT_LIST_REFS;
+ client->state = GOTD_CLIENT_STATE_NEW;
client->id = iconnect.client_id;
client->fd = s;
s = -1;
struct gotd_imsg_connect_repo_child ireq;
int pipe[2];
- if (client->state != GOTD_STATE_EXPECT_LIST_REFS)
+ if (client->state != GOTD_CLIENT_STATE_ACCESS_GRANTED)
return got_error_msg(GOT_ERR_BAD_REQUEST,
"unexpected repo child ready signal received");
err = gotd_imsg_recv_error(&client_id, &imsg);
break;
case GOTD_IMSG_ACCESS_GRANTED:
+ client->state = GOTD_CLIENT_STATE_ACCESS_GRANTED;
break;
default:
do_disconnect = 1;
err = gotd_imsg_recv_error(&client_id, &imsg);
break;
case GOTD_IMSG_CLIENT_SESSION_READY:
- if (client->state != GOTD_STATE_EXPECT_LIST_REFS) {
+ if (client->state != GOTD_CLIENT_STATE_ACCESS_GRANTED) {
err = got_error(GOT_ERR_PRIVSEP_MSG);
break;
}
blob - 3c7194f856798d1eab7423b732b4dad29644e13e
blob + de4f9c2c78944e2a095e39c114c19e9baed240f5
--- gotd/gotd.h
+++ gotd/gotd.h
};
TAILQ_HEAD(gotd_repolist, gotd_repo);
-enum gotd_client_state {
+enum gotd_session_state {
GOTD_STATE_EXPECT_LIST_REFS,
GOTD_STATE_EXPECT_CAPABILITIES,
GOTD_STATE_EXPECT_WANT,
gid_t egid;
char repo_name[NAME_MAX];
int is_writing;
- enum gotd_client_state state;
pid_t session_child_pid;
pid_t repo_child_pid;
};
blob - a6b8f011af70edd6ca8e1dd6ffc0658788c67ad1
blob + a1e9bda45d13cafee15c71ea7364217a9a432442
--- gotd/session.c
+++ gotd/session.c
} gotd_session;
static struct gotd_session_client {
- enum gotd_client_state state;
+ enum gotd_session_state state;
int is_writing;
struct gotd_client_capability *capabilities;
size_t ncapa_alloc;