"pw user mod" with "-G" would add user into group multiple times?
Peter Xu
xzpeter at gmail.com
Mon Mar 23 12:19:24 UTC 2015
Hi, all,
I found that I could add the same user into same group for many times, like:
root at PeterDev2:/usr/src/lib# pw user mod -n peter1 -G petergroup1
root at PeterDev2:/usr/src/lib# pw group show petergroup1
petergroup1:*:1001:peter1
root at PeterDev2:/usr/src/lib# pw user mod -n peter1 -G petergroup1
root at 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
More information about the freebsd-bugs
mailing list