* Apply the GPL here.
*/
-/* $Id: confparse.h,v 1.1 2005/01/12 07:44:57 mmondor Exp $ */
+/* $Id: confparse.h,v 1.2 2005/01/13 06:19:56 mmondor Exp $ */
/* our structures */
{SCONFT_PASSWD, SCONFF_PASSWD, VARTYPE_NAME},
{SCONFT_CLASS, SCONFF_CLASS, VARTYPE_NAME},
{SCONFT_FLAGS, SCONFF_FLAGS, VARTYPE_NAME},
+ {SCONFT_MASK, SCONFF_MASK, VARTYPE_NAME},
{(char *) 0, 0, 0}
};
{SCONFT_PASSWD, SCONFF_PASSWD, VARTYPE_NAME},
{SCONFT_ACCESS, SCONFF_ACCESS, VARTYPE_NAME},
{SCONFT_CLASS, SCONFF_CLASS, VARTYPE_NAME},
+ {SCONFT_MASK, SCONFF_MASK, VARTYPE_NAME},
{(char *) 0, 0, 0}
};
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-/* $Id: s_conf.c,v 1.1 2005/01/12 07:44:57 mmondor Exp $ */
+/* $Id: s_conf.c,v 1.2 2005/01/13 06:19:56 mmondor Exp $ */
#include "struct.h"
#include "common.h"
MyFree(ptr->ipmask);
MyFree(ptr->passwd);
MyFree(ptr->hostmask);
+ MyFree(ptr->fakehost);
MyFree(ptr->class_name);
MyFree(ptr);
return;
}
MyFree(ptr->passwd);
MyFree(ptr->nick);
+ MyFree(ptr->fakehost);
MyFree(ptr->class_name);
MyFree(ptr);
return;
tmp->type = NULL;
DupString(x->class_name, tmp->value);
}
+ else if(tmp->type && (tmp->type->flag & SCONFF_MASK))
+ {
+ if (x->fakehost)
+ {
+ confparse_error("Multiple mask definitions", lnum);
+ free_oper(x);
+ return -1;
+ }
+ tmp->type = NULL;
+ DupString(x->fakehost, tmp->value);
+ }
}
if(!x->nick)
{
tmp->type = NULL;
}
+ else if(tmp->type && (tmp->type->flag & SCONFF_MASK))
+ {
+ char *p = tmp->value;
+ int bad_dns = 0;
+ int dots = 0;
+ if(x->fakehost)
+ {
+ confparse_error("Multiple hostmask definitions", lnum);
+ free_allow(x);
+ return -1;
+ }
+ while (*p)
+ {
+ if (!IsAlnum(*p))
+ {
+#ifdef RFC1035_ANAL
+ if ((*p != '-') && (*p != '.'))
+#else
+ if ((*p != '-') && (*p != '.') &&
+ (*p != '_') && (*p != '/'))
+#endif
+ bad_dns = YES;
+ }
+ if (*p == '.')
+ dots++;
+ p++;
+ }
+ if (bad_dns || !dots)
+ {
+ confparse_error("Invalid hostmask encountered",lnum);
+ free_allow(x);
+ return -1;
+ }
+ tmp->type = NULL;
+ DupString(x->fakehost, tmp->value);
+ x->flags |= CONF_FLAGS_I_FAKE_HOST;
+
+ }
}
if(!x->ipmask && !x->hostmask)
{
old_oper->hosts[i] = aoper->hosts[i];
old_oper->hosts[i] = NULL;
old_oper->passwd = aoper->passwd;
+ MyFree(old_oper->fakehost);
+ if (aoper->fakehost)
+ DupString(old_oper->fakehost, aoper->fakehost);
+ else
+ old_oper->fakehost = NULL;
old_oper->class_name = aoper->class_name;
old_oper->class = find_class(aoper->class_name);
old_oper->class->refs++;
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-/* $Id: s_user.c,v 1.1 2005/01/12 07:44:57 mmondor Exp $ */
+/* $Id: s_user.c,v 1.2 2005/01/13 06:19:56 mmondor Exp $ */
#include "struct.h"
#include "common.h"
return cbuf;
}
+static void
+client_set_fakehost(aClient *sptr, aAllow *pwaconf)
+{
+ if (pwaconf->flags & CONF_FLAGS_I_FAKE_HOST)
+ {
+ sptr->user->real_oper_host =
+ MyMalloc(strlen(sptr->user->host) + 1);
+ sptr->user->real_oper_username =
+ MyMalloc(strlen(sptr->user->username) + 1);
+ sptr->user->real_oper_ip =
+ MyMalloc(strlen(sptr->hostip) + 1);
+ strcpy(sptr->user->real_oper_host, sptr->user->host);
+ strcpy(sptr->user->real_oper_username, sptr->user->username);
+ strcpy(sptr->user->real_oper_ip, sptr->hostip);
+ strncpyzt(sptr->user->host, pwaconf->fakehost, HOSTLEN + 1);
+ strncpy(sptr->sockhost, pwaconf->fakehost, HOSTLEN + 1);
+ }
+}
+
#if (RIDICULOUS_PARANOIA_LEVEL>=1)
-static int
+static char *
check_oper_can_mask(aClient *sptr, char *name, char *password, char **onick)
{
aOper *aoper;
sendto_realops("Failed OPERMASK attempt by %s (%s@%s) [No Entry for "
"%s]", sptr->name, sptr->user->username,
sptr->user->host, name);
- return 0;
+ return NULL;
}
/* use first two chars of the password they send in as salt */
*onick = aoper->nick;
sendto_realops("%s [%s] (%s@<hidden>) has masked their hostname.",
sptr->name, aoper->nick, sptr->user->username);
- return 1;
+ return (aoper->fakehost ? aoper->fakehost : Staff_Address);
}
sendto_realops("Failed OPERMASK attempt by %s (%s@%s) [Bad Password]",
sptr->name, sptr->user->username, sptr->user->host);
- return 0;
+ return NULL;
}
#endif
char *opptr;
char *onick;
char *tmpptr;
+ char *ohost;
char tmppwd[PASSWDLEN + 1];
if(!(opptr = strchr(onptr, ':')))
+ {
+#endif
+ client_set_fakehost(sptr,pwaconf);
+#if (RIDICULOUS_PARANOIA_LEVEL>=1)
break;
+ }
*opptr++ = '\0';
if((tmpptr = strchr(opptr, ':')))
*tmpptr++ = '\0';
- if(check_oper_can_mask(sptr, onptr, opptr, &onick) != 0)
+ if((ohost = check_oper_can_mask(sptr,onptr,opptr, &onick)) != NULL)
{
sendto_one(sptr, ":%s NOTICE %s :*** Your hostname has "
"been masked.",
strcpy(sptr->user->real_oper_host, sptr->user->host);
strcpy(sptr->user->real_oper_username, sptr->user->username);
strcpy(sptr->user->real_oper_ip, sptr->hostip);
- strncpyzt(sptr->user->host, Staff_Address, HOSTLEN + 1);
+ strncpyzt(sptr->user->host, ohost, HOSTLEN + 1);
strncpyzt(sptr->user->username, onick, USERLEN + 1);
strncpyzt(sptr->username, onick, USERLEN + 1);
sptr->flags |= FLAGS_GOTID; /* fake ident */
sptr->ip.s_addr = 0;
strcpy(sptr->hostip, "0.0.0.0");
- strncpy(sptr->sockhost, Staff_Address, HOSTLEN + 1);
+ strncpy(sptr->sockhost, ohost, HOSTLEN + 1);
}
if(tmpptr)
else
sptr->passwd[0] = '\0';
} while(0);
+ else
+ client_set_fakehost(sptr,pwaconf);
#endif
sendto_realops_lev(CCONN_LEV, "Client connecting: %s (%s@%s) [%s] {%s}",