From owner-freebsd-questions@FreeBSD.ORG Sun May 5 06:12:23 2013 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 6330CC26 for ; Sun, 5 May 2013 06:12:23 +0000 (UTC) (envelope-from talayeh.asadi@gmail.com) Received: from mail-qa0-x230.google.com (mail-qa0-x230.google.com [IPv6:2607:f8b0:400d:c00::230]) by mx1.freebsd.org (Postfix) with ESMTP id 2659D13B for ; Sun, 5 May 2013 06:12:23 +0000 (UTC) Received: by mail-qa0-f48.google.com with SMTP id i13so990953qae.14 for ; Sat, 04 May 2013 23:12:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:mime-version:reply-to:sender:in-reply-to:references:from :date:x-google-sender-auth:message-id:subject:to:cc:content-type; bh=fF1ZfzI0Fj2/SgMjbZYVy/9cRUnglljfx6Z5u6I2KP0=; b=V6mEK9msWih3pTfT/xi54TGzhbxopl1SfTvDvfwvFx5Nzv6eQn9I4jSX1jgHxDJ8qL bB6N0eru9p3FJtKKGbgOVyq0XdiMEx/7uKKEi/6Y+0j7M8fD4Sds5EgxLWXaPnfYD9+9 rCjgXV8iHsY1USgN4x8/aD3U8X6glIIRdFxQvJvnfREYO6LCxo1/dLbOHf1yBjTnGFco 0voY2shwrCPp5KxFJX+d8/CC9fnOKYlYBf1prTE1NkeQleLaoDzqHHVzkIcBJqW84TYL 9YpnNjsiuiqp2estAFVOA/opndWSjkaEfYHjEaRfyJRlt2zrAiQwI8FCfumcwwj+DH3W NY2w== X-Received: by 10.224.35.67 with SMTP id o3mr19081033qad.11.1367734342584; Sat, 04 May 2013 23:12:22 -0700 (PDT) MIME-Version: 1.0 Sender: talayeh.asadi@gmail.com Received: by 10.49.106.38 with HTTP; Sat, 4 May 2013 23:12:02 -0700 (PDT) In-Reply-To: <20130501110147.c69f408b.freebsd@edvax.de> References: <20130417173544.25266cd6.freebsd@edvax.de> <20130501110147.c69f408b.freebsd@edvax.de> From: takCoder Date: Sun, 5 May 2013 10:42:02 +0430 X-Google-Sender-Auth: qD0GJ6fvFM-Dq2ro2Q2f8KrJFkQ Message-ID: Subject: Re: pwd.db/spwd.db file corupption when having unsafe system poweroff To: Polytropon Content-Type: text/plain; charset=ISO-8859-1 X-Content-Filtered-By: Mailman/MimeDel 2.1.14 Cc: freebsd-questions@freebsd.org X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: tak.official@gmail.com List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 05 May 2013 06:12:23 -0000 First, thank you for your quick and complete reply :) then: > Furthermore, file system corruption due to an abrupt > cut of power should be avoided. Whenever the system comes > up in a non-clean state, fsck should be run first, _then_ > the boot process should continue. Still it's possible that > this process leaves truncated files behind (e. g. the > binary database files with a length of zero, which implies > they will have to be rebuilt by pwd_mkdb). > > i added fsck_background=no to rc.conf but i still see the error.. and i don't see any differance in system startup output! how should i know it's working?? > Alternatively to pw, you could try adduser, which is more > an interactive program, but can perform the same tasks. > Again, it would take care of updating all required files. > This is the situation one would expect after the program > ended, or at least some seconds after one got back to the > root prompt. > when i tried using adduser, when a error occurs(like multiple definition of a username), it's pw who reports the errors! it means that adduser also uses pw.. is this functionality of "taking care of updating all required files", an add-on appeared in add-user?? > During the 2 minutes, you could use programs like lsof > (it's in ports) to check if a program has a file open, > so you could capture the "power off while writing to > file" incident. > i tried using lsof as well , but there was no differance.. yes! when i use pw -h 0 parameter, 10 extra files are added to the lsof list.. but exactly after i enter the password, all of them are closed(none of these files are of those main 5 files of users..lib files and alike..).. and in later monitoring with lsof, i could not catch the time when these files are in use!.. i'll write a shell to monitor it more detailed though.. After you could not login again, did you check the > files involved in the login process? > yes, file sizes are ok but pwd.db and swpd.db are out of use..(also once i opened passwd with nano and it had irrational characters..). always if i use pwd_mkdb or just replace these two files, in next startup system will come up fine! now there is something special about my own servers, which i'm suspicious of.. i've add an executable file to my /usr/local/etc/rc.d dir, which tries to initiate some parts of myserver.. this includes usernames as well.. i mean, i may have template users during system uptime, which i won't need in next startup.. this initiliazer will remove those unwanted users and redifine main usernames, using pw.. it works fine while having safe shutdowns but when i have the bug-generator scenario, it won't work.. may it be the conflict of running my initializer and fsck ? or is it true that rc.d files are executed in shutdown process as well? is shutdown process started when i start pressing power button for 4 seconds?? i don't know what else to think of...