Maxim Bourmistrov wrote:
Hello [EMAIL PROTECTED]
Do we have a bug in 'usermod'?

The situation:
groupadd -g 1111 site1 ; groupadd -g 1112 site12; groupadd -g 1123 site123
then add same user to the groups
usermod -G site1 en;usermod -G site12 en; usermod -G site123 en
user 'en' will appear 3 times in group 'site1' and 2 times in 'site12'

Maxim mentioned this earlier on IRC before mailing and I had a look. The patch below seems to fix it. I know it's trivial but it may save someone a few minutes :-).

--- user.c.orig Wed Jul  6 11:21:25 2005
+++ user.c      Wed Jul  6 11:29:03 2005
@@ -540,7 +540,8 @@
                        continue;
                }
                for (i = 0 ; i < ngroups ; i++) {
-                       if (strncmp(groups[i], buf, colon - buf) == 0) {
+                        if (strlen(groups[i]) == (colon - buf) &&
+                            strncmp(groups[i], buf, colon - buf) == 0) {
                                while (isspace(buf[cc - 1]))
                                        cc--;
                                buf[(j = cc)] = '\0';

Reply via email to