From nobody@FreeBSD.org  Wed Oct 22 19:11:05 2008
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 3F0291065671
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 22 Oct 2008 19:11:05 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id 2D58C8FC21
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 22 Oct 2008 19:11:05 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.3/8.14.3) with ESMTP id m9MJB45b078148
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 22 Oct 2008 19:11:04 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.3/8.14.3/Submit) id m9MJB4WG078147;
	Wed, 22 Oct 2008 19:11:04 GMT
	(envelope-from nobody)
Message-Id: <200810221911.m9MJB4WG078147@www.freebsd.org>
Date: Wed, 22 Oct 2008 19:11:04 GMT
From: Martin Beran <mb@tns.cz>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [patch] /etc/rc.d/geli does not mount partitions using both journal and eli
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         128299
>Category:       conf
>Synopsis:       [patch] /etc/rc.d/geli does not mount partitions using both journal and eli
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-rc
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Oct 22 19:20:00 UTC 2008
>Closed-Date:    
>Last-Modified:  Thu Feb 26 02:40:01 UTC 2009
>Originator:     Martin Beran
>Release:        7.0-RELEASE-p5
>Organization:
Trusted Network Solutions, a. s.
>Environment:
FreeBSD mb.tns.cz 7.0-RELEASE-p5 FreeBSD 7.0-RELEASE-p5 #4: Tue Oct 21 09:03:29 CEST 2008     root@mb.tns.cz:/usr/obj/usr/src/sys/MB  i386
>Description:
I have a file system on a device that combines GELI with GJOURNAL. I should be mounted during system startup, but it is not. The corresponding line in /etc/fstab is:
/dev/ad0s2d.journal.eli /mntgeli        ufs     rw,async        1       2
This causes an error in scripts /etc/rc.d/geli and /etc/rc.d/geli2 and the file system is not mounted. The scripts do not handle devices with names containing a dot except the dot in ".eli" suffix. The additional dot is propagated to the value   of variable $provider_, which is later used as a part of another variable name. Also, the scripts would not handle a situation with GELI not being the top layer in a stack of GEOM modules, for example, if the GJOURNAL and GELI were swapped (/dev/ad0s2d.eli.journal).
>How-To-Repeat:
Add an /etc/fstab line for mounting a file system on a device consisting of a GELI over GJOURNAL or GJOURNAL over GELI and reboot. The file system will not be mounted by the system startup scripts.
>Fix:
The attached patch corrects only the case of GELI over GJOURNAL, not GJOURNAL over GELI.

Patch attached with submission follows:

diff -cr rc.d/geli /etc/rc.d/geli
*** rc.d/geli	Wed Oct 22 20:54:46 2008
--- /etc/rc.d/geli	Wed Oct 22 08:13:01 2008
***************
*** 54,59 ****
--- 54,60 ----
  
  	for provider in ${devices}; do
  		provider_=`ltr ${provider} '/' '_'`
+ 		provider_=`ltr ${provider_} '.' '_'`
  
  		eval "flags=\${geli_${provider_}_flags}"
  		if [ -z "${flags}" ]; then
diff -cr rc.d/geli2 /etc/rc.d/geli2
*** rc.d/geli2	Wed Oct 22 20:54:46 2008
--- /etc/rc.d/geli2	Wed Oct 22 08:12:34 2008
***************
*** 43,48 ****
--- 43,49 ----
  
  	for provider in ${devices}; do
  		provider_=`ltr ${provider} '/' '_'`
+ 		provider_=`ltr ${provider_} '.' '_'`
  
  		eval "autodetach=\${geli_${provider_}_autodetach}"
  		if [ -z "${autodetach}" ]; then


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->freebsd-rc 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Thu Oct 23 12:07:33 UTC 2008 
Responsible-Changed-Why:  
Over to maintainer(s). 

http://www.freebsd.org/cgi/query-pr.cgi?pr=128299 

