Closes #121.
Changelog: squashed commits fixing tab style
Changelog: update 'return true' to match file's style (no parens).
#include "defines.h"
#include "chkname.h"
+int allow_bad_names = false;
+
static bool is_valid_name (const char *name)
{
+ if (allow_bad_names) {
+ return true;
+ }
+
/*
* User/group names must match [a-z_][a-z0-9_-]*[$]
*/
+
if (('\0' == *name) ||
!((('a' <= *name) && ('z' >= *name)) || ('_' == *name))) {
return false;
<para>
The options which apply to the <command>newusers</command> command are:
</para>
+ <variablelist remap='IP'>
+ <varlistentry>
+ <term>
+ <option>--badname</option>
+ </term>
+ <listitem>
+ <para>
+ Allow names that do not conform to standards.
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
<variablelist remap='IP' condition="no_pam">
<varlistentry>
<term><option>-c</option>, <option>--crypt-method</option></term>
The options which apply to the <command>pwck</command> command are:
</para>
<variablelist remap='IP'>
+ <varlistentry>
+ <term>
+ <option>--badname</option>
+ </term>
+ <listitem>
+ <para>
+ Allow names that do not conform to standards.
+ </para>
+ </listitem>
+ </varlistentry>
<varlistentry>
<term><option>-h</option>, <option>--help</option></term>
<listitem>
<para>The options which apply to the <command>useradd</command> command are:
</para>
<variablelist remap='IP'>
+ <varlistentry>
+ <term>
+ <option>--badname</option>
+ </term>
+ <listitem>
+ <para>
+ Allow names that do not conform to standards.
+ </para>
+ </listitem>
+ </varlistentry>
<varlistentry>
<term>
<option>-b</option>, <option>--base-dir</option> <replaceable>BASE_DIR</replaceable>
</para>
</listitem>
</varlistentry>
+ <varlistentry>
+ <term>
+ <option>-b</option>, <option>--badnames</option>
+ </term>
+ <listitem>
+ <para>
+ Allow names that do not conform to standards.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>
+ <option>-b</option>, <option>--badnames</option>
+ </term>
+ <listitem>
+ <para>
+ Allow names that do not conform to standards.
+ </para>
+ </listitem>
+ </varlistentry>
<varlistentry>
<term>
<option>-c</option>, <option>--comment</option> <replaceable>COMMENT</replaceable>
static void open_files (void);
static void close_files (void);
+extern int allow_bad_names;
+
/*
* usage - display usage message and exit
*/
"\n"
"Options:\n"),
Prog);
+ (void) fputs (_(" -b, --badnames allow bad names\n"), usageout);
#ifndef USE_PAM
(void) fprintf (usageout,
_(" -c, --crypt-method METHOD the crypt method (one of %s)\n"),
{
int c;
static struct option long_options[] = {
+ {"badnames", no_argument, NULL, 'b'},
#ifndef USE_PAM
{"crypt-method", required_argument, NULL, 'c'},
#endif /* !USE_PAM */
while ((c = getopt_long (argc, argv,
#ifndef USE_PAM
#ifdef USE_SHA_CRYPT
- "c:hrs:",
+ "c:bhrs:",
#else /* !USE_SHA_CRYPT */
- "c:hr",
+ "c:bhr",
#endif /* !USE_SHA_CRYPT */
#else /* USE_PAM */
- "hr",
+ "bhr",
#endif
long_options, NULL)) != -1) {
switch (c) {
+ case 'b':
+ allow_bad_names = true;
+ break;
#ifndef USE_PAM
case 'c':
crypt_method = optarg;
static void check_pw_file (int *errors, bool *changed);
static void check_spw_file (int *errors, bool *changed);
+extern int allow_bad_names;
+
/*
* fail_exit - do some cleanup and exit with the given error code
*/
"Options:\n"),
Prog);
}
+ (void) fputs (_(" -b, --badnames allow bad names\n"), usageout);
(void) fputs (_(" -h, --help display this help message and exit\n"), usageout);
(void) fputs (_(" -q, --quiet report errors only\n"), usageout);
(void) fputs (_(" -r, --read-only display errors and warnings\n"
{
int c;
static struct option long_options[] = {
+ {"badnames", no_argument, NULL, 'b'},
{"help", no_argument, NULL, 'h'},
{"quiet", no_argument, NULL, 'q'},
{"read-only", no_argument, NULL, 'r'},
/*
* Parse the command line arguments
*/
- while ((c = getopt_long (argc, argv, "ehqrR:s",
+ while ((c = getopt_long (argc, argv, "behqrR:s",
long_options, NULL)) != -1) {
switch (c) {
+ case 'b':
+ allow_bad_names = true;
+ break;
case 'h':
usage (E_SUCCESS);
/*@notreached@*/break;
/*
* Check for invalid usernames. --marekm
*/
+
if (!is_valid_user_name (pwd->pw_name)) {
printf (_("invalid user name '%s'\n"), pwd->pw_name);
*errors += 1;
static long sys_ngroups;
static bool do_grp_update = false; /* group files need to be updated */
+extern int allow_bad_names;
+
static bool
bflg = false, /* new default root of home directory */
cflg = false, /* comment (GECOS) field for new account */
"\n"
"Options:\n"),
Prog, Prog, Prog);
+ (void) fputs (_(" --badnames do not check for bad names\n"), usageout);
(void) fputs (_(" -b, --base-dir BASE_DIR base directory for the home directory of the\n"
" new account\n"), usageout);
#ifdef WITH_BTRFS
#ifdef WITH_BTRFS
{"btrfs-subvolume-home", no_argument, NULL, 200},
#endif
+ {"badnames", no_argument, NULL, 201},
{"comment", required_argument, NULL, 'c'},
{"home-dir", required_argument, NULL, 'd'},
{"defaults", no_argument, NULL, 'D'},
case 200:
subvolflg = true;
break;
+ case 201:
+ allow_bad_names = true;
+ break;
case 'c':
if (!VALID (optarg)) {
fprintf (stderr,
static void move_mailbox (void);
#endif
+extern int allow_bad_names;
+
static void date_to_str (/*@unique@*//*@out@*/char *buf, size_t maxsize,
long int date)
{
"\n"
"Options:\n"),
Prog);
+ (void) fputs (_(" -b, --badnames allow bad names\n"), usageout);
(void) fputs (_(" -c, --comment COMMENT new value of the GECOS field\n"), usageout);
(void) fputs (_(" -d, --home HOME_DIR new home directory for the user account\n"), usageout);
(void) fputs (_(" -e, --expiredate EXPIRE_DATE set account expiration date to EXPIRE_DATE\n"), usageout);
int c;
static struct option long_options[] = {
{"append", no_argument, NULL, 'a'},
+ {"badnames", no_argument, NULL, 'b'},
{"comment", required_argument, NULL, 'c'},
{"home", required_argument, NULL, 'd'},
{"expiredate", required_argument, NULL, 'e'},
{NULL, 0, NULL, '\0'}
};
while ((c = getopt_long (argc, argv,
- "ac:d:e:f:g:G:hl:Lmop:R:s:u:UP:"
+ "abc:d:e:f:g:G:hl:Lmop:R:s:u:UP:"
#ifdef ENABLE_SUBIDS
"v:w:V:W:"
#endif /* ENABLE_SUBIDS */
case 'a':
aflg = true;
break;
+ case 'b':
+ allow_bad_names = true;
+ break;
case 'c':
if (!VALID (optarg)) {
fprintf (stderr,