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

No error for incorrect ServerBin #2470

Closed
michaelrsweet opened this issue Aug 10, 2007 · 5 comments
Closed

No error for incorrect ServerBin #2470

michaelrsweet opened this issue Aug 10, 2007 · 5 comments
Milestone

Comments

@michaelrsweet
Copy link
Collaborator

Version: 1.3rc2
CUPS.org User: twaugh.redhat

If the ServerBin is configured incorrectly (as often seems to happen when using KDE to configure CUPS), 'lpinfo -v' hangs and gives no response. Similarly for 'lpinfo -m'.

Here is a patch to fix that. It performs a sanity check just before calling fork(), to make sure that the binary it is about to execute is executable.

Seen in bug #250840:
https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=250840

@michaelrsweet
Copy link
Collaborator Author

CUPS.org User: twaugh.redhat

Sorry, please ignore first version; I attached the wrong file.

The v2 file is the one I meant to attach.

@michaelrsweet
Copy link
Collaborator Author

CUPS.org User: mike

I took a slightly different approach to a fix - conf.c now has a CUPSD_VARTYPE_PATHNAME option type, which ServerBin and a handful of other directives now use to prevent setting of those directives to invalid values.

In addition, cupsdStartProcess() in process.c now does an access check on the command before it does the fork/exec dance so that we can get some early detection of missing files.

A patch is attached...

@michaelrsweet
Copy link
Collaborator Author

"cups-command-error.patch":

--- cups-1.3rc2/scheduler/client.c.command-error 2007-08-10 10:33:18.000000000 +0100
+++ cups-1.3rc2/scheduler/client.c 2007-08-10 10:37:44.000000000 +0100
@@ -2266,6 +2266,13 @@
{
int fd; /* Standard input file descriptor */

  • if (access(command, X_OK) != 0)
  • {
  • cupsdLogMessage(CUPS_LOG_ERROR,
  •       "cupsdSendCommand: %d Unable to execute \"%s\"",
    
  •       con->http.fd, command)
    
  •  return (0);
    
  • }

if (con->filename)
{

@michaelrsweet
Copy link
Collaborator Author

"cups-command-error_v2.patch":

--- cups-1.3rc2/scheduler/client.c.command-error 2007-08-10 10:33:18.000000000 +0100
+++ cups-1.3rc2/scheduler/client.c 2007-08-10 10:37:44.000000000 +0100
@@ -2266,6 +2266,13 @@
{
int fd; /* Standard input file descriptor */

  • if (access(command, X_OK) != 0)
  • {
  • cupsdLogMessage(CUPSD_LOG_ERROR,
  •       "cupsdSendCommand: %d Unable to execute \"%s\"",
    
  •       con->http.fd, command);
    
  • return (0);
  • }

if (con->filename)
{

@michaelrsweet
Copy link
Collaborator Author

"str2470.patch":

Index: scheduler/process.c

--- scheduler/process.c (revision 6782)
+++ scheduler/process.c (working copy)
@@ -131,6 +131,13 @@
"cupsdStartProcess("%s", %p, %p, %d, %d, %d)",
command, argv, envp, infd, outfd, errfd);

  • if (access(command, X_OK))
  • {
  • cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to execute %s: %s", command,
  •                strerror(errno));
    
  • return (0);
  • }

#if defined(APPLE)
if (envp)
{
Index: scheduler/conf.c

--- scheduler/conf.c (revision 6782)
+++ scheduler/conf.c (working copy)
@@ -56,7 +56,8 @@
{
CUPSD_VARTYPE_INTEGER, /* Integer option /
CUPSD_VARTYPE_STRING, /
String option */

  • CUPSD_VARTYPE_BOOLEAN /* Boolean option */
  • CUPSD_VARTYPE_BOOLEAN, /* Boolean option */
  • CUPSD_VARTYPE_PATHNAME /* File/directory name option */
    } cupsd_vartype_t;

typedef struct
@@ -81,7 +82,7 @@
{ "BrowseInterval", &BrowseInterval, CUPSD_VARTYPE_INTEGER },
#ifdef HAVE_LDAP
{ "BrowseLDAPBindDN", &BrowseLDAPBindDN, CUPSD_VARTYPE_STRING },

  • { "BrowseLDAPCACertFile", &BrowseLDAPCACertFile, CUPSD_VARTYPE_STRING },
  • { "BrowseLDAPCACertFile", &BrowseLDAPCACertFile, CUPSD_VARTYPE_PATHNAME },
    { "BrowseLDAPDN", &BrowseLDAPDN, CUPSD_VARTYPE_STRING },
    { "BrowseLDAPPassword", &BrowseLDAPPassword, CUPSD_VARTYPE_STRING },
    { "BrowseLDAPServer", &BrowseLDAPServer, CUPSD_VARTYPE_STRING },
    @@ -152,20 +153,20 @@
    { "RIPCache", &RIPCache, CUPSD_VARTYPE_STRING },
    { "RootCertDuration", &RootCertDuration, CUPSD_VARTYPE_INTEGER },
    { "ServerAdmin", &ServerAdmin, CUPSD_VARTYPE_STRING },
  • { "ServerBin", &ServerBin, CUPSD_VARTYPE_STRING },
  • { "ServerBin", &ServerBin, CUPSD_VARTYPE_PATHNAME },
    #ifdef HAVE_SSL
  • { "ServerCertificate", &ServerCertificate, CUPSD_VARTYPE_STRING },
  • { "ServerCertificate", &ServerCertificate, CUPSD_VARTYPE_PATHNAME },

if defined(HAVE_LIBSSL) || defined(HAVE_GNUTLS)

  • { "ServerKey", &ServerKey, CUPSD_VARTYPE_STRING },
  • { "ServerKey", &ServerKey, CUPSD_VARTYPE_PATHNAME },

endif /* HAVE_LIBSSL || HAVE_GNUTLS _/

#endif /_ HAVE_SSL */
{ "ServerName", &ServerName, CUPSD_VARTYPE_STRING },

  • { "ServerRoot", &ServerRoot, CUPSD_VARTYPE_STRING },
  • { "ServerRoot", &ServerRoot, CUPSD_VARTYPE_PATHNAME },
    { "StateDir", &StateDir, CUPSD_VARTYPE_STRING },
    #ifdef HAVE_AUTHORIZATION_H
    { "SystemGroupAuthKey", &SystemGroupAuthKey, CUPSD_VARTYPE_STRING },
    #endif /* HAVE_AUTHORIZATION_H */
  • { "TempDir", &TempDir, CUPSD_VARTYPE_STRING },
  • { "TempDir", &TempDir, CUPSD_VARTYPE_PATHNAME },
    { "Timeout", &Timeout, CUPSD_VARTYPE_INTEGER },
    { "UseNetworkDefault", &UseNetworkDefault, CUPSD_VARTYPE_BOOLEAN }
    };
    @@ -3076,6 +3077,20 @@
    value, linenum);
    break;
  • case CUPSD_VARTYPE_PATHNAME :
  •        if (value[0] == '/')
    
  •     strlcpy(temp, value, sizeof(temp));
    
  •   else
    
  •     snprintf(temp, sizeof(temp), "%s/%s", ServerRoot, value);
    
  •        if (access(temp, 0))
    
  •   {
    
  •     cupsdLogMessage(CUPSD_LOG_ERROR,
    
  •                     "File or directory for \"%s %s\" on line %d "
    
  •             "does not exist!", line, value, linenum);
    
  •          break;
    
  •   }
    
    case CUPSD_VARTYPE_STRING :
    cupsdSetString((char **)var->ptr, value);
    break;

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