Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 21 Oct 2018 14:40:46 +0000 (UTC)
From:      "Andrey V. Elsukov" <ae@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r339535 - head/sbin/ifconfig
Message-ID:  <201810211440.w9LEekNc071561@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ae
Date: Sun Oct 21 14:40:45 2018
New Revision: 339535
URL: https://svnweb.freebsd.org/changeset/base/339535

Log:
  Do not allow use `create` keyword as hostname when ifconfig(8) is invoked
  for already existing interface.
  
  It appeared, that ifconfig(8) assumes `create` keyword as hostname and
  tries to resolve it, when `ifconfig ifname create` invoked for already
  existing interface. This can produce some unexpected results, when hostname
  resolving has successfully happened. This patch adds check for such case.
  When an interface is already exists, and create is only one argument,
  return error message. But when there are some other arguments, just remove
  create keyword from the arguments list.
  
  Obtained from:	Yandex LLC
  MFC after:	3 weeks
  Sponsored by:	Yandex LLC
  Differential Revision:	https://reviews.freebsd.org/D17171

Modified:
  head/sbin/ifconfig/ifconfig.c

Modified: head/sbin/ifconfig/ifconfig.c
==============================================================================
--- head/sbin/ifconfig/ifconfig.c	Sun Oct 21 14:23:56 2018	(r339534)
+++ head/sbin/ifconfig/ifconfig.c	Sun Oct 21 14:40:45 2018	(r339535)
@@ -504,6 +504,18 @@ main(int argc, char *argv[])
 			}
 #endif
 			errx(1, "interface %s does not exist", ifname);
+		} else {
+			/*
+			 * Do not allow use `create` command as hostname if
+			 * address family is not specified.
+			 */
+			if (argc > 0 && (strcmp(argv[0], "create") == 0 ||
+			    strcmp(argv[0], "plumb") == 0)) {
+				if (argc == 1)
+					errx(1, "interface %s already exist",
+					    ifname);
+				argc--, argv++;
+			}
 		}
 	}
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201810211440.w9LEekNc071561>