[PATCH] initscripts: checkroot.sh ignores fsck result

Bug #28067 reported by Debian Bug Importer
40
Affects Status Importance Assigned to Milestone
sysvinit (Debian)
Fix Released
Unknown
sysvinit (Ubuntu)
Fix Released
Critical
Unassigned

Bug Description

Automatically imported from Debian bug report #342160 http://bugs.debian.org/342160

Revision history for this message
In , Thomas Hood (jdthood-yahoo) wrote : Re: checkroot.sh ignores fsck result

tags 342160 pending
stop

Ilguiz Latypov wrote:
> The /etc/init.d/checkroot.sh script ignored the fsck's "PLEASE REBOOT
> LINUX NOW" exit code because the code is stored too late.

Thanks for reporting this.

The bug has been fixed in svn.
--
Thomas

Revision history for this message
In , Thomas Hood (jdthood-yahoo) wrote : pending

package initscripts sysv-rc sysvinit
tags 338801 pending
tags 338736 fixed-in-experimental
tags 342160 fixed-in-experimental
tags 342744 fixed-in-experimental
stop

Revision history for this message
In , Thomas Hood (jdthood-yahoo) wrote : Re: [Pkg-sysvinit-devel] Bug#346148: checkroot.sh: does not properly handle fsck exit states

tags 346148 fixed-in-experimental patch pending
severity 342160 critical
merge 346148 342160
found 346148 2.86.ds1-4
stop

Wouter Verhelst wrote:
> I just noticed that my laptop, at bootup, started an fsck for the root
> filesystem, claiming that it was a filesystem with errors. When it was
> about 20% done, it exited, and told me to rerun it manually. I expected
> a prompt for my root password and to be put in single-user mode, but
> this did not happen; instead, my system did a normal boot.
>
> This should _never_ happen! If the fsck fails, all sorts of bad things
> might have happened with the file system; continueing the boot at that
> point is a very good way to lose all your data.

Thanks for reporting the bug.

checkroot.sh in at 2.86.ds1-[46] contains a bug such that the return status
of fsck is ignored. This bug has been fixed in more recent releases (to
experimental).

Additional info:

Reading checkroot.sh I see that it only continues with booting if the fsck
return status is 0 or 1. If the status is 2 or 3 then the system is rebooted
after five seconds. If the status is greater than 3 then a shell is started.

The comment in checkroot.sh says "A return code of 1 indicates that file system
errors were corrected but that the boot may proceed."

The fsck(8) and fsck.ext3(8) man pages say that 1 means "File system errors
corrected".
--
Thomas Hood

Revision history for this message
Debian Bug Importer (debzilla) wrote : initscripts: checkroot.sh ignores fsck result

Automatically imported from Debian bug report #342160 http://bugs.debian.org/342160

Revision history for this message
Debian Bug Importer (debzilla) wrote :

Message-Id: <E1EjO62-0002If-Ms@ei>
Date: Mon, 05 Dec 2005 16:42:05 -0500
From: Ilguiz Latypov <email address hidden>
To: Debian Bug Tracking System <email address hidden>
Subject: initscripts: checkroot.sh ignores fsck result

Package: initscripts
Version: 2.86.ds1-6
Severity: normal
Tags: patch

The /etc/init.d/checkroot.sh script ignored the fsck's "PLEASE REBOOT
LINUX NOW" exit code because the code is stored too late. As a result,
the fixes fsck made to my filesystem could be corrupted again because
the system didn't reboot immediately.

Besides, the if/then/else/fi statement's syntax was messed up.
Surprisingly, it was still valid according to "sh -n".

Here is the suggested patch.

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
--- checkroot.sh.orig 2005-11-19 06:40:50.000000000 -0500
+++ checkroot.sh 2005-12-05 16:35:34.000000000 -0500
@@ -249,12 +249,13 @@
                fi
                log_action_msg "Will now check root file system"
                fsck $spinner $force $fix -T -t $roottype $rootdev
- if [ "$?" = 0 ]
- log_success_msg "Done checking root file system"
+ FSCKCODE=$?
+ if [ "$FSCKCODE" = 0 ]
                then
+ log_success_msg "Done checking root file system"
+ else
                        log_failure_msg "Done checking root file system"
                fi
- FSCKCODE=$?
        fi

        #
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

