2
0
mirror of https://github.com/sudo-project/sudo.git synced 2025-08-22 09:57:41 +00:00

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.
This commit is contained in:
Todd C. Miller 2010-06-11 09:53:44 -04:00
parent 6d0b74cf13
commit 3516d7f0e3
2 changed files with 9 additions and 13 deletions

4
TODO
View File

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

View File

@ -84,14 +84,14 @@
#include <gram.h>
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) {