Some notes

This commit is contained in:
Félix Baylac-Jacqué 2022-10-04 11:34:43 +02:00
parent 7e8283170c
commit 1502e8dab9
Signed by: picnoir
GPG Key ID: EFD315F31848DBA4
5 changed files with 14 additions and 0 deletions

View File

@ -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)
{

View File

@ -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)

View File

@ -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

View File

@ -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)

View File

@ -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
{