Skip site navigation (1)Skip section navigation (2)
Date:      07 Sep 1998 18:54:49 -0400
From:      Kevin Street <street@iname.com>
To:        Dr R D Gidden <rdg@theleys.cambs.sch.uk>
Cc:        freebsd-questions@FreeBSD.ORG
Subject:   Re: Invalid master.passwd file
Message-ID:  <87af4b3552.fsf@kstreet.interlog.com>
In-Reply-To: Kevin Street's message of "07 Sep 1998 17:29:42 -0400"
References:  <Marcel-1.08-0907181724-0b0cqa6@barium.theleys.cambs.sch.uk> <87hfyj4nnd.fsf@kstreet.interlog.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Kevin Street <street@iname.com> writes:

> Dr R D Gidden <rdg@theleys.cambs.sch.uk> writes:

>    snip 
> 
> > I have over 700 users in this file (AARGH!): is it possible 
> > to work back from the .db file(s)?  My backup was just 
> > *before* a whole slew of new users were added :-((
> 
> Bob, I don't know about working backwards from the .db files, but have 
> you checked in /var/backups to see if there's a good version there?

Oh, and come to think of it, it is easy to get the info from the .db
files too if you have really wiped out master.passwd & all backups.
If you run this as root it should print out a copy of the
master.passwd file that it reads from spwd.db.  (If you run it as a
normal user you get "*" for all the passwords.)

#include <sys/types.h>
#include <pwd.h>

int
main(int argc, char **argv)
{
   struct passwd * pw;
   pw = getpwent();
   while (0 != pw) {
      printf("%s:%s:%d:%d:%s:%d:%d:%s:%s:%s\n",
	     pw->pw_name, pw->pw_passwd, pw->pw_uid, pw->pw_gid,
	     pw->pw_class, pw->pw_change, pw->pw_expire,
	     pw->pw_gecos, pw->pw_dir, pw->pw_shell);
      pw = getpwent();
   }
   endpwent();
   return 0;
}
  

-- 
Kevin Street
street@iName.com

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?87af4b3552.fsf>