]> granicus.if.org Git - sudo/commitdiff
Ignore files ending in '~' in sudo.d (emacs backup files)
authorTodd C. Miller <Todd.Miller@courtesan.com>
Sun, 19 Apr 2009 12:56:42 +0000 (12:56 +0000)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Sun, 19 Apr 2009 12:56:42 +0000 (12:56 +0000)
toke.c
toke.l

diff --git a/toke.c b/toke.c
index 955c2e1fa3edf5dadc5c915487f2903d2405e10d..dd4c67675a862007ef54547d2b8125aa79217c36 100644 (file)
--- a/toke.c
+++ b/toke.c
@@ -3258,9 +3258,11 @@ switch_dir(stack, dirpath)
        return(FALSE);
     }
     while ((dent = readdir(dir))) {
-       /* Ignore files that have a '.' in them. */
-       if (strchr(dent->d_name, '.') != NULL)
+       /* Ignore files that end in '~' or have a '.' in them. */
+       if (dent->d_namlen == 0 || dent->d_name[dent->d_namlen - 1] == '~'
+           || strchr(dent->d_name, '.') != NULL) {
            continue;
+       }
        if (asprintf(&path, "%s/%s", dirpath, dent->d_name) == -1) {
            closedir(dir);
            goto bad;
diff --git a/toke.l b/toke.l
index 6a604a885d3f3e09887915db7cb3f6a4653b8472..cc18cec9c4c819aa84e40ec3b16437967800163a 100644 (file)
--- a/toke.l
+++ b/toke.l
@@ -663,9 +663,11 @@ switch_dir(stack, dirpath)
        return(FALSE);
     }
     while ((dent = readdir(dir))) {
-       /* Ignore files that have a '.' in them. */
-       if (strchr(dent->d_name, '.') != NULL)
+       /* Ignore files that end in '~' or have a '.' in them. */
+       if (dent->d_namlen == 0 || dent->d_name[dent->d_namlen - 1] == '~'
+           || strchr(dent->d_name, '.') != NULL) {
            continue;
+       }
        if (asprintf(&path, "%s/%s", dirpath, dent->d_name) == -1) {
            closedir(dir);
            goto bad;