-
Notifications
You must be signed in to change notification settings - Fork 125
Description
xsos v0.7.27 last mod 2021-03-12
I noticed this issue:
./xsos --os --scrub > /tmp/1
sed: -e expression #1, char 40: unterminated `s' command
And I went digging.
$ bash -x ./xsos --os --scrub
[snip]
+ proc_cmdline='BOOT_IMAGE=(hd0,msdos1)/boot/vmlinuz-4.18.0-240.22.1.el8.x86_64 root=UUID=348d0b1f-d963-4eaa-a7a4-6f65536f649e ro i915.preliminary_hw_support=1 crashkernel=auto rd.lvm.lv=VolGroup/usr ipv6.disable=1'
+ [[ y == y ]]
++ sed 's/\033[1;33mSCRUBBED\033[0;0m/HOSTNAME/g'
sed: -e expression #1, char 40: unterminated `s' command
+ proc_cmdline=
[snip]
Went to the code (lines 1177-1178):
proc_cmdline=$(sed -r 's,^BOOT_IMAGE=/[[:graph:]]+ ,,' "$1"/proc/cmdline)
echo test ${hostname%%.*}
[[ $XSOS_SCRUB_IP_HN == y ]] && proc_cmdline=$(sed "s/${hostname%%.*}/HOSTNAME/g" <<<"$proc_cmdline")
Huh. Why is my ${hostname%%.*} filled with \033[1;33mSCRUBBED\033[0;0m? That's odd to have colors in the hostname.
I decided to see what happened if I turned off the colors. I tried ./xsos -x --os --scrub > /tmp/2 and no errors! 🎊 That's confirmation that the colors are indeed the problem. I almost submitted a pull request because that's easy enough to filter the colors out of the SCRUBBED statement. But I had a weird thought.
$ bash -x ./xsos -x --os --scrub
[snip]
+ [[ y == y ]]
++ sed s/SCRUBBED/HOSTNAME/g
+ proc_cmdline='BOOT_IMAGE=(hd0,msdos1)/boot/vmlinuz-4.18.0-240.22.1.el8.x86_64 root=UUID=348d0b1f-d963-4eaa-a7a4-6f65536f649e ro i915.preliminary_hw_support=1 crashkernel=auto rd.lvm.lv=VolGroup/usr ipv6.disable=1'
[snip]
Um.... Why is the script replacing SCRUBBED with HOSTNAME? That's kinda pointless if the actual hostname is in the /proc/cmdline and who has "SCRUBBED" in their /proc/cmdline? 😜
I found the relevant code on line 1137
[[ $XSOS_SCRUB_IP_HN == y ]] && hostname="${c[Warn2]}SCRUBBED${c[0]}"
Hrm. There's a couple of different ways I could attempt to solve this. I think the way I would do it is to only check for the scrubbed hostname for the display on line 1141, and leave the actual hostname variable alone. Because it looks like it is used a few more times (1179, 1194, 3070), but once it has been altered with the "SCRUBBED" (with or without colors) then the pattern match used isn't really matching anything of value if the hostname is actually in /proc/cmdline or grub cmdline.
Since this is the first time I'm looking at this, I didn't want to be too presumptuous and just start hacking/slashing my way of solving it. I thought it would best be to alert of the issues and what I found.