]> granicus.if.org Git - sudo/commitdiff
Remove tfd from struct sudoersfile; it is not used.
authorTodd C. Miller <Todd.Miller@courtesan.com>
Fri, 11 Jun 2010 13:53:44 +0000 (09:53 -0400)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Fri, 11 Jun 2010 13:53:44 +0000 (09:53 -0400)
Add prev pointer to struct sudoersfile.
Declare list of sudoersfile using TQ_DECLARE.
Use tq_append to append sudoers entries to the tail queue.

TODO
plugins/sudoers/visudo.c

diff --git a/TODO b/TODO
index 403ac5addc86f1bb4358004f402c590a5d3fdacb..d314f086a58b76e01c07d7bbcc90fdf542cab7a5 100644 (file)
--- 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
index bf9c94f2d520fa74f12fa94d5637d2dfc559672c..f6b23dc7c7c35f4c63d8969546a4d0e3a1170499 100644 (file)
 #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) {