From jamie@psi-domain.co.uk  Tue May  8 08:36:36 2001
Return-Path: <jamie@psi-domain.co.uk>
Received: from rafiu.psi-domain.co.uk (rafiu.psi-domain.co.uk [212.87.84.199])
	by hub.freebsd.org (Postfix) with ESMTP id 971D237B423
	for <FreeBSD-gnats-submit@freebsd.org>; Tue,  8 May 2001 08:36:35 -0700 (PDT)
	(envelope-from jamie@psi-domain.co.uk)
Received: by rafiu.psi-domain.co.uk (Postfix, from userid 1001)
	id 9C4B5402EC6; Tue,  8 May 2001 16:32:02 +0100 (BST)
Message-Id: <20010508153202.9C4B5402EC6@rafiu.psi-domain.co.uk>
Date: Tue,  8 May 2001 16:32:02 +0100 (BST)
From: jamie@psi-domain.co.uk
Reply-To: jamie@psi-domain.co.uk
To: FreeBSD-gnats-submit@freebsd.org
Subject: Listing all users in the passwd file
X-Send-Pr-Version: 3.2

>Number:         27205
>Category:       bin
>Synopsis:       Listing all users in the passwd file
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Tue May 08 08:40:00 PDT 2001
>Closed-Date:    Sun Jun 10 05:58:23 PDT 2001
>Last-Modified:  Sun Jun 10 06:02:00 PDT 2001
>Originator:     Jamie Heckford
>Release:        FreeBSD 4.2-STABLE i386
>Organization:
Psi-Domain Limited 
>Environment:

FreeBSD storm.psi-domain.co.uk 4.2-STABLE FreeBSD 4.2-STABLE #2: Fri Mar  2 10:32:25 GMT 2001

>Description:

I was recently trying to discover a way of getting a list of all users on
one of my systems, and could not find an easy way to do it.

I discovered the following awk script that prints out all users on the system
(from /etc/passwd). (Courtesy of sendmail.org)

awk -F: '$3 > 100 { print $1 }' /etc/passwd 

Which will print out a list of all users in the passwd file wuth a UID greater
than 100.

Could this be turned into a command such as "userlist", and/or would it be
deemed usefull?

Another good feature that many people get stuck on is for sending email to
all users on the system. Maybe it could be included as part of the sendmail
distro, with something like:

awk -F: '$3 > 100 { print $1 }' /etc/passwd > /etc/mail/allusers

and put in cron.daily.

This could then be a default in /etc/mail/aliases:

allusers:       :include:/etc/mail/allusers

What do you think? :)

Jamie
 

>How-To-Repeat:

userlist
--------

awk -F: '$3 > 100 { print $1 }' /etc/passwd

Sendmail
-------

awk -F: '$3 > 100 { print $1 }' /etc/passwd > /etc/mail/allusers
echo "allusers:   :include:/etc/mail/allusers" >> /etc/aliases ; newaliases
echo "#\!/bin/sh" > /etc/periodic/350.allusers
echo "awk -F: '$3 > 100 { print $1 }' /etc/passwd > /etc/mail/allusers" >> /etc/periodic/350.allusers
chmod 0755 /etc/periodic/350.allusers

>Fix:

Tested the above and worked fine, just need someone to tell me its great
or completly useless! :)

>Release-Note:
>Audit-Trail:

From: Peter Pentchev <roam@orbitel.bg>
To: jamie@psi-domain.co.uk
Cc: FreeBSD-gnats-submit@freebsd.org
Subject: Re: bin/27205: Listing all users in the passwd file
Date: Tue, 8 May 2001 20:03:21 +0300

 You might want to make a port out of this..
 
 G'luck,
 Peter
 
 -- 
 This sentence would be seven words long if it were six words shorter.
 
 On Tue, May 08, 2001 at 04:32:02PM +0100, jamie@psi-domain.co.uk wrote:
 > 
 > >Number:         27205
 > >Category:       bin
 > >Synopsis:       Listing all users in the passwd file
 > >Originator:     Jamie Heckford
 > >Release:        FreeBSD 4.2-STABLE i386
 > >Organization:
 > Psi-Domain Limited 
 > >Environment:
 > 
 > FreeBSD storm.psi-domain.co.uk 4.2-STABLE FreeBSD 4.2-STABLE #2: Fri Mar  2 10:32:25 GMT 2001
 > 
 > >Description:
 > 
 > I was recently trying to discover a way of getting a list of all users on
 > one of my systems, and could not find an easy way to do it.
 > 
 > I discovered the following awk script that prints out all users on the system
 > (from /etc/passwd). (Courtesy of sendmail.org)
 > 
 > awk -F: '$3 > 100 { print $1 }' /etc/passwd 
 > 
 > Which will print out a list of all users in the passwd file wuth a UID greater
 > than 100.
 > 
 > Could this be turned into a command such as "userlist", and/or would it be
 > deemed usefull?
State-Changed-From-To: open->closed 
State-Changed-By: schweikh 
State-Changed-When: Sun Jun 10 05:58:23 PDT 2001 
State-Changed-Why:  
The system provides the getpwent(3) routine to iterate through 
the passwd file and also takes care of other sources (like NIS). 
In a script you'd say s.t. like 
perl -e 'while(($name)=getpwent){print "$namen"}' 
No, we're not making separate executables for such one-liners. 
There would be just too many :-) 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=27205 
>Unformatted:
