fail if HOME environment variable is not set
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
ssh-import-id |
Fix Released
|
Low
|
Unassigned | ||
ssh-import-id (Ubuntu) |
Fix Released
|
Low
|
Unassigned | ||
Xenial |
Won't Fix
|
Low
|
Unassigned | ||
Bionic |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
=== Begin SRU Template ===
[Impact]
Running ssh-import-id without environment variable HOME set
will fail and print an error message like:
TypeError: join() argument must be str or bytes, not 'NoneType'
[Test Case]
$ name="my-x"
$ ud=$(printf '%s\n%s\n' '#!/bin/sh' 'ssh-import-id smoser')
$ lxc launch ubuntu-daily:xenial "$name" "--config=
To see failure, you can then just:
$ lxc exec "$name" -- cat /run/cloud-
{
"v1": {
"datasource": "DataSourceHetz
"errors": [
"('scripts-
]
}
}
$ lxc exec "$name" -- grep "ssh-import-id lp:smoser" /root/.
echo GOOD || echo FAIL
[Regression Potential]
Regression is unlikely. The code only does anything if HOME is not present.
This has been in Artful and Bionic since 2016-09-16.
[Other Info]
Upstream merge proposal:
https:/
=== End SRU Template ===
I've modified /usr/bin/
TypeError: join() argument must be str or bytes, not 'NoneType'
Then, running:
$ env -u HOME ssh-import-id smoser
Traceback (most recent call last):
File "/usr/bin/
main()
File "/usr/bin/
k = import_keys(proto, username, parser.
File "/usr/lib/
local_keys = key_list(
File "/usr/lib/
output_file = parser.
File "/usr/lib/
genericpath
File "/usr/lib/
(funcname, s.__class_
TypeError: join() argument must be str or bytes, not 'NoneType'
I came to find this by trying to launch an instance with:
$ ec2metadata --user-data
#!/bin/sh
exec >/my.log 2>&1
cat /proc/uptime
date -R
ssh-import-id smoser
The basic issue is that the environment that cloud-init runs in does not have HOME set.
I suggest using os.path.expanduser
def authorized_
return os.path.
ProblemType: Bug
DistroRelease: Ubuntu 16.04
Package: ssh-import-id 5.5-0ubuntu1 [modified: usr/bin/
ProcVersionSign
Uname: Linux 4.4.0-18-generic x86_64
ApportVersion: 2.20.1-0ubuntu1
Architecture: amd64
Date: Fri Apr 15 17:36:09 2016
Ec2AMI: ami-929f8cf8
Ec2AMIManifest: ubuntu-
Ec2Availability
Ec2InstanceType: m3.medium
Ec2Kernel: unavailable
Ec2Ramdisk: unavailable
PackageArchitec
ProcEnviron:
TERM=xterm-
PATH=(custom, no user)
XDG_RUNTIME_
LANG=en_US.UTF-8
SHELL=/bin/bash
SourcePackage: ssh-import-id
UpgradeStatus: No upgrade log present (probably fresh install)
Related branches
- ssh-import-id: Pending requested
-
Diff: 28 lines (+10/-1)1 file modifiedssh_import_id/__init__.py (+10/-1)
- Robie Basak: Needs Information
-
Diff: 43 lines (+16/-1)2 files modifieddebian/changelog (+6/-0)
ssh_import_id/__init__.py (+10/-1)
Changed in ssh-import-id (Ubuntu): | |
status: | New → Confirmed |
importance: | Undecided → Low |
Changed in ssh-import-id: | |
status: | New → Confirmed |
importance: | Undecided → Low |
tags: | added: bot-stop-nagging |
Changed in ssh-import-id (Ubuntu): | |
assignee: | nobody → Scott Moser (smoser) |
Changed in ssh-import-id: | |
status: | Confirmed → In Progress |
assignee: | nobody → Scott Moser (smoser) |
Changed in ssh-import-id: | |
assignee: | Scott Moser (smoser) → Dustin Kirkland (kirkland) |
Changed in ssh-import-id: | |
status: | In Progress → Fix Committed |
Changed in ssh-import-id (Ubuntu): | |
status: | Confirmed → Fix Committed |
assignee: | nobody → Dustin Kirkland (kirkland) |
description: | updated |
Changed in ssh-import-id (Ubuntu Xenial): | |
status: | New → In Progress |
importance: | Undecided → Low |
assignee: | nobody → Scott Moser (smoser) |
Changed in ssh-import-id: | |
status: | Fix Committed → Confirmed |
status: | Confirmed → Incomplete |
status: | Incomplete → Fix Released |
Changed in ssh-import-id (Ubuntu Xenial): | |
status: | In Progress → Fix Released |
tags: |
added: verification-failed-xenial removed: verification-failed-xeniall |
description: | updated |
description: | updated |
A recreate for this is as simple as: user.user- data=$ud"
$ ud=$(printf '%s\n%s\n' '#!/bin/sh' 'ssh-import-id smoser')
$ lxc launch ubuntu-daily:xenial "--config=
A work around is to just to set the HOME environment:
$ ud=$(printf '%s\n%s\n' '#!/bin/sh' 'HOME=/root ssh-import-id smoser')