Date: Thu, 19 Nov 1998 01:45:29 +0900 (JST) From: yohta@bres.tsukuba.ac.jp To: FreeBSD-gnats-submit@FreeBSD.ORG Subject: bin/8745: adduser permit adding `root' and mail aliased username Message-ID: <199811181645.BAA02656@rishiri.bsys.tsukuba.ac.jp>
next in thread | raw e-mail | index | archive | help
>Number: 8745
>Category: bin
>Synopsis: adduser permit adding `root' and mail aliased username
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Wed Nov 18 08:50:01 PST 1998
>Last-Modified:
>Originator: Yoshihiko OHTA
>Organization:
University of Tsukuba
>Release: FreeBSD 2.2.7-RELEASE i386
>Environment:
FreeBSD rishiri.bsys.tsukuba.ac.jp 2.2.7-RELEASE FreeBSD 2.2.7-RELEASE #0: Fri
Nov 6 00:01:44 JST 1998
yohta@rishiri.bsys.tsukuba.ac.jp:/usr/src/sys/compile/FMVTP i386
>Description:
adduser(8) checkes username before really add to database if
new username is already used or not. But it can't reject
`root' because its uid = 0 (`if' statement return false).
And I propose to check mail aliases too.
>How-To-Repeat:
# adduser -batch root user default "Charlie &" Password
>Fix:
I propose below patch. It may not deal with all potential
problem, and not thought deaply.
I make this patch with 2.2.7-RELEASE(adduser.perl,v 1.19.2.10)
but patchable to FreeBSD-current(adduser.perl,v 1.41).
--- /usr/sbin/adduser Wed Jul 22 17:15:20 1998
+++ /home/yohta/bin/adduser Thu Nov 19 01:28:47 1998
@@ -41,6 +41,7 @@
$home = "/home"; # default HOME
$etc_shells = "/etc/shells";
$etc_passwd = "/etc/master.passwd";
+ $sendmail_cf = "/etc/sendmail.cf";
$group = "/etc/group";
$pwd_mkdb = "pwd_mkdb -p"; # program for building passwd database
@@ -66,6 +67,9 @@
$password = ''; # password for new users
+ # mailaliases
+ $aliasname = ''; # mail aliases of sendmail
+
# group
$groupname =''; # $groupname{groupname} = gid
$groupmembers = ''; # $groupmembers{gid} = members of group/kommalist
@@ -256,6 +260,40 @@
close P;
}
+# read /etc/aliases and some(if exist)
+sub mailalias_read {
+ local(@aliasfile, $aliases, $item, $description);
+
+ print "Check $sendmail_cf\n" if $verbose;
+ open(A, "$sendmail_cf") || die "$sendmail_cf: $!\n";
+
+ while(<A>) {
+ chop;
+ if (/^O AliasFile=/) {
+ s/^O AliasFile=//;
+ s/\s.*$//;
+ push(@aliasesfile, split(/,/, $_));
+ }
+ }
+ close A;
+
+ foreach $aliases (@aliasesfile) {
+ open(A, $aliases) || die "$aliases: $!\n";
+ while (<A>) {
+ chop;
+ # ignore comments
+ next if /^\s*$/;
+ next if /^\s*#/;
+
+ ($item, $description) = split(/\s*:\s*/, $_, 2);
+ print "$item already exists with alias: $aliasname{$item}!\n"
+ if $aliasname{$item} && $verbose;
+ $aliasname{$item} = $description;
+ }
+ close A;
+ }
+}
+
# read /etc/group
sub group_read {
local($g_groupname,$pw,$g_gid, $memb);
@@ -321,8 +359,17 @@
warn "Wrong username. " .
"Please use only lowercase characters or digits\a\n";
return 0;
- } elsif ($username{$name}) {
+ } elsif (defined($username{$name})) {
warn "Username ``$name'' already exists!\a\n"; return 0;
+ } elsif ($aliasname{$name}) {
+ warn "Mail alias ``$name'' already exists!\a\n";
+ if ($#batch < 0) {
+ return 0 unless
+ &confirm_yn("Really want to continue with this username?",
+ "yes");
+ } else {
+ warn "But going on...\n";
+ }
}
return $name;
}
@@ -1437,6 +1484,7 @@
&passwd_check; # check for valid passwdb
&shells_read; # read /etc/shells
&passwd_read; # read /etc/master.passwd
+&mailalias_read; # read /etc/aliases and some(if exist)
&group_read; # read /etc/group
&group_check; # check for incon*
exit 0 if $check_only; # only check consistence and exit
>Audit-Trail:
>Unformatted:
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199811181645.BAA02656>
