+ if (opts & OPT_GID) {
+ /* -g was there, but "addgroup -g num user group"
+ * is a no-no */
+ bb_show_usage();
+ }
+
+ /* check if group and user exist */
+ xuname2uid(argv[0]); /* unknown user: exit */
+ gr = xgetgrnam(argv[1]); /* unknown group: exit */
+ /* check if user is already in this group */
+ for (; *(gr->gr_mem) != NULL; (gr->gr_mem)++) {
+ if (!strcmp(argv[0], *(gr->gr_mem))) {
+ /* user is already in group: do nothing */
+ return EXIT_SUCCESS;
+ }
+ }
+ if (update_passwd(bb_path_group_file, argv[1], NULL, argv[0]) < 0) {
+ return EXIT_FAILURE;
+ }
+# if ENABLE_FEATURE_SHADOWPASSWDS
+ update_passwd(bb_path_gshadow_file, argv[1], NULL, argv[0]);
+# endif
+ } else
+#endif /* ENABLE_FEATURE_ADDUSER_TO_GROUP */
+ {
+ die_if_bad_username(argv[0]);
+ new_group(argv[0], gid);
+
+ }
+ /* Reached only on success */
+ return EXIT_SUCCESS;