]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Use the directories loaded into the libcups global data.
authormike <mike@7a7537e8-13f0-0310-91df-b6672ffda945>
Tue, 2 Feb 2010 04:08:37 +0000 (04:08 +0000)
committermike <mike@7a7537e8-13f0-0310-91df-b6672ffda945>
Tue, 2 Feb 2010 04:08:37 +0000 (04:08 +0000)
git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@8975 7a7537e8-13f0-0310-91df-b6672ffda945

systemv/lppasswd.c
systemv/lpstat.c

index 9e90669bfe8e9e2398ae29b3cd87931c93f5bdb1..708f72cb71d969f786ed198b725685b3c664b2b3 100644 (file)
@@ -1,9 +1,9 @@
 /*
  * "$Id$"
  *
- *   MD5 password program for the Common UNIX Printing System (CUPS).
+ *   MD5 password program for CUPS.
  *
- *   Copyright 2007-2009 by Apple Inc.
+ *   Copyright 2007-2010 by Apple Inc.
  *   Copyright 1997-2006 by Easy Software Products.
  *
  *   These coded instructions, statements, and computer programs are the
@@ -31,9 +31,7 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 
-#include <cups/string.h>
-#include <cups/cups.h>
-#include <cups/i18n.h>
+#include <cups/globals.h>
 #include <cups/md5.h>
 
 #ifndef WIN32
@@ -79,7 +77,6 @@ main(int  argc,                               /* I - Number of command-line arguments */
                groupline[17],          /* Group from line */
                md5line[33],            /* MD5-sum from line */
                md5new[33];             /* New MD5 sum */
-  const char   *root;                  /* CUPS server root directory */
   char         passwdmd5[1024],        /* passwd.md5 file */
                passwdold[1024],        /* passwd.old file */
                passwdnew[1024];        /* passwd.tmp file */
@@ -88,6 +85,7 @@ main(int  argc,                               /* I - Number of command-line arguments */
   int          flag;                   /* Password check flags... */
   int          fd;                     /* Password file descriptor */
   int          error;                  /* Write error */
+  _cups_globals_t *cg = _cupsGlobals();        /* Global data */
 #if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET)
   struct sigaction action;             /* Signal action */
 #endif /* HAVE_SIGACTION && !HAVE_SIGSET*/
@@ -113,18 +111,11 @@ main(int  argc,                           /* I - Number of command-line arguments */
 
  /*
   * Find the server directory...
-  *
-  * We use the CUPS_SERVERROOT environment variable when we are running
-  * as root or when lppasswd is not setuid...
   */
 
-  if ((root = getenv("CUPS_SERVERROOT")) == NULL ||
-      (getuid() != geteuid() && getuid()))
-    root = CUPS_SERVERROOT;
-
-  snprintf(passwdmd5, sizeof(passwdmd5), "%s/passwd.md5", root);
-  snprintf(passwdold, sizeof(passwdold), "%s/passwd.old", root);
-  snprintf(passwdnew, sizeof(passwdnew), "%s/passwd.new", root);
+  snprintf(passwdmd5, sizeof(passwdmd5), "%s/passwd.md5", cg->cups_serverroot);
+  snprintf(passwdold, sizeof(passwdold), "%s/passwd.old", cg->cups_serverroot);
+  snprintf(passwdnew, sizeof(passwdnew), "%s/passwd.new", cg->cups_serverroot);
 
  /*
   * Find the default system group...
index e3542c94b3f875e193b6396337a8ee4149352c84..a1fa7bf86065dff2b60fe86e18ee7a110cc3220d 100644 (file)
@@ -1,9 +1,9 @@
 /*
  * "$Id$"
  *
- *   "lpstat" command for the Common UNIX Printing System (CUPS).
+ *   "lpstat" command for CUPS.
  *
- *   Copyright 2007-2009 by Apple Inc.
+ *   Copyright 2007-2010 by Apple Inc.
  *   Copyright 1997-2006 by Easy Software Products.
  *
  *   These coded instructions, statements, and computer programs are the
 #include <stdio.h>
 #include <stdlib.h>
 #include <errno.h>
-#include <cups/http-private.h>
-#include <cups/string.h>
-#include <cups/cups.h>
-#include <cups/i18n.h>
+#include <cups/globals.h>
 #include <cups/debug.h>
 
 
@@ -1518,7 +1515,7 @@ show_printers(const char  *printers,      /* I - Destinations */
   char         printer_uri[HTTP_MAX_URI],
                                        /* Printer URI */
                printer_state_time[255];/* Printer state time */
-  const char   *root;                  /* Server root directory... */
+  _cups_globals_t *cg = _cupsGlobals();        /* Global data */
   static const char *pattrs[] =                /* Attributes we need for printers... */
                {
                  "printer-name",
@@ -1543,9 +1540,6 @@ show_printers(const char  *printers,      /* I - Destinations */
   DEBUG_printf(("show_printers(printers=\"%s\", num_dests=%d, dests=%p, "
                 "long_status=%d)\n", printers, num_dests, dests, long_status));
 
-  if ((root = getenv("CUPS_SERVERROOT")) == NULL)
-    root = CUPS_SERVERROOT;
-
   if (printers != NULL && !strcmp(printers, "all"))
     printers = NULL;
 
@@ -1820,10 +1814,11 @@ show_printers(const char  *printers,    /* I - Destinations */
            if (make_model && strstr(make_model, "System V Printer"))
              _cupsLangPrintf(stdout,
                              _("\tInterface: %s/interfaces/%s\n"),
-                             root, printer);
+                             cg->cups_serverroot, printer);
            else if (make_model && !strstr(make_model, "Raw Printer"))
              _cupsLangPrintf(stdout,
-                             _("\tInterface: %s/ppd/%s.ppd\n"), root, printer);
+                             _("\tInterface: %s/ppd/%s.ppd\n"),
+                             cg->cups_serverroot, printer);
           }
          _cupsLangPuts(stdout, _("\tOn fault: no alert\n"));
          _cupsLangPuts(stdout, _("\tAfter fault: continue\n"));
@@ -1933,10 +1928,11 @@ show_printers(const char  *printers,    /* I - Destinations */
                if (make_model && strstr(make_model, "System V Printer"))
                  _cupsLangPrintf(stdout,
                                  _("\tInterface: %s/interfaces/%s\n"),
-                                 root, printer);
+                                 cg->cups_serverroot, printer);
                else if (make_model && !strstr(make_model, "Raw Printer"))
                  _cupsLangPrintf(stdout,
-                                 _("\tInterface: %s/ppd/%s.ppd\n"), root, printer);
+                                 _("\tInterface: %s/ppd/%s.ppd\n"),
+                                 cg->cups_serverroot, printer);
               }
              _cupsLangPuts(stdout, _("\tOn fault: no alert\n"));
              _cupsLangPuts(stdout, _("\tAfter fault: continue\n"));