New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sanitize hostname handling (fate #319639) #101
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,13 @@ | ||
#! /usr/bin/perl | ||
|
||
# helper script that | ||
# | ||
# (1) writes a list of assigned IP adresses to STDOUT, and | ||
# | ||
# (2) writes the FQDN or, if not available, the first IP to STDERR | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. returning value through STDERR seems a bit obscure to me. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. true, but I documented it... If you think this a serious problem, I could go and rewrite the script. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. as this is about implementing new feature and not about a hotfix I'd go for more clean implementation. |
||
# | ||
# The address in (2) should be something we can be reached by via network. | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the docs! I would also add a sample wicked output, so that the parser loop makes more sense to the future maintainer: # wicked show all
lo up
link: #1, state up
type: loopback
config: compat:suse:/etc/sysconfig/network/ifcfg-lo
leases: ipv4 static granted
leases: ipv6 static granted
addr: ipv4 127.0.0.1/8 [static]
addr: ipv6 ::1/128 [static]
ens7 up
link: #2, state up, mtu 1500
type: ethernet, hwaddr 52:54:00:05:0a:2c
config: compat:suse:/etc/sysconfig/network/ifcfg-ens7
eth1 up
link: #3, state up, mtu 1500
type: ethernet, hwaddr 52:54:00:d7:57:86
config: compat:suse:/etc/sysconfig/network/ifcfg-eth1
leases: ipv4 dhcp granted
leases: ipv6 dhcp requesting
addr: ipv4 10.230.34.112/18 [dhcp]
route: ipv4 default via 10.230.63.254 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fair enough; added |
||
$up = 0; | ||
|
||
for (`wicked show all 2>/dev/null`) { | ||
|
@@ -18,7 +26,10 @@ for (`wicked show all 2>/dev/null`) { | |
} | ||
|
||
if(@addr) { | ||
system "hostname $addr[0]"; | ||
chomp ($host = `hostname -f 2>/dev/null`); | ||
$host = $addr[0] if $host !~ /\./; | ||
|
||
print STDERR "$host\n"; | ||
|
||
print "IP addresses:\n"; | ||
print " $_\n" for @addr; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hostip_from_wicked
prints hostname including\n
at the end. Isn't it a problem (e.g.) here?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, shell swallows white space
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ehm, ok. So why do you explicitly append it? I'm just curios, not blocker for me ;-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No idea; the code is not by me. If you say it's not necessary, I'm fine with another line.