/*
- * "$Id: lppasswd.c 5925 2006-09-05 19:43:11Z mike $"
+ * "$Id: lppasswd.c 6649 2007-07-11 21:46:42Z mike $"
*
- * MD5 password program for the Common UNIX Printing System (CUPS).
+ * MD5 password program for CUPS.
*
+ * Copyright 2007-2010 by Apple Inc.
* Copyright 1997-2006 by Easy Software Products.
*
* These coded instructions, statements, and computer programs are the
- * property of Easy Software Products and are protected by Federal
- * copyright law. Distribution and use rights are outlined in the file
- * "LICENSE.txt" which should have been included with this file. If this
- * file is missing or damaged please contact Easy Software Products
- * at:
- *
- * Attn: CUPS Licensing Information
- * Easy Software Products
- * 44141 Airport View Drive, Suite 204
- * Hollywood, Maryland 20636 USA
- *
- * Voice: (301) 373-9600
- * EMail: cups-info@cups.org
- * WWW: http://www.cups.org
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file. If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*
* Contents:
*
#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
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 */
int flag; /* Password check flags... */
int fd; /* Password file descriptor */
int error; /* Write error */
+ _cups_globals_t *cg = _cupsGlobals(); /* Global data */
+ cups_lang_t *lang; /* Language info */
#if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET)
struct sigaction action; /* Signal action */
#endif /* HAVE_SIGACTION && !HAVE_SIGSET*/
_cupsSetLocale(argv);
+ lang = cupsLangDefault();
/*
* Check to see if stdin, stdout, and stderr are still open...
/*
* 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...
if (getuid() && getuid() != geteuid() && (op != CHANGE || username))
{
_cupsLangPuts(stderr,
- _("lppasswd: Only root can add or delete passwords!\n"));
+ _("lppasswd: Only root can add or delete passwords\n"));
return (1);
}
if (op != DELETE)
{
- if ((passwd = cupsGetPassword(_("Enter password:"))) == NULL)
+ if ((passwd = cupsGetPassword(
+ _cupsLangString(lang, _("Enter password:")))) == NULL)
return (1);
if ((newpass = strdup(passwd)) == NULL)
return (1);
}
- if ((passwd = cupsGetPassword(_("Enter password again:"))) == NULL)
+ if ((passwd = cupsGetPassword(
+ _cupsLangString(lang, _("Enter password again:")))) == NULL)
return (1);
if (strcmp(passwd, newpass) != 0)
{
_cupsLangPuts(stderr,
- _("lppasswd: Sorry, passwords don't match!\n"));
+ _("lppasswd: Sorry, passwords don't match\n"));
return (1);
}
if ((fd = open(passwdnew, O_WRONLY | O_CREAT | O_EXCL, 0400)) < 0)
{
if (errno == EEXIST)
- _cupsLangPuts(stderr, _("lppasswd: Password file busy!\n"));
+ _cupsLangPuts(stderr, _("lppasswd: Password file busy\n"));
else
_cupsLangPrintf(stderr,
_("lppasswd: Unable to open password file: %s\n"),
strcmp(httpMD5(username, "CUPS", oldpass, md5new), md5line) != 0)
{
_cupsLangPuts(stderr,
- _("lppasswd: Sorry, password doesn't match!\n"));
+ _("lppasswd: Sorry, password doesn't match\n"));
error = 1;
}
else
if (error)
{
- _cupsLangPuts(stderr, _("lppasswd: Password file not updated!\n"));
+ _cupsLangPuts(stderr, _("lppasswd: Password file not updated\n"));
unlink(passwdnew);
/*
- * End of "$Id: lppasswd.c 5925 2006-09-05 19:43:11Z mike $".
+ * End of "$Id: lppasswd.c 6649 2007-07-11 21:46:42Z mike $".
*/