Re: get_uid sub critic

2004-02-09 Thread Kenton Brede
On Mon, Feb 09, 2004 at 09:46:10AM -0500, Bob Showalter ([EMAIL PROTECTED]) wrote: > Kenton Brede wrote: > > I've written the following subroutine to snag the next available UID > > in the 700 range from /etc/passwd. I then use the return value with > > "useradd" to add a new user. > > Note that

RE: get_uid sub critic

2004-02-09 Thread Bob Showalter
Kenton Brede wrote: > I've written the following subroutine to snag the next available UID > in the 700 range from /etc/passwd. I then use the return value with > "useradd" to add a new user. Note that this algorithm contains a race condition. Between the scan of /etc/passwd and the call to usera

Re: get_uid sub critic

2004-02-09 Thread John W. Krahn
Kenton Brede wrote: > > On Sat, Feb 07, 2004 at 02:08:26PM -0800, John W. Krahn ([EMAIL PROTECTED]) wrote: > > Thanks for your response. Where do I begin asking questions about this > one, hehe. > > > sub get_uid { > > my ( $start, $end ) = @_; > > --$start; > > defined getpwuid $st

Re: get_uid sub critic

2004-02-09 Thread John W. Krahn
Kenton Brede wrote: > > On Sat, Feb 07, 2004 at 07:42:30PM -, Rob Dixon ([EMAIL PROTECTED]) wrote: > > > > sub get_uid { > > my %list; > > @list{map {(split /:/)[2]} } = (); > > map reads the UID variables from into @list. Into %list actually. @list{} is a hash slice. > What I d

Re: get_uid sub critic

2004-02-08 Thread R. Joseph Newton
Rob Dixon wrote: > Kenton Brede wrote: > > __DATA__ > > user1:x:700:101:user1:/dev/null:/bin/false > > user2:x:706:101:user2:/dev/null:/bin/false > > user3:x:707:101:user3:/dev/null:/bin/false > > user4:x:708:101:user4:/dev/null:/bin/false > > Hi Kenton. > > How does this look? > > sub get_uid {

Re: get_uid sub critic

2004-02-07 Thread Kenton Brede
On Sat, Feb 07, 2004 at 02:08:26PM -0800, John W. Krahn ([EMAIL PROTECTED]) wrote: > Kenton Brede wrote: > > > > I've written the following subroutine to snag the next available UID in > > the 700 range from /etc/passwd. I then use the return value with > > "useradd" to add a new user. > > > > T

Re: get_uid sub critic

2004-02-07 Thread Kenton Brede
On Sat, Feb 07, 2004 at 07:42:30PM -, Rob Dixon ([EMAIL PROTECTED]) wrote: >> Kenton Brede wrote: >> > Hi Kenton. Hi, thanks for the great code. > How does this look? Well ... complex :) Let me see if I can put this in English. > sub get_uid { > my %list; > @list{map {(split /

Re: get_uid sub critic

2004-02-07 Thread John W. Krahn
Kenton Brede wrote: > > I've written the following subroutine to snag the next available UID in > the 700 range from /etc/passwd. I then use the return value with > "useradd" to add a new user. > > The subroutine works fine. If no UID 700 is found it returns 700. > It then returns the next avai

Re: get_uid sub critic

2004-02-07 Thread Rob Dixon
Kenton Brede wrote: > > I've written the following subroutine to snag the next available UID in > the 700 range from /etc/passwd. I then use the return value with > "useradd" to add a new user. > > The subroutine works fine. If no UID 700 is found it returns 700. > It then returns the next availa

Re: get_uid sub critic

2004-02-07 Thread Paul Johnson
On Sat, Feb 07, 2004 at 12:57:45PM -0600, Kenton Brede wrote: > I've written the following subroutine to snag the next available UID in > the 700 range from /etc/passwd. I then use the return value with > "useradd" to add a new user. > > The subroutine works fine. If no UID 700 is found it retu