From: Todd C. Miller Date: Fri, 11 Jun 2010 13:53:44 +0000 (-0400) Subject: Remove tfd from struct sudoersfile; it is not used. X-Git-Tag: SUDO_1_8_0~483 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3516d7f0e36d3dff0b492f1a7c8478397abd901e;p=sudo 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. --- diff --git a/TODO b/TODO index 403ac5add..d314f086a 100644 --- a/TODO +++ b/TODO @@ -204,3 +204,7 @@ TODO list (most will be addressed in sudo 2.0) 72) Add flag to sudoreplay to select which streams to replay 73) Can we read pending input before closing pty and replay? + +74) Replace "sudoers" will "policy" in sudo.pod sensibly + +75) Check for accessing closed fds w/ valgrind diff --git a/plugins/sudoers/visudo.c b/plugins/sudoers/visudo.c index bf9c94f2d..f6b23dc7c 100644 --- a/plugins/sudoers/visudo.c +++ b/plugins/sudoers/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 @@ struct interface *interfaces; struct sudo_user sudo_user; struct passwd *list_pw; sudo_printf_t sudo_printf = visudo_printf; -static struct sudoerslist { - struct sudoersfile *first, *last; -} sudoerslist; +static struct sudoersfile_list sudoerslist; static struct rbtree *alias_freelist; int @@ -747,10 +745,10 @@ open_sudoers(const char *path, int doedit, int *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); @@ -761,13 +759,7 @@ open_sudoers(const char *path, int doedit, int *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) {