From 1502e8dab92a6aa8c778d782b85aaca2e200d11a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Baylac-Jacqu=C3=A9?= Date: Tue, 4 Oct 2022 11:34:43 +0200 Subject: [PATCH] Some notes --- nscd/connections.c | 1 + nscd/hstcache.c | 9 +++++++++ nscd/nscd-client.h | 1 + nscd/nscd_gethst_r.c | 2 ++ resolv/netdb.h | 1 + 5 files changed, 14 insertions(+) diff --git a/nscd/connections.c b/nscd/connections.c index 531d2e83df..7d62126430 100644 --- a/nscd/connections.c +++ b/nscd/connections.c @@ -1163,6 +1163,7 @@ request from '%s' [%ld] not handled due to missing permission"), dbg_log ("\t%s", serv2str[req->type]); } + // HERE: request handler /* Handle the request. */ switch (req->type) { diff --git a/nscd/hstcache.c b/nscd/hstcache.c index 69472f1bc0..7ddcc217da 100644 --- a/nscd/hstcache.c +++ b/nscd/hstcache.c @@ -60,6 +60,7 @@ const struct iovec hst_iov_disabled = }; +// HERE: interesting test cases /* This is the standard reply in case we haven't found the dataset. */ static const hst_response_header notfound = { @@ -269,19 +270,26 @@ cache_addhst (struct database_dyn *db, int fd, request_header *req, cp = dataset->strdata; + // Payload????? Not sure :/ + // 1. hname string cp = mempcpy (cp, hst->h_name, h_name_len); + // 2. table containing the lenghts of each alias cp = mempcpy (cp, h_aliases_len, h_aliases_cnt * sizeof (uint32_t)); /* The normal addresses first. */ addresses = cp; + // 3. Iterating on the result addr, serializing them. Each part is h_length wide. + // TODO: find h_length size. for (cnt = 0; cnt < h_addr_list_cnt; ++cnt) cp = mempcpy (cp, hst->h_addr_list[cnt], hst->h_length); + // 4. Iterating on the aliases, serializing them one by one according to their size previously sent. /* Then the aliases. */ aliases = cp; for (cnt = 0; cnt < h_aliases_cnt; ++cnt) cp = mempcpy (cp, hst->h_aliases[cnt], h_aliases_len[cnt]); + // 5. Size sanity check assert (cp == dataset->strdata + total - offsetof (struct dataset, strdata)); @@ -424,6 +432,7 @@ lookup (int type, void *key, struct hostent *resultbufp, char *buffer, } +// HERE: top-level hst imp static time_t addhstbyX (struct database_dyn *db, int fd, request_header *req, void *key, uid_t uid, struct hashentry *he, struct datahead *dh) diff --git a/nscd/nscd-client.h b/nscd/nscd-client.h index ca9e6def1a..66c0d6524c 100644 --- a/nscd/nscd-client.h +++ b/nscd/nscd-client.h @@ -114,6 +114,7 @@ typedef struct } gr_response_header; +// HERE: header struct /* Structure sent in reply to host query. Note that this struct is sent also if the service is disabled or there is no record found. */ typedef struct diff --git a/nscd/nscd_gethst_r.c b/nscd/nscd_gethst_r.c index 31d13580a1..1310824890 100644 --- a/nscd/nscd_gethst_r.c +++ b/nscd/nscd_gethst_r.c @@ -129,6 +129,7 @@ __nscd_get_nl_timestamp (void) int __nss_have_localdomain attribute_hidden; +//HERE impl. Client!?!? It reads from the socket to **result static int nscd_gethst_r (const char *key, size_t keylen, request_type type, struct hostent *resultbuf, char *buffer, size_t buflen, @@ -214,6 +215,7 @@ nscd_gethst_r (const char *key, size_t keylen, request_type type, if (h_name == NULL) { + // Read here sock = __nscd_open_socket (key, keylen, type, &hst_resp, sizeof (hst_resp)); if (sock == -1) diff --git a/resolv/netdb.h b/resolv/netdb.h index ac268f035f..76fbd97f79 100644 --- a/resolv/netdb.h +++ b/resolv/netdb.h @@ -94,6 +94,7 @@ extern const char *hstrerror (int __err_num) __THROW; #endif +// HERE: payload??? Nope, it's transformed /* Description of data base entry for a single host. */ struct hostent {