summaryrefslogtreecommitdiffstats
path: root/adduser
diff options
context:
space:
mode:
authorWolfram Schneider <wosch@FreeBSD.org>1996-12-29 21:56:31 +0000
committerWolfram Schneider <wosch@FreeBSD.org>1996-12-29 21:56:31 +0000
commitd8f99db12f55e1f07f7eb60a408904a29aa56d65 (patch)
treee9fde85ad04ad8a55dfae38918f6a270bd846b4a /adduser
parent77f867733f1e90fa723677dada8e2b5914bbb57c (diff)
downloadpw-darwin-d8f99db12f55e1f07f7eb60a408904a29aa56d65.tar.gz
pw-darwin-d8f99db12f55e1f07f7eb60a408904a29aa56d65.tar.zst
pw-darwin-d8f99db12f55e1f07f7eb60a408904a29aa56d65.zip
Allow dash `-' (except for first char) and underscore `_' in usernames.
pointed out by: max
Diffstat (limited to 'adduser')
-rw-r--r--adduser/adduser.perl6
-rw-r--r--adduser/rmuser.perl6
2 files changed, 7 insertions, 5 deletions
diff --git a/adduser/adduser.perl b/adduser/adduser.perl
index 98ed4a5..42a1c5e 100644
--- a/adduser/adduser.perl
+++ b/adduser/adduser.perl
@@ -24,7 +24,7 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $Id: adduser.perl,v 1.23 1996/12/23 00:10:19 mpp Exp $
+# $Id: adduser.perl,v 1.24 1996/12/29 15:06:52 wosch Exp $
# read variables
@@ -307,7 +307,7 @@ sub new_users_name {
local($name);
while(1) {
- $name = &confirm_list("Enter username", 1, "A-Za-z0-9_", "");
+ $name = &confirm_list("Enter username", 1, "a-z0-9_-", "");
if (length($name) > 16) {
warn "Username is longer than 16 chars\a\n";
next;
@@ -320,7 +320,7 @@ sub new_users_name {
sub new_users_name_valid {
local($name) = @_;
- if ($name !~ /^[a-z0-9]+$/) {
+ if ($name !~ /^[a-z0-9_][a-z0-9_\-]*$/) {
warn "Wrong username. " .
"Please use only lowercase characters or digits\a\n";
return 0;
diff --git a/adduser/rmuser.perl b/adduser/rmuser.perl
index c55862a..73b42ae 100644
--- a/adduser/rmuser.perl
+++ b/adduser/rmuser.perl
@@ -30,7 +30,7 @@
#
# Guy Helmer <ghelmer@alpha.dsu.edu>, 07/17/96
#
-# $Id: rmuser.perl,v 1.1 1996/11/17 03:51:33 wosch Exp $
+# $Id: rmuser.perl,v 1.2 1996/12/07 21:25:12 ache Exp $
sub LOCK_SH {0x01;}
sub LOCK_EX {0x02;}
@@ -101,6 +101,8 @@ if ($< != 0) {
if ($#ARGV == 0) {
# Username was given as a parameter
$login_name = pop(@ARGV);
+ die "Sorry, login name must contain alphanumeric characters only.\n"
+ if ($login_name !~ /^[a-z0-9_][a-z0-9_\-]*$/);
} else {
# Get the user name from the user
$login_name = &get_login_name;
@@ -229,7 +231,7 @@ sub get_login_name {
print "Enter login name for user to remove: ";
$login_name = <>;
chop $login_name;
- if (!($login_name =~ /[A-Za-z0-9_]/)) {
+ if (!($login_name =~ /^[a-z0-9_][a-z0-9_\-]*$/)) {
print STDERR "Sorry, login name must contain alphanumeric characters only.\n";
} elsif (length($login_name) > 16 || length($login_name) == 0) {
print STDERR "Sorry, login name must be 16 characters or less.\n";