Subject: Re: useradd: spaces and $ in usernames
To: None <tech-userlevel@netbsd.org>
From: Christos Zoulas <christos@zoulas.com>
List: tech-userlevel
Date: 11/16/2001 21:40:27
In article <Pine.GSO.4.21.0111160121580.3526-100000@rfhpc8317>,
Hubert Feyrer <hubert.feyrer@informatik.fh-regensburg.de> wrote:
>On Fri, 16 Nov 2001, Hubert Feyrer wrote:
>> The following patch works at least on 1.5.3_ALPHA, and I'd like to commit
>> it if there are no major objections:
>
>Here's an update that even handles creating, deleting, copying of
>skel-files properly!
Well, not if the file has a quote in it. Look in
/usr/src/usr.bin/make/var.c:VarQuote(), on how to do this properly.
christos
> - Hubert
>
>Index: user.c
>===================================================================
>RCS file: /cvsroot/basesrc/usr.sbin/user/user.c,v
>retrieving revision 1.20.4.8
>diff -u -r1.20.4.8 user.c
>--- user.c 2001/02/26 18:01:17 1.20.4.8
>+++ user.c 2001/11/16 00:20:49
>@@ -243,7 +244,7 @@
>
> (void) seteuid(uid);
> /* we add the "|| true" to keep asystem() quiet if there is a non-zero
>exit status. */
>- (void) asystem("%s -rf %s > /dev/null 2>&1 || true", RM, dir);
>+ (void) asystem("%s -rf '%s' > /dev/null 2>&1 || true", RM, dir);
> (void) seteuid(0);
> if (rmdir(dir) < 0) {
> warnx("Unable to remove all files in `%s'\n", dir);
>@@ -385,11 +386,11 @@
> if (n == 0) {
> warnx("No \"dot\" initialisation files found");
> } else {
>- (void) asystem("cd %s; %s -rw -pe %s . %s",
>+ (void) asystem("cd '%s'; %s -rw -pe %s . '%s'",
> skeldir, PAX, (verbose) ? "-v" : "", dir);
> }
>- (void) asystem("%s -R -h %d:%d %s", CHOWN, uid, gid, dir);
>- (void) asystem("%s -R u+w %s", CHMOD, dir);
>+ (void) asystem("%s -R -h %d:%d '%s'", CHOWN, uid, gid, dir);
>+ (void) asystem("%s -R u+w '%s'", CHMOD, dir);
> return n;
> }
>
>@@ -619,7 +621,7 @@
> char *cp;
>
> for (cp = login ; *cp ; cp++) {
>- if (!isalnum(*cp) && *cp != '.' && *cp != '_' && *cp != '-') {
>+ if (*cp == ':' || *cp == '\'') {
> return 0;
> }
> }
>@@ -971,7 +973,7 @@
> (void) pw_abort();
> errx(EXIT_FAILURE, "home directory `%s' already exists", home);
> } else {
>- if (asystem("%s -p %s", MKDIR, home) != 0) {
>+ if (asystem("%s -p '%s'", MKDIR, home) != 0) {
> (void) close(ptmpfd);
> (void) pw_abort();
> err(EXIT_FAILURE, "can't mkdir `%s'", home);
>@@ -1144,7 +1146,7 @@
> }
> if (up != NULL) {
> if ((up->u_flags & F_MKDIR) &&
>- asystem("%s %s %s", MV, homedir, pwp->pw_dir) != 0) {
>+ asystem("%s '%s' '%s'", MV, homedir, pwp->pw_dir) != 0) {
> (void) close(ptmpfd);
> (void) pw_abort();
> err(EXIT_FAILURE, "can't move `%s' to `%s'",
>
>--
>Want to get a clue on IPv6 but don't know where to start? Try this:
>* Basics -> http://www.onlamp.com/pub/a/onlamp/2001/05/24/ipv6_tutorial.html
>* Setup -> http://www.onlamp.com/pub/a/onlamp/2001/06/01/ipv6_tutorial.html
>Of course with your #1 IPv6 ready operating system -> http://www.NetBSD.org/
>