-- System Information:
Debian Release: testing/unstable
  APT prefers unstable
  APT policy: (800, 'unstable')
Architecture: i386 (i686)
Shell: /bin/sh linked to /bin/bash
Kernel: Linux 2.6.14-2-k7
Locale: LANG=ru_RU.KOI8-R, LC_CTYPE=ru_RU.KOI8-R (charmap=KOI8-R)

Versions of packages initscripts depends on:
ii coreutils 5.93-5 The GNU core utilities
ii dpkg 1.13.11.0.1 package maintenance system for Deb
ii e2fsprogs 1.38-2 ext2 file system utilities and lib
ii libc6 2.3.5-8.1 GNU C Library: Shared libraries an
ii lsb-base 3.0-11 Linux Standard Base 3.0 init scrip
ii util-linux 2.12p-8 Miscellaneous system utilities

initscripts recommends no packages.

-- no debconf information

Revision history for this message
Debian Bug Importer (debzilla) wrote :

Message-ID: <email address hidden>
Date: Sat, 10 Dec 2005 18:36:41 +0100
From: Thomas Hood <email address hidden>
To: <email address hidden>
Subject: Re: checkroot.sh ignores fsck result

tags 342160 pending
stop

Ilguiz Latypov wrote:
> The /etc/init.d/checkroot.sh script ignored the fsck's "PLEASE REBOOT
> LINUX NOW" exit code because the code is stored too late.

Thanks for reporting this.

The bug has been fixed in svn.
--
Thomas

Revision history for this message
Debian Bug Importer (debzilla) wrote :

Message-ID: <email address hidden>
Date: Sun, 18 Dec 2005 00:10:29 +0100
From: Thomas Hood <email address hidden>
To: Debian Bug Tracking System <email address hidden>
Subject: pending

package initscripts sysv-rc sysvinit
tags 338801 pending
tags 338736 fixed-in-experimental
tags 342160 fixed-in-experimental
tags 342744 fixed-in-experimental
stop

Revision history for this message
Debian Bug Importer (debzilla) wrote :

Message-ID: <email address hidden>
Date: Fri, 06 Jan 2006 12:01:40 +0100
From: Thomas Hood <email address hidden>
To: <email address hidden>
Cc: <email address hidden>
Subject: Re: [Pkg-sysvinit-devel] Bug#346148: checkroot.sh: does not properly handle fsck exit states

tags 346148 fixed-in-experimental patch pending
severity 342160 critical
merge 346148 342160
found 346148 2.86.ds1-4
stop

Wouter Verhelst wrote:
> I just noticed that my laptop, at bootup, started an fsck for the root
> filesystem, claiming that it was a filesystem with errors. When it was
> about 20% done, it exited, and told me to rerun it manually. I expected
> a prompt for my root password and to be put in single-user mode, but
> this did not happen; instead, my system did a normal boot.
>
> This should _never_ happen! If the fsck fails, all sorts of bad things
> might have happened with the file system; continueing the boot at that
> point is a very good way to lose all your data.

Thanks for reporting the bug.

checkroot.sh in at 2.86.ds1-[46] contains a bug such that the return status
of fsck is ignored. This bug has been fixed in more recent releases (to
experimental).

Additional info:

Reading checkroot.sh I see that it only continues with booting if the fsck
return status is 0 or 1. If the status is 2 or 3 then the system is rebooted
after five seconds. If the status is greater than 3 then a shell is started.

The comment in checkroot.sh says "A return code of 1 indicates that file system
errors were corrected but that the boot may proceed."

The fsck(8) and fsck.ext3(8) man pages say that 1 means "File system errors
corrected".
--
Thomas Hood

Revision history for this message
Debian Bug Importer (debzilla) wrote :

*** Bug 28053 has been marked as a duplicate of this bug. ***

Revision history for this message
In , Petter Reinholdtsen (pere-debian) wrote : Bug#342160: fixed in sysvinit 2.86.ds1-11
Download full text (14.4 KiB)

Source: sysvinit
Source-Version: 2.86.ds1-11

We believe that the bug you reported is fixed in the latest version of
sysvinit, which is due to be installed in the Debian FTP archive:

initscripts_2.86.ds1-11_i386.deb
  to pool/main/s/sysvinit/initscripts_2.86.ds1-11_i386.deb
sysv-rc_2.86.ds1-11_all.deb
  to pool/main/s/sysvinit/sysv-rc_2.86.ds1-11_all.deb
