[Bug 2023924] Re: The latest version creates /\"/var/lib/hibinit-agent\" directory
Launchpad Bug Tracker
2023924 at bugs.launchpad.net
Wed Jul 26 01:17:11 UTC 2023
This bug was fixed in the package ec2-hibinit-agent -
1.0.0-0ubuntu11.22.04.3
---------------
ec2-hibinit-agent (1.0.0-0ubuntu11.22.04.3) jammy; urgency=medium
* d/p/lp2023924-remove-quotes-from-state-dir.patch: fixes an issue where a
weird directory would be created in root (LP: #2023924)
* d/p/lp2024505-fix-locale-issue.patch: fixes an issue where certain locales
can cause an error when trying to decode the output of `df -P`
(LP: #2024505)
-- Mitchell Dzurick <mitchell.dzurick at canonical.com> Tue, 20 Jun 2023
17:01:17 -0700
** Changed in: ec2-hibinit-agent (Ubuntu Lunar)
Status: Fix Committed => Fix Released
--
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to ec2-hibinit-agent in Ubuntu.
https://bugs.launchpad.net/bugs/2023924
Title:
The latest version creates /\"/var/lib/hibinit-agent\" directory
Status in ec2-hibinit-agent package in Ubuntu:
Fix Released
Status in ec2-hibinit-agent source package in Focal:
Fix Released
Status in ec2-hibinit-agent source package in Jammy:
Fix Released
Status in ec2-hibinit-agent source package in Kinetic:
Fix Released
Status in ec2-hibinit-agent source package in Lunar:
Fix Released
Status in ec2-hibinit-agent source package in Mantic:
Fix Released
Bug description:
[Impact]
A state-dir directory is created to store instance state for AWS EC2 instances. This package parses a configuration file variable with quotes and makes the quotes part of the full path, thus creating a directory titles '"' in root.
[Fix]
Remove the quotes in the configuration file. See upstream commit https://github.com/aws/amazon-ec2-hibinit-agent/commit/d87d6365009f1663247fd8595b487c59d9b121f1
[Test Case]
# General test case
1.
# Create AWS EC2 instance
AWS_REGION="eu-north-1"
AWS_AMI="ami-07ca74b1a97901682"
AWS_KEY="your key name"
AWS_SECURITY_GROUP="security instance that allows ssh from anywhere"
aws ec2 run-instances \
--region ${AWS_REGION} \
--image-id ${AWS_AMI} \
--count 1 \
--instance-type t3.micro \
--key-name ${AWS_KEY} \
--metadata-options "HttpTokens=required" \
--security-group-ids ${AWS_SECURITY_GROUP} \
--tag-specifications 'ResourceType=instance,Tags=[{Key=Name,Value=focal-test-hibinit}]' \
--block-device-mappings '[{"DeviceName":"/dev/sda1","Ebs":{"Encrypted":true,"DeleteOnTermination":true,"VolumeSize":8,"VolumeType":"gp2"}}]' \
--hibernation-options 'Configured=true'
2. SSH into instance
3. Remove weird directory if it exists
$ sudo rm -rf /'"'/
4. Start hibinit-agent
$ sudo systemctl start hibinit-agent
5. check for dir
# before fix
$ ll / | head -n 3
total 4096080
drwxr-xr-x 3 root root 4096 Jun 20 22:25 "/
drwxr-xr-x 20 root root 4096 Jun 20 22:25 ./
# after fix
$ ll / | head -n 3
total 4096076
drwxr-xr-x 19 root root 4096 Jun 20 22:25 ./
drwxr-xr-x 19 root root 4096 Jun 20 22:25 ../
# On upgrade
This test case ensures that /"/ is uninstalled on upgrade during from d/postinst.
1. Create an AWS instance
AWS_REGION="eu-north-1"
AWS_AMI="ami-07ca74b1a97901682"
AWS_KEY="your key name"
AWS_SECURITY_GROUP="security instance that allows ssh from anywhere"
aws ec2 run-instances \
--region ${AWS_REGION} \
--image-id ${AWS_AMI} \
--count 1 \
--instance-type t3.micro \
--key-name ${AWS_KEY} \
--metadata-options "HttpTokens=required" \
--security-group-ids ${AWS_SECURITY_GROUP} \
--tag-specifications 'ResourceType=instance,Tags=[{Key=Name,Value=focal-test-hibinit}]' \
--block-device-mappings '[{"DeviceName":"/dev/sda1","Ebs":{"Encrypted":true,"DeleteOnTermination":true,"VolumeSize":8,"VolumeType":"gp2"}}]' \
--hibernation-options 'Configured=true'
2. Check for directory (ec2-hibinit-agent will be installed by default, and therefore directory will exist by default)
$ file /\"/
/"/: directory
3. Upgrade ec2-hibinit-agent
$ # add ppa if needed
$ sudo apt update -y && sudo apt upgrade ec2-hibinit-agent -y
--- snippet from upgrade ---
The following packages will be upgraded:
ec2-hibinit-agent
1 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.
Need to get 12.6 kB of archives.
After this operation, 2048 B of additional disk space will be used.
Get:1 https://ppa.launchpadcontent.net/mitchdz/ec2-hibinit-agent-locale-and-quotes-fix/ubuntu lunar/main amd64 ec2-hibinit-agent all 1.0.0-0ubuntu13.2~lunar6 [12.6 kB]
Fetched 12.6 kB in 0s (82.2 kB/s)
(Reading database ... 125081 files and directories currently installed.)
Preparing to unpack .../ec2-hibinit-agent_1.0.0-0ubuntu13.2~lunar6_all.deb ...
Unpacking ec2-hibinit-agent (1.0.0-0ubuntu13.2~lunar6) over (1.0.0-0ubuntu13.1) ...
Setting up ec2-hibinit-agent (1.0.0-0ubuntu13.2~lunar6) ...
Installing new version of config file /etc/hibinit-config.cfg ...
Removing file /"/var/lib/hibinit-agent"/hibernation-enabled
Recursively removing directories /"/var/lib/hibinit-agent"
---
4. check for erroneous directory existence
$ file /\"/
/"/: cannot open `/"/' (No such file or directory)
[Where things can go wrong]
Past logic could look for the weird directory path (did test for this, and nothing along these lines were seen), on upgrade old path remains in filesystem without being deleted.
[Original Report]
The latest version 1.0.0-0ubuntu9.3 creates incorrect state-dir directory which includes double quotes in its name - /\"/var/lib/hibinit-agent\"/. I can see this behavior on Focal. See also upstream commit
https://github.com/aws/amazon-ec2-hibinit-agent/commit/d87d6365009f1663247fd8595b487c59d9b121f1
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/ec2-hibinit-agent/+bug/2023924/+subscriptions
More information about the foundations-bugs
mailing list