NetBSD Problem Report #53553
From eric@cirr.com Sat Aug 25 22:17:56 2018
Return-Path: <eric@cirr.com>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
by mollari.NetBSD.org (Postfix) with ESMTPS id ED6517A1F1
for <gnats-bugs@gnats.NetBSD.org>; Sat, 25 Aug 2018 22:17:56 +0000 (UTC)
Message-Id: <20180825221752.856FF1BC05@snoopy.cirr.com>
Date: Sat, 25 Aug 2018 17:17:52 -0500 (CDT)
From: eric@cirr.com
Reply-To: eric@cirr.com
To: gnats-bugs@NetBSD.org
Subject: gpt biosboot forcibly prepends /usr/mdec to any other paht
X-Send-Pr-Version: 3.95
>Number: 53553
>Category: bin
>Synopsis: gpt biosboot forcibly prepends /usr/mdec to any other paht
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: jnemeth
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sat Aug 25 22:20:00 +0000 2018
>Closed-Date:
>Last-Modified: Wed Jun 09 03:37:56 +0000 2021
>Originator: eric@cirr.com
>Release: NetBSD 8.0_STABLE
>Organization:
Eric Schnoebelen eric@cirr.com http://www.cirr.com
IBM is really really good at documentation. They may implement
something so amazingly stupid it makes you slap your forehead,
but darn if they don't document what they did. -- Kevin P. Neal
>Environment:
System: NetBSD snoopy 8.0_STABLE NetBSD 8.0_STABLE (GENERIC) #3: Thu Aug 16 22:38:01 CDT 2018 eric@bob-the-builder:/work/eric/NetBSD-8/obj/amd64/sys/arch/amd64/compile/GENERIC amd64
Architecture: x86_64
Machine: amd64
>Description:
Attempting to use a gpt(8) biosboot subcommand with a file
in any location other than /usr/mdec gets /usr/mdec forcibly
prepended to the path.
>How-To-Repeat:
I was attempting to install the -HEAD version of gptmbr.bin
on a disk, on a system running NetBSD 8. The file was in
a subdirectory of my home directory.
Below is a copy of the sessions:
snoopy-> sudo gpt -v biosboot -A -c usr/mdec/gptmbr.bin -i 1 sd0
/dev/rsd0d: mediasize=3000592982016; sectorsize=512; blocks=5860533168
gpt: /dev/rsd0d: Can't open `/usr/mdec/usr/mdec/gptmbr.bin' (No such
file or directory)
gpt: /dev/rsd0d: Error reading bootcode
snoopy-> sudo gpt -v biosboot -A -c ./usr/mdec/gptmbr.bin -i 1 sd0
/dev/rsd0d: mediasize=3000592982016; sectorsize=512; blocks=5860533168
gpt: /dev/rsd0d: Can't open `/usr/mdec/./usr/mdec/gptmbr.bin' (No such
file or directory)
gpt: /dev/rsd0d: Error reading bootcode
snoopy-> sudo install usr/mdec/gptmbr.bin /usr/mdec/gptmbr-8.99.22.bin
snoopy-> sudo gpt -v biosboot -A -c !$ -i 1 sd0
sudo gpt -v biosboot -A -c /usr/mdec/gptmbr-8.99.22.bin -i 1 sd0
/dev/rsd0d: mediasize=3000592982016; sectorsize=512; blocks=5860533168
/dev/rsd0d: Partition 1 marked as bootable
snoopy->
For giggles and grins, I decided to change to the directory
where the gptmbr.bin file is located, and it works.
snoopy-> pushd usr/mdec/
~/usr/mdec ~
snoopy-> sudo gpt -v biosboot -A -c gptmbr.bin -i 1 sd0
/dev/rsd0d: mediasize=3000592982016; sectorsize=512; blocks=5860533168
/dev/rsd0d: Partition 1 marked as bootable
snoopy-> sudo gpt -v biosboot -A -c ./gptmbr.bin -i 1 sd0
/dev/rsd0d: mediasize=3000592982016; sectorsize=512; blocks=5860533168
/dev/rsd0d: Partition 1 marked as bootable
snoopy->
It seems that gpt is forcibly prepending '/usr/mdec' on
any path that has a directory seperator in it? Or any file
that is not in the current working directory? (I haven't
examined the code, but I did quickly check to see if the
code was unchanged between netbsd-8 and HEAD.
>Fix:
Work-around: move to the same directory as the biosboot image file.
Fix: Unknown, I haven't examined the code beyond a 'cvs diff'
between netbsd-8 and -HEAD
>Release-Note:
>Audit-Trail:
From: Robert Elz <kre@munnari.OZ.AU>
To: gnats-bugs@NetBSD.org
Cc:
Subject: Re: bin/53553: gpt biosboot forcibly prepends /usr/mdec to any other paht
Date: Sun, 26 Aug 2018 07:05:56 +0700
Date: Sat, 25 Aug 2018 22:20:00 +0000 (UTC)
From: eric@cirr.com
Message-ID: <20180825222000.986E47A111@mollari.NetBSD.org>
| It seems that gpt is forcibly prepending '/usr/mdec' on
| any path that has a directory seperator in it? Or any file
| that is not in the current working directory?
It uses /usr/mdec for any name that isn't a full path name. I'm guessing
that when you did the later tests you still have gptmbr.bin installed in
/usr/mdec - it would have been using that one.
| Work-around: move to the same directory as the biosboot image file.
Use a full path name if you want to get the file from elsewhere.
Whether it could allow more flexibility (not prepend /usr/mdec if the name
starts ./ or ../ as well as /) is someone else's decision, but at the very
least the man page needs improvement.
kre
From: eric@cirr.com (Eric Schnoebelen)
To: gnats-bugs@NetBSD.org
Cc: gnats-admin@netbsd.org, netbsd-bugs@netbsd.org
Subject: Re: bin/53553: gpt biosboot forcibly prepends /usr/mdec to any other paht
Date: Sat, 25 Aug 2018 19:43:55 -0500
Robert Elz writes:
- The following reply was made to PR bin/53553; it has been noted by GNATS.
-
- From: Robert Elz <kre@munnari.OZ.AU>
- To: gnats-bugs@NetBSD.org
- Cc:
- Subject: Re: bin/53553: gpt biosboot forcibly prepends /usr/mdec to any oth
- er paht
- Date: Sun, 26 Aug 2018 07:05:56 +0700
-
- Date: Sat, 25 Aug 2018 22:20:00 +0000 (UTC)
- From: eric@cirr.com
- Message-ID: <20180825222000.986E47A111@mollari.NetBSD.org>
-
- | It seems that gpt is forcibly prepending '/usr/mdec' on
- | any path that has a directory seperator in it? Or any file
- | that is not in the current working directory?
-
- It uses /usr/mdec for any name that isn't a full path name. I'm guessing
- that when you did the later tests you still have gptmbr.bin installed in
- /usr/mdec - it would have been using that one.
It may well have been taking it from the wrwong place when I was
attempting from the current directory. I'll acknowledge I
didn't verify that well enough.
- | Work-around: move to the same directory as the biosboot image file.
-
- Use a full path name if you want to get the file from elsewhere.
I would have sworn I tried that and got an error. But I didn't.
- Whether it could allow more flexibility (not prepend /usr/mdec if the name
- starts ./ or ../ as well as /) is someone else's decision, but at the very
- least the man page needs improvement.
Yes, please. If I get bored after getting this problem machine
to boot, I'll look into that.
Thanks,
Eric
--
Eric Schnoebelen eric@cirr.com http://www.cirr.com
Whenever people agree with me I always feel I must be wrong.
-- Oscar Wilde
Responsible-Changed-From-To: bin-bug-people->jnemeth
Responsible-Changed-By: jnemeth@NetBSD.org
Responsible-Changed-When: Sun, 26 Aug 2018 00:46:30 +0000
Responsible-Changed-Why:
I'll hande it.
State-Changed-From-To: open->feedback
State-Changed-By: jnemeth@NetBSD.org
State-Changed-When: Sun, 26 Aug 2018 00:46:30 +0000
State-Changed-Why:
I asked a question.
From: John Nemeth <jnemeth@cue.bc.ca>
To: gnats-bugs@NetBSD.org, gnats-admin@netbsd.org, netbsd-bugs@netbsd.org
Cc:
Subject: Re: bin/53553: gpt biosboot forcibly prepends /usr/mdec to any other paht
Date: Sat, 25 Aug 2018 17:41:18 -0700
On Aug 25, 10:20pm, eric@cirr.com wrote:
}
} >Number: 53553
} >Category: bin
} >Synopsis: gpt biosboot forcibly prepends /usr/mdec to any other paht
} >Description:
} Attempting to use a gpt(8) biosboot subcommand with a file
} in any location other than /usr/mdec gets /usr/mdec forcibly
} prepended to the path.
The code is:
if (bootpath == NULL)
bp = strdup(DEFAULT_BOOTDIR "/" DEFAULT_BOOTCODE);
else if (*bootpath == '/')
bp = strdup(bootpath);
else {
if (asprintf(&bp, "%s/%s", DEFAULT_BOOTDIR, bootpath) < 0)
bp = NULL;
}
It would be easy enough to change the second part to see if the
path starts with "." which is a common way of stopping the prepending
of a default path. I'm undecided if it should check for "/" anywhere
in the path. However, if that's what people think is best, I'm
willing to make either change. I checked the installboot source
to see what it does, and it just uses the path as given. I think
adding a default path makes it somewhat more convenient to use.
}-- End of excerpt from eric@cirr.com
From: matthew green <mrg@eterna.com.au>
To: John Nemeth <jnemeth@cue.bc.ca>
Cc: gnats-bugs@NetBSD.org, gnats-admin@netbsd.org,
netbsd-bugs@netbsd.org
Subject: re: bin/53553: gpt biosboot forcibly prepends /usr/mdec to any other paht
Date: Sun, 26 Aug 2018 11:21:18 +1000
> path starts with "." which is a common way of stopping the prepending
> of a default path. I'm undecided if it should check for "/" anywhere
> in the path. However, if that's what people think is best, I'm
> willing to make either change. I checked the installboot source
> to see what it does, and it just uses the path as given. I think
> adding a default path makes it somewhat more convenient to use.
i think any path with a / should probably be used as-is. only
final names should look in /usr/mdec..
alternatively, try the named path _as is_ first, and if that
does not work, try it under /usr/mdec.
.mrg.
From: eric@cirr.com (Eric Schnoebelen)
To: gnats-bugs@NetBSD.org
Cc: gnats-admin@netbsd.org, netbsd-bugs@netbsd.org
Subject: Re: bin/53553: gpt biosboot forcibly prepends /usr/mdec to any other paht
Date: Fri, 31 Aug 2018 11:28:52 -0500
John Nemeth writes:
- On Aug 25, 10:20pm, eric@cirr.com wrote:
- } >Number: 53553
- } >Category: bin
- } >Synopsis: gpt biosboot forcibly prepends /usr/mdec to any othe=
r paht
- } >Description:
- } Attempting to use a gpt(8) biosboot subcommand with a file
- } in any location other than /usr/mdec gets /usr/mdec forcibly
- } prepended to the path.
- =
- The code is:
- =
- if (bootpath =3D=3D NULL)
- bp =3D strdup(DEFAULT_BOOTDIR "/" DEFAULT_BOOTCODE);
- else if (*bootpath =3D=3D '/')
- bp =3D strdup(bootpath);
- else {
- if (asprintf(&bp, "%s/%s", DEFAULT_BOOTDIR, bootpath) <=
0)
- bp =3D NULL;
- }
- =
- It would be easy enough to change the second part to see if the
- path starts with "." which is a common way of stopping the prepending
- of a default path. I'm undecided if it should check for "/" anywhere
- in the path. However, if that's what people think is best, I'm
- willing to make either change. I checked the installboot source
- to see what it does, and it just uses the path as given. I think
- adding a default path makes it somewhat more convenient to use.
After a few days reflection, I would be happy if the current
mechanisms were documented on the gpt(8) manual page.
Given the lack of documentation there, and the first error when
trying an unanchored path, I followed the common practice of
prepending './' to try and anchor do the current directory.
=46rom my perspective, either choice would be sufficent to remove
the frustration I experienced. However, the second might bring it into
line with a large number of other tools. =
Thanks,
Eric
State-Changed-From-To: feedback->open
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Wed, 09 Jun 2021 03:37:56 +0000
State-Changed-Why:
Feedback was received, in 2018.
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.46 2020/01/03 16:35:01 leot Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2020
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.