diff options
author | Andrey V. Elsukov <ae@FreeBSD.org> | 2018-10-21 14:40:45 +0000 |
---|---|---|
committer | Andrey V. Elsukov <ae@FreeBSD.org> | 2018-10-21 14:40:45 +0000 |
commit | 5c88595e07a4c311931be2acb5017bb45a7f5e46 (patch) | |
tree | 6db14000e0015a07a9d6f88eb00778c2e63db1a8 /sbin | |
parent | ea7fdebe801f22674e8c864823ed4685e54bbddb (diff) | |
download | src-5c88595e07a4c311931be2acb5017bb45a7f5e46.tar.gz src-5c88595e07a4c311931be2acb5017bb45a7f5e46.zip |
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
Notes
Notes:
svn path=/head/; revision=339535
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/ifconfig/ifconfig.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/sbin/ifconfig/ifconfig.c b/sbin/ifconfig/ifconfig.c index 64ed407bdffd..3a36c431c86e 100644 --- a/sbin/ifconfig/ifconfig.c +++ b/sbin/ifconfig/ifconfig.c @@ -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++; + } } } |