Skip to content
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

Added named.conf API transformation script to spec #7

Closed
wants to merge 1 commit into from

Conversation

tkrizek
Copy link
Contributor

@tkrizek tkrizek commented Jan 9, 2017

A script that converts old-style configuration API of named.conf
to the new-style API after rpm isntallation was added to contrib
specfile.
Required version of BIND was also bumped to 9.11.

LIBPATH=/usr/lib
fi

while read -r PATTERN
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This construct is used only to allow multiple lines to make the sed script a bit more readable.

do
SEDSCRIPT+="$PATTERN"
done <<EOF
/^\s*dynamic-db/,/};/ {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This scopes the changes only to dynamic-db part, until }; is found. This will fail in rare cases when }; is used as a part of string (i.e. in password) or in comment.

done <<EOF
/^\s*dynamic-db/,/};/ {

s/\(\s*\)arg\s\+\(["']\)\([a-Z_]\+\s\)/\1\3\2/g;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Transforms arg "name value" to name "value". Also works with single quotes.

s/^dynamic-db/dyndb/;

s@\(dyndb "[^"]\+"\)@\1 "$LIBPATH/bind/ldap.so"@;
s@\(dyndb '[^']\+'\)@\1 '$LIBPATH/bind/ldap.so'@;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$LIBPATH properly handles differences between i686 and x86_64.

Works with both single and double quotes.

s@\(dyndb "[^"]\+"\)@\1 "$LIBPATH/bind/ldap.so"@;
s@\(dyndb '[^']\+'\)@\1 '$LIBPATH/bind/ldap.so'@;

/\s*library[^;]\+;/d;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the old way of providing the path to library.

/\s*cache_ttl[^;]\+;/d;
/\s*psearch[^;]\+;/d;
/\s*serial_autoincrement[^;]\+;/d;
/\s*zone_refresh[^;]\+;/d;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove these deprecated options that are no longer supported.

}
EOF

sed -i.bak -e "$SEDSCRIPT" /etc/named.conf
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Run the sed script. Make a backup of /etc/named.conf. It may be useful if the transformation fails and the user needs to manually edit the /etc/named.conf file to use the new-style API.

@tkrizek
Copy link
Contributor Author

tkrizek commented Jan 9, 2017

This patch is meant to fix existing IPA installations when they're upgraded to use BIND-9.11. New IPA installations are covered by freeipa/freeipa#351

The script is written in sed. I added some inline comments for better clarity.

@MartinBasti
Copy link

IMO those explanatory comments should be in code not in github

@MartinBasti
Copy link

otherwise LGTM

A script that converts old-style configuration API of named.conf
to the new-style API after rpm isntallation was added to contrib
specfile.
Required version of BIND was also bumped to 9.11.
@tkrizek
Copy link
Contributor Author

tkrizek commented Feb 9, 2017

@tkrizek tkrizek closed this Feb 9, 2017
@tkrizek tkrizek added the pushed label Feb 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants