Hi Nils,

I found the bug: 6486630 in dhcp client config, net-svc overwrites any
manual changes in hosts/ipnodes.

I've put it on the request-sponsor table.

Thanks.

Bonnie

Nils Goroll wrote On 10/26/06 06:39,:
> the webtool does not return a bugid.
> 
> There's a fix to be put into /lib/svc/method/net-svc (replaces the
> existing function)
> 
> Nils
> 
> 
> 
> ------------------------------------------------------------------------
> 
> #
> # update_files
> # This routine takes as a parameter, the name of the respective file 
> # (hosts or ipnodes) to update with the new host name and IP address.
> #
> update_files ()
> {
>       filename=$1;
> 
>       # escape dots for egrep
>       ipaddr_re="`echo $ipaddr | sed 's:\.:\\\.:g'`"
> 
>       # check if the address and host are already in the file
>       # as we need them - in this case we dont need to edit
>       # the file at all
>       #       
>       # - The ipaddr must be first field with optional whitespace in front
>       # - Either the hostname follows seperated by one whitespace (first
>       #   case of grouping after ipaddr), or it follows later
>       # - if the hostname is in a field further right, it must always
>       #   be preceeded by whitespace (ensured by first grouping)
>       #   and terminated by either whitespace, EOL or a comment
> 
>       # strip off all comments before matching
>       sed 's/#.*//' /etc/inet/${filename} | \
>           /usr/bin/egrep \
>               "^[     ]*${ipaddr_re}([        ]|[     ].*[     
> ])${hostname}([        #]|$)" \
>               >/dev/null \
>               && return
> 
>       # If we get here, we know that we are going to edit the file,
>       # so delete any "Added by DHCP" comments
>       /usr/bin/sed -e 's/[     ]*# Added by DHCP$//' /etc/inet/${filename} \
>           > /tmp/${filename}_clear.$$
> 
>       if /usr/bin/grep "^[    ]*$ipaddr[      ]" /etc/inet/${filename} 
> >/dev/null ; then
>               #
>               # IP address is already in the file, but the hostname
>               # isn't (otherwise we would have bailed out in the first
>               # egrep for ipaddr + host)
>               #
>               # Therefore, we append the proper DHCP hostname to the existing
>               # line by putting it in front of EOL or a comment, whatever is 
> first
>               #
>               /usr/bin/sed -e "/^[    ]*${ipaddr_re}[         ].*#/ {
>                                         s/\\(#.*\\)\$/        ${hostname}     
> \\1 # Added by DHCP/
>                                         n
>                                       }
>                                /^[    ]*${ipaddr_re}[         ]/ s/\$/        
> ${hostname}     # Added by DHCP/" \
>                   /tmp/${filename}_clear.$$ >/tmp/${filename}.$$
>               if [ $? != 0 ] ; then
>                       # Emergency exit, sed failed
>                       mv -f /tmp/${filename}_clear.$$ /tmp/${filename}.$$
>               fi
>       else
>               #
>               # IP address is missing from the respective file.  Now check
>               # to see if the hostname is present with a different IP.
>               #
>               shift $#        # Clear $0-9 in case grep fails
>               set -- `/usr/bin/grep -s -v '^#' /tmp/${filename}_clear.$$ | \
>                   /usr/bin/egrep "[    ]${hostname}([  #]|$)"`
> 
>               if [ $# -gt 0 ]; then
>                       #
>                       # Hostname is present in the file. Rewrite this line
>                       # to have the new IP address and the DHCP comment.
>                       #
>                       # include whitespace in group to keep proper formatting
>                       /usr/bin/sed -e "s/^[   ]*${1}\\([      
> ].*\\)\$/${ipaddr}\\1   # Added by DHCP/" \
>                           /tmp/${filename}_clear.$$ >/tmp/${filename}.$$
> 
>                       if [ $? != 0 ] ; then
>                           # Emergency exit, sed failed
>                           mv -f /tmp/${filename}_clear.$$ /tmp/${filename}.$$
>                       fi
> 
>               else
>                       #
>                       # Hostname is not present in the named file.
>                       # Add a new line for the host at the end of
>                       # the new respective file.
>                       #
>                       /usr/bin/mv /tmp/${filename}_clear.$$ \
>                           /tmp/${filename}.$$
>                       echo "${ipaddr}\t${hostname}\t# Added by DHCP" \
>                           >>/tmp/${filename}.$$
>               fi
>       fi
> 
>       /usr/bin/rm -f /tmp/${filename}_clear.$$
>       mv_file /tmp/${filename}.$$ /etc/inet/${filename} 444
> }
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> request-sponsor mailing list
> request-sponsor at opensolaris.org


Reply via email to