const char *notafter, bool warnings, bool store_options,
sudo_ldap_iter_t iter)
{
+ struct cmndspec_list negated_cmnds = TAILQ_HEAD_INITIALIZER(negated_cmnds);
+ struct member_list negated_hosts = TAILQ_HEAD_INITIALIZER(negated_hosts);
struct cmndspec *cmndspec = NULL;
struct cmndspec *prev_cmndspec = NULL;
struct sudo_command *c;
while ((host = iter(&hosts)) != NULL) {
if ((m = host_to_member(host)) == NULL)
goto oom;
- /* Negated hosts have precedence so insert them at the end. */
if (m->negated)
- TAILQ_INSERT_TAIL(&priv->hostlist, m, entries);
+ TAILQ_INSERT_TAIL(&negated_hosts, m, entries);
else
- TAILQ_INSERT_HEAD(&priv->hostlist, m, entries);
+ TAILQ_INSERT_TAIL(&priv->hostlist, m, entries);
}
+ /* Negated hosts take precedence so we insert them at the end. */
+ TAILQ_CONCAT(&priv->hostlist, &negated_hosts, entries);
}
/*
/* Negated commands have precedence so insert them at the end. */
if (negated)
- TAILQ_INSERT_TAIL(&priv->cmndlist, cmndspec, entries);
+ TAILQ_INSERT_TAIL(&negated_cmnds, cmndspec, entries);
else
- TAILQ_INSERT_HEAD(&priv->cmndlist, cmndspec, entries);
+ TAILQ_INSERT_TAIL(&priv->cmndlist, cmndspec, entries);
/* Initialize cmndspec */
TAGS_INIT(cmndspec->tags);
prev_cmndspec = cmndspec;
}
}
+ /* Negated commands take precedence so we insert them at the end. */
+ TAILQ_CONCAT(&priv->cmndlist, &negated_cmnds, entries);
+
debug_return_ptr(priv);
oom: