ubuntu preseed install fails to set a hostname

Bug #1452202 reported by bugproxy on 2015-05-06
30
This bug affects 4 people
Affects Status Importance Assigned to Milestone
debian-installer (Ubuntu)
Medium
Eric Desrochers
Trusty
Medium
Eric Desrochers
Xenial
Medium
Eric Desrochers
Bionic
Medium
Eric Desrochers
netcfg (Debian)
New
Unknown
preseed (Ubuntu)
Medium
Eric Desrochers
Trusty
Medium
Eric Desrochers
Xenial
Medium
Eric Desrochers
Bionic
Medium
Eric Desrochers

Bug Description

[Impact]

 * DHCP hostname take precedence over netcfg/hostname, if set.

The problem is that the system read the preseed file after having run netcfg, thus the preseed parameter cannot be loaded straight from the start.

[Test Case]

 * HOWTO reproduce :

Install Ubuntu using a preseed[1] file[2] and add the following line in the preseed recipe :
d-i netcfg/hostname string <HOSTNAME>

If the machine get a HOSTNAME from DHCP server or from a reverse lookup, netcfg/hostname doesn't take precedence.

[1] - url=http://<WEB_SERVER>/<PRESEED_FILE>
[2] - https://help.ubuntu.com/lts/installation-guide/example-preseed.txt

[Regression Potential]

 * none expected, the change is trivial and has been intensively jointly tested by myself and cyphermox.

[Other Info]

 * Debian bug : https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=755848
   Patch has been submitted to Debian
 * There is an old patch introduced in 2012 [Use netcfg/hostname for the hostname if found. (Closes: #606636)] but that doesn't work as expected.

[Original Description]

== Comment: #0 - Edward R. Cheslek <email address hidden> - 2015-04-28 18:04:01 ==
---Problem Description---
An install using a preseed file fails to configure the hostname of the system being installed.

Contact Information = <email address hidden>

---uname output---
Ubuntu 15.04 ppc64le

Machine Type = Tuleta pKVM guest

---Debugger---
A debugger is not configured

---Steps to Reproduce---
 set up an automated install using a preseed file. Grub menu entry:

menuentry "Test" {
        linux ubuntu-installer/ppc64el/vmlinux tasks=standard pkgsel/language-pack-patterns= pkgsel/install-language-support=false auto=true preseed/url=http://10.33.11.31/data/autoinst/ted.preseed
        initrd ubuntu-installer/ppc64el/initrd.gz
}

The install will begin, and reach the hostname configuration screen, then stop, waiting for input. The hostname is set in the preseed file, which is attached.

Install method: http from ports.ubuntu.com

Install disk info: n/a

Install ISO Information: n/a

*Additional Instructions for <email address hidden>:
-Post a private note with access information to the machine that the bug is occuring on.

== Comment: #1 - SANDHYA VENUGOPALA <email address hidden> - 2015-04-29 06:08:18 ==
Some literature that is floating around -

when booting from an installation CD and using a preseed file on a network, the installer will need answers to some questions (hostname, network configuration, ...) before it can load the preseed file. On the other hand, including a customized preseed file in a setup CD will allow for more automation, but requires re-mastering of the CD.

The configuration of domain and host name, and keymap are still being asked, even if you have them in your preseed file as shown above. So if you want to kickstart the preseeded installation without a single questions asked, append the following more options to kernel boot prompt:

console-keymaps-at/keymap=us hostname=myhost domain=example.com locale=en_US

Perhaps David Heller can throw some light on this and let us know if its bug.

== Comment: #2 - Edward R. Cheslek <email address hidden> - 2015-04-29 07:57:29 ==
I'm booting and installing from the network. Even if I leave the hostname related options out of my preseed, it still picks up and displays the correct hostname from dhcp.

== Comment: #3 - David Heller <email address hidden> - 2015-05-05 14:12:52 ==
I'm not very familiar with this particular preseed option so I'm not sure how it's supposed to behave. However, in a quick test on Ubuntu 15.04, adding "netcfg/hostname=blah" to the kernel cmdline worked: it successfully overrode the hostname from DHCP (the way it is usually set in my environment) with no other changes required.

In the preseed however, I could not make it work, even if I commented out the related lines:

#d-i netcfg/get_hostname string unassigned-hostname
#d-i netcfg/get_domain string unassigned-domain
d-i netcfg/hostname string blah

And looking in the installer log, it could be a order of operations thing, since we see it picking up the hostname from DHCP before retrieving the preseed...

# cat /var/log/syslog | egrep "hostname|seed"
May 5 16:10:16 netcfg[2270]: INFO: DHCP hostname: "myhost"
May 5 16:10:16 netcfg[2270]: DEBUG: Preseeding domain from global: ibm.com
May 5 16:10:16 main-menu[301]: INFO: Menu item 'network-preseed' selected
May 5 16:10:18 preseed: successfully loaded preseed file from ftp://9.114.211.201/install/autoinst/myhost

That said: this doesn't tell exactly when the hostname was *set*, or if it should be overridden even if it is set at that point.

IMHO it should work the same way in the preseed as it does command-line, regardless of order, since that is what the user is requesting. If the installer already "set" the hostname from DHCP info, well, it should set it again with what the user wants.

But I don't know if this is supported or expected to work in all cases. Frankly, I'm not even sure if this is the correct way to do it in preseed (although it seems like it is).

But I think it's fair to mirror this to Ubuntu to ask.

== Comment: #5 - Edward R. Cheslek <email address hidden> - 2015-05-05 16:21:35 ==
I can set the hostname on the linux kernel line in grub, and it will show up correctly in the installer, but my issue is that the install still asks me to confirm that the hostname is correct. I want to proceed through my install totally unattended.

Default Comment by Bridge

tags: added: architecture-ppc64le bugnameltc-124423 severity-high targetmilestone-inin1510

Default Comment by Bridge

Default Comment by Bridge

Thank you for taking the time to report this bug and helping to make Ubuntu better. It seems that your bug report is not filed about a specific source package though, rather it is just filed against Ubuntu in general. It is important that bug reports be filed about source packages so that people interested in the package can find the bugs about it. You can find some hints about determining what package your bug might be about at https://wiki.ubuntu.com/Bugs/FindRightPackage. You might also ask for help in the #ubuntu-bugs irc channel on Freenode.

To change the source package that this bug is filed about visit https://bugs.launchpad.net/ubuntu/+bug/1452202/+editstatus and add the package name in the text box next to the word Package.

[This is an automated message. I apologize if it reached you inappropriately; please just reply to this message indicating so.]

tags: added: bot-comment
tags: added: vivid
affects: ubuntu → debian-installer (Ubuntu)

Confirming/Triaged: I can reproduce this here easily; preseeded hostname should indeed get used. As I recall this isn't a new issue.

Setting priority to medium since there is an "easy" workaround for it.

Changed in debian-installer (Ubuntu):
status: New → Triaged
importance: Undecided → Medium
Steve Langasek (vorlon) on 2015-08-27
Changed in debian-installer (Ubuntu):
assignee: nobody → Mathieu Trudel-Lapierre (mathieu-tl)

Looks to me like you're "just" missing adding 'priority=critical' on the command-line to avoid being asked for the hostname. This happens before while the hostname is preseeded, the network needs to be brought up before it can be read, and netcfg does both bringing up the network and setting the hostname. Setting the debconf priority to 'critical' avoids the initial questions about the keymap and hostname/network settings. In other words, this means for a fully-automated, unattended preseeded install, you wouldn't need to specify hostname or keymap/locale, as SANDHYA VENUGOPALA suggested.

There still appears to be a bug though, in the way that netcfg doesn't honor the preseeded settings and set the hostname in /target (or in the installer environment, for that matter).

I will leave to your choice whether you want to close this bug report now, or keep it open for the netcfg bug I described, which still matches the title and description.

------- Comment From <email address hidden> 2015-09-09 09:54 EDT-------
Making the comment external -

Edward R. Cheslek 2015-09-08 21:16:54 EDT

Mathieu, I guess you're the developer who will be fixing this netcfg issue? If that's that's the case, then it's at your discretion whether you'd prefer to close this as "will not fix", or drive the netcfg issue to resolution here. For me, I'd prefer to keep everything contained to this one bug, for clarity/completeness. If you do open a new bug, please cc myself and <email address hidden>.

Yes, I'd be the one fixing this issue -- I'm just responding to the fact that this was initially opened as "how can I make d-i not ask for the hostname, to get a fully unattended install". In this sense, the bug is "fixed", by bringing up debconf priority, the install will be unattended.

Now, I'd like to have an idea on how important teaching netcfg to apply hostname again later (either from what is received from DHCP or from preseeded settings), so we know whether this changes any priorities.

Reassigning to netcfg which is the correct package where to fix this.

affects: debian-installer (Ubuntu) → netcfg (Ubuntu)
Changed in netcfg (Ubuntu):
status: Triaged → In Progress
bugproxy (bugproxy) wrote :

------- Comment From <email address hidden> 2016-01-28 06:04 EDT-------
Canonical,

Any updates?

bugproxy (bugproxy) wrote :

------- Comment From <email address hidden> 2016-03-15 05:48 EDT-------
Canonical,

Any updates?

bugproxy (bugproxy) wrote :

------- Comment From <email address hidden> 2016-06-27 02:58 EDT-------
What would be the target release for this bug?

bugproxy (bugproxy) wrote :

------- Comment From <email address hidden> 2016-07-08 02:29 EDT-------
.

Sandhya Venugopala (vsandhya) wrote :

Hi Mathieu Trudel-Lapierre,

Kindly let us know the updates and target release.

Changed in netcfg:
status: Unknown → New

This bug is still on my list, but there hasn't been progress for the moment. The workaround I can think of to set hostname during the install would be to preseed the value on the command-line (setting netcfg/hostname=whatever along with priority=critical, etc.).

Eric Desrochers (slashd) on 2016-09-20
Changed in netcfg (Ubuntu):
assignee: Mathieu Trudel-Lapierre (cyphermox) → Eric Desrochers (slashd)
Eric Desrochers (slashd) wrote :

Fix for Yakkety

description: updated
description: updated
Eric Desrochers (slashd) wrote :

Fix for Trusty

tags: added: sts
Eric Desrochers (slashd) on 2016-09-21
description: updated
Eric Desrochers (slashd) on 2016-09-21
description: updated
description: updated

The attachment "Fix for Yakkety" seems to be a debdiff. The ubuntu-sponsors team has been subscribed to the bug report so that they can review and hopefully sponsor the debdiff. If the attachment isn't a patch, please remove the "patch" flag from the attachment, remove the "patch" tag, and if you are member of the ~ubuntu-sponsors, unsubscribe the team.

[This is an automated message performed by a Launchpad user owned by ~brian-murray, for any issue please contact him.]

tags: added: patch
Eric Desrochers (slashd) on 2016-09-28
Changed in netcfg (Ubuntu Trusty):
assignee: nobody → Eric Desrochers (slashd)
importance: Undecided → Medium
status: New → In Progress
Eric Desrochers (slashd) on 2016-09-28
description: updated
bugproxy (bugproxy) wrote :

------- Comment From <email address hidden> 2016-09-29 10:13 EDT-------
This bug is actually targeted 15.10, which is past end of life.
To submitter, is this reproducible on 16.04 or 16.10?
If so, please retarget or close.
Thanks!

Default Comment by Bridge

Default Comment by Bridge

Default Comment by Bridge

Changed in netcfg (Ubuntu Xenial):
importance: Undecided → Medium
affects: netcfg → ubuntu-translations
Changed in ubuntu-translations:
importance: Unknown → Undecided
no longer affects: ubuntu-translations
Changed in netcfg (Debian):
status: Unknown → New
Eric Desrochers (slashd) wrote :

I have deleted the proposed .debdiff as I want to re-work them a little bit.

Will re-submit once my re-work is completed.

Eric

Eric Desrochers (slashd) wrote :

Additional note about the re-work.

The original patch I have submitted works as expected by overriding the hostname but ...

I noticed after more testing that if LVM is used partman rely on "/etc/hostname" to name the VG[1] for instance : <hostname>--vg-root.

Unfortunately, the current patch does the hostname overriden after that the Volume Group is created which make the vg name and hostname inconsistent.

The re-work of the patch will consist on making sure the hostname override happens before the vgcreate to keep things consistent and not having a vg group that display the hostname before it has been overriden.

[1] - lib/auto-lvm.sh
278 auto_lvm_perform() {
279 # Use hostname as default vg name (if available)
280 local defvgname pv vg_file vg_name
281 # $pv_devices will be overridden with content from $VG_MAP_DIR
282 local pv_devices
283
284 db_get partman-auto-lvm/new_vg_name
285 if [ -z "$RET" ]; then
286 if [ -s /etc/hostname ]; then
287 defvgname=$(cat /etc/hostname | head -n 1 | tr -d " ")
288 fi
289 if [ "$defvgname" ]; then
290 db_set partman-auto-lvm/new_vg_name $defvgname-vg
291 else
292 db_set partman-auto-lvm/new_vg_name Ubuntu
293 fi
294 fi

Eric Desrochers (slashd) wrote :

Moving the script in preseed src code under "network-preseed.postinst" address the vg name creation situation (see previous comment).

It basically make "netcfg/hostname",if set, to load (override the hostname) before the "Volume Group" creation start which build the vg name based on the hostname (/etc/hostname)

Thanks cyphermox for your help.

Eric

Eric Desrochers (slashd) wrote :

Debdiff for Yakkety

Eric Desrochers (slashd) wrote :

Debdiff for Trusty

bugproxy (bugproxy) wrote :

Default Comment by Bridge

Eric Desrochers (slashd) wrote :

Debdiff for Xenial

Changed in netcfg (Ubuntu Xenial):
assignee: nobody → Eric Desrochers (slashd)
status: New → In Progress
Eric Desrochers (slashd) on 2016-10-05
tags: added: sts-sponsor
removed: targetmilestone-inin1510 vivid
tags: added: sts-sru
description: updated
description: updated
bugproxy (bugproxy) on 2016-10-05
tags: added: targetmilestone-inin1510

Since we changed stuff in preseed, fixing up the package links...

affects: netcfg (Ubuntu) → preseed (Ubuntu)
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package preseed - 1.71ubuntu3

---------------
preseed (1.71ubuntu3) yakkety; urgency=medium

  * Fix for netcfg/hostname, if set, to take precedence. (LP: #1452202)
    - Modify debian/network-preseed.postinst

 -- Eric Desrochers <email address hidden> Wed, 05 Oct 2016 11:50:09 -0400

Changed in preseed (Ubuntu):
status: In Progress → Fix Released

Hello bugproxy, or anyone else affected,

Accepted preseed into xenial-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/preseed/1.71ubuntu1.1 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, and change the tag from verification-needed to verification-done. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed. In either case, details of your testing will help us make a better decision.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance!

Changed in preseed (Ubuntu Xenial):
status: In Progress → Fix Committed
tags: added: verification-needed
Eric Desrochers (slashd) wrote :

I have tested "preseed - 1.71ubuntu1.1" by rebuilding the source code on a PPA along with d-i "20101020ubuntu451.6" in order to get a mini.iso.

I confirmed the mini.iso override the hostname as expected if "netcfg/hostname" is set and that the override occurred before the disk configuration for the vg name to match with the overridden hostname, if LVM is use.

Eric

tags: added: verification-done
removed: verification-needed
Eric Desrochers (slashd) wrote :

Next step, is to increase the version of d-i for Y/X/T for the change in preseed to be rebuild and be part of the new ISOs (Daily)

Eric

Changed in debian-installer (Ubuntu):
status: New → In Progress
Changed in debian-installer (Ubuntu Trusty):
status: New → In Progress
Changed in debian-installer (Ubuntu):
importance: Undecided → Medium
Changed in debian-installer (Ubuntu Xenial):
status: New → In Progress
Changed in debian-installer (Ubuntu Trusty):
importance: Undecided → Medium
Changed in debian-installer (Ubuntu Xenial):
importance: Undecided → Medium
Eric Desrochers (slashd) wrote :

d-i debdiff for Yakkety

Eric Desrochers (slashd) wrote :

d-i debdiff for Xenial

Eric Desrochers (slashd) wrote :

d-i debdiff for Trusty

Changed in debian-installer (Ubuntu):
assignee: nobody → Eric Desrochers (slashd)
Changed in debian-installer (Ubuntu Xenial):
assignee: nobody → Eric Desrochers (slashd)
Changed in debian-installer (Ubuntu Trusty):
assignee: nobody → Eric Desrochers (slashd)

Ok, looks like yakkety already has picked up the latest preseed in the current debian-installer package in the images; marking this one Fix Released.

Changed in debian-installer (Ubuntu):
status: In Progress → Fix Released
Brian Murray (brian-murray) wrote :

Hello bugproxy, or anyone else affected,

Accepted preseed into trusty-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/preseed/1.62ubuntu1.1 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, and change the tag from verification-needed to verification-done. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed. In either case, details of your testing will help us make a better decision.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance!

Changed in preseed (Ubuntu Trusty):
status: In Progress → Fix Committed
tags: removed: verification-done
tags: added: verification-needed
Eric Desrochers (slashd) wrote :

I have tested on Trusty with "preseed - 1.62ubuntu1.1" by rebuilding the source code on a PPA along with d-i " 20101020ubuntu318.40" in order to get a mini.iso.

I confirmed the mini.iso override the hostname as expected if "netcfg/hostname" is set and that the override occurred before the disk configuration for the vg name to match with the overridden hostname, if LVM is use.

Eric

tags: added: verification-done
removed: verification-needed
Martin Pitt (pitti) wrote :

Hello bugproxy, or anyone else affected,

Accepted debian-installer into trusty-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/debian-installer/20101020ubuntu318.41 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, and change the tag from verification-needed to verification-done. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed. In either case, details of your testing will help us make a better decision.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance!

Changed in debian-installer (Ubuntu Trusty):
status: In Progress → Fix Committed
tags: removed: verification-done
tags: added: verification-needed
Eric Desrochers (slashd) wrote :

The d-i debdiff contains no changes, it is only to allow the rebuild (Daily ISO) to happen and to pick up the latest change in preseed package.

Eric

tags: added: verification-done
removed: verification-needed
Louis Bouchard (louis) on 2016-10-20
tags: removed: sts-sponsor

Default Comment by Bridge

Default Comment by Bridge

Default Comment by Bridge

Default Comment by Bridge

Default Comment by Bridge

Default Comment by Bridge

Default Comment by Bridge

Default Comment by Bridge

Launchpad Janitor (janitor) wrote :

This bug was fixed in the package preseed - 1.62ubuntu1.1

---------------
preseed (1.62ubuntu1.1) trusty; urgency=medium

  * Fix for netcfg/hostname, if set, to take precedence. (LP: #1452202)
    - Modify debian/network-preseed.postinst

 -- Eric Desrochers <email address hidden> Wed, 05 Oct 2016 11:58:53 -0400

Changed in preseed (Ubuntu Trusty):
status: Fix Committed → Fix Released

The verification of the Stable Release Update for preseed has completed successfully and the package has now been released to -updates. Subsequently, the Ubuntu Stable Release Updates Team is being unsubscribed and will not receive messages about this bug report. In the event that you encounter a regression using the package from -updates please report a new bug using ubuntu-bug and tag the bug report regression-update so we can easily find any regressions.

Launchpad Janitor (janitor) wrote :

This bug was fixed in the package preseed - 1.71ubuntu1.1

---------------
preseed (1.71ubuntu1.1) xenial; urgency=medium

  * Fix for netcfg/hostname, if set, to take precedence. (LP: #1452202)
    - Modify debian/network-preseed.postinst

 -- Eric Desrochers <email address hidden> Wed, 05 Oct 2016 12:01:39 -0400

Changed in preseed (Ubuntu Xenial):
status: Fix Committed → Fix Released
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package debian-installer - 20101020ubuntu318.41

---------------
debian-installer (20101020ubuntu318.41) trusty; urgency=medium

  * No change rebuild to pick up the latest change in preseed (LP: #1452202)

 -- Eric Desrochers <email address hidden> Mon, 17 Oct 2016 17:29:25 -0400

Changed in debian-installer (Ubuntu Trusty):
status: Fix Committed → Fix Released

Hello bugproxy, or anyone else affected,

Accepted debian-installer into xenial-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/debian-installer/20101020ubuntu451.7 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation on how to enable and use -proposed.Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, and change the tag from verification-needed to verification-done. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed. In either case, details of your testing will help us make a better decision.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance!

Changed in debian-installer (Ubuntu Xenial):
status: In Progress → Fix Committed
tags: removed: verification-done
tags: added: verification-needed

Hello bugproxy, or anyone else affected,

Accepted debian-installer into xenial-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/debian-installer/20101020ubuntu451.8 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation on how to enable and use -proposed.Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, and change the tag from verification-needed to verification-done. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed. In either case, details of your testing will help us make a better decision.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance!

Adam Conrad (adconrad) wrote :

Hello bugproxy, or anyone else affected,

Accepted debian-installer into xenial-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/debian-installer/20101020ubuntu451.9 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation on how to enable and use -proposed.Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, and change the tag from verification-needed to verification-done. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed. In either case, details of your testing will help us make a better decision.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance!

------- Comment From <email address hidden> 2016-12-07 05:06 EDT-------
Hi Edward ,

Kindly update the bug once tested.

Adam Conrad (adconrad) wrote :

Still waiting on someone to test the xenial debian-installer upload and tell us that the bug is indeed fixed there.

Eric Desrochers (slashd) wrote :

The patch has been tested a while ago, but the tag never been changed.

I change the tag to verification-done.

Thanks Adam for pointing this out.

Eric

tags: added: verification-done
removed: verification-needed
bugproxy (bugproxy) wrote :

------- Comment From <email address hidden> 2017-01-12 11:42 EDT-------
This is fixed, thanks everyone.

Launchpad Janitor (janitor) wrote :

This bug was fixed in the package debian-installer - 20101020ubuntu451.9

---------------
debian-installer (20101020ubuntu451.9) xenial; urgency=medium

  * Bump FLOPPY_SIZE by 2MB on amd64 and i386 for linux-firmware growth.

debian-installer (20101020ubuntu451.8) xenial; urgency=medium

  * No change rebuild to pick up the latest change in preseed (LP: #1452202)

 -- Adam Conrad <email address hidden> Wed, 07 Dec 2016 01:10:51 -0700

Changed in debian-installer (Ubuntu Xenial):
status: Fix Committed → Fix Released
Louis Bouchard (louis) on 2017-03-22
tags: added: sts-sru-done
removed: sts-sru
Peter Wu (lekensteyn) wrote :

There are two problems with the patch:
1. netcfg/hostname=ubuntu (or any value containing "ubuntu") remains unfixed.
2. Certain DHCP hostnames can result in corrupting the hosts file.

For example, with DHCP name "node" and "netcfg/hostname=newname" we have this command:
/bin/sed -i "s/$CURRENT_HOSTNAME/$NETCFG_HOSTNAME/" /etc/hosts
which would change "ff02::1 ip6-allnodes" into "ff02::1 ip6-allnewnames".

(I actually ran into the first issue, trying to set hostname "ubuntu" which failed and resulted in a hostname that consists of an IP address...)

Peter Wu (lekensteyn) wrote :

See also the comments in https://unix.stackexchange.com/questions/106614/preseed-cfg-ignoring-hostname-setting, and in particular the reference to
http://d-i.alioth.debian.org/manual/en.i386/apbs04.html#preseed-network
The hostname is probably a very common case though.

I am currently using this in my preseed file (tested with Ubuntu 16.04.2 mini.iso):

d-i preseed/early_command string hostname=ubuntu; \
    sed "s/^127.0.1.1\t.*/127.0.1.1\t$hostname/" -i /etc/hosts; \
    echo "$hostname" > /etc/hostname; hostname "$hostname"

Proposal: revert the current patch and suggest the above preseed config *or* modify preseed:
1. Change sed commands to something like the above.
2. Remove "f ! echo "$RET" | grep -q 'ubuntu';" such that the hostname is unconditionally set when netcfg/hostname is given.

Note that "127.0.1.1\t%s" originates from netcfg-1.135ubuntu4.2, function netcfg_write_common in netcfg-common.c. This exact match does not rely on the current hostname which should possible regex injection issues.

Hua Zhang (zhhuabj) wrote :

I think Peter Wu is totally right.

In addition to above two problems, there is still another problem with the patch that the present regular expression '/bin/sed -i "s/$CURRENT_HOSTNAME/$NETCFG_HOSTNAME/" /etc/hosts' can't handle multiple hostname case:

$ echo '127.0.1.1 ubuntu.me.com ubuntu' |sed "s/ubuntu/newnode/"
127.0.1.1 newnode.me.com ubuntu

$ echo '127.0.1.1 ubuntu.me.com ubuntu' |sed "s/ubuntu/newnode/g"
127.0.1.1 newnode.me.com newnode

Hua Zhang (zhhuabj) wrote :

Maybe we can use the following regex instead, 'awk '$1 ~ /^127|localhost/ {print $0}'' is used to fix 'ff02::1 ip6-allnodes' case, and add 'g' option to modifity all hostname.

$ hostname=ubuntu
$ echo '127.0.1.1 ubuntu.me.com ubuntu' |awk '$1 ~ /^127|localhost/ {print $0}' |sed "s/\s*\(${hostname}\)\(\s*\)/\tnewnode/g"
127.0.1.1 newnode.me.com newnode

Addition, also need to remove "f ! echo "$RET" | grep -q 'ubuntu';" as Peter Wu said above

Hua Zhang (zhhuabj) wrote :

I mean:

/usr/bin/awk '$1 ~ /^127|localhost/ {print $0}' /etc/hosts | /bin/sed "s/\s*\(${CURRENT_HOSTNAME}\)\(\s*\)/\t${NETCFG_HOSTNAME}/g"

Default Comment by Bridge

Default Comment by Bridge

Default Comment by Bridge

Default Comment by Bridge

Default Comment by Bridge

Default Comment by Bridge

Default Comment by Bridge

Default Comment by Bridge

Default Comment by Bridge

Default Comment by Bridge

Default Comment by Bridge

Hua Zhang (zhhuabj) wrote :

The following regex is more better

/bin/sed -i "/^[127|localhost]/s/${CURRENT_HOSTNAME}/${NETCFG_HOSTNAME}/g" /etc/hosts

Eric Desrochers (slashd) wrote :

Hi Hua Zhang,

Just as an FYI...

A rebuild of "d-i" will be also required after your "preseed" SRU change in order to generate a new Minimal image of Ubuntu (mini.iso).

Note that there is a "d-i" FTBTFS situation that will need to be fix for "d-i" before the "d-i" rebuilt for the package to successfully build. I have already reported the bug about it:
LP: #1743787

- Eric

Hua Zhang (zhhuabj) wrote :
Hua Zhang (zhhuabj) wrote :
Hua Zhang (zhhuabj) wrote :
Hua Zhang (zhhuabj) wrote :
Hua Zhang (zhhuabj) wrote :
Hua Zhang (zhhuabj) on 2018-01-24
tags: added: sts-sru-needed
removed: sts-sru-done verification-done
Hua Zhang (zhhuabj) wrote :

Remove the debdiff for "d-i" for Trusty only and Eric will take care of it in lp bug #1743787

Eric Desrochers (slashd) wrote :

Hi Joshua,

As discussed on irc, It would be best for Trusty to use the debdiff I made found in LP: #1743787.

Otherwise, when the "d-i" rebuild will be needed to generate a new mini.iso for instance, "d-i" will fail to build.

Everything is documented in the bug.

- Eric

Default Comment by Bridge

I don't think I'd want to have the patches provided applied as-is. There are multiple problems with them:

- The default hostname is 'ubuntu', and is the value you will get if nothing is preseeded -- we *do* need to skip it in this case, although the grep may need to be more precise. A name like 'ubuntuxenial' should match this grep.

- The sed needs to be fixed to more appropriately catch for the exact string, rather than any substring -- ie. it should not match 'ipv6-allnodes' if the name received from DHCP was 'node'. It should only match and replace for 'node'.

- You do not want to replace for all of 127 in /etc/hosts: you should not replace 127.0.0.1, but instead only "add" (replace, if necessary) 127.0.1.1; so maybe simply replace that entire line (to account for the case where multiple hostnames are set).

Eric Desrochers (slashd) wrote :

IIUC,one of the goal mentioned by cyphermox here seems to avoid the grep cmd to catch ubuntu pattern where hostname has ubuntu in it.

Example:
sometextbeforeubuntusometextafter
ubuntusometextafter
sometextbeforeubuntu

and only catch it when it is 'ubuntu' nothing else.

I think "-w" should suffice to keep the if statement remove in Joshua' proposal.

# man grep
-w, --word-regexp
              Select only those lines containing matches that form whole words.

if ! echo "$RET" | grep -qw 'ubuntu'; then
or
if ! echo "$RET" | grep -q '\<ubuntu\>'; then

Some quick tests I quickly ran on my laptop :
# echo "beforeubuntuafter" | grep -w "ubuntu"
# echo "beforeubuntuafter" | grep -w "ubuntu"
# echo "ubuntuafter" | grep -w "ubuntu"
# echo "ubuntu" | grep -w "ubuntu"
ubuntu

That should cover at least that one item.

Thoughts ?

- Eric

Hua Zhang (zhhuabj) wrote :

Hi Eric,

I think your proposal '-w' is good, so I will change to use:

if ! echo "$RET" | grep -qw 'ubuntu'; then

Mathieu,

How about using '/b' ? I mean using the following regex

/bin/sed -i "s/\b${CURRENT_HOSTNAME}\b/${NETCFG_HOSTNAME}/g" /etc/hosts

I have done some test below:

hua@t440p:~$ echo "node" | sed "s/\bnode\b/newnode/g"
newnode
hua@t440p:~$ echo "node." | sed "s/\bnode\b/newnode/g"
newnode.
hua@t440p:~$ echo "node.me.com" | sed "s/\bnode\b/newnode/g"
newnode.me.com
hua@t440p:~$ echo "ipv6-allnodes" | sed "s/\bnode\b/newnode/g"
ipv6-allnodes
hua@t440p:~$ echo "ipv6-allnodes node node.me.com node2 node2.me.com" | sed "s/\bnode\b/newnode/g"
ipv6-allnodes newnode newnode.me.com node2 node2.me.com

any thoughts ?

- joshua

Eric Desrochers (slashd) wrote :

Joshua,

That look good to me.

So I would suggest:

1) Keep the if statement and add the -w option to grep to be more robust
2) Modify the sed cmd with word boundaries (\b) to be more robust as well.

Can you build preseed & "d-i" in your PPA to generate a mini.iso and test the reproducer ?
If it fix the above situation, please redo the debdiff and we *cyphermox and I" will review it again.

Thanks

- Eric

Eric Desrochers (slashd) wrote :

Joshua,

Could you also report another bug against preseed for this particular case with this one as a reference ? With its own SRU justification tmpl, ....

It'll make sponsor and SRU team life easier to review.

- Eric

Hua Zhang (zhhuabj) wrote :

According to Eric's above comment, I've opened a new bug to track this at - https://bugs.launchpad.net/ubuntu/+source/preseed/+bug/1745531

tags: added: sts-sru-done
removed: sts-sru-needed
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers

Remote bug watches

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