ssh-import-id gh:$missing-user does not flush stdout properly
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
ssh-import-id |
Fix Released
|
Medium
|
Michael Hudson-Doyle | ||
ssh-import-id (Ubuntu) |
Fix Released
|
Medium
|
Unassigned | ||
Bionic |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
[Impact]
Invoking ssh-import-id gh:$missing_user in a non-interactive context produces no output.
I want to change subiquity to invoke ssh-import-id directly and helpful error messages are important in giving useful feedback to the user.
[Test case]
"ssh-import-id gh:mwhudso 2>&1 | cat" should output "no such user" or some similar helpful messsage, not nothing at all.
[Regression potential]
The upload to bionic unapproved is an untested combination of patches so needs careful testing. Fortunately each patch is small and mostly independent so testing each affected area of code should not be too onerous.
[Original Description]
mwhudson@
Username "mwhudso" not found at GitHub API
mwhudson@
mwhudson@
What happened? The offending code looks like
if resp.status_code == 404:
print('Username "%s" not found at GitHub API' % ghid)
os._exit(1)
print does not flush by default. When stdout is a terminal you get an implicit flush on newline but when it's a pipe you do not and calling _exit(1) exits the process without flushing the buffers either. Two fixes suggest themselves: 1) add flush=True to the print() calls 2) exiting more conventionally by e.g. calling sys.exit()
Changed in ssh-import-id: | |
assignee: | nobody → Michael Hudson-Doyle (mwhudson) |
importance: | Undecided → Medium |
status: | New → Fix Committed |
Changed in ssh-import-id (Ubuntu): | |
status: | New → Confirmed |
importance: | Undecided → Medium |
description: | updated |
description: | updated |
This bug was fixed in the package ssh-import-id - 5.7-24- g4001a38e- 0ubuntu1
--------------- g4001a38e- 0ubuntu1) cosmic; urgency=medium
ssh-import-id (5.7-24-
* New upstream snapshot.
- debian/postinst: Correctly check old version.
- debian/: Adjust packaging to include debian's changes and fix
lintian warnings.
- Migrate upstream to git.
- Add running of pycodestyle and pylint via tox and fix warnings.
- Convert tabs to spaces for indentation globally.
- Get path to user's authorized_keys even if HOME is not set.
(LP: #1570997)
- Exit with sys.exit() rather than os._exit.
[Michael Hudson-Doyle] (LP: #1770302)
- Launchpad: check status code of response when fetching ssh keys.
[Michael Hudson-Doyle] (LP: #1770305)
- Fix NameError on unknown service/proto. [Michael Hudson-Doyle]
- debian/rules: no longer run pep8 in debian build.
- Use setup.py's console_scripts to write ssh-import-id to /usr/bin.
-- Scott Moser <email address hidden> Fri, 11 May 2018 14:56:46 -0400