From: Alan T. DeKok Date: Wed, 6 Sep 2017 18:37:40 +0000 (-0400) Subject: add async_safe to tokenized xlat X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=49cdc8b32eed2b56bb3be99e96b6b09b95935b75;p=thirdparty%2Ffreeradius-server.git add async_safe to tokenized xlat so we can track if an expansion is async-safe --- diff --git a/src/main/xlat.h b/src/main/xlat.h index d7bf1a6324f..61a7dfb5afc 100644 --- a/src/main/xlat.h +++ b/src/main/xlat.h @@ -61,6 +61,8 @@ struct xlat_exp { char const *fmt; //!< The format string. size_t len; //!< Length of the format string. + bool async_safe; //!< carried from all of the children + xlat_state_t type; //!< type of this expansion. xlat_exp_t *next; //!< Next in the list. diff --git a/src/main/xlat_tokenize.c b/src/main/xlat_tokenize.c index af2517f35ff..344292baea4 100644 --- a/src/main/xlat_tokenize.c +++ b/src/main/xlat_tokenize.c @@ -161,6 +161,8 @@ static ssize_t xlat_tokenize_alternation(TALLOC_CTX *ctx, char *fmt, xlat_exp_t p += slen; } + node->async_safe = (node->child->async_safe && node->alternate->async_safe); + *head = node; return p - fmt; } @@ -271,6 +273,7 @@ static ssize_t xlat_tokenize_expansion(TALLOC_CTX *ctx, char *fmt, xlat_exp_t ** } p += slen; + node->async_safe = (node->xlat->async_safe && node->child->async_safe); *head = node; rad_assert(node->next == NULL); @@ -318,6 +321,7 @@ static ssize_t xlat_tokenize_expansion(TALLOC_CTX *ctx, char *fmt, xlat_exp_t ** node->fmt = node->attr->tmpl_unknown_name; XLAT_DEBUG("VIRTUAL <-- %s", node->fmt); + node->async_safe = node->xlat->async_safe; *head = node; rad_assert(node->next == NULL); q++; @@ -338,6 +342,7 @@ static ssize_t xlat_tokenize_expansion(TALLOC_CTX *ctx, char *fmt, xlat_exp_t ** return -1; /* second character of format string */ } *p++ = '\0'; + node->async_safe = true; /* attribute expansions are always async-safe */ *head = node; rad_assert(node->next == NULL); @@ -502,6 +507,7 @@ static ssize_t xlat_tokenize_literal(TALLOC_CTX *ctx, char *fmt, xlat_exp_t **he * Squash zero-width literals */ if (node->len > 0) { + node->async_safe = true; /* literals are always true */ *head = node; } else { @@ -747,7 +753,10 @@ ssize_t xlat_tokenize_request(TALLOC_CTX *ctx, REQUEST *request, char const *fmt /* * Zero length expansion, return a zero length node. */ - if (slen == 0) *head = talloc_zero(ctx, xlat_exp_t); + if (slen == 0) { + MEM(*head = talloc_zero(ctx, xlat_exp_t)); + (*head)->async_safe = true; + } /* * Output something like: