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

[oneimage] Check if graph service address got from dhcp is valid url #324

Merged
merged 2 commits into from
Feb 23, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions files/image_config/updategraph/updategraph
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,14 @@ if [ "$src" = "dhcp" ]; then

HOSTNAME=`hostname -s`
GRAPH_URL=`sonic-cfggen -t /tmp/dhcp_graph_url -a "{\"hostname\": \"$HOSTNAME\"}"`
URL_REGEX='^(https?|ftp|file)://[-A-Za-z0-9\+&@#/%?=~_|!:,.;]*[-A-Za-z0-9\+&@#/%=~_|]$'
if [[ ! $GRAPH_URL =~ $URL_REGEX ]]; then
echo "Invalid graph url. Skipping graph update."
Copy link
Collaborator

Choose a reason for hiding this comment

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

print out the url for debug purpose

exit 0
fi
if [ "$dhcp_as_static" = "true" ]; then
sed -i "/src=d/d" /etc/sonic/updategraph.conf
echo "src=$GRAPH_URL" >> /etc/sonic/updategraph.conf
sed -i "/src=/d" /etc/sonic/updategraph.conf
echo "src=\"$GRAPH_URL\"" >> /etc/sonic/updategraph.conf
fi
else
GRAPH_URL=$src
Expand Down