Changeset 2375

Show
Ignore:
Timestamp:
04/18/07 02:06:44 (2 years ago)
Author:
tg
Message:

replace get_next_uid() and get_next_gid() with a collision-free algorithm
taken from MirBSD adduser(8) but converted from mksh(1) with internal file
parsing to fork'n'exec'ing grep(1)

untested

may solve #274, #275

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/freewrt/package/base-files/Makefile

    r2366 r2375  
    1010PKG_NAME:=              base-files 
    1111PKG_VERSION:=           1.0 
    12 PKG_RELEASE:=           23 
     12PKG_RELEASE:=           24 
    1313WRKDIST=                ${WRKDIR}/base-files 
    1414NO_DISTFILES:=          1 
  • trunk/freewrt/package/base-files/files/etc/functions.sh

    r2149 r2375  
    5454 
    5555get_next_uid() { 
    56         uid=$(grep -v -e ^nobody: -e ^admin: $IPKG_INSTROOT/etc/passwd | \ 
    57             tail -n 1 | awk -F : '{ print $3 }') 
    58         echo $((uid+1)) 
     56        uid=1 
     57        while grep "^[^:]*:[^:]*:$uid:" $IPKG_INSTROOT/etc/passwd \ 
     58            >/dev/null 2>&1; do 
     59                uid=$(($uid+1)) 
     60        done 
     61        echo $uid 
    5962} 
    6063 
    6164get_next_gid() { 
    62         gid=$(grep -v -e ^nogroup: -e ^admin: $IPKG_INSTROOT/etc/group | \ 
    63             tail -n 1 | awk -F : '{ print $3 }') 
    64         echo $((gid+1)) 
     65        gid=1 
     66        while grep "^[^:]*:[^:]*:$gid:" $IPKG_INSTROOT/etc/group \ 
     67            >/dev/null 2>&1; do 
     68                gid=$(($gid+1)) 
     69        done 
     70        echo $gid 
    6571}