This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Undernet IRC Server Source Code.".
The branch, u2_10_12_branch has been updated
via 5dd977c1dc9f33ddfbca5eb11fb8f3b95c7e5359 (commit)
via 46f401ef80a4bede99ed5034d03836f6e7ca6936 (commit)
via d0a284c68368f5cd58309293e936f82e032f7ae8 (commit)
from ac43a9ca643546041560c7386b7c34d28d57ee4e (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 5dd977c1dc9f33ddfbca5eb11fb8f3b95c7e5359
Author: Michael Poole <[email protected]>
Date: Thu Apr 24 20:55:51 2014 -0400
s_auth.c: Move username-cleaning logic to a separate function.
We want to bypass this when IAuth sends a forced username ('o' command),
but also to clean the username before we send the username to IAuth.
Also get rid of one local variable in auth_set_username().
diff --git a/ircd/s_auth.c b/ircd/s_auth.c
index 83693a2..476cce5 100644
--- a/ircd/s_auth.c
+++ b/ircd/s_auth.c
@@ -213,6 +213,31 @@ static int preregister_user(struct Client *cptr);
typedef int (*iauth_cmd_handler)(struct IAuth *iauth, struct Client *cli,
int parc, char **params);
+/** Copies a username, cleaning it in the process.
+ *
+ * @param[out] dest Destination buffer for user name.
+ * @param[in] src Source buffer for user name. Must be distinct from
+ * \a dest.
+ */
+void clean_username(char *dest, const char *src)
+{
+ int rlen = USERLEN;
+ char ch;
+
+ /* First character can be ~, later characters cannot. */
+ if (!IsCntrl(*src))
+ {
+ ch = *src++;
+ *dest++ = IsUserChar(ch) ? ch : '_';
+ rlen--;
+ }
+ while (rlen-- && !IsCntrl(ch = *src++))
+ {
+ *dest++ = (IsUserChar(ch) && (ch != '~')) ? ch : '_';
+ }
+ *dest = '\0';
+}
+
/** Set username for user associated with \a auth.
* @param[in] auth Client authorization request to work on.
* @return Zero if client is kept, CPTR_KILLED if client rejected.
@@ -223,11 +248,9 @@ static int auth_set_username(struct AuthRequest *auth)
struct User *user = cli_user(sptr);
char *d;
char *s;
- int rlen = USERLEN;
int killreason;
short upper = 0;
short lower = 0;
- short pos = 0;
short leadcaps = 0;
short other = 0;
short digits = 0;
@@ -235,32 +258,26 @@ static int auth_set_username(struct AuthRequest *auth)
char ch;
char last;
- if (FlagHas(&auth->flags, AR_IAUTH_USERNAME))
+ if (FlagHas(&auth->flags, AR_IAUTH_FUSERNAME))
{
- ircd_strncpy(cli_user(sptr)->username, cli_username(sptr), USERLEN);
+ ircd_strncpy(user->username, cli_username(sptr), USERLEN);
}
- else
+ else if (IsIdented(sptr))
{
- /* Copy username from source to destination. Since they may be the
- * same, and we may prefix with a '~', use a buffer character (ch)
- * to hold the next character to copy.
- */
- s = IsIdented(sptr) ? cli_username(sptr) : user->username;
- last = *s++;
- d = user->username;
- if (HasFlag(sptr, FLAG_DOID) && !IsIdented(sptr))
- {
- *d++ = '~';
- --rlen;
- }
- while (last && !IsCntrl(last) && rlen--)
+ clean_username(user->username, cli_username(sptr));
+ }
+ else if (HasFlag(sptr, FLAG_DOID))
+ {
+ /* Prepend ~ to user->username. */
+ s = user->username;
+ s[USERLEN-1] = '\0';
+ for (last = '~'; (ch = *s) != '\0'; )
{
- ch = *s++;
- *d++ = IsUserChar(last) ? last : '_';
- last = (ch != '~') ? ch : '_';
+ *s++ = last;
+ last = ch;
}
- *d = 0;
- }
+ *s = '\0';
+ } /* else cleaned version of client-provided name is in place */
/* If username is empty or just ~, reject. */
if ((user->username[0] == '\0')
@@ -283,7 +300,7 @@ static int auth_set_username(struct AuthRequest *auth)
s = d = user->username + (user->username[0] == '~');
for (last = '\0';
(ch = *d++) != '\0';
- pos++, last = ch)
+ last = ch)
{
if (IsLower(ch))
{
@@ -293,13 +310,13 @@ static int auth_set_username(struct AuthRequest *auth)
{
upper++;
/* Accept caps as leading if we haven't seen lower case or digits yet.
*/
- if ((leadcaps || pos == 0) && !lower && !digits)
+ if ((leadcaps || last == '\0') && !lower && !digits)
leadcaps++;
}
else if (IsDigit(ch))
{
digits++;
- if (pos == 0 || !IsDigit(last))
+ if (!IsDigit(last))
{
digitgroups++;
/* If more than two groups of digits, reject. */
@@ -311,7 +328,7 @@ static int auth_set_username(struct AuthRequest *auth)
{
other++;
/* If -_. exist at start, consecutively, or more than twice, reject. */
- if (pos == 0 || last == '-' || last == '_' || last == '.' || other > 2)
+ if (last == '\0' || last == '-' || last == '_' || last == '.' || other
> 2)
goto badid;
}
else /* All other punctuation is rejected. */
@@ -1089,10 +1106,10 @@ int auth_set_user(struct AuthRequest *auth, const char
*username, const char *ho
FlagClr(&auth->flags, AR_NEEDS_USER);
cptr = auth->client;
ircd_strncpy(cli_info(cptr), userinfo, REALLEN);
- ircd_strncpy(cli_user(cptr)->username, username, USERLEN);
+ clean_username(cli_user(cptr)->username, username);
ircd_strncpy(cli_user(cptr)->host, cli_sockhost(cptr), HOSTLEN);
if (IAuthHas(iauth, IAUTH_UNDERNET))
- sendto_iauth(cptr, "U %s %s %s :%s", username, hostname, servername,
userinfo);
+ sendto_iauth(cptr, "U %s %s %s :%s", cli_user(cptr)->username, hostname,
servername, userinfo);
else if (IAuthHas(iauth, IAUTH_ADDLINFO))
sendto_iauth(cptr, "U %s", username);
return check_auth_finished(auth);
commit 46f401ef80a4bede99ed5034d03836f6e7ca6936
Author: Michael Poole <[email protected]>
Date: Thu Apr 24 20:34:06 2014 -0400
Quash various warnings from higher levels of compiler warnings.
Two changes are to avoid never-true checks that a local array is not a
null pointer; two changes are to the length arguments of memset/memcpy.
(The MD5 change is just for cleaning up; the parser change should only
affect systems where sizeof(long) != sizeof(struct ListenerFlags*), but
that is not true of any system that is likely to run ircu2.)
diff --git a/ircd/crule.c b/ircd/crule.c
index 1a1fd21..a91aecb 100644
--- a/ircd/crule.c
+++ b/ircd/crule.c
@@ -737,7 +737,7 @@ static int crule_parsearglist(CRuleNodePtr argrootp, int
*next_tokp, const char*
#if !defined(CR_DEBUG) && !defined(CR_CHKCONF)
collapse(currarg);
#endif
- if (!BadPtr(currarg))
+ if (currarg[0] != '\0')
{
DupString(argelemp, currarg);
argrootp->arg[argrootp->numargs++] = (void *)argelemp;
diff --git a/ircd/ircd_md5.c b/ircd/ircd_md5.c
index fd14a34..0d7d73e 100644
--- a/ircd/ircd_md5.c
+++ b/ircd/ircd_md5.c
@@ -154,7 +154,7 @@ void MD5Final(unsigned char digest[16], struct MD5Context
*ctx)
MD5Transform(ctx->buf, (uint32 *) ctx->in);
byteReverse((unsigned char *) ctx->buf, 4);
memcpy(digest, ctx->buf, 16);
- memset(ctx, 0, sizeof(ctx)); /* In case it's sensitive */
+ memset(ctx, 0, sizeof(*ctx)); /* In case it's sensitive */
}
#ifndef ASM_MD5
diff --git a/ircd/ircd_parser.y b/ircd/ircd_parser.y
index a43b944..64a112c 100644
--- a/ircd/ircd_parser.y
+++ b/ircd/ircd_parser.y
@@ -709,7 +709,7 @@ portblock: PORT '{' portitems '}' ';' {
hosts = link;
}
for (link = hosts; link != NULL; link = link->next) {
- memcpy(&flags_here, &listen_flags, sizeof(&flags_here));
+ memcpy(&flags_here, &listen_flags, sizeof(flags_here));
switch (link->flags & (USE_IPV4 | USE_IPV6)) {
case USE_IPV4:
FlagSet(&flags_here, LISTEN_IPV4);
diff --git a/ircd/m_pass.c b/ircd/m_pass.c
index eb08e9f..e34e681 100644
--- a/ircd/m_pass.c
+++ b/ircd/m_pass.c
@@ -116,7 +116,7 @@ int mr_pass(struct Client* cptr, struct Client* sptr, int
parc, char* parv[])
--len;
password[len] = '\0';
- if (EmptyString(password))
+ if (password[0] == '\0')
return need_more_params(cptr, "PASS");
ircd_strncpy(cli_passwd(cptr), password, PASSWDLEN);
commit d0a284c68368f5cd58309293e936f82e032f7ae8
Author: Michael Poole <[email protected]>
Date: Thu Apr 24 20:27:03 2014 -0400
iauth: Send an empty "u" message on ident lookup failure.
Otherwise an iauthd might wait indefinitely (i.e. too long) before trying
to make a decision on the client.
diff --git a/doc/readme.iauth b/doc/readme.iauth
index 54a011f..1962d9c 100644
--- a/doc/readme.iauth
+++ b/doc/readme.iauth
@@ -174,12 +174,14 @@ Compatibility: ircd only sends the <username> parameter.
u - Client Username
Syntax: <id> u <username>
+Syntax: <id> u
Example: 5 u notbuddha
States: REGISTER(1)
Next State: -
Comments: Indicates a more reliable username for the client.
Compatibility: This is an Undernet extension and ircd does not send
it. It is enabled by the iauth instance requesting the U policy.
+ If the identd lookup fails for a user, no username is passed.
n - Client Nickname
Syntax: <id> n <nickname>
diff --git a/ircd/s_auth.c b/ircd/s_auth.c
index ddeabbc..83693a2 100644
--- a/ircd/s_auth.c
+++ b/ircd/s_auth.c
@@ -679,6 +679,8 @@ static void read_auth_reply(struct AuthRequest* auth)
if (IsUserPort(auth->client))
sendheader(auth->client, REPORT_FAIL_ID);
++ServerStats->is_abad;
+ if (IAuthHas(iauth, IAUTH_UNDERNET))
+ sendto_iauth(auth->client, "u");
} else {
if (IsUserPort(auth->client))
sendheader(auth->client, REPORT_FIN_ID);
-----------------------------------------------------------------------
Summary of changes:
doc/readme.iauth | 2 +
ircd/crule.c | 2 +-
ircd/ircd_md5.c | 2 +-
ircd/ircd_parser.y | 2 +-
ircd/m_pass.c | 2 +-
ircd/s_auth.c | 77 ++++++++++++++++++++++++++++++++-------------------
6 files changed, 54 insertions(+), 33 deletions(-)
hooks/post-receive
--
Undernet IRC Server Source Code.
_______________________________________________
Patches mailing list
[email protected]
http://undernet.sbg.org/mailman/listinfo/patches