From owner-freebsd-questions@FreeBSD.ORG Sun Nov 22 08:14:18 2009 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CD09F106566B for ; Sun, 22 Nov 2009 08:14:18 +0000 (UTC) (envelope-from m.seaman@infracaninophile.co.uk) Received: from smtp.infracaninophile.co.uk (gate6.infracaninophile.co.uk [IPv6:2001:8b0:151:1::1]) by mx1.freebsd.org (Postfix) with ESMTP id 502BC8FC16 for ; Sun, 22 Nov 2009 08:14:18 +0000 (UTC) Received: from happy-idiot-talk.infracaninophile.co.uk (localhost [IPv6:::1]) (authenticated bits=0) by smtp.infracaninophile.co.uk (8.14.3/8.14.3) with ESMTP id nAM8E6jk009611; Sun, 22 Nov 2009 08:14:12 GMT (envelope-from m.seaman@infracaninophile.co.uk) X-DKIM: Sendmail DKIM Filter v2.8.3 smtp.infracaninophile.co.uk nAM8E6jk009611 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=infracaninophile.co.uk; s=200708; t=1258877652; bh=Hu7XCoF6OA/62U42Bo2ChNLHXV1bIy71xhNRsQdPWuM=; h=Message-ID:Date:From:MIME-Version:To:CC:Subject:References: In-Reply-To:Content-Type:Cc:Content-Type:Date:From:In-Reply-To: Message-ID:Mime-Version:References:To; z=Message-ID:=20<4B08F2C8.2040901@infracaninophile.co.uk>|Date:=20S un,=2022=20Nov=202009=2008:14:00=20+0000|From:=20Matthew=20Seaman= 20|Organization:=20Infracaninophi le|User-Agent:=20Thunderbird=202.0.0.23=20(X11/20090823)|MIME-Vers ion:=201.0|To:=20George=20Sanders=20|CC:=20f reebsd-questions@freebsd.org|Subject:=20Re:=20How=20can=20I=20resc ue=20my=20passwd=20file=20after=20corrupting=20it=20(and=20why=0D= 0A=20does=09it=20still=20work)=20?|References:=20<739790.37971.qm@ web111611.mail.gq1.yahoo.com>|In-Reply-To:=20<739790.37971.qm@web1 11611.mail.gq1.yahoo.com>|X-Enigmail-Version:=200.95.6|Content-Typ e:=20multipart/signed=3B=20micalg=3Dpgp-sha256=3B=0D=0A=20protocol =3D"application/pgp-signature"=3B=0D=0A=20boundary=3D"------------ enig866FC67F137ED464D9025FAC"; b=IBQpxN6SwDgYQ4r14GZAvYlk0l2OYrIfFBacYSxCPz93gzW3Mr1cyouM3f8u9Bjwr RH2caHcVb1DSmnmiiRnjMjfDH/ajfw/YqDs2SzG0/6Q4fmf19OgblliyhjC2+PZuHu NrNXuGZ1PasDtf6er/GZyQui56KfCJ7NXczPJk40= X-Authentication-Warning: happy-idiot-talk.infracaninophile.co.uk: Host localhost [IPv6:::1] claimed to be happy-idiot-talk.infracaninophile.co.uk Message-ID: <4B08F2C8.2040901@infracaninophile.co.uk> Date: Sun, 22 Nov 2009 08:14:00 +0000 From: Matthew Seaman Organization: Infracaninophile User-Agent: Thunderbird 2.0.0.23 (X11/20090823) MIME-Version: 1.0 To: George Sanders References: <739790.37971.qm@web111611.mail.gq1.yahoo.com> In-Reply-To: <739790.37971.qm@web111611.mail.gq1.yahoo.com> X-Enigmail-Version: 0.95.6 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="------------enig866FC67F137ED464D9025FAC" X-Virus-Scanned: clamav-milter 0.95.3 at happy-idiot-talk.infracaninophile.co.uk X-Virus-Status: Clean X-Spam-Status: No, score=-3.0 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VERIFIED,NO_RELAYS autolearn=ham version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on happy-idiot-talk.infracaninophile.co.uk Cc: freebsd-questions@freebsd.org Subject: Re: How can I rescue my passwd file after corrupting it (and why does it still work) ? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 22 Nov 2009 08:14:18 -0000 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig866FC67F137ED464D9025FAC Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable George Sanders wrote: >=20 > I do some automated account creation on a FreeBSD 6.x system ... and un= beknownst to me, the '/' filesystem was completely full when I did my las= t account creation, resulting in: >=20 > /: write failed, filesystem is full > pwd_mkdb: /etc/pwd.db to /etc/pwd.db.tmp: No space left on device > pw: passwd file update: No space left on device > pwd_mkdb: corrupted entry > pwd_mkdb: at line #187 > pwd_mkdb: /mnt/etc/master.passwd: Inappropriate file type or format >=20 > My situation is now as follows: >=20 > passwd and master.passwd have a lot of lines missing, and one or two ma= ngled lines toward the end. So a LOT of user accounts are gone. >=20 > BUT, all of those missing accounts still work. >=20 > So ...=20 >=20 > 1) why do all of the accounts that are missing from both passwd and mas= ter.passwd continue to work properly (they can authenticate and log in ov= er SSH and so on) ? >=20 > 2) how can I get back to healthy ? >=20 > I suspect that somehow my (s)pwd.db files are still healthy ... is it p= ossible to reconstruct complete passwd/master.passwd files using the exis= ting (s)pwd.db files ? There's a backup copy of master.passwd, groups and aliases stored in /var= /backups every time any of those files are changed -- the backups are created by t= he overnight periodic cron jobs, so you should be able to restore yesterday'= s status quo. Otherwise, you can sort of reconstruct the missing entries from yor maste= r.passwd file by using pw(8) -- eg: % pw user show -n matthew matthew:*:1001:1001::0:0:Matthew Seaman:/home/matthew:/bin/tcsh prints out the master.passwd entry for the user account but *without* the= password crypt-text. You can use: % pw user show -a=20 to get a list of all users. This should use spwd.db rather than the orig= inal flat files -- it will enumerate all users from LDAP or NIS if your machin= e is configured to use those. Unfortunately, you will have to merge in the cr= ypted password strings by hand or else get all your users to set new passwords.= Cheers, Matthew --=20 Dr Matthew J Seaman MA, D.Phil. 7 Priory Courtyard Flat 3 PGP: http://www.infracaninophile.co.uk/pgpkey Ramsgate Kent, CT11 9PW --------------enig866FC67F137ED464D9025FAC Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.13 (FreeBSD) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEAREIAAYFAksI8s4ACgkQ8Mjk52CukIyR8ACeOnvHrGgQgGR8KtgHiAikCJ8c BZEAniF4q8CvEjavFuuvORGgibWWPXiB =zZfc -----END PGP SIGNATURE----- --------------enig866FC67F137ED464D9025FAC--