sysvinit_2.86.ds1-11.diff.gz
  to pool/main/s/sysvinit/sysvinit_2.86.ds1-11.diff.gz
sysvinit_2.86.ds1-11.dsc
  to pool/main/s/sysvinit/sysvinit_2.86.ds1-11.dsc
sysvinit_2.86.ds1-11_i386.deb
  to pool/main/s/sysvinit/sysvinit_2.86.ds1-11_i386.deb

A summary of the changes between this version and the previous one is
attached.

Thank you for reporting the bug, which will now be closed. If you
have further comments please address them to <email address hidden>,
and the maintainer will reopen the bug report if appropriate.

Debian distribution maintenance software
pp.
Petter Reinholdtsen <email address hidden> (supplier of updated sysvinit package)

(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing <email address hidden>)

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Format: 1.7
Date: Sun, 22 Jan 2006 22:17:38 +0100
Source: sysvinit
Binary: sysv-rc sysvinit initscripts
Architecture: source i386 all
Version: 2.86.ds1-11
Distribution: unstable
Urgency: low
Maintainer: sysvinit maintainers <email address hidden>
Changed-By: Petter Reinholdtsen <email address hidden>
Description:
 initscripts - Scripts for initializing and shutting down the system
 sysv-rc - System-V-like runlevel change mechanism
 sysvinit - System-V-like init utilities
Closes: 55143 89481 95390 116366 160329 186880 189356 213028 220025 227540 237074 238861 242957 258290 272066 275680 286082 286479 316423 323749 327865 328582 328764 330155 331397 332309 333836 336172 338736 338801 339023 339979 340017 341075 341097 342160 342744 343596 343862 343863 343993 344001 344089 344547 344547 345267 345269 345272 345273 345321 345370 345719 345968 346139 346415
Changes:
 sysvinit (2.86.ds1-11) unstable; urgency=low
 .
   [ Thomas Hood ]
   * rcS(5): Improve
   * sulogin(8): Improve; mention -t option (Closes: #186880)
   * bootlogd(8): Improve; mention need for PTY support
   * initscripts postinst: Update to reflect script name changes
   * initscripts: Harmonize PATH settings
   * checkroot.sh: Don't check for need to start /sbin/update.
     We don't support pre-2.4 kernels any more.
   * checkroot.sh, mountall.sh: Run swapon with -v if VERBOSE!=no
   * Remove obsolete lintian overrides
   * Previous release also
     closes: #258290 "bootlogd: Bad file descriptor"
     closes: #327865 "bootlogd stopped working"
     closes: #328764 "bootlogd fails to start"
 .
   [ Petter Reinholdtsen ]
   * Time to upload all these changes into unstable (Closes: #341075)
   * Revert default VERBOSE value to "yes" to reduce the amount of
     user visible changes in this upload.
 .
 sysvinit (2.86.ds1-10) experimental; urgency=low
 .
   [ Thomas Hood ]
   * bootclean: Adapt from old bootclean.sh; handle return status mor...

Revision history for this message
Tormod Volden (tormodvolden) wrote : Re: initscripts: checkroot.sh ignores fsck result

Can confirm this on dapper up to date. "/ contains a file system with errors, check forced. Inodes... /: UNEXPECTED INCONSISTENCY; RUN fsck MANUALLY" but then it just goes on with "done checking file system" (twice). And the same happens at the next boot, so clearly nothing was fixed by itself.

Changed in sysvinit:
status: Unconfirmed → Confirmed
Revision history for this message
Tormod Volden (tormodvolden) wrote :

> Reading checkroot.sh I see that it only continues with booting if the fsck
return status is 0 or 1.

AFAICS this is wrong. The return status is lost after the log_failure_msg call anyway, so the script always think everything went well.

Revision history for this message
Tormod Volden (tormodvolden) wrote : fixes the ignored return status from fsck

Please accept this humble patch. This little cleanup fixes the problem and can help avoid bad longtime fs corruption.

Revision history for this message
Tormod Volden (tormodvolden) wrote :

This can cause dataloss. It is fixed upstream, but not in dapper.

Revision history for this message
Scott James Remnant (Canonical) (canonical-scott) wrote :

Fixed in dapper now.

Changed in sysvinit:
status: Unconfirmed → Fix Released
status: Confirmed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.