static int do_matchwild(User * u)
{
    char *pat = strtok(NULL, " ");
    char *str = strtok(NULL, " ");
    if (pat && str)
        notice_user(s_OperServ, u, "%d", match_wild(pat, str));
    else
        notice_user(s_OperServ, u, "Syntax error.");
    return MOD_CONT;
}
Exemple #2
0
void
set_pass (char *nick, char *uh, char *pass, char *newpass)
{
	struct	helperlist *c;
	char	*ptr = NULL;
#if	ENCRYPT_PASSWORDS == ON
	char	*salt = "8fei3k";
#endif

	c = helperhead;
	strlwr (uh);


#if	ENCRYPT_PASSWORDS == ON
	if ((ptr = crypt (pass, salt)) == NULL)	/* encrypt old password */
		return;
#else
	ptr = (char *)pass;
#endif

	while (c)
	{
		if (!match_wild (c->uh, uh) == 0)
		{
			if (strcmp (c->pass, ptr) == 0 || strcmp (c->pass, "0") == 0)
			{
#if				ENCRYPT_PASSWORDS == ON
				if ((ptr = crypt (newpass, salt)) == NULL)	/* encrypt new password */
					return;
#else
				ptr = (char *)newpass;
#endif
				strncpy (c->pass, ptr, sizeof (c->pass));
				L012 (nick, uh);
				save_changes ();
				return;
			}
			else
			{
				L013 (nick);
				return;
			}
		}
		c = c->next;
	}
	L014 (nick);
}
Exemple #3
0
long
verify_pass (char *nick, char *chan, char *uh, char *pass)
{
	struct	helperlist *c;
	char	*ptr = NULL;
#if	ENCRYPT_PASSWORDS == ON
	char	*salt = "8fei3k";
#endif

	c = helperhead;
	strlwr (uh);

#if	ENCRYPT_PASSWORDS == ON
	if ((ptr = crypt (pass, salt)) == NULL)
		return 0;
#else
	ptr = (char *)pass;
#endif

	while (c)
	{
		if (!match_wild (c->uh, uh) == 0)
		{
			if (*c->pass == '0')
				return 0;		/* no pass set */
			if (strcmp (c->pass, ptr) == 0)
			{
				if (c->chan[0] == '#' && c->chan[1] == '*')
					return c->level;

				if (*chan == '*')
					return c->level;

				if (stricmp (c->chan, chan) == 0)
					return c->level;

				return 0;		/* don't match chan access */
			}
		}
		c = c->next;
	}
	return 0;
}
int mdsip_find_user_mapping(char *hostfile, char *ipaddr, char *host, char *name, char **local_account)
{
  FILE *f = fopen(hostfile,"r");
  int ok = 0;
  if (f)
  {
    char line[1024];
    char *line_name;
    char *line_local_account;
    char *match_host = 0;
    char *match_ipaddr = 0;
    int i;
    match_ipaddr = strcpy(malloc((ipaddr ? strlen(ipaddr) : 0)+strlen(name)+2),name);
    if (ipaddr)
    {
      strcat(match_ipaddr,"@");
      strcat(match_ipaddr,ipaddr);
    }
    if (host)
    {
      match_host = strcpy(malloc(strlen(host)+strlen(name)+2),name);
      strcat(match_host,"@");
      strcat(match_host,host);
    }

    while (ok==0 && fgets(line,1023,f))
    {
      if (line[0] != '#')
      {
        size_t len=strcspn(line,"|");
        size_t wildlen=strcspn(line,"*%");
        if ((len < strlen(line)) && (ipaddr || (wildlen == strlen(line))))
	{
          line_name=line;
          line_name[len]=0;
          line_local_account=line+len+1;
          while(line_name[0] == 32 || line_name[0] == 8) line_name++;
          for (i=strlen(line_name);(i>0) && ((line_name[i-1] == 32) || (line_name[i-1] == 8)); line_name[i-1]=0,i--);
          if (i>0)
          {
            int match_type=1;
            int line_name_free=0;
            if (strcspn(line_name,"@")==strlen(line_name))
	    {
              line_name = strcpy(malloc(strlen(line_name)+3),line_name);
              strcat(line_name,"@*");
              line_name_free=1;
            }
            if (line_name[0] == '!')
	    {
              match_type = 2;
              line_name++;
            }
            if (match_wild(match_ipaddr,line_name) || (match_host && match_wild(match_host,line_name)))
            {
	      while(line_local_account[0] == 32 || line_local_account[0] == 8) line_local_account++;
	      for (i=strlen(line_local_account);i>0 && (line_local_account[i-1] == 32 || line_local_account[i-1] == 8); line_local_account[i-1]=0,i--);
              line_local_account[strlen(line_local_account)-1]=0;
	      *local_account = strcpy(malloc(strlen(line_local_account)+1),line_local_account);
              ok = match_type;
	    }
            if (line_name_free)
              free(line_name);
          }
        }
      }
    }
    free(match_ipaddr);
    free(match_host);
    fclose(f);
  }
  else
  {
    printf("Unable to open hostfile: %s\n",hostfile);
    ok=2;
  }
  return ok == 1;
}
Exemple #5
0
int
check_access (char *uh, char *chan, int toggle, char *nick)
{
	long i = 0, length = 0, A = 0, X = 0, Y = 0;
	struct helperlist *c;
	struct userlist *c2;
	char temp[STRING_LONG] = { 0 };

	c = helperhead;
	c2 = userhead;
	strlwr (uh);

	if (toggle == 0)
	{							/* get access level */
		while (c2)
		{
			if (stricmp (c2->uh, uh) == 0)
			{
				if (((stricmp (c2->chan, chan) == 0) || (stricmp ("#*", chan) == 0)))	/* privmsg */
				{
					if (stricmp (c2->nick, nick) == 0)
					{
						return c2->level;
					}
				}
			}
			c2 = c2->next;
		}
		return 0;				/* no matches? */
	}
	else
		while (c != NULL)
		{
			if (!match_wild (c->uh, uh) == 0)
			{
				if (*c->pass == '0')
				{
					L001 (nick, Mynick);
					return 0;
				}
				if (c->chan[1] != '*')
					if (stricmp (c->chan, chan) != 0)
						return 0;
				c->num_join++;
				if (*c->greetz == '+')
					A = 1;
				strncpy (data, "", sizeof (data));
				length = Y = strlen (c->greetz);
				if (length > 1)
				{
					while (length > 0)
					{
						length--;
						X++;
						if (c->greetz[length] == '^')
						{
							i++;
							snprintf (temp, sizeof (temp), "%s%s", nick, data);
						}
						else if (c->greetz[length] == '%')
						{
							i++;
							snprintf (temp, sizeof (temp), "%u%s", c->num_join, data);
						}
						else if (c->greetz[length] == '$')
						{
							i++;
							snprintf (temp, sizeof (temp), "%s%s", uh, data);
						}
						else if (c->greetz[length] == '&')
						{
							i++;
							snprintf (temp, sizeof (temp), "%s%s", chan, data);
						}
						else
							snprintf (temp, sizeof (temp), "%c%s", c->greetz[length], data);
						if (X == Y && A == 1)
							continue;
						strncpy (data, temp, sizeof (data));
					}			/* While */
#if JOIN_GREET == 1
					if (i == 0)
					{
						if (setinfo_lastcomm (uh) == 0)
						{
							S ("PRIVMSG %s :%ld\2!\2\37(\37%s\37)\37\2:\2 %s\n",
							   chan, c->num_join, nick, c->greetz);
						}
					}
					else if (A == 1)
					{
						if (setinfo_lastcomm (uh) == 0)
						{
							S ("PRIVMSG %s :\1ACTION %s\1\n", chan, data);
						}
					}
					else
					{
						if (setinfo_lastcomm (uh) == 0)
						{
							S ("PRIVMSG %s :%s\n", chan, data);
						}
					}
#endif
					return c->level;
				}
			}
			c = c->next;
		}
	return 0;
}