Hi David,
while (pwd != NULL) {
if (pwd->pw_uid == uid) {
- int i = strlen(nbuf1);
- if(nbuf1[i-1]=='\n')
- nbuf1[i-1] = 0;
+ char *p=strchr(nbuf1,'\n');
+ if(p) *p='\0';
pwd->pw_passwd = crypt(nbuf1, salt);
}
yes, your suggestion is quite shorter.
I just took the corresponding code from login.c without questioning its
efficiency. I'll never do it again ;-)
by the way: we had to correct login.c anyway: replace that `write-read` pair
for prompting for a password with getpass(<prompt>); since we're busy on
that source, we can as well change the \n-removal according to your
suggestion.
ciao,
Mario.