From nobody@FreeBSD.org  Tue Sep 15 19:20:03 2009
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 343281065679
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 15 Sep 2009 19:20:03 +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 1F0068FC15
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 15 Sep 2009 19:20:03 +0000 (UTC)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.3/8.14.3) with ESMTP id n8FJK2sI055267
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 15 Sep 2009 19:20:02 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.3/8.14.3/Submit) id n8FJK291055266;
	Tue, 15 Sep 2009 19:20:02 GMT
	(envelope-from nobody)
Message-Id: <200909151920.n8FJK291055266@www.freebsd.org>
Date: Tue, 15 Sep 2009 19:20:02 GMT
From: "deeptech71@gmail.com" <deeptech71@gmail.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: if the hostname is empty, opiepasswd(1) creates a seed too short
X-Send-Pr-Version: www-3.1
X-GNATS-Notify: dt71@gmx.com

>Number:         138855
>Category:       bin
>Synopsis:       [patch] if the hostname is empty, opiepasswd(1) creates a seed too short
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Sep 15 19:30:01 UTC 2009
>Closed-Date:    
>Last-Modified:  Mon Dec 30 03:58:22 UTC 2013
>Originator:     deeptech71@gmail.com
>Release:        ~CURRENT
>Organization:
>Environment:
FreeBSD  8.0-BETA2 FreeBSD 8.0-BETA2 #0 r196195M: Fri Aug 14 02:25:06 UTC 2009 devhc@:/usr/obj/usr/src/sys/HQ  i386

>Description:
An opie seed should be at least 6 chars long. It defaults to 2 chars from the hostname and 4 random digits.

I have don't have a hostname (not set in rc.conf) (equivalent to hostname being "" instead of not existing?). The result is that opiepasswd creates a seed with 4 chars only. Later, opiekey(1) rejects this seed.
>How-To-Repeat:
# hostname ""
switch to a user who has never used opie (no entry in /etc/opiekeys)
# opiepasswd -cf
>Fix:
Could use one or two random chars if the hostname is too short (trivially patch contrib/bin/newseed.c?).

>Release-Note:
>Audit-Trail:

From: Remko Lodder <remko@elvandar.org>
To: deeptech71@gmail.com
Cc: freebsd-gnats-submit@FreeBSD.org
Subject: Re: bin/138855: if the hostname is empty, opiepasswd(1) creates a seed too short
Date: Tue, 15 Sep 2009 21:47:05 +0200

 I wonder whether this falls into the category "dont do that"  
 situation, where people do things that we do not support. Like using a  
 custom kernel, this smells like something that people choose for  
 themselves.
 
 
 -- 
 /"\   Best regards,                        | remko@FreeBSD.org
 \ /   Remko Lodder                      | remko@EFnet
 X    http://www.evilcoder.org/    |
 / \   ASCII Ribbon Campaign    | Against HTML Mail and News
 

From: "deeptech71@gmail.com" <deeptech71@gmail.com>
To: bug-followup@freebsd.org
Cc:  
Subject: Re: bin/138855: if the hostname is empty, opiepasswd(1) creates a 
	seed too short
Date: Sat, 21 Nov 2009 06:06:06 +0000

 Why are short hostnames unsupported?
 
 Anyways, here's a basic patch to check for short hostnames as much as
 "no hostnames". Not tested.
 I have no idea where "ke" came from. Is it better than generating a
 couple (or more) of random characters?

From: "deeptech71@gmail.com" <deeptech71@gmail.com>
To: bug-followup@freebsd.org
Cc:  
Subject: Re: bin/138855: if the hostname is empty, opiepasswd(1) creates a 
	seed too short
Date: Sat, 21 Nov 2009 06:14:58 +0000

 --0015175cd9fc104fea0478db83d7
 Content-Type: text/plain; charset=ISO-8859-1
 
 
 
 --0015175cd9fc104fea0478db83d7
 Content-Type: application/octet-stream; name="newseed_ke.patch"
 Content-Disposition: attachment; filename="newseed_ke.patch"
 Content-Transfer-Encoding: base64
 X-Attachment-Id: f_g2a1nue90
 
 SW5kZXg6IGNvbnRyaWIvb3BpZS9saWJvcGllL25ld3NlZWQuYwo9PT09PT09PT09PT09PT09PT09
 PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ci0tLSBjb250
 cmliL29waWUvbGlib3BpZS9uZXdzZWVkLmMJKHJldmlzaW9uIDE5NjE5NSkKKysrIGNvbnRyaWIv
 b3BpZS9saWJvcGllL25ld3NlZWQuYwkod29ya2luZyBjb3B5KQpAQCAtODAsNiArODAsMTMgQEAK
 IAkJCXV0c25hbWUubm9kZW5hbWVbMF0gPSAnayc7CiAJCQl1dHNuYW1lLm5vZGVuYW1lWzFdID0g
 J2UnOwogCQl9CisJCWVsc2UgaWYgKCF1dHNuYW1lLm5vZGVuYW1lWzBdKQorCQl7CisJCQl1dHNu
 YW1lLm5vZGVuYW1lWzBdID0gJ2snOworCQkJdXRzbmFtZS5ub2RlbmFtZVsxXSA9ICdlJzsKKwkJ
 fQorCQllbHNlIGlmICghdXRzbmFtZS5ub2RlbmFtZVsxXSkKKwkJCXV0c25hbWUubm9kZW5hbWVb
 MV0gPSAnZSc7CiAJCXV0c25hbWUubm9kZW5hbWVbMl0gPSAwOwogCiAJCWlmIChzbnByaW50Zihz
 ZWVkLCBPUElFX1NFRURfTUFYKzEsICIlcyUwNGQiLCB1dHNuYW1lLm5vZGVuYW1lLAo=
 --0015175cd9fc104fea0478db83d7--

From: Marcin Cieslak <saper@saper.info>
To: bug-followup@FreeBSD.org
Cc: deeptech71@gmail.com
Subject: Re: bin/138855: [patch] if the hostname is empty, opiepasswd(1)
 creates a seed too short
Date: Sun, 19 Dec 2010 21:14:36 +0000

 This patch:
 
 Index: newseed.c
 ===================================================================
 --- newseed.c	(revision 212217)
 +++ newseed.c	(working copy)
 @@ -81,6 +81,10 @@
   			utsname.nodename[1] = 'e';
   		}
   		utsname.nodename[2] = 0;
 +		if (!isalnum(utsname.nodename[0])
 +			utsname.nodename[0] = 'k';
 +		if (!isalnum(utsname.nodename[1])
 +			utsname.nodename[1] = 'f';
 
   		if (snprintf(seed, OPIE_SEED_MAX+1, "%s%04d", utsname.nodename,
   				(rand() % 9999) + 1) >= OPIE_SEED_MAX+1)
 
 should fix seed generation also for one-letter hostnames (the
 generated seed for hostname "x" was "x." and the opiepasswd failed
 as well because of the isalnum() check in writerec.c.
 
 //Marcin
 
>Unformatted:
