Thread View: news.software.nntp
7 messages
7 total messages
Started by Giovanni Lopedote
Tue, 19 Sep 2000 00:00
Got it! ckpasswd -f bug (INN 2.3.0)
Author: Giovanni Lopedote
Date: Tue, 19 Sep 2000 00:00
Date: Tue, 19 Sep 2000 00:00
28 lines
1394 bytes
1394 bytes
Hi everyone!
I wasn't able get authentication working with INN 2.3.0 and a passwords
file... so I've gone into the code and I've found out why. The -f option of
ckpasswd command won't work at all. The trouble arises in the GetFilePass
function of ckpasswd.c at lines 75-78:
if (!(colon = strchr(iter, ':')))
return(0);
*colon = 0;
strcpy(pass, iter);
I've modified it as follows:
if (colon = strchr(iter, ':'))
*colon = 0;
strcpy(pass, iter);
now it works and accepts also lines in the form "<user>:<encrypted
pass>:<other crap, ignored>".
Giovanni Lopedote
Bari, Italy
neuromante@gmx.net
Re: Got it! ckpasswd -f bug (INN 2.3.0)
Author: bill davidsen
Date: Tue, 19 Sep 2000 00:00
Date: Tue, 19 Sep 2000 00:00
32 lines
1744 bytes
1744 bytes
In article <8q7kje$gds$1@nread1.inwind.it>, Giovanni Lopedote <nospamplease@gmx.net> wrote: | I wasn't able get authentication working with INN 2.3.0 and a passwords | file... so I've gone into the code and I've found out why. The -f option of | ckpasswd command won't work at all. The trouble arises in the GetFilePass | function of ckpasswd.c at lines 75-78: | | if (!(colon = strchr(iter, ':'))) | return(0); | *colon = 0; | strcpy(pass, iter); | | I've modified it as follows: | | if (colon = strchr(iter, ':')) | *colon = 0; | strcpy(pass, iter); | | now it works and accepts also lines in the form "<user>:<encrypted | pass>:<other crap, ignored>". The original code rejected data which did not contain the ':' character. I'm not sure that a sanity check on expected format counts as a "bug." -- bill davidsen <davidsen@tmr.com> CTO, TMR Associates, Inc Make the rules? I don't make the rules. I don't even FOLLOW the rules!
Re: Got it! ckpasswd -f bug (INN 2.3.0)
Author: Giovanni Lopedote
Date: Tue, 19 Sep 2000 23:43
Date: Tue, 19 Sep 2000 23:43
103 lines
4391 bytes
4391 bytes
(my real email address is at the end of the message)
"bill davidsen" <davidsen@tmr.com> ha scritto nel messaggio
news:8q83h1$gn2$1@newssvr02.news.prodigy.com...
> The original code rejected data which did not contain the ':'
> character. I'm not sure that a sanity check on expected format counts as
> a "bug."
Maybe you can think different if you take a look at the whole code. Yes,
that one is a sanity check, but in the wrong place, I think. The one on
expected format is done before, at line 63. This was the whole function:
char *GetFilePass(char *name, char *file)
{
FILE *pwfile;
char buf[SMBUF];
char *colon, *iter;
int found;
static char pass[SMBUF];
pwfile = fopen(file, "r");
if (!pwfile)
return(0);
found = 0;
while ((!found) && fgets(buf, sizeof(buf), pwfile)) {
buf[strlen(buf)-1] = 0; /* clean off the \n */
63-> if (!(colon = strchr(buf, ':'))) {
fclose(pwfile);
return(0);
}
*colon = 0;
if (!strcmp(buf, name))
found = 1;
}
70->fclose(pwfile);
if (!found)
return(0);
iter = colon+1;
75->if (!(colon = strchr(iter, ':')))
-> return(0);
-> *colon = 0;
-> strcpy(pass, iter);
return(pass);
}
and this is the piece of code in main() that calls it:
183-> rpass = GetFilePass(uname, fname);
[...]
if (!rpass) {
fprintf(stderr, "ckpasswd: user %s does not exist.\n", uname);
exit(1);
}
if (strcmp(rpass, crypt(pass, rpass)) == 0) {
printf("User:%s\n", uname);
exit(0);
}
fprintf(stderr, "ckpasswd: user %s password doesn't match.\n", uname);
exit(1);
}
let's suppose we have a well-formed line in the passwords file:
foo:EncryptedPassword
and that we are checking the password of "foo". The GetFilePass function
consists of two parts: the first one (which ends at line 70) parses all the
lines of the file looking for one starting with "foo:". Then, at line 75,
iter points to what's after the colon (the 'E' in our example). At line 75,
strchr returns a null pointer as there are no other colons; this turns into
a true condition for the "if" at line 75 and then GetFilePass() exits
returning a null pointer instead of a pointer to the password. So, no matter
if the password was right or wrong, ckpasswd -f exits with "user foo does
not exist".
In my correction:
75->if (colon = strchr(iter, ':'))
-> *colon = 0;
-> strcpy(pass, iter);
the condition for the if is false and then GetFilePass returns a pointer to
the string "EncryptedPassword", as it should be; this string is then
compared (through crypt()) with the user supplied password and if it matches
the authentication is confirmed. What happen if the "if" condition at line
75 becomes true? Let's suppose now that the line was, instead:
foo:EncryptedPassword:crap
*colon=0 truncates iter to "EncryptedPassword" and then the authentication
can still be made in the right way.
If you don't want this to happen, making ckpasswd more restrictive on the
file format, you simply have to delete lines 75-77.
As I told, I was not able to get it working until I've made this correction.
Giovanni Lopedote
Bari, Italy
neuromante@gmx.net
Re: Got it! ckpasswd -f bug (INN 2.3.0)
Author: Aidan Cully
Date: Wed, 20 Sep 2000 05:53
Date: Wed, 20 Sep 2000 05:53
24 lines
2251 bytes
2251 bytes
FYI, when I wrote ckpasswd (I'm pretty sure I wrote it, but it's been so long...), I wrote it with the idea that people would use ckpasswd -f on a standard-issue unix /etc/passwd format file. Ignoring the stuff that comes after the second ':' was a compromise, based on the fact that different *nixes have different numbers of fields in the pwent. If I could have, I would have made it count the number of ':'s, and maybe even use standard getpwent() type functions for iterating over the file. In news.software.nntp, "Giovanni Lopedote" <nospamplease@gmx.net> wrote: > Maybe you can think different if you take a look at the whole code. Yes, > that one is a sanity check, but in the wrong place, I think. The one on > expected format is done before, at line 63. This was the whole function: The first one is because we need to get the name out, reliably. It's not the whole sanity check, it's just the part of the sanity check that's needed to match the correct line in the file. > As I told, I was not able to get it working until I've made this correction. I'm sorry I missed your original message. I don't know how to treat your correction... I just wanted to explain the code a bit more. --aidan
Re: Got it! ckpasswd -f bug (INN 2.3.0)
Author: bill davidsen
Date: Thu, 21 Sep 2000 00:00
Date: Thu, 21 Sep 2000 00:00
42 lines
2677 bytes
2677 bytes
In article <39c7f695@wsnews.worldshare.net>, Giovanni Lopedote <nospamplease@gmx.net> wrote: | (my real email address is at the end of the message) | | "bill davidsen" <davidsen@tmr.com> ha scritto nel messaggio | news:8q83h1$gn2$1@newssvr02.news.prodigy.com... | | > The original code rejected data which did not contain the ':' | > character. I'm not sure that a sanity check on expected format counts as | > a "bug." | | Maybe you can think different if you take a look at the whole code. Yes, | that one is a sanity check, but in the wrong place, I think. The one on | expected format is done before, at line 63. This was the whole function: [... snip ...] | let's suppose we have a well-formed line in the passwords file: | | foo:EncryptedPassword This is why I said it's not a bug... the expected file format is UNIX passwd file format, and that's not a well-formed line. You have modified the logic to accept another format by removing the check, but code to validate the expected format is not a "bug," it is correct code. The code as originally written works correctly for correct input. You do the original author a great disservice by calling this a bug. If I fed it a file with the password in MD5 format instead of crypt, I certainly wouldn't call it a bug when it didn't work. And I would call a change to use another format a "local hack" rather than a "bug fix." You didn't understand how to produce an input file in expected format, that's certainly a reason to see if the documentation needs clarification. But it is not a problem with the original code, which works as intended. -- bill davidsen <davidsen@tmr.com> CTO, TMR Associates, Inc Make the rules? I don't make the rules. I don't even FOLLOW the rules!
Re: Got it! ckpasswd -f bug (INN 2.3.0)
Author: Giovanni Lopedote
Date: Fri, 22 Sep 2000 00:00
Date: Fri, 22 Sep 2000 00:00
109 lines
5085 bytes
5085 bytes
(my real email address is at the end of the message) > | Maybe you can think different if you take a look at the whole code. Yes, > | that one is a sanity check, but in the wrong place, I think. The one on > | expected format is done before, at line 63. This was the whole function: > > [... snip ...] > > | let's suppose we have a well-formed line in the passwords file: > | > | foo:EncryptedPassword > > This is why I said it's not a bug... the expected file format is UNIX > passwd file format, and that's not a well-formed line. You have modified > the logic to accept another format by removing the check, but code to > validate the expected format is not a "bug," it is correct code. > > The code as originally written works correctly for correct input. You > do the original author a great disservice by calling this a bug. If I > fed it a file with the password in MD5 format instead of crypt, I > certainly wouldn't call it a bug when it didn't work. And I would call a > change to use another format a "local hack" rather than a "bug fix." > > You didn't understand how to produce an input file in expected format, > that's certainly a reason to see if the documentation needs > clarification. But it is not a problem with the original code, which > works as intended. It seems this is becoming a personal question for you, and probably it's gonna end up with a flame, so this is my last post about this topic. Probably you don't have the good habit of reading a whole message before writing a reply. As I wrote: me> [...] and then GetFilePass() exits me>returning a null pointer instead of a pointer to the password. So, no matter me>if the password was right or wrong, ckpasswd -f exits with "user foo does me>not exist". This means that the original ckpasswd -f option will never work. Never. Sure. This is what happens (you can use it as an exploit for the bug): - when you try to enter as "foo" it exits with "user foo does not exist" - when you try to enter as "foo:" it exits with "user foo password does not match" > The code as originally written works correctly for correct input. You > do the original author a great disservice by calling this a bug. > [...] > But it is not a problem with the original code, which > works as intended. Are you sure? Did you verify by your own? I did. I don't want to process the author or whatsoever, doing this would be really stupid. The programmers are making a good work, and for free, and I could never say them "thank you" enough. Just, I think I've found a bug and I want to help other people using this great piece of software. > If I > fed it a file with the password in MD5 format instead of crypt, I > certainly wouldn't call it a bug when it didn't work. Infact that's why I wrote (in my post "Re: ckpasswd options?) to use Apache's "htpasswd -d" to create the password file (the -d option does not use MD5). > And I would call a > change to use another format a "local hack" rather than a "bug fix." me>If you don't want this to happen, making ckpasswd more restrictive on the me>file format, you simply have to delete lines 75-77. My first post was just a suggestion on how to correct a bug, as not everyone is interested in programming, but instead everyone wants a solution that works. And it works. Then, when I got your reply (which was quite offending), I had to explain the whole thing. If this is still not enough, this is the reply I've got when I've posted my fix to inn-bugs@isc.org: >To: djcomputer@gmx.net >Cc: inn-bugs@isc.org >Subject: Re: Got it! ckpasswd -f bug (INN 2.3.0) >From: Katsuhiro Kondou <kondou@nec.co.jp> >Date: Wed, 20 Sep 2000 19:47:54 +0900 (JST) >Lines: 9 > >In article <4.3.2.20000919144809.00af5a60@192.168.0.1>, > ^GiuAnZ^ <djcomputer@gmx.net> wrote; > >} now it works and accepts also lines in the form "<user>:<encrypted >} pass>:<other crap, ignored>". > >Fixed. Thanks. >-- >Katsuhiro Kondou And if this is still not enough, you are on your own. Giovanni Lopedote Bari, Italy http:/www.neuromante.net/ neuromante@gmx.net
Re: Got it! ckpasswd -f bug (INN 2.3.0)
Author: Curt Welch
Date: Tue, 26 Sep 2000 01:51
Date: Tue, 26 Sep 2000 01:51
81 lines
4893 bytes
4893 bytes
"Giovanni Lopedote" <nospamplease@gmx.net> wrote: > It seems this is becoming a personal question for you, and probably it's > gonna end up with a flame, so this is my last post about this topic. > Probably you don't have the good habit of reading a whole message before > writing a reply. Giovanni, I'm sorry, but you are wrong and Bill is right. Maybe this is just a language issue and you aren't understanding the point Bill was making. Or maybe you think he doesn't understand yours. He does. The program would not accept input files in the format: user1:password1 user2:password2 This is because it was neven designed to accept password files in that format. It was designed for reading unix password files which have look something like this: user:password:uid:gid:gecos:dir:shell With that format of input, the code had to look for, and null terminate, the colon after the encrypted password. How it behaves if the colon is missing is not important. The author choose to make it pretend like the line was never found by returning 0. You are right in the fact that the program would not accept password files in the format you wanted it to. And your change allows the code to accept both now. It was a "bug" for you because it didn't do what you though it should do. We understant that. But it wasn't a real bug, because the code did exactly what it was designed to do. Saying it was a bug implies the person who wrote the code made a mistake. He didn't. The only mistake here is that you didn't understand the orginal code. If by "bug" you simply mean the code doesn't have a feature you want it do, then you are using the term "bug" wrong. In your orginal message, you wrote: > Hi everyone! > I wasn't able get authentication working with INN 2.3.0 and a passwords > file... so I've gone into the code and I've found out why. The -f option > of ckpasswd command won't work at all. You were very wrong here when you sait it "won't work at all". It worked fine, you just had no clue how to make it work. All you had to do was add colons to your input file after the encrypted password. What you should have said is "it won't work at all for an apache format password file". And then you wrote: > now it works and accepts also lines in the form "<user>:<encrypted > pass>:<other crap, ignored>". You write that as if you not only fixed it, but made it accept lines in this other format as well. You clearly had no clue as to what the code did before you modified it. I assume you have never worked with Unix password files before so you didn't understand what the documentation (or the code) was doing (or why). That's fine. We all live and learn. But it seems that you also didn't undertand Bill's multiple posts. All he was trying to say is that your change to the code didn't fix a bug as you claimed, but that it simply modified the code to allow it to accept yet another file format. He understands that your change make it work for your format password files and that it didn't work for those files before your change. That's not what he was talking about. I hope you understand his point of view now. If you don't, I'll be happy to try to explain it to you some more. I know you are not stupid, so it must just be a language or pride issue that prevents you from understanding what we are trying to say. Or maybe you did finally undetstand what he was talking about and I've just wasted my time writing all this :).... -- Curt Welch http://CurtWelch.Com/ curt@kcwc.com Webmaster for http://NewsReader.Com/
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads