openbmc/build/tmp/deploy/sdk/witherspoon-2019-08-08/sysroots/armv6-openbmc-linux-gnueabi/usr/src/debug/shadow/4.6-r0/shadow-4.6/libmisc/find_new_gid.c
int find_new_gid(bool sys_group, gid_t* gid,
                 /*@null@*/ gid_t const* preferred_gid)
{
    bool* used_gids;
    const struct group* grp;
    gid_t gid_min, gid_max, preferred_min;
    gid_t group_id, id;
    gid_t lowest_found, highest_found;
    int result;
    int nospam = 0;

    assert(gid != NULL);

    /*
     * First, figure out what ID range is appropriate for
     * automatic assignment
     */
    result = get_ranges(sys_group, &gid_min, &gid_max, &preferred_min);
    if (result == EINVAL)
    {
        return -1;
    }

    /* Check if the preferred GID is available */
    if (preferred_gid)
    {
        result = check_gid(*preferred_gid, preferred_min, gid_max, NULL);
        if (result == 0)
        {
            /*
             * Make sure the GID isn't queued for use already
             */
            if (gr_locate_gid(*preferred_gid) == NULL)
            {
                *gid = *preferred_gid;
                return 0;
            }
            /*
             * gr_locate_gid() found the GID in an as-yet uncommitted
             * entry. We'll proceed below and auto-set a GID.
             */
        }
        else if (result == EEXIST || result == ERANGE)
        {
            /*
             * Continue on below. At this time, we won't
             * treat these two cases differently.
             */
        }
        else
        {
            /*
             * An unexpected error occurred. We should report
             * this and fail the group creation.
             * This differs from the automatic creation
             * behavior below, since if a specific GID was
             * requested and generated an error, the user is
             * more likely to want to stop and address the
             * issue.
             */
            fprintf(stderr,
                    _("%s: Encountered error attempting to use "
                      "preferred GID: %s\n"),
                    Prog, strerror(result));
            return -1;
        }
    }

    /*
     * Search the entire group file,
     * looking for the next unused value.
     *
     * We first check the local database with gr_rewind/gr_next to find
     * all local values that are in use.
     *
     * We then compare the next free value to all databases (local and
     * remote) and iterate until we find a free one. If there are free
     * values beyond the lowest (system groups) or highest (non-system
     * groups), we will prefer those and avoid potentially reclaiming a
     * deleted group (which can be a security issue, since it may grant
     * access to files belonging to that former group).
     *
     * If there are no GIDs available at the end of the search, we will
     * have no choice but to iterate through the range looking for gaps.
     *
     */

    /* Create an array to hold all of the discovered GIDs */
    used_gids = malloc(sizeof(bool) * (gid_max + 1));
    if (NULL == used_gids)
    {
        fprintf(stderr, _("%s: failed to allocate memory: %s\n"), Prog,
                strerror(errno));
        return -1;
    }
    memset(used_gids, false, sizeof(bool) * (gid_max + 1));

    /* First look for the lowest and highest value in the local database */
    (void)gr_rewind();
    highest_found = gid_min;
    lowest_found = gid_max;
    while ((grp = gr_next()) != NULL)
    {
        /*
         * Does this entry have a lower GID than the lowest we've found
         * so far?
         */
        if ((grp->gr_gid <= lowest_found) && (grp->gr_gid >= gid_min))
        {
            lowest_found = grp->gr_gid - 1;
        }

        /*
         * Does this entry have a higher GID than the highest we've found
         * so far?
         */
        if ((grp->gr_gid >= highest_found) && (grp->gr_gid <= gid_max))
        {
            highest_found = grp->gr_gid + 1;
        }

        /* create index of used GIDs */
        if (grp->gr_gid >= gid_min && grp->gr_gid <= gid_max)
        {

            used_gids[grp->gr_gid] = true;
        }
    }

    if (sys_group)
    {
        /*
         * For system groups, we want to start from the
         * top of the range and work downwards.
         */

        /*
         * At the conclusion of the gr_next() search, we will either
         * have a presumed-free GID or we will be at GID_MIN - 1.
         */
        if (lowest_found < gid_min)
        {
            /*
             * In this case, a GID is in use at GID_MIN.
             *
             * We will reset the search to GID_MAX and proceed down
             * through all the GIDs (skipping those we detected with
             * used_gids) for a free one. It is a known issue that
             * this may result in reusing a previously-deleted GID,
             * so administrators should be instructed to use this
             * auto-detection with care (and prefer to assign GIDs
             * explicitly).
             */
            lowest_found = gid_max;
        }

        /* Search through all of the IDs in the range */
        for (id = lowest_found; id >= gid_min; id--)
        {
            result = check_gid(id, gid_min, gid_max, used_gids);
            if (result == 0)
            {
                /* This GID is available. Return it. */
                *gid = id;
                free(used_gids);
                return 0;
            }
            else if (result == EEXIST)
            {
                /* This GID is in use, we'll continue to the next */
            }
            else
            {
                /*
                 * An unexpected error occurred.
                 *
                 * Only report it the first time to avoid spamming
                 * the logs
                 *
                 */
                if (!nospam)
                {
                    fprintf(stderr,
                            _("%s: Can't get unique system GID (%s). "
                              "Suppressing additional messages.\n"),
                            Prog, strerror(result));
                    SYSLOG((LOG_ERR, "Error checking available GIDs: %s",
                            strerror(result)));
                    nospam = 1;
                }
                /*
                 * We will continue anyway. Hopefully a later GID
                 * will work properly.
                 */
            }
        }

        /*
         * If we get all the way through the loop, try again from GID_MAX,
         * unless that was where we previously started. (NOTE: the worst-case
         * scenario here is that we will run through (GID_MAX - GID_MIN - 1)
         * cycles *again* if we fall into this case with lowest_found as
         * GID_MAX - 1, all groups in the range in use and maintained by
         * network services such as LDAP.)
         */
        if (lowest_found != gid_max)
        {
            for (id = gid_max; id >= gid_min; id--)
            {
                result = check_gid(id, gid_min, gid_max, used_gids);
                if (result == 0)
                {
                    /* This GID is available. Return it. */
                    *gid = id;
                    free(used_gids);
                    return 0;
                }
                else if (result == EEXIST)
                {
                    /* This GID is in use, we'll continue to the next */
                }
                else
                {
                    /*
                     * An unexpected error occurred.
                     *
                     * Only report it the first time to avoid spamming
                     * the logs
                     *
                     */
                    if (!nospam)
                    {
                        fprintf(stderr,
                                _("%s: Can't get unique system GID (%s). "
                                  "Suppressing additional messages.\n"),
                                Prog, strerror(result));
                        SYSLOG((LOG_ERR, "Error checking available GIDs: %s",
                                strerror(result)));
                        nospam = 1;
                    }
                    /*
                     * We will continue anyway. Hopefully a later GID
                     * will work properly.
                     */
                }
            }
        }
    }
    else
    { /* !sys_group */
        /*
         * For non-system groups, we want to start from the
         * bottom of the range and work upwards.
         */

        /*
         * At the conclusion of the gr_next() search, we will either
         * have a presumed-free GID or we will be at GID_MAX + 1.
         */
        if (highest_found > gid_max)
        {
            /*
             * In this case, a GID is in use at GID_MAX.
             *
             * We will reset the search to GID_MIN and proceed up
             * through all the GIDs (skipping those we detected with
             * used_gids) for a free one. It is a known issue that
             * this may result in reusing a previously-deleted GID,
             * so administrators should be instructed to use this
             * auto-detection with care (and prefer to assign GIDs
             * explicitly).
             */
            highest_found = gid_min;
        }

        /* Search through all of the IDs in the range */
        for (id = highest_found; id <= gid_max; id++)
        {
            result = check_gid(id, gid_min, gid_max, used_gids);
            if (result == 0)
            {
                /* This GID is available. Return it. */
                *gid = id;
                free(used_gids);
                return 0;
            }
            else if (result == EEXIST)
            {
                /* This GID is in use, we'll continue to the next */
            }
            else
            {
                /*
                 * An unexpected error occurred.
                 *
                 * Only report it the first time to avoid spamming
                 * the logs
                 *
                 */
                if (!nospam)
                {
                    fprintf(stderr,
                            _("%s: Can't get unique GID (%s). "
                              "Suppressing additional messages.\n"),
                            Prog, strerror(result));
                    SYSLOG((LOG_ERR, "Error checking available GIDs: %s",
                            strerror(result)));
                    nospam = 1;
                }
                /*
                 * We will continue anyway. Hopefully a later GID
                 * will work properly.
                 */
            }
        }

        /*
         * If we get all the way through the loop, try again from GID_MIN,
         * unless that was where we previously started. (NOTE: the worst-case
         * scenario here is that we will run through (GID_MAX - GID_MIN - 1)
         * cycles *again* if we fall into this case with highest_found as
         * GID_MIN + 1, all groups in the range in use and maintained by
         * network services such as LDAP.)
         */
        if (highest_found != gid_min)
        {
            for (id = gid_min; id <= gid_max; id++)
            {
                result = check_gid(id, gid_min, gid_max, used_gids);
                if (result == 0)
                {
                    /* This GID is available. Return it. */
                    *gid = id;
                    free(used_gids);
                    return 0;
                }
                else if (result == EEXIST)
                {
                    /* This GID is in use, we'll continue to the next */
                }
                else
                {
                    /*
                     * An unexpected error occurred.
                     *
                     * Only report it the first time to avoid spamming
                     * the logs
                     *
                     */
                    if (!nospam)
                    {
                        fprintf(stderr,
                                _("%s: Can't get unique GID (%s). "
                                  "Suppressing additional messages.\n"),
                                Prog, strerror(result));
                        SYSLOG((LOG_ERR, "Error checking available GIDs: %s",
                                strerror(result)));
                        nospam = 1;
                    }
                    /*
                     * We will continue anyway. Hopefully a later GID
                     * will work properly.
                     */
                }
            }
        }
    }

    /* The code reached here and found no available IDs in the range */
    fprintf(stderr, _("%s: Can't get unique GID (no more available GIDs)\n"),
            Prog);
    SYSLOG((LOG_WARN, "no more available GIDs on the system"));
    free(used_gids);
    return -1;
}
/*
 * find_new_gid - Find a new unused GID.
 *
 * If successful, find_new_gid provides an unused group ID in the
 * [GID_MIN:GID_MAX] range.
 * This ID should be higher than all the used GID, but if not possible,
 * the lowest unused ID in the range will be returned.
 *
 * Return 0 on success, -1 if no unused GIDs are available.
 */
Find a new unused GID.
If successful, find_new_gid provides an unused group ID in the
[GID_MIN:GID_MAX] range.
This ID should be higher than all the used GID, but if not possible,
the lowest unused ID in the range will be returned.

Return 0 on success, -1 if no unused GIDs are available.
Find a new unused GID . If successful find_new_gid provides an unused group ID in the [ GID_MIN : GID_MAX ] range . This ID should be higher than all the used GID but if not possible the lowest unused ID in the range will be returned . Return 0 on success - 1 if no unused GIDs are available .
int find_new_gid(bool sys_group, gid_t* gid,
                  gid_t const* preferred_gid)
{
    bool* used_gids;
    const struct group* grp;
    gid_t gid_min, gid_max, preferred_min;
    gid_t group_id, id;
    gid_t lowest_found, highest_found;
    int result;
    int nospam = 0;
    assert(gid != NULL);
    result = get_ranges(sys_group, &gid_min, &gid_max, &preferred_min);
    if (result == EINVAL)
    {
        return -1;
    }
    if (preferred_gid)
    {
        result = check_gid(*preferred_gid, preferred_min, gid_max, NULL);
        if (result == 0)
        {
            if (gr_locate_gid(*preferred_gid) == NULL)
            {
                *gid = *preferred_gid;
                return 0;
            }
        }
        else if (result == EEXIST || result == ERANGE)
        {
        }
        else
        {
            fprintf(stderr,
                    _("%s: Encountered error attempting to use "
                      "preferred GID: %s\n"),
                    Prog, strerror(result));
            return -1;
        }
    }
    used_gids = malloc(sizeof(bool) * (gid_max + 1));
    if (NULL == used_gids)
    {
        fprintf(stderr, _("%s: failed to allocate memory: %s\n"), Prog,
                strerror(errno));
        return -1;
    }
    memset(used_gids, false, sizeof(bool) * (gid_max + 1));
    (void)gr_rewind();
    highest_found = gid_min;
    lowest_found = gid_max;
    while ((grp = gr_next()) != NULL)
    {
        if ((grp->gr_gid <= lowest_found) && (grp->gr_gid >= gid_min))
        {
            lowest_found = grp->gr_gid - 1;
        }
        if ((grp->gr_gid >= highest_found) && (grp->gr_gid <= gid_max))
        {
            highest_found = grp->gr_gid + 1;
        }
        if (grp->gr_gid >= gid_min && grp->gr_gid <= gid_max)
        {
            used_gids[grp->gr_gid] = true;
        }
    }
    if (sys_group)
    {
        if (lowest_found < gid_min)
        {
            lowest_found = gid_max;
        }
        for (id = lowest_found; id >= gid_min; id--)
        {
            result = check_gid(id, gid_min, gid_max, used_gids);
            if (result == 0)
            {
                *gid = id;
                free(used_gids);
                return 0;
            }
            else if (result == EEXIST)
            {
            }
            else
            {
                if (!nospam)
                {
                    fprintf(stderr,
                            _("%s: Can't get unique system GID (%s). "
                              "Suppressing additional messages.\n"),
                            Prog, strerror(result));
                    SYSLOG((LOG_ERR, "Error checking available GIDs: %s",
                            strerror(result)));
                    nospam = 1;
                }
            }
        }
        if (lowest_found != gid_max)
        {
            for (id = gid_max; id >= gid_min; id--)
            {
                result = check_gid(id, gid_min, gid_max, used_gids);
                if (result == 0)
                {
                    *gid = id;
                    free(used_gids);
                    return 0;
                }
                else if (result == EEXIST)
                {
                }
                else
                {
                    if (!nospam)
                    {
                        fprintf(stderr,
                                _("%s: Can't get unique system GID (%s). "
                                  "Suppressing additional messages.\n"),
                                Prog, strerror(result));
                        SYSLOG((LOG_ERR, "Error checking available GIDs: %s",
                                strerror(result)));
                        nospam = 1;
                    }
                }
            }
        }
    }
    else
    { 
        if (highest_found > gid_max)
        {
            highest_found = gid_min;
        }
        for (id = highest_found; id <= gid_max; id++)
        {
            result = check_gid(id, gid_min, gid_max, used_gids);
            if (result == 0)
            {
                *gid = id;
                free(used_gids);
                return 0;
            }
            else if (result == EEXIST)
            {
            }
            else
            {
                if (!nospam)
                {
                    fprintf(stderr,
                            _("%s: Can't get unique GID (%s). "
                              "Suppressing additional messages.\n"),
                            Prog, strerror(result));
                    SYSLOG((LOG_ERR, "Error checking available GIDs: %s",
                            strerror(result)));
                    nospam = 1;
                }
            }
        }
        if (highest_found != gid_min)
        {
            for (id = gid_min; id <= gid_max; id++)
            {
                result = check_gid(id, gid_min, gid_max, used_gids);
                if (result == 0)
                {
                    *gid = id;
                    free(used_gids);
                    return 0;
                }
                else if (result == EEXIST)
                {
                }
                else
                {
                    if (!nospam)
                    {
                        fprintf(stderr,
                                _("%s: Can't get unique GID (%s). "
                                  "Suppressing additional messages.\n"),
                                Prog, strerror(result));
                        SYSLOG((LOG_ERR, "Error checking available GIDs: %s",
                                strerror(result)));
                        nospam = 1;
                    }
                }
            }
        }
    }
    fprintf(stderr, _("%s: Can't get unique GID (no more available GIDs)\n"),
            Prog);
    SYSLOG((LOG_WARN, "no more available GIDs on the system"));
    free(used_gids);
    return -1;
}
int find_new_gid ( bool sys_group , gid_t * gid , gid_t const * preferred_gid ) { bool * used_gids ; const struct group * grp ; gid_t gid_min , gid_max , preferred_min ; gid_t group_id , id ; gid_t lowest_found , highest_found ; int result ; int nospam = 0 ; assert ( gid != NULL ) ; result = get_ranges ( sys_group , & gid_min , & gid_max , & preferred_min ) ; if ( result == EINVAL ) { return -1 ; } if ( preferred_gid ) { result = check_gid ( * preferred_gid , preferred_min , gid_max , NULL ) ; if ( result == 0 ) { if ( gr_locate_gid ( * preferred_gid ) == NULL ) { * gid = * preferred_gid ; return 0 ; } } else if ( result == EEXIST || result == ERANGE ) { } else { fprintf ( stderr , _ ( " " " \n " ) , Prog , strerror ( result ) ) ; return -1 ; } } used_gids = malloc ( sizeof ( bool ) * ( gid_max + 1 ) ) ; if ( NULL == used_gids ) { fprintf ( stderr , _ ( " \n " ) , Prog , strerror ( errno ) ) ; return -1 ; } memset ( used_gids , false , sizeof ( bool ) * ( gid_max + 1 ) ) ; ( void ) gr_rewind ( ) ; highest_found = gid_min ; lowest_found = gid_max ; while ( ( grp = gr_next ( ) ) != NULL ) { if ( ( grp -> gr_gid <= lowest_found ) && ( grp -> gr_gid >= gid_min ) ) { lowest_found = grp -> gr_gid - 1 ; } if ( ( grp -> gr_gid >= highest_found ) && ( grp -> gr_gid <= gid_max ) ) { highest_found = grp -> gr_gid + 1 ; } if ( grp -> gr_gid >= gid_min && grp -> gr_gid <= gid_max ) { used_gids [ grp -> gr_gid ] = true ; } } if ( sys_group ) { if ( lowest_found < gid_min ) { lowest_found = gid_max ; } for ( id = lowest_found ; id >= gid_min ; id -- ) { result = check_gid ( id , gid_min , gid_max , used_gids ) ; if ( result == 0 ) { * gid = id ; free ( used_gids ) ; return 0 ; } else if ( result == EEXIST ) { } else { if ( ! nospam ) { fprintf ( stderr , _ ( " " " \n " ) , Prog , strerror ( result ) ) ; SYSLOG ( ( LOG_ERR , " " , strerror ( result ) ) ) ; nospam = 1 ; } } } if ( lowest_found != gid_max ) { for ( id = gid_max ; id >= gid_min ; id -- ) { result = check_gid ( id , gid_min , gid_max , used_gids ) ; if ( result == 0 ) { * gid = id ; free ( used_gids ) ; return 0 ; } else if ( result == EEXIST ) { } else { if ( ! nospam ) { fprintf ( stderr , _ ( " " " \n " ) , Prog , strerror ( result ) ) ; SYSLOG ( ( LOG_ERR , " " , strerror ( result ) ) ) ; nospam = 1 ; } } } } } else { if ( highest_found > gid_max ) { highest_found = gid_min ; } for ( id = highest_found ; id <= gid_max ; id ++ ) { result = check_gid ( id , gid_min , gid_max , used_gids ) ; if ( result == 0 ) { * gid = id ; free ( used_gids ) ; return 0 ; } else if ( result == EEXIST ) { } else { if ( ! nospam ) { fprintf ( stderr , _ ( " " " \n " ) , Prog , strerror ( result ) ) ; SYSLOG ( ( LOG_ERR , " " , strerror ( result ) ) ) ; nospam = 1 ; } } } if ( highest_found != gid_min ) { for ( id = gid_min ; id <= gid_max ; id ++ ) { result = check_gid ( id , gid_min , gid_max , used_gids ) ; if ( result == 0 ) { * gid = id ; free ( used_gids ) ; return 0 ; } else if ( result == EEXIST ) { } else { if ( ! nospam ) { fprintf ( stderr , _ ( " " " \n " ) , Prog , strerror ( result ) ) ; SYSLOG ( ( LOG_ERR , " " , strerror ( result ) ) ) ; nospam = 1 ; } } } } } fprintf ( stderr , _ ( " \n " ) , Prog ) ; SYSLOG ( ( LOG_WARN , " " ) ) ; free ( used_gids ) ; return -1 ; }
find_new_gid - Find a new unused GID.
find_new_gid - Find a new unused GID .
/*@null@*/ /*
     * First, figure out what ID range is appropriate for
     * automatic assignment
     */ /* Check if the preferred GID is available */ /*
             * Make sure the GID isn't queued for use already
             */ /*
             * gr_locate_gid() found the GID in an as-yet uncommitted
             * entry. We'll proceed below and auto-set a GID.
             */ /*
             * Continue on below. At this time, we won't
             * treat these two cases differently.
             */ /*
             * An unexpected error occurred. We should report
             * this and fail the group creation.
             * This differs from the automatic creation
             * behavior below, since if a specific GID was
             * requested and generated an error, the user is
             * more likely to want to stop and address the
             * issue.
             */ /*
     * Search the entire group file,
     * looking for the next unused value.
     *
     * We first check the local database with gr_rewind/gr_next to find
     * all local values that are in use.
     *
     * We then compare the next free value to all databases (local and
     * remote) and iterate until we find a free one. If there are free
     * values beyond the lowest (system groups) or highest (non-system
     * groups), we will prefer those and avoid potentially reclaiming a
     * deleted group (which can be a security issue, since it may grant
     * access to files belonging to that former group).
     *
     * If there are no GIDs available at the end of the search, we will
     * have no choice but to iterate through the range looking for gaps.
     *
     */ /* Create an array to hold all of the discovered GIDs */ /* First look for the lowest and highest value in the local database */ /*
         * Does this entry have a lower GID than the lowest we've found
         * so far?
         */ /*
         * Does this entry have a higher GID than the highest we've found
         * so far?
         */ /* create index of used GIDs */ /*
         * For system groups, we want to start from the
         * top of the range and work downwards.
         */ /*
         * At the conclusion of the gr_next() search, we will either
         * have a presumed-free GID or we will be at GID_MIN - 1.
         */ /*
             * In this case, a GID is in use at GID_MIN.
             *
             * We will reset the search to GID_MAX and proceed down
             * through all the GIDs (skipping those we detected with
             * used_gids) for a free one. It is a known issue that
             * this may result in reusing a previously-deleted GID,
             * so administrators should be instructed to use this
             * auto-detection with care (and prefer to assign GIDs
             * explicitly).
             */ /* Search through all of the IDs in the range */ /* This GID is available. Return it. */ /* This GID is in use, we'll continue to the next */ /*
                 * An unexpected error occurred.
                 *
                 * Only report it the first time to avoid spamming
                 * the logs
                 *
                 */ /*
                 * We will continue anyway. Hopefully a later GID
                 * will work properly.
                 */ /*
         * If we get all the way through the loop, try again from GID_MAX,
         * unless that was where we previously started. (NOTE: the worst-case
         * scenario here is that we will run through (GID_MAX - GID_MIN - 1)
         * cycles *again* if we fall into this case with lowest_found as
         * GID_MAX - 1, all groups in the range in use and maintained by
         * network services such as LDAP.)
         */ /* This GID is available. Return it. */ /* This GID is in use, we'll continue to the next */ /*
                     * An unexpected error occurred.
                     *
                     * Only report it the first time to avoid spamming
                     * the logs
                     *
                     */ /*
                     * We will continue anyway. Hopefully a later GID
                     * will work properly.
                     */ /* !sys_group */ /*
         * For non-system groups, we want to start from the
         * bottom of the range and work upwards.
         */ /*
         * At the conclusion of the gr_next() search, we will either
         * have a presumed-free GID or we will be at GID_MAX + 1.
         */ /*
             * In this case, a GID is in use at GID_MAX.
             *
             * We will reset the search to GID_MIN and proceed up
             * through all the GIDs (skipping those we detected with
             * used_gids) for a free one. It is a known issue that
             * this may result in reusing a previously-deleted GID,
             * so administrators should be instructed to use this
             * auto-detection with care (and prefer to assign GIDs
             * explicitly).
             */ /* Search through all of the IDs in the range */ /* This GID is available. Return it. */ /* This GID is in use, we'll continue to the next */ /*
                 * An unexpected error occurred.
                 *
                 * Only report it the first time to avoid spamming
                 * the logs
                 *
                 */ /*
                 * We will continue anyway. Hopefully a later GID
                 * will work properly.
                 */ /*
         * If we get all the way through the loop, try again from GID_MIN,
         * unless that was where we previously started. (NOTE: the worst-case
         * scenario here is that we will run through (GID_MAX - GID_MIN - 1)
         * cycles *again* if we fall into this case with highest_found as
         * GID_MIN + 1, all groups in the range in use and maintained by
         * network services such as LDAP.)
         */ /* This GID is available. Return it. */ /* This GID is in use, we'll continue to the next */ /*
                     * An unexpected error occurred.
                     *
                     * Only report it the first time to avoid spamming
                     * the logs
                     *
                     */ /*
                     * We will continue anyway. Hopefully a later GID
                     * will work properly.
                     */ /* The code reached here and found no available IDs in the range */