From owner-freebsd-bugs@FreeBSD.ORG Mon Mar 23 12:19:24 2015 Return-Path: Delivered-To: freebsd-bugs@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id E09BB77F for ; Mon, 23 Mar 2015 12:19:23 +0000 (UTC) Received: from mail-ig0-x22e.google.com (mail-ig0-x22e.google.com [IPv6:2607:f8b0:4001:c05::22e]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id A6C4AFEC for ; Mon, 23 Mar 2015 12:19:23 +0000 (UTC) Received: by igbud6 with SMTP id ud6so40142409igb.1 for ; Mon, 23 Mar 2015 05:19:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=CwLVRfTaqNSGus6plopKfry+C9iQHK5bdZM0lN2fYIM=; b=W+Hk6E4nd6ZllNJSk2B3lM9qC6VYptqfNRLH09ZVtgLyW9VmeuQHgOHASJYJ4nLpPn 9DfAt+1KPtyKost5RuSu3cqeT5udIz5+sb6bZe6bA7FkJlmuYxwJS2k/tMqtydCDgLwa n6o1SliZvcUvmvPXeNpJFQN7rEgJMII3CWN4ZO2pQoOUlyTx0rWbMvlwcJNg/HyJ3L7R LmNePt/HX9ibyZ68/bUENE9k7qEXxlVI4uwRGxDFtWRSCg+0zh6C89PBCjb6eyJOfoAi +e01uNfYOKeWxY2wehvfMgi3ZBYi0a+fawdyI+orQWkps+wQvbcaTsIuPK5G9BokMKcY /5Vw== MIME-Version: 1.0 X-Received: by 10.50.4.97 with SMTP id j1mr13911667igj.46.1427113163160; Mon, 23 Mar 2015 05:19:23 -0700 (PDT) Received: by 10.50.249.177 with HTTP; Mon, 23 Mar 2015 05:19:23 -0700 (PDT) Date: Mon, 23 Mar 2015 20:19:23 +0800 Message-ID: Subject: "pw user mod" with "-G" would add user into group multiple times? From: Peter Xu To: freebsd-bugs@freebsd.org Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.18-1 X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Mar 2015 12:19:24 -0000 Hi, all, I found that I could add the same user into same group for many times, like: root@PeterDev2:/usr/src/lib# pw user mod -n peter1 -G petergroup1 root@PeterDev2:/usr/src/lib# pw group show petergroup1 petergroup1:*:1001:peter1 root@PeterDev2:/usr/src/lib# pw user mod -n peter1 -G petergroup1 root@PeterDev2:/usr/src/lib# pw group show petergroup1 petergroup1:*:1001:peter1,peter1 This is strange. I had a look at the source code at /usr/src/lib/libutil/gr_util.c and found that there is no check on whether the group already has the specific user when doing gr_add(). Further, I checked the commit log of BSD head on SVN, it seems that there was the check: https://svnweb.freebsd.org/base?view=revision&revision=244736 But it is removed in another refactoring: https://svnweb.freebsd.org/base?view=revision&revision=247919 So... Is it a bug? Peter