Skip to content

Commit 3261b3b

Browse files
author
Joe K
authored
Merge pull request #125 from joeysk2012/user-agent-change
Adding user-agent to IMDS requests
2 parents 9432c13 + 74639fb commit 3261b3b

File tree

4 files changed

+34
-5
lines changed

4 files changed

+34
-5
lines changed

GNUmakefile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
pkgname=amazon-ec2-net-utils
2-
version=2.6.0
2+
version=2.7.0
33

44
# Used by 'install'
55
PREFIX?=/usr/local
@@ -26,12 +26,16 @@ ${DIRS}:
2626
define varsubst
2727
sed -i "s,AMAZON_EC2_NET_UTILS_LIBDIR,${PREFIX}/share/${pkgname},g" $1
2828
endef
29+
define varsubstlibs
30+
sed -i "s,AMAZON_EC2_NET_UTILS_VERSION,${version},g" $1
31+
endef
2932

3033
.PHONY: install
3134
install: ${SHELLSCRIPTS} ${UDEVRULES} ${SHELLLIBS} | ${DIRS} ## Install the software. Respects DESTDIR
3235
$(foreach f,${SHELLSCRIPTS},tgt=${BINDIR}/$$(basename --suffix=.sh $f);\
3336
install -m755 $f $$tgt;${call varsubst,$$tgt};)
34-
$(foreach f,${SHELLLIBS},install -m644 $f ${SHARE_DIR})
37+
$(foreach f,${SHELLLIBS},tgt=${SHARE_DIR}/$$(basename $f);\
38+
install -m644 $f $$tgt;${call varsubstlibs,$$tgt};)
3539
$(foreach f,${UDEVRULES},install -m644 $f ${UDEVDIR};)
3640
$(foreach f,$(wildcard systemd/network/*.network),install -m644 $f ${SYSTEMD_NETWORK_DIR};)
3741
$(foreach f,$(wildcard systemd/system/*.service systemd/system/*.timer),install -m644 $f ${SYSTEMD_SYSTEM_DIR};)

amazon-ec2-net-utils.spec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Name: amazon-ec2-net-utils
2-
%define base_version 2.6.0
2+
%define base_version 2.7.0
33
%define source_version %{base_version}%{?_source_version_suffix}
44
Version: %{base_version}%{?_rpm_version_suffix}
55
Release: 1%{?dist}

debian/changelog

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
amazon-ec2-net-utils (2.7.0) unstable; urgency=medium
2+
3+
* New upstream release 2.7.0
4+
5+
-- Joe Kurokawa <joekurok@amazon.com> Thu, 26 Jun 2025 01:04:33 +0000
6+
17
amazon-ec2-net-utils (2.6.0) unstable; urgency=medium
28

39
* New upstream release 2.6.0

lib/lib.sh

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ declare unitdir
1919
declare lockdir
2020
declare reload_flag
2121

22+
# Version information - substituted during installation
23+
declare PACKAGE_VERSION="AMAZON_EC2_NET_UTILS_VERSION"
24+
if [ -z "$PACKAGE_VERSION" ]; then
25+
PACKAGE_VERSION="unknown"
26+
fi
27+
declare -r USER_AGENT="amazon-ec2-net-utils/$PACKAGE_VERSION"
2228
declare -r imds_endpoints=("http://169.254.169.254/latest" "http://[fd00:ec2::254]/latest")
2329
declare -r imds_token_path="api/token"
2430
declare -r syslog_facility="user"
@@ -39,7 +45,15 @@ declare self_iface_name=""
3945
make_token_request() {
4046
local ep=${1:-""}
4147
local interface=${2:-""}
42-
local -a curl_opts=(--max-time 5 --connect-timeout 0.15 -s --fail -X PUT -H "X-aws-ec2-metadata-token-ttl-seconds: 60")
48+
local -a curl_opts=(
49+
--max-time 5
50+
--connect-timeout 0.15
51+
-s
52+
--fail
53+
-X PUT
54+
-H "X-aws-ec2-metadata-token-ttl-seconds: 60"
55+
-A "$USER_AGENT"
56+
)
4357
if [ -n "$interface" ]; then
4458
curl_opts+=(--interface "$interface")
4559
fi
@@ -135,7 +149,12 @@ get_meta() {
135149
fi
136150
local url="${imds_endpoint}/meta-data/${key}"
137151
local meta rc
138-
local curl_opts=(-s --max-time 5 -H "X-aws-ec2-metadata-token:${imds_token}" -f)
152+
local curl_opts=(
153+
-s
154+
--max-time 5
155+
-H "X-aws-ec2-metadata-token:${imds_token}"
156+
-f
157+
-A "$USER_AGENT")
139158
if [[ "$imds_interface" != "$default_route" ]]; then
140159
curl_opts+=(--interface "$imds_interface")
141160
fi

0 commit comments

Comments
 (0)