Debian Bug report logs -
#239238
adduser: addgroup --system fails if group already exists
Reported by: Marc Haber <mh+debian-bugs@zugschlus.de>
Date: Sun, 21 Mar 2004 18:03:01 UTC
Severity: normal
Tags: confirmed, patch
Found in version 3.51
Fixed in version adduser/3.52
Done: Roland Bauerschmidt <rb@debian.org>
Bug is archived. No further changes may be made.
Toggle useless messages
Report forwarded to debian-bugs-dist@lists.debian.org, Roland Bauerschmidt <rb@debian.org>:
Bug#239238; Package adduser.
(full text, mbox, link).
Acknowledgement sent to Marc Haber <mh+debian-bugs@zugschlus.de>:
New Bug report received and forwarded. Copy sent to Roland Bauerschmidt <rb@debian.org>.
(full text, mbox, link).
Message #5 received at submit@bugs.debian.org (full text, mbox, reply):
Package: adduser
Version: 3.51
Severity: normal
Hi,
If adduser --system is called, and the account to be created exists,
and is a system account, adduser complains but returns a successful
exit value.
addgroup should behave the same, but it doesn't - as we determined in
private e-mail.
Additionally, adduser --system fails badly if the group does already
exist:
$ sudo addgroup --system --force-badname Debian-test
Allowing use of questionable username.
Adding group Debian-test (105)...
Done.
$ sudo adduser --group --system --home /var/spool/exim4 --no-create-home --disabled-login --force-badname Debian-test
Allowing use of questionable username.
adduser: The group Debian-test' already exists.
$ echo $?
1
$
Greetings
Marc
-- System Information:
Debian Release: testing/unstable
APT prefers unstable
APT policy: (500, 'unstable')
Architecture: i386 (i686)
Kernel: Linux 2.4.25-darren
Locale: LANG=C, LC_CTYPE=C
Versions of packages adduser depends on:
ii debconf 1.4.16 Debian configuration management sy
ii passwd 1:4.0.3-21 Change and administer password and
ii perl-base 5.8.3-2 The Pathologically Eclectic Rubbis
-- debconf information excluded
Information forwarded to debian-bugs-dist@lists.debian.org, Roland Bauerschmidt <rb@debian.org>:
Bug#239238; Package adduser.
(full text, mbox, link).
Acknowledgement sent to Marc Haber <mh+debian-bugs@zugschlus.de>:
Extra info received and forwarded to list. Copy sent to Roland Bauerschmidt <rb@debian.org>.
(full text, mbox, link).
Message #10 received at 239238@bugs.debian.org (full text, mbox, reply):
tags #239238 patch
thanks
The attached patch solves both problems shown in the bug report, and I
hope that it doesn't introduce new bugs.
Unfortunately, it's pretty intrusive :-(
Greetings
Marc
Index: adduser
===================================================================
RCS file: /var/local/cvs/debian/adduser/adduser,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 adduser
--- a/adduser 28 Aug 2003 19:13:28 -0000 1.1.1.1
+++ b/adduser 23 Mar 2004 19:10:26 -0000
@@ -264,6 +264,11 @@
## addsysgroup ##
#################
if ($action eq "addsysgroup") {
+ # Check if requested group already exists and we can exit safely
+ if (existing_group_ok($new_name, $new_gid)) {
+ printf (_("Group %s does already exist. Exiting...\n"), $new_name) if $verbose;
+ exit 0;
+ }
dief (_("The group `%s' already exists.\n"),$new_name)
if (defined getgrnam($new_name));
dief (_("The GID `%s' is already in use.\n"),$new_gid)
@@ -356,17 +361,13 @@
################
elsif ($action eq "addsysuser") {
# Check if requested user already exists and we can exit safely
- if ((@tuser = getpwnam($new_name)) && (
- (!defined($new_uid) && $tuser[2] >= $config{"first_system_uid"} &&
- $tuser[2] <= $config{"last_system_uid"} ) ||
- (defined($new_uid) && $tuser[2] == $new_uid)
- )) {
+ if (existing_user_ok($new_name, $new_uid)) {
printf (_("User %s does already exist. Exiting...\n"), $new_name) if $verbose;
exit 0;
}
$new_gid = $nogroup_id
if (!$ingroup_name && !defined($new_gid) && !$make_group_also);
- &check_user_group();
+ check_user_group(1);
printf (_("Adding system user %s...\n"),$new_name) if $verbose;
if (!defined($new_uid) && $make_group_also) {
@@ -404,7 +405,8 @@
}
&invalidate_nscd();
- if ($make_group_also) {
+ # if we reach this point, and the group does already exist, we can use it.
+ if ($make_group_also && !getgrnam($new_name)) {
print _("Adding new group $new_name ($new_gid).\n") if $verbose;
$undogroup = $new_name;
&systemcall('/usr/sbin/groupadd', '-g', $new_gid, $new_name);
@@ -451,7 +453,7 @@
if ($config{"usergroups"} eq "yes") { $make_group_also = 1; }
else { $new_gid = $config{"users_gid"}; }
}
- &check_user_group();
+ check_user_group(0);
$first_uid = $new_firstuid || $config{"first_uid"};
$last_uid = $new_lastuid || $config{"last_uid"};
printf _("Adding user %s...\n"),$new_name if $verbose;
@@ -594,16 +596,68 @@
1;
}
+sub existing_user_ok {
+ # returns 1 if
+ # - the user doesn't exist or
+ # - a system user is to be created
+ # - the account already exists as a system user and
+ # - if an explicit UID is given, that UID matches the existing user.
+ my($new_name,$new_uid) = @_;
+ my ($dummy1,$dummy2,$uid);
+ if (($dummy1,$dummy2,$uid) = getpwnam($new_name)) {
+ if( defined($new_uid) && $uid == $new_uid ) {
+ ##+#print "uid";
+ return 1;
+ }
+ if( $uid >= $config{"first_system_uid"} &&
+ $uid <= $config{"last_system_uid" } ) {
+ ##+#print "range";
+ return 1;
+ }
+ } else {
+ ##+#print "existing";
+ return 0;
+ }
+}
+
+sub existing_group_ok {
+ # returns 1 if
+ # - the group doesn't exist or
+ # - a system group is to be created
+ # - the group already exists as a system group and
+ # - if an explicit GID is given, that GID matches the existing group.
+ my($new_name,$new_gid) = @_;
+ my ($dummy1,$dummy2,$gid);
+ if (($dummy1,$dummy2,$gid) = getgrnam($new_name)) {
+ if( defined($new_gid) && $gid == $new_gid ) {
+ return 1;
+ }
+ if( $gid >= $config{"first_system_gid"} &&
+ $gid <= $config{"last_system_gid" } ) {
+ return 1;
+ }
+ } else {
+ return 0;
+ }
+}
-sub check_user_group() {
- dief(_("The user `%s\' already exists.\n"),$new_name) if(defined getpwnam($new_name));
- dief(_("The UID `%s' already exists.\n"),$new_uid)
- if (defined($new_uid) && getpwuid($new_uid));
+sub check_user_group {
+ my ($system) = @_;
+ if( !$system || !existing_user_ok($new_name, $new_uid) ) {
+ dief(_("The user `%s\' already exists.\n"),$new_name)
+ if(defined getpwnam($new_name));
+ dief(_("The UID `%s' already exists.\n"),$new_uid)
+ if (defined($new_uid) && getpwuid($new_uid));
+ }
if ($make_group_also) {
- dief(_("The group `%s' already exists.\n"),$new_name)
- if (defined getgrnam($new_name));
- dief(_("The GID `%s' already exists.\n"),$new_uid)
- if (defined($new_uid) && defined(getgrgid($new_uid)));
+ if( !$system || !existing_group_ok($new_name, $new_uid) ) {
+ print "not system: $system\n" if !$system;
+ print "not OK\n" if !existing_group_ok($new_name, $new_uid);
+ dief(_("The group `%s' already exists.\n"),$new_name)
+ if (defined getgrnam($new_name));
+ dief(_("The GID `%s' already exists.\n"),$new_uid)
+ if (defined($new_uid) && defined(getgrgid($new_uid)));
+ }
}
else {
dief(_("The group `%s' doesn't exist.\n"),$ingroup_name)
Tags added: patch
Request was from Marc Haber <mh+debian-bugs@zugschlus.de>
to control@bugs.debian.org.
(full text, mbox, link).
Tags added: confirmed
Request was from Marc Haber <mh+debian-packages@zugschlus.de>
to control@bugs.debian.org.
(full text, mbox, link).
Acknowledgement sent to Marc Haber <mh+debian-packages@zugschlus.de>:
Extra info received and filed, but not forwarded.
(full text, mbox, link).
Message #19 received at 239238-quiet@bugs.debian.org (full text, mbox, reply):
tags #239238 confirmed
thanks
On Tue, Mar 23, 2004 at 07:22:49PM +0000, Marc Haber wrote:
> The attached patch solves both problems shown in the bug report, and I
> hope that it doesn't introduce new bugs.
As I now have write access to adduser svn, this patch will be
included in the next version.
Greetings
Marc
--
-----------------------------------------------------------------------------
Marc Haber | "I don't trust Computers. They | Mailadresse im Header
Karlsruhe, Germany | lose things." Winona Ryder | Fon: *49 721 966 32 15
Nordisch by Nature | How to make an American Quilt | Fax: *49 721 966 31 29
Tags added: pending
Request was from Marc Haber <mh+debian-packages@zugschlus.de>
to control@bugs.debian.org.
(full text, mbox, link).
Acknowledgement sent to Marc Haber <mh+debian-packages@zugschlus.de>:
Extra info received and filed, but not forwarded.
(full text, mbox, link).
Message #26 received at 239238-quiet@bugs.debian.org (full text, mbox, reply):
tags #239238 pending
tags #143738 pending
thanks
committed to svn:
* addgroup --system does no longer fail if system group already
exists. Closes: #239238.
* adduser now gives clearer error messages when user/group to be
created as system user/group already exists as non-system.
Thanks to Henrique de Moraes Holschuh. Closes: #143738.
Greetings
Marc
--
-----------------------------------------------------------------------------
Marc Haber | "I don't trust Computers. They | Mailadresse im Header
Karlsruhe, Germany | lose things." Winona Ryder | Fon: *49 721 966 32 15
Nordisch by Nature | How to make an American Quilt | Fax: *49 721 966 31 29
Reply sent to Roland Bauerschmidt <rb@debian.org>:
You have taken responsibility.
(full text, mbox, link).
Notification sent to Marc Haber <mh+debian-bugs@zugschlus.de>:
Bug acknowledged by developer.
(full text, mbox, link).
Message #31 received at 239238-close@bugs.debian.org (full text, mbox, reply):
Source: adduser
Source-Version: 3.52
We believe that the bug you reported is fixed in the latest version of
adduser, which is due to be installed in the Debian FTP archive:
adduser_3.52.dsc
to pool/main/a/adduser/adduser_3.52.dsc
adduser_3.52.tar.gz
to pool/main/a/adduser/adduser_3.52.tar.gz
adduser_3.52_all.deb
to pool/main/a/adduser/adduser_3.52_all.deb
A summary of the changes between this version and the previous one is
attached.
Thank you for reporting the bug, which will now be closed. If you
have further comments please address them to 239238@bugs.debian.org,
and the maintainer will reopen the bug report if appropriate.
Debian distribution maintenance software
pp.
Roland Bauerschmidt <rb@debian.org> (supplier of updated adduser package)
(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing ftpmaster@debian.org)
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Format: 1.7
Date: Sun, 28 Mar 2004 17:57:26 +0200
Source: adduser
Binary: adduser
Architecture: source all
Version: 3.52
Distribution: unstable
Urgency: low
Maintainer: Roland Bauerschmidt <rb@debian.org>
Changed-By: Roland Bauerschmidt <rb@debian.org>
Description:
adduser - Add and remove users and groups
Closes: 138618 141016 143738 156013 158370 190631 207944 215025 215364 216420 219438 223828 230360 230364 230381 230651 232062 233285 233552 236494 238807 238923 239140 239236 239238 239261 239376 239579 240103
Changes:
adduser (3.52) unstable; urgency=low
.
* Roland Bauerschmidt:
* Removed junk from po/nb.po.
* Updated Brazilian Portuguese translation of the Debconf
templates by Andre Luis Lopes <andrelop@debian.org>.
Closes: #207944.
* Updated Catalan translations by Jordi Mallach <jordi@debian.org>
Closes: #190631.
* Updated Dutch translation of the Debconf templates by
cobaco@linux.be. Closes: #215364.
* Fixed POT file generation, patch provided by Eugeniy Meshcheryakov
<eugen@univ.kiev.ua>. Closes: #233285.
The "-L Perl" is added to xgettext, which imposes a versioned
dependency on gettext >= 0.13.
* Updated Swedish translation of the Debconf templates by
Leonard Norrgard <vinsci@refactor.fi>. Closes: #230381.
* Fixed a typo in Spanish translation, reported by Jesus Roncero
<jesus@roncero.org>. Closes: #223828.
* Updated Danish translation by Morten Brix Pedersen <morten@wtf.dk>.
Closes: #216420.
* Added Simplified Chinese translations, both for programs and
Debconf templates, by Carlos Z.F. Liu <carlos_liu@yahoo.com>.
Closes: #230651.
* Added Czech translations, both for programs and Debconf templates, by
Miroslav Kure <kurem@upcase.inf.upol.cz>. Closes: #232062.
* Added Ukranian translations, both for programs and Debconf templates,
by Eugeniy Meshcheryakov <eugen@univ.kiev.ua>. Closes: #233552.
* Applied patch by Denis Barbier <barbier@debian.org> for most translation
related changes. Thanks a lot for the help. Closes: #236494.
.
* Marc Haber:
* add myself to Uploaders: and debian/copyright.
* modify changelog to see who did which change.
* fix adduser.8 to correctly document adduser --system --group.
Renamed translated adduser.8 man pages after discussion on
#debian-devel. Closes: #239236. Closes: #219438.
* addgroup --system does no longer fail if system group already
exists. Closes: #239238.
* adduser now gives clearer error messages when user/group to be
created as system user/group already exists as non-system.
Thanks to Henrique de Moraes Holschuh. Closes: #143738.
* add --system option to deluser. Adapt man pages. Rename
translated man pages. Closes: #239261.
* add --home option to deluser. Adapt man page. Closes: #239376
* adapt deluser's systemcall() to honor --debug
* add --only-if-empty switch to delgroup. Adapt man page.
Closes: #239579
* delgroup will of course delete non-system groups, contrary to
comments and docs. Fix comments and docs
* Improve warnings regarding --no-create-home. Thanks to Chris
Halls. Closes: #141016.
* deluser: Check for existing $pw_homedir before find to avoid
warning if home dir not present.
* fix debconf UI reference in templates. Thanks to Joey Hess.
Closes: #215025.
* fix german debconf template.
* capitalize default choice N in correctness prompt of code and
po files. Thanks to Justin B Rye. Closes: #238807.
* Add turkish po-debconf translation. Thanks to Recai Oktas.
Closes: #239140.
* Include alioth link and mailing list to package description.
* add --backup-to parameter to deluser. Closes: #138618.
* Include updated Swedish translation of debconf template. Thanks
to André Dahlqvist. Closes: #238923.
* recode changelog to utf-8.
* honor setgid_home for directories in /etc/skel. Thanks to Jeff
Tranter. Closes: #158370.
* use temporary file for backup file list. Thanks to Christoph
Ulrich Scholler. Closes: #230364. Closes: #230360.
* hand down --quiet and --debug settings to adduser.local. Thanks
to Karl M. Hegbloom. Closes: #240103. Closes: #156013.
* Standards-Version: 3.6.1
Files:
2eefdb9f26c59c51efab05877d8fdbd9 561 base important adduser_3.52.dsc
24d1420ac2b2f8ac0a45feaea46707a0 91591 base important adduser_3.52.tar.gz
63f44ac383cfdb81922c6633965ad76a 74644 base important adduser_3.52_all.deb
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
iD8DBQFAZvZDDpXnNan6F/8RAn6dAKCBOAbq2BPuWjfTsCKWy+aZr2yDPwCgke3W
TnGZdqUeRiulkLv6HPZqrXI=
=Kt4D
-----END PGP SIGNATURE-----
Send a report that this bug log contains spam.
Debian bug tracking system administrator <owner@bugs.debian.org>.
Last modified:
Thu Jan 4 23:57:58 2018;
Machine Name:
buxtehude
Debian Bug tracking system
Debbugs is free software and licensed under the terms of the GNU
Public License version 2. The current version can be obtained
from https://bugs.debian.org/debbugs-source/.
Copyright © 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson,
2005-2017 Don Armstrong, and many other contributors.