Note: This is a beta release of Red Hat Bugzilla 5.0. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Also email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback here.
Bug 80220 - The last character is stripped from password if reading it from STDIN
Summary: The last character is stripped from password if reading it from STDIN
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: passwd
Version: 8.0
Hardware: All
OS: Linux
Target Milestone: ---
Assignee: Tomas Mraz
QA Contact: Mike McLean
Depends On: 71152
TreeView+ depends on / blocked
Reported: 2002-12-22 17:43 UTC by Konstantin Andreev
Modified: 2005-10-31 22:00 UTC (History)
1 user (show)

Fixed In Version: passwd-0.68-10
Doc Type: Bug Fix
Doc Text:
Clone Of:
Last Closed: 2005-03-25 09:31:31 UTC

Attachments (Terms of Use)

Description Konstantin Andreev 2002-12-22 17:43:54 UTC
From Bugzilla Helper:
User-Agent: Mozilla/4.0 (compatible; MSIE 5.5; Windows 95)

Description of problem:
The passwd.c indicates that this is by design error:
	i = read(STDIN_FILENO, newPassword,
	 sizeof(newPassword) - 1);
	newPassword[i - 1] = '\0';

I can assume this was done to strip line feed character when reading password 
from one-string files. This is not a correct behaviour. It's a user 
responsibility to supply just the data the user wants.

For compatibility reasons you may correct this error by introducing new option 
like '--not-strip'. When this option applied, passwd should not strip the last 

Version-Release number of selected component (if applicable):

How reproducible:

Steps to Reproduce:
1. Execute in bash:
echo -n boguspas | passwd --stdin someuser
2. Try to login as 'someuser'

Actual Results:  Can't login with 'boguspas', but can login with 'boguspa' 

Expected Results:  Login with 'boguspas' password.

Note You need to log in before you can comment on or make changes to this bug.