Bug 1027945 - /lib/udev/rename_device unable to handle HWADDR with comments
/lib/udev/rename_device unable to handle HWADDR with comments
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: initscripts (Show other bugs)
7.0
Unspecified Unspecified
high Severity medium
: rc
: ---
Assigned To: initscripts Maintenance Team
Jan Ščotka
:
Depends On:
Blocks: 909279
  Show dependency treegraph
 
Reported: 2013-11-07 08:31 EST by Jan Ščotka
Modified: 2016-11-25 08:07 EST (History)
3 users (show)

See Also:
Fixed In Version: initscripts-9.49.18-1.el7
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2015-03-05 05:52:12 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Jan Ščotka 2013-11-07 08:31:44 EST
Hi,
renaming binary /lib/udev/rename_device is unable to deal with comments after HWADDR=52:54:00:12:34:56
after boot, name of device is not ahoj, but system specific ens4 name

it is allowed in initscripts to have comments in bash style
renaming should deal with line like HWADDR=52:54:00:12:34:56 #comment here 
Without comment it works well.

What do you think?
    Thanks&Regards
    Honza

3: ens4: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 52:54:00:12:34:56 brd ff:ff:ff:ff:ff:ff
    inet 10.0.2.15/24 scope global dynamic ens4
       valid_lft 86372sec preferred_lft 86372sec
    inet6 fe80::5054:ff:fe12:3456/64 scope link 
       valid_lft forever preferred_lft forever
[root@localhost ~]# cat /etc/sysc
sysconfig/   sysctl.conf  sysctl.d/    

[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-ens4 
DEVICE=ahoj
ONBOOT=yes
BOOTPROTO=dhcp
HWADDR=52:54:00:12:34:56 #comment here 
TYPE=Ethernet

[root@localhost ~]# rpm -qa initscripts
initscripts-9.49.7-1.el7.x86_64
Comment 1 Jan Ščotka 2013-11-07 08:39:18 EST
Hi,
another thing is similar, but result is much more worse. Same problem with comment in DEVICE string
[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-ens4 
DEVICE=ahoj #commet here
ONBOOT=yes
BOOTPROTO=dhcp
HWADDR=52:54:00:12:34:56  
TYPE=Ethernet

result:
3: ahoj_#commet_he: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 52:54:00:12:34:56 brd ff:ff:ff:ff:ff:ff
    inet 10.0.2.15/24 scope global dynamic ahoj_#commet_he
       valid_lft 86378sec preferred_lft 86378sec
    inet6 fe80::5054:ff:fe12:3456/64 scope link 
       valid_lft forever preferred_lft forever

 Thanks&regards
 Honza
Comment 3 Lukáš Nykrýn 2013-11-08 08:30:58 EST
I think that something like this should be sufficient:

diff --git a/src/rename_device.c b/src/rename_device.c
index 8e28154..bb5e6b8 100644
--- a/src/rename_device.c
+++ b/src/rename_device.c
@@ -120,6 +120,14 @@ int isCfg(const struct dirent *dent) {
 }
 
 static inline char *dequote(char *start, char *end) {
+        char *c;
+        //remove comments and trailing whitespace
+        c = strchr(start, '#');
+        if (c!=NULL)
+                *c='\0';
+
+        g_strchomp(start);
+
        if (end==NULL) {
                end=start;
                while(*end) end++;
Comment 6 Lukáš Nykrýn 2014-03-10 11:56:09 EDT
This issue is not a blocker so reassigning to 7.1
Comment 10 Leos Pol 2015-01-13 11:45:08 EST
initscripts-9.49.23-1.el7

I've tried:
1. comment in HWADDR line
2. comment in DEVICE line
3. DEVICE name with hash char like "ahoj#comment"
Comment 12 errata-xmlrpc 2015-03-05 05:52:12 EST
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHBA-2015-0471.html

Note You need to log in before you can comment on or make changes to this bug.