From: Yoshihiro Ota <ota@j.email.ne.jp>
To: bug-followup@FreeBSD.org, mb@tns.cz
Cc:  
Subject: Re: conf/128299: [patch] /etc/rc.d/geli does not mount partitions
 using both journal and eli
Date: Mon, 16 Feb 2009 23:22:43 -0500

 Hi, Martin.
 
 I think a patch at http://www.freebsd.org/cgi/query-pr.cgi?pr=kern/120091
 fixes your porblem, too.
 
 Do you mind if you try and report it?
 
 Thanks,
 Hiro

From: Martin Beran <mb@tns.cz>
To: bug-followup@FreeBSD.org, Yoshihiro Ota <ota@j.email.ne.jp>
Cc:  
Subject: Re: conf/128299: [patch] /etc/rc.d/geli does not mount partitions using both journal and eli
Date: Tue, 17 Feb 2009 09:50:13 +0100

 On Mon, Feb 16, 2009 at 11:22:43PM -0500, Yoshihiro Ota wrote:
 
 Hi, Hiro,
 
 > I think a patch at http://www.freebsd.org/cgi/query-pr.cgi?pr=kern/120091
 > fixes your porblem, too.
 > 
 > Do you mind if you try and report it?
 
 I tried the patch. It solves the second half of the problem - mounting
 a DEVICE.eli.journal. But for successful mount of both DEVICE.eli.journal and
 DEVICE.journal.eli, I still need my patch for /etc/rc.d/geli and
 /etc/rc.d/geli2. Otherwise, I get:
 
 eval: ${geli_ad0s2d....}: Bad substitution
 
 Running "sh -x /etc/rc.d/geli start" reveals the reason of this error:
 
 ...
 + geli_expand_entry  /dev/ad0s2d.journal.eli 
 + local devices3
 + local entry dev tail
 + tail=/dev/ad0s2d.journal.eli
 + true
 + dev=/dev/ad0s2d.journal.eli
 + devices3= /dev/ad0s2d.journal.eli
 + tail=
 + break
 + dev=
 + echo /dev/ad0s2d.journal.eli
 + devices=/dev/ad0s2d.journal.eli
 + provider=/dev/ad0s2d.journal
 + provider=ad0s2d.journal
 + devices2= ad0s2d.journal
 + echo ad0s2d.journal
 + devices=ad0s2d.journal
 + [ -z  ]
 + [ -n  ]
 + /sbin/sysctl -n kern.geom.eli.tries
 + geli_tries=3
 + ltr ad0s2d.journal / _
 + local _str _src _dst _out _com
 + _str=ad0s2d.journal
 + _src=/
 + _dst=_
 + _out=
 + IFS=/
 + [ -z  ]
 + _out=ad0s2d.journal
 + echo ad0s2d.journal
 + provider_=ad0s2d.journal
 + eval flags=${geli_ad0s2d.journal_flags}
 eval: ${geli_ad0s2d....}: Bad substitution
 
 -- 
 Martin Beran

From: Yoshihiro Ota <ota@j.email.ne.jp>
To: bug-followup@FreeBSD.org
Cc: mb@tns.cz
Subject: Re: conf/128299: [patch] /etc/rc.d/geli does not mount partitions
 using both journal and eli
Date: Wed, 25 Feb 2009 21:31:03 -0500

 I see it now.
 
 I forgot how I tested it but it seems I only tested "geli_expand_entry"
 function.  I remember that it extracted multiple occurrences of .eli's in
 a single path.
 
 I think I only tested .eli.journal really would get mounted as I didn't
 have any devices to test with.
 
 
 By the way, I don't think DEVICE.journal.eli will be helpful.  Journaing
 needs to be fs-aware.  It logs the records of file system updates.
 However, if you put GEOM eli on top of it, DEVICE.journal only sees
 encripted block and as a result, gournaling is effectively disabled.
 In another word, it needs to be the last GEOM layer.
 
 Is that right?
 
 Regards,
 Hiro
>Unformatted:
