Bug 138855 - [patch] if the hostname is empty, opiepasswd(1) creates a seed too short
Summary: [patch] if the hostname is empty, opiepasswd(1) creates a seed too short
Status: Open
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: unspecified
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-bugs mailing list
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-09-15 20:30 UTC by deeptech71@gmail.com
Modified: 2017-12-31 22:27 UTC (History)
0 users

See Also:


Attachments
newseed_ke.patch (563 bytes, patch)
2009-11-21 06:14 UTC, deeptech71@gmail.com
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description deeptech71@gmail.com 2009-09-15 20:30:01 UTC
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.

Fix: 

Could use one or two random chars if the hostname is too short (trivially patch contrib/bin/newseed.c?).
How-To-Repeat: # hostname ""
switch to a user who has never used opie (no entry in /etc/opiekeys)
# opiepasswd -cf
Comment 1 Remko Lodder 2009-09-15 20:47:05 UTC
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
Comment 2 deeptech71@gmail.com 2009-11-21 06:06:06 UTC
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?
Comment 3 Marcin Cieślak 2010-12-19 21:14:36 UTC
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
Comment 4 Eitan Adler freebsd_committer freebsd_triage 2017-12-31 07:58:36 UTC
For bugs matching the following criteria:

Status: In Progress Changed: (is less than) 2014-06-01

Reset to default assignee and clear in-progress tags.

Mail being skipped