Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

backend code ignores backends after hitting broken symbolic link #1953

Closed
michaelrsweet opened this issue Sep 3, 2006 · 5 comments
Closed

Comments

@michaelrsweet
Copy link
Collaborator

Version: 1.2.2
CUPS.org User: ecatmur

lpinfo -v was not listing parallel ports.

/usr/libexec/cups/backends contained two broken symlinks. After deleting the broken symlinks, lpinfo -v listed the parallel ports.

@michaelrsweet
Copy link
Collaborator Author

CUPS.org User: ecatmur

The problem is in cupsDirRead:

do
{
if (readdir_r(dp->dir, (struct dirent *)buffer, &entry))
{
DEBUG_printf((" readdir_r() failed - %s\n", strerror(errno)));
return (NULL);
}

if (!entry)
{
  DEBUG_puts("    readdir_r() returned a NULL pointer!");
  return (NULL);
}

DEBUG_printf(("    readdir_r() returned \"%s\"...\n", entry->d_name));

}
while (!strcmp(entry->d_name, ".") || !strcmp(entry->d_name, ".."));

/*

  • Copy the name over and get the file information...
    */

    strlcpy(dp->entry.filename, entry->d_name, sizeof(dp->entry.filename));

    snprintf(filename, sizeof(filename), "%s/%s", dp->directory, entry->d_name);
    if (stat(filename, &(dp->entry.fileinfo)))
    {
    DEBUG_printf((" stat() failed for "%s" - %s...\n", filename,
    strerror(errno)));
    return (NULL);
    }

    /*

  • Return the entry...
    */

    return (&(dp->entry));
    }

It returns NULL, indicating error reading directory or end of directory, if the stat fails. It should instead just loop to the next dirent.

@michaelrsweet
Copy link
Collaborator Author

CUPS.org User: ecatmur

cupsDirRead-dont-end-on-failed-stat.patch

Suggested patch.

@michaelrsweet
Copy link
Collaborator Author

CUPS.org User: mike

Fixed in Subversion repository.

@michaelrsweet
Copy link
Collaborator Author

"cupsDirRead-dont-end-on-failed-stat.patch":

--- cups/dir.c 2006/09/03 08:53:52 1.1
+++ cups/dir.c 2006/09/03 08:57:17
@@ -381,22 +381,24 @@ cupsDirRead(cups_dir_t dp) / I - Dire
}

 DEBUG_printf(("    readdir_r() returned \"%s\"...\n", entry->d_name));
  • }
  • while (!strcmp(entry->d_name, ".") || !strcmp(entry->d_name, ".."));
  • /*
  • * Copy the name over and get the file information...
  • */
  • if (!strcmp(entry->d_name, ".") || !strcmp(entry->d_name, ".."))
  •  continue;
    

- strlcpy(dp->entry.filename, entry->d_name, sizeof(dp->entry.filename));

  • snprintf(filename, sizeof(filename), "%s/%s", dp->directory, entry->d_name);
  • if (stat(filename, &(dp->entry.fileinfo)))
  • {
  • DEBUG_printf((" stat() failed for "%s" - %s...\n", filename,
  •              strerror(errno)));
    
  • return (NULL);
  • }
  • /*
  • * Copy the name over and get the file information...
  • */
  • strlcpy(dp->entry.filename, entry->d_name, sizeof(dp->entry.filename));
  • snprintf(filename, sizeof(filename), "%s/%s", dp->directory, entry->d_name);
  • if (stat(filename, &(dp->entry.fileinfo)))
  • {
  •  DEBUG_printf(("    stat() failed for \"%s\" - %s...\n", filename,
    
  •       strerror(errno)));
    
  •  continue;
    
  • }
  • } while (0);

/*

  • Return the entry...

@michaelrsweet
Copy link
Collaborator Author

"str1953.patch":

Index: dir.c

--- dir.c (revision 5922)
+++ dir.c (working copy)
@@ -366,7 +366,7 @@

  • Try reading an entry that is not "." or ".."...
    */

  • do

  • for (;;)
    {
    if (readdir_r(dp->dir, (struct dirent *)buffer, &entry))
    {
    @@ -381,28 +381,31 @@
    }

    DEBUG_printf((" readdir_r() returned "%s"...\n", entry->d_name));

  • }

  • while (!strcmp(entry->d_name, ".") || !strcmp(entry->d_name, ".."));

  • /*

  • * Copy the name over and get the file information...

  • */

  • if (!strcmp(entry->d_name, ".") || !strcmp(entry->d_name, ".."))

  •  continue;
    
  • strlcpy(dp->entry.filename, entry->d_name, sizeof(dp->entry.filename));

  • /*

  • * Copy the name over and get the file information...

  • */

  • snprintf(filename, sizeof(filename), "%s/%s", dp->directory, entry->d_name);

  • if (stat(filename, &(dp->entry.fileinfo)))

  • {

  • DEBUG_printf((" stat() failed for "%s" - %s...\n", filename,

  •              strerror(errno)));
    
  • return (NULL);

  • }

  • strlcpy(dp->entry.filename, entry->d_name, sizeof(dp->entry.filename));

  • /*

  • * Return the entry...

  • */

  • snprintf(filename, sizeof(filename), "%s/%s", dp->directory, entry->d_name);

  • return (&(dp->entry));

  • if (stat(filename, &(dp->entry.fileinfo)))

  • {

  •  DEBUG_printf(("    stat() failed for \"%s\" - %s...\n", filename,
    
  •                strerror(errno)));
    
  •  continue;
    
  • }

  • /*
  • * Return the entry...
  • */
  • return (&(dp->entry));
  • }
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant