Hello,
the username length is set to 20 in the source code. (defines.h CLIENT_USER_LEN) I need to use authentication on our irc server. But unfortunately our user id that we can use is the email address. There is no other shorter uid yet. The email addresses are of course longer then 20 for most of the users.
Do you see a problem of increasing this value to 50? Except that max messages length will be shorter. I mean if I would change it, do other parts of the code need to be changed? Or could there maybe strange problems in whatever cases? I tested it and it works in general, but I still wanted to ask.
Thanks Marco
Hi Marco!
Am 03.09.2014 um 10:11 schrieb Marco Schirrmeister marco@schirrmeister.net:
the username length is set to 20 in the source code. (defines.h CLIENT_USER_LEN) I need to use authentication on our irc server. But unfortunately our user id that we can use is the email address. There is no other shorter uid yet. The email addresses are of course longer then 20 for most of the users.
Do you see a problem of increasing this value to 50? Except that max messages length will be shorter. I mean if I would change it, do other parts of the code need to be changed? Or could there maybe strange problems in whatever cases? I tested it and it works in general, but I still wanted to ask.
ngIRCd uses the full username only for authentication, afterwards the "username" used in IRC is the part up to the "@" character. So I don't expect any problems, I even think that we should increase this limit by default.
Ah, and checking the RFCs, I don't see any limit specified there at all …
On the other hand, simply increasing CLIENT_USER_LEN is probably not the right thing to do, because this constant is used in a few other places (for example in the CLIENT structure), which always only see the part in front of the first "@" character and therefore would waste memory. It would be better to use two constants and only increase the new one, which would be used for the CLIENT.orig_user field in src/ngircd/client.h.
Thanks! Alex
On Sep 3, 2014, at 12:11 PM, Alexander Barton alex@barton.de wrote:
Hi Marco!
Am 03.09.2014 um 10:11 schrieb Marco Schirrmeister marco@schirrmeister.net:
the username length is set to 20 in the source code. (defines.h CLIENT_USER_LEN) I need to use authentication on our irc server. But unfortunately our user id that we can use is the email address. There is no other shorter uid yet. The email addresses are of course longer then 20 for most of the users.
Do you see a problem of increasing this value to 50? Except that max messages length will be shorter. I mean if I would change it, do other parts of the code need to be changed? Or could there maybe strange problems in whatever cases? I tested it and it works in general, but I still wanted to ask.
ngIRCd uses the full username only for authentication, afterwards the "username" used in IRC is the part up to the "@" character. So I don't expect any problems, I even think that we should increase this limit by default.
If you can or would increase that by default, that would of course be nice. Or maybe configurable in the ngircd.conf.
Ah, and checking the RFCs, I don't see any limit specified there at all …
On the other hand, simply increasing CLIENT_USER_LEN is probably not the right thing to do, because this constant is used in a few other places (for example in the CLIENT structure), which always only see the part in front of the first "@" character and therefore would waste memory. It would be better to use two constants and only increase the new one, which would be used for the CLIENT.orig_user field in src/ngircd/client.h.
Thanks for that info. I will talk with our developers if they can modify and add this.
Thank you Marco
Am 03.09.2014 um 12:11 schrieb Alexander Barton alex@barton.de:
Am 03.09.2014 um 10:11 schrieb Marco Schirrmeister marco@schirrmeister.net:
the username length is set to 20 in the source code. (defines.h CLIENT_USER_LEN) I need to use authentication on our irc server. But unfortunately our user id that we can use is the email address. There is no other shorter uid yet. The email addresses are of course longer then 20 for most of the users.
Do you see a problem of increasing this value to 50? Except that max messages length will be shorter. I mean if I would change it, do other parts of the code need to be changed? Or could there maybe strange problems in whatever cases? I tested it and it works in general, but I still wanted to ask.
ngIRCd uses the full username only for authentication, afterwards the "username" used in IRC is the part up to the "@" character. So I don't expect any problems, I even think that we should increase this limit by default.
Ah, and checking the RFCs, I don't see any limit specified there at all …
On the other hand, simply increasing CLIENT_USER_LEN is probably not the right thing to do, because this constant is used in a few other places (for example in the CLIENT structure), which always only see the part in front of the first "@" character and therefore would waste memory. It would be better to use two constants and only increase the new one, which would be used for the CLIENT.orig_user field in src/ngircd/client.h.
Probably something like the patch attached? But beware, this one seems to work for me but isn't much tested …
Regards Alex
From d5e6dac49768e76ce37416f234cf658e25fa75b7 Mon Sep 17 00:00:00 2001
From: Alexander Barton alex@barton.de Date: Wed, 3 Sep 2014 16:03:28 +0200 Subject: [PATCH] Allow longer usernames for authentication
--- src/ngircd/client.c | 10 +--------- src/ngircd/client.h | 5 +++-- src/ngircd/defines.h | 4 ++++ 3 files changed, 8 insertions(+), 11 deletions(-)
diff --git a/src/ngircd/client.c b/src/ngircd/client.c index 9795662..07d448f 100644 --- a/src/ngircd/client.c +++ b/src/ngircd/client.c @@ -427,7 +427,7 @@ Client_SetOrigUser(CLIENT UNUSED *Client, const char UNUSED *User) assert(Client != NULL); assert(User != NULL);
-#if defined(PAM) && defined(IDENTAUTH) +#if defined(PAM) strlcpy(Client->orig_user, User, sizeof(Client->orig_user)); #endif } /* Client_SetOrigUser */ @@ -731,15 +731,7 @@ Client_User( CLIENT *Client ) */ GLOBAL char * Client_OrigUser(CLIENT *Client) { -#ifndef IDENTAUTH - char *user = Client->user; - - if (user[0] == '~') - user++; - return user; -#else return Client->orig_user; -#endif } /* Client_OrigUser */
#endif diff --git a/src/ngircd/client.h b/src/ngircd/client.h index c6fcec0..4185d21 100644 --- a/src/ngircd/client.h +++ b/src/ngircd/client.h @@ -52,8 +52,9 @@ typedef struct _CLIENT char *cloaked; /* cloaked hostname of the client */ char *ipa_text; /* textual representaton of IP address */ char user[CLIENT_USER_LEN]; /* user name ("login") */ -#if defined(PAM) && defined(IDENTAUTH) - char orig_user[CLIENT_USER_LEN];/* user name supplied by USER command */ +#if defined(PAM) + char orig_user[CLIENT_AUTHUSER_LEN]; + /* original user name supplied by USER command */ #endif char info[CLIENT_INFO_LEN]; /* long user name (user) / info text (server) */ char modes[CLIENT_MODE_LEN]; /* client modes */ diff --git a/src/ngircd/defines.h b/src/ngircd/defines.h index a140c9d..456c4c9 100644 --- a/src/ngircd/defines.h +++ b/src/ngircd/defines.h @@ -109,6 +109,10 @@ #else # define CLIENT_USER_LEN 10 #endif +/** Max. length of user names saved for authentication (used by PAM) */ +#ifdef PAM +# define CLIENT_AUTHUSER_LEN 64 +#endif
/** Max. length of "real names" (including NULL). */ #define CLIENT_NAME_LEN 32