From 55230a6adc9e306718d02e8cd3261db5f779322f Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Fri, 11 Jun 2010 09:54:48 -0400 Subject: [PATCH] Remove tfd from struct sudoersfile; it is not used. Add prev pointer to struct sudoersfile. Declare list of sudoersfile using TQ_DECLARE. Use tq_append to append sudoers entries to the tail queue. --HG-- branch : 1.7 --- visudo.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/visudo.c b/visudo.c index 8fe920b2d..6fd333854 100644 --- a/visudo.c +++ b/visudo.c @@ -84,14 +84,14 @@ #include struct sudoersfile { + struct sudoersfile *prev, *next; char *path; char *tpath; int fd; - int tfd; int modified; int doedit; - struct sudoersfile *next; }; +TQ_DECLARE(sudoersfile); /* * Function prototypes @@ -136,9 +136,7 @@ int num_interfaces; struct interface *interfaces; struct sudo_user sudo_user; struct passwd *list_pw; -static struct sudoerslist { - struct sudoersfile *first, *last; -} sudoerslist; +static struct sudoersfile_list sudoerslist; static struct rbtree *alias_freelist; int @@ -763,10 +761,10 @@ open_sudoers(path, doedit, keepopen) entry = emalloc(sizeof(*entry)); entry->path = estrdup(path); entry->modified = 0; + entry->prev = entry; entry->next = NULL; entry->fd = open(entry->path, O_RDWR | O_CREAT, SUDOERS_MODE); entry->tpath = NULL; - entry->tfd = -1; entry->doedit = doedit; if (entry->fd == -1) { warning("%s", entry->path); @@ -777,13 +775,7 @@ open_sudoers(path, doedit, keepopen) errorx(1, "%s busy, try again later", entry->path); if ((fp = fdopen(entry->fd, "r")) == NULL) error(1, "%s", entry->path); - /* XXX - macro here? */ - if (sudoerslist.last == NULL) - sudoerslist.first = sudoerslist.last = entry; - else { - sudoerslist.last->next = entry; - sudoerslist.last = entry; - } + tq_append(&sudoerslist, entry); } else { /* Already exists, open .tmp version if there is one. */ if (entry->tpath != NULL) { -- 2.50.1