Skip to content

Commit b508d5f

Browse files
joshtriplettdavem330
authored andcommitted
net: ipconfig: Don't override command-line hostnames or domains
If the user specifies a hostname or domain name as part of the ip= command-line option, preserve it and don't overwrite it with one supplied by DHCP/BOOTP. For instance, ip=::::myhostname::dhcp will use "myhostname" rather than ignoring and overwriting it. Fix the comment on ic_bootp_string that suggests it only copies a string "if not already set"; it doesn't have any such logic. Signed-off-by: Josh Triplett <josh@joshtriplett.org> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent dd62766 commit b508d5f

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

net/ipv4/ipconfig.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -886,7 +886,7 @@ static void __init ic_bootp_send_if(struct ic_device *d, unsigned long jiffies_d
886886

887887

888888
/*
889-
* Copy BOOTP-supplied string if not already set.
889+
* Copy BOOTP-supplied string
890890
*/
891891
static int __init ic_bootp_string(char *dest, char *src, int len, int max)
892892
{
@@ -935,12 +935,15 @@ static void __init ic_do_bootp_ext(u8 *ext)
935935
}
936936
break;
937937
case 12: /* Host name */
938-
ic_bootp_string(utsname()->nodename, ext+1, *ext,
939-
__NEW_UTS_LEN);
940-
ic_host_name_set = 1;
938+
if (!ic_host_name_set) {
939+
ic_bootp_string(utsname()->nodename, ext+1, *ext,
940+
__NEW_UTS_LEN);
941+
ic_host_name_set = 1;
942+
}
941943
break;
942944
case 15: /* Domain name (DNS) */
943-
ic_bootp_string(ic_domain, ext+1, *ext, sizeof(ic_domain));
945+
if (!ic_domain[0])
946+
ic_bootp_string(ic_domain, ext+1, *ext, sizeof(ic_domain));
944947
break;
945948
case 17: /* Root path */
946949
if (!root_server_path[0])

0 commit comments

Comments
 (0)