/*
- * "$Id: lppasswd.c 6649 2007-07-11 21:46:42Z mike $"
+ * "$Id: lppasswd.c 10996 2013-05-29 11:51:34Z msweet $"
*
* MD5 password program for CUPS.
*
- * Copyright 2007-2010 by Apple Inc.
+ * Copyright 2007-2011 by Apple Inc.
* Copyright 1997-2006 by Easy Software Products.
*
* These coded instructions, statements, and computer programs are the
* Local functions...
*/
-static void usage(FILE *fp);
+static void usage(FILE *fp) __attribute__((noreturn));
/*
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."));
return (1);
}
if ((oldpass = strdup(passwd)) == NULL)
{
_cupsLangPrintf(stderr,
- _("lppasswd: Unable to copy password string: %s\n"),
+ _("lppasswd: Unable to copy password string: %s"),
strerror(errno));
return (1);
}
if ((newpass = strdup(passwd)) == NULL)
{
_cupsLangPrintf(stderr,
- _("lppasswd: Unable to copy password string: %s\n"),
+ _("lppasswd: Unable to copy password string: %s"),
strerror(errno));
return (1);
}
if (strcmp(passwd, newpass) != 0)
{
_cupsLangPuts(stderr,
- _("lppasswd: Sorry, passwords don't match\n"));
+ _("lppasswd: Sorry, passwords don't match."));
return (1);
}
if (strlen(newpass) < 6 || strstr(newpass, username) != NULL || flag != 3)
{
- _cupsLangPuts(stderr,
- _("lppasswd: Sorry, password rejected.\n"
- "Your password must be at least 6 characters long, "
- "cannot contain\n"
- "your username, and must contain at least one letter "
- "and number.\n"));
+ _cupsLangPuts(stderr, _("lppasswd: Sorry, password rejected."));
+ _cupsLangPuts(stderr, _("Your password must be at least 6 characters "
+ "long, cannot contain your username, and must "
+ "contain at least one letter and number."));
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."));
else
- _cupsLangPrintf(stderr,
- _("lppasswd: Unable to open password file: %s\n"),
+ _cupsLangPrintf(stderr, _("lppasswd: Unable to open password file: %s"),
strerror(errno));
return (1);
if ((outfile = fdopen(fd, "w")) == NULL)
{
- _cupsLangPrintf(stderr,
- _("lppasswd: Unable to open password file: %s\n"),
+ _cupsLangPrintf(stderr, _("lppasswd: Unable to open password file: %s"),
strerror(errno));
unlink(passwdnew);
infile = fopen(passwdmd5, "r");
if (infile == NULL && errno != ENOENT && op != ADD)
{
- _cupsLangPrintf(stderr,
- _("lppasswd: Unable to open password file: %s\n"),
+ _cupsLangPrintf(stderr, _("lppasswd: Unable to open password file: %s"),
strerror(errno));
fclose(outfile);
if (fputs(line, outfile) == EOF)
{
_cupsLangPrintf(stderr,
- _("lppasswd: Unable to write to password file: %s\n"),
+ _("lppasswd: Unable to write to password file: %s"),
strerror(errno));
error = 1;
break;
if (fputs(line, outfile) == EOF)
{
_cupsLangPrintf(stderr,
- _("lppasswd: Unable to write to password file: %s\n"),
+ _("lppasswd: Unable to write to password file: %s"),
strerror(errno));
error = 1;
break;
(strcmp(username, userline) || strcmp(groupname, groupline)))
{
_cupsLangPrintf(stderr,
- _("lppasswd: user \"%s\" and group \"%s\" do not exist.\n"),
+ _("lppasswd: user \"%s\" and group \"%s\" do not exist."),
username, groupname);
error = 1;
}
if (oldpass &&
strcmp(httpMD5(username, "CUPS", oldpass, md5new), md5line) != 0)
{
- _cupsLangPuts(stderr,
- _("lppasswd: Sorry, password doesn't match\n"));
+ _cupsLangPuts(stderr, _("lppasswd: Sorry, password doesn't match."));
error = 1;
}
else
if (fputs(line, outfile) == EOF)
{
_cupsLangPrintf(stderr,
- _("lppasswd: Unable to write to password file: %s\n"),
+ _("lppasswd: Unable to write to password file: %s"),
strerror(errno));
error = 1;
}
if (error)
{
- _cupsLangPuts(stderr, _("lppasswd: Password file not updated\n"));
-
+ _cupsLangPuts(stderr, _("lppasswd: Password file not updated."));
+
unlink(passwdnew);
return (1);
if (link(passwdmd5, passwdold) && errno != ENOENT)
{
_cupsLangPrintf(stderr,
- _("lppasswd: failed to backup old password file: %s\n"),
+ _("lppasswd: failed to backup old password file: %s"),
strerror(errno));
unlink(passwdnew);
return (1);
if (rename(passwdnew, passwdmd5) < 0)
{
- _cupsLangPrintf(stderr,
- _("lppasswd: failed to rename password file: %s\n"),
+ _cupsLangPrintf(stderr, _("lppasswd: failed to rename password file: %s"),
strerror(errno));
unlink(passwdnew);
return (1);
usage(FILE *fp) /* I - File to send usage to */
{
if (getuid())
- _cupsLangPuts(fp, _("Usage: lppasswd [-g groupname]\n"));
+ _cupsLangPuts(fp, _("Usage: lppasswd [-g groupname]"));
else
- _cupsLangPuts(fp,
+ _cupsLangPuts(fp,
_("Usage: lppasswd [-g groupname] [username]\n"
" lppasswd [-g groupname] -a [username]\n"
- " lppasswd [-g groupname] -x [username]\n"));
+ " lppasswd [-g groupname] -x [username]"));
exit(1);
}
/*
- * End of "$Id: lppasswd.c 6649 2007-07-11 21:46:42Z mike $".
+ * End of "$Id: lppasswd.c 10996 2013-05-29 11:51:34Z msweet $".
*/