Exemplo n.º 1
0
/*
 * me_forcenick
 *      parv[1] = forcenick victim
 *      parv[2] = new nickname 
 */
static int
me_forcenick(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
	struct Client *target_p, *exist_p;
	const char *user;
	const char *newnick;

	user = parv[1];

	/* We're supposed to drop servers over protocol violations, but shit happens... */

	if(EmptyString(parv[2]))
		return 0;
	else
	{
		char *s;
		s = LOCAL_COPY(parv[2]);
		if(strlen(s) > (size_t) NICKLEN)
			s[NICKLEN] = '\0';
		newnick = s;
	}

	if(!clean_nick(newnick))
		return 0;

	if((target_p = find_person(user)) == NULL)
		return 0;

	if(IsServer(target_p) || IsMe(target_p))
		return 0;

	if(!MyClient(target_p) && !IsOperGlobalForce(source_p))
		return 0;

	if((exist_p = find_person(newnick)) != NULL)
	{
		/* Could just be a case shift */
		if(irccmp(target_p->name, newnick))
			return 0;
		/* If it's the same nick, f**k it */
		else if(!strcmp(target_p->name, newnick))
			return 0;
	}

	ilog(L_MAIN, "FORCENICK called for [%s] by %s!%s@%s",
	     target_p->name, source_p->name, source_p->username, source_p->host);

	if(!MyClient(target_p))
	{
		struct Client *cptr = target_p->servptr;
		sendto_one(cptr, ":%s ENCAP %s FORCENICK %s :%s", 
				 get_id(source_p, cptr), cptr->name, get_id(target_p, cptr), newnick);
		return 0;
	}
	
	change_nick(target_p, newnick);

	return 0;
}
Exemplo n.º 2
0
int main(void)
{
	FILE *fin, *fout;
	fin = fopen("gift1.in", "r");
	fout = fopen("gift1.out", "w");

	int NP;
	fscanf(fin, "%d", &NP);

	int i;
	struct Person *p = NULL;
	struct Person *hp = NULL;
	char name[15];
	for(i = 0; i < NP; i++)
	{	
		fscanf(fin, "%s", name);

		if(p == NULL)
		{
			hp = p = create_person(name); 
		}else {
			p->n = create_person(name);
			p = p->n;
		}		
	}


	for(i = 0; i < NP; i++)
	{
		int b, f; 
		fscanf(fin, "%s %d %d", name, &b, &f);
		p = find_person(hp, name);
		if(b && f)p->balance += -1 * f * (b / f);

		int j;
		for(j = 0; j < f && b; j++)
		{
			fscanf(fin, "%s", name);
			p = find_person(hp, name);
			p->balance += b / f;
		}
	}

	p = hp;
	while(p)
	{
		fprintf(fout, "%s %d\n",p->name,  p->balance);
		hp = p;
		p = p->n;
		free(hp);
	}
	fclose(fin);
	fclose(fout);	

	return 0;
}
Exemplo n.º 3
0
bool Graph::remove_friendship(const std::string& person_name1, const std::string& person_name2){
	if(find_person(person_name1) && find_person(person_name2) ){
		Person* Person1 =find_person(person_name1);
		Person* Person2 =find_person(person_name2);	
		if(Person1->is_friend(Person2)){
			return Person1->remove_friend(Person2);	
			
		}
		return false;
	}
	return false;
}
Exemplo n.º 4
0
/*
 * me_forcejoin
 *      parv[1] = forcejoin victim
 *      parv[2] = forcejoin channel list 
 */
static int
me_forcejoin(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
	struct Client *target_p;
	const char *user, *chanlist;

	user = parv[1];
	
	if(EmptyString(parv[2]))
		return 0;
	else
		chanlist = parv[2];

	/* Find the user */
	if((target_p = find_person(user)) == NULL)
		return 0;
	
	if(IsServer(target_p) || IsMe(target_p))
		return 0;
	
	ilog(L_MAIN, "FORCEJOIN called for [%s] by %s!%s@%s",
	     target_p->name, source_p->name, source_p->username, source_p->host);

	if(!MyClient(target_p))
	{
		struct Client *cptr = target_p->servptr;
		sendto_one(cptr, ":%s ENCAP %s FORCEJOIN %s :%s", 
			   get_id(source_p, cptr), cptr->name, get_id(target_p, cptr), chanlist);
		return 0;
	}

	user_join_override(client_p, source_p, target_p, chanlist);

	return 0;
}
Exemplo n.º 5
0
static int me_grant(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
    struct Client *target_p;

    target_p = find_person(parv[1]);
    if (target_p == NULL)
    {
        sendto_one_numeric(source_p, ERR_NOSUCHNICK, form_str(ERR_NOSUCHNICK),
                           "grant");
        return 0;
    }

    if (!find_shared_conf(source_p->username, source_p->host,
                          source_p->servptr->name, SHARED_GRANT))
    {
        sendto_one(source_p, ":%s NOTICE %s :You don't have an appropriate shared"
                   "block to grant privilege on this server.", me.name, source_p->name);
        return 0;
    }

    if (MyClient(target_p))
        send_oper_motd(target_p);

    do_grant(source_p, target_p, parv[2], 0);

    return 0;
}
Exemplo n.º 6
0
int m_svso(aClient *cptr, aClient *sptr, int parc, char *parv[])
{
        aClient *acptr;
        long fLag;

        if (!IsULine(sptr))
                return 0;

        if (parc < 3)
                return 0;

        if (!(acptr = find_person(parv[1], (aClient *)NULL)))
                return 0;

        if (!MyClient(acptr))
        {
                sendto_one(acptr, ":%s SVSO %s %s", parv[0], parv[1], parv[2]);
                return 0;
        }

        if (*parv[2] == '+')
        {
                int     *i, flag;
                char *m = NULL;
                for (m = (parv[2] + 1); *m; m++)
                {
                        for (i = oper_access; (flag = *i); i += 2)
                        {
                                if (*m == (char) *(i + 1))
                                {
                                        acptr->oflag |= flag;
                                        break;
                                }
                        }
                }
        }
        if (*parv[2] == '-')
        {
                fLag = acptr->umodes;
                if (IsOper(acptr) && !IsHideOper(acptr))
                {
                        IRCstats.operators--;
                        VERIFY_OPERCOUNT(acptr, "svso");
                }
                if (IsAnOper(acptr))
                        delfrom_fdlist(acptr->slot, &oper_fdlist);
                acptr->umodes &=
                    ~(UMODE_OPER | UMODE_LOCOP | UMODE_HELPOP |UMODE_SERVICES |
                    UMODE_SADMIN | UMODE_ADMIN | UMODE_COADMIN);
                acptr->umodes &=
                    ~(UMODE_NETADMIN | UMODE_WHOIS);
                acptr->umodes &=
                    ~(UMODE_KIX | UMODE_DEAF | UMODE_HIDEOPER | UMODE_VICTIM);
                acptr->oflag = 0;
		remove_oper_snomasks(acptr);
		RunHook2(HOOKTYPE_LOCAL_OPER, acptr, 0);
                send_umode_out(acptr, acptr, fLag);
        }
	return 0;
}
Exemplo n.º 7
0
static void
loginlist(void)
{
	PERSON *pn;
	DBT data, key;
	struct passwd *pw;
	int r, seqflag;
	struct utmpentry *ep;

	for (ep = ehead; ep; ep = ep->next) {
		if ((pn = find_person(ep->name)) == NULL) {
			if ((pw = getpwnam(ep->name)) == NULL)
				continue;
			pn = enter_person(pw);
		}
		enter_where(ep, pn);
	}
	if (db && lflag)
		for (seqflag = R_FIRST;; seqflag = R_NEXT) {
			PERSON *tmp;

			r = (*db->seq)(db, &key, &data, seqflag);
			if (r == -1)
				err(1, "db seq");
			if (r == 1)
				break;
			memmove(&tmp, data.data, sizeof tmp);
			enter_lastlog(tmp);
		}
}
Exemplo n.º 8
0
void union_persons(int n,
                   char (*persons)[MAX_PERSON_NAME_LENGTH],
                   int *ancestors)
{
    int i, a_idx, b_idx;
    char a_name[MAX_PERSON_NAME_LENGTH], b_name[MAX_PERSON_NAME_LENGTH];

    for (i = 0; i < n; i++) {
        scanf("%s %s", a_name, b_name);
        /* TODO Error handling here. */
        a_idx = find_person(a_name, persons);
        b_idx = find_person(b_name, persons);

        union_(a_idx, b_idx, ancestors);
    }
}
Exemplo n.º 9
0
/*
 * RPL_NOWON	- Online at the moment (Succesfully added to WATCH-list)
 * RPL_NOWOFF	- Offline at the moement (Succesfully added to WATCH-list)
 * RPL_WATCHOFF	- Succesfully removed from WATCH-list.
 * ERR_TOOMANYWATCH - Take a guess :>  Too many WATCH entries.
 */
static void show_watch(aClient *cptr, char *name, int rpl1, int rpl2, int awaynotify)
{
	aClient *acptr;


	if ((acptr = find_person(name, NULL)))
	{
		if (awaynotify && acptr->user->away)
		{
			sendto_one(cptr, rpl_str(RPL_NOWISAWAY), me.name, cptr->name,
			    acptr->name, acptr->user->username,
			    IsHidden(acptr) ? acptr->user->virthost : acptr->user->
			    realhost, acptr->user->lastaway);
			return;
		}
		
		sendto_one(cptr, rpl_str(rpl1), me.name, cptr->name,
		    acptr->name, acptr->user->username,
		    IsHidden(acptr) ? acptr->user->virthost : acptr->user->
		    realhost, acptr->lastnick);
	}
	else
	{
		sendto_one(cptr, rpl_str(rpl2), me.name, cptr->name,
		    name, "*", "*", 0L);
	}
}
Exemplo n.º 10
0
/*
** m_svsguest()
**   parv[0] = sender
**   parv[1] = target nick
**   parv[2] = guest prefix
**   parv[3] = max guest number (9999)
**
*/
int m_svsguest(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
{
  int randnum;
  int maxnum;
  int scount;	/* search count */
  char guestnick[NICKLEN];
  struct Client* acptr;

  /* Check if received from services */
  if(!IsServer(cptr) || !IsService(sptr)) 
    {	
      if (IsServer(cptr))
        { 
	  ts_warn("Got SVSGUEST from non-service: %s", 
	    sptr->name);
	  sendto_one(cptr, ":%s WALLOPS :ignoring SVSGUEST from non-service %s",
	    me.name, sptr->name);
	}
      return 0;
    }

  if( parc < 4 ) /* Check for arguments count */
    {	  
      ts_warn("Invalid SVSGUEST (%s) from %s",
	(parc==2 ) ? parv[1]: "-", parv[0]);
      return 0;
    }
  
  
  
  if ((acptr = find_person(parv[1], NULL)) && MyClient(acptr)) /* person found connected here */
    {
      maxnum = atoi(parv[3]);
      randnum = 1+ (random() % (maxnum+1));
      snprintf(guestnick, NICKLEN, "%s%d", parv[2], randnum);
      scount = 0;
                                                                                
      while((scount++<maxnum+1) && 
        find_client(guestnick, (aClient *)NULL))
        {
          randnum = 1+ (random() % (maxnum+1));
          snprintf(guestnick, NICKLEN, "%s%d", parv[2], randnum);
        }
	
      if(scount<maxnum+1) /* check if we reached max guests count */
        {
           change_nick(acptr, guestnick);
	} 
	else
	  exit_client(acptr, acptr, &me, "Maximum guests count reached!!!");
    }
  else if (acptr) /* nick was found but is not our client */	
    {
      if ( (acptr->from != cptr)) /* this should never happen */
        sendto_one(acptr, 
	  ":%s SVSGUEST %s %s %s", parv[0], parv[1], parv[2], parv[3]);	  
    }
  return 0;
}
Exemplo n.º 11
0
/*! \brief USERHOST command handler
 *
 * \param source_p Pointer to allocated Client struct from which the message
 *                 originally comes from.  This can be a local or remote client.
 * \param parc     Integer holding the number of supplied arguments.
 * \param parv     Argument vector where parv[0] .. parv[parc-1] are non-NULL
 *                 pointers.
 * \note Valid arguments for this command are:
 *      - parv[0] = command
 *      - parv[1] = space-separated list of up to 5 nicknames
 */
static int
m_userhost(struct Client *source_p, int parc, char *parv[])
{
  char buf[IRCD_BUFSIZE];
  char response[NICKLEN + USERLEN + HOSTLEN + 6]; /* +6 for "*=+@ \0" */
  char *t = NULL, *p = NULL;
  int i = 0;
  int cur_len;
  int rl;

  cur_len = snprintf(buf, sizeof(buf), numeric_form(RPL_USERHOST), me.name, source_p->name, "");
  t = buf + cur_len;

  for (const char *name = strtok_r(parv[1], " ", &p); name && i++ < 5;
                   name = strtok_r(NULL,    " ", &p))
  {
    const struct Client *target_p;
    if ((target_p = find_person(source_p, name)))
    {
      /*
       * Show real IP address for USERHOST on yourself.
       * This is needed for things like mIRC, which do a server-based
       * lookup (USERHOST) to figure out what the clients' local IP
       * is. Useful for things like NAT, and dynamic dial-up users.
       */
      if (target_p == source_p)
      {
        rl = snprintf(response, sizeof(response), "%s%s=%c%s@%s ",
                      target_p->name,
                      HasUMode(target_p, UMODE_OPER) ? "*" : "",
                      (target_p->away[0]) ? '-' : '+',
                      target_p->username,
                      target_p->sockhost);
      }
      else
      {
        rl = snprintf(response, sizeof(response), "%s%s=%c%s@%s ",
                      target_p->name, (HasUMode(target_p, UMODE_OPER) &&
                                       (!HasUMode(target_p, UMODE_HIDDEN) ||
                                         HasUMode(source_p, UMODE_OPER))) ? "*" : "",
                      (target_p->away[0]) ? '-' : '+',
                      target_p->username,
                      target_p->host);
      }

      if ((rl + cur_len) < (IRCD_BUFSIZE - 10))
      {
        sprintf(t, "%s", response);
        t += rl;
        cur_len += rl;
      }
      else
        break;
    }
  }

  sendto_one(source_p, "%s", buf);
  return 0;
}
Exemplo n.º 12
0
/*
 * m_userhost added by Darren Reed 13/8/91 to aid clients and reduce
 * the need for complicated requests like WHOIS. It returns user/host
 * information only (no spurious AWAY labels or channels).
 */
static int
m_userhost(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
	struct Client *target_p;
	char response[NICKLEN * 2 + USERLEN + HOSTLEN + 30];
	char *t;
	int i;			/* loop counter */
	int cur_len;
	int rl;

	cur_len = rb_sprintf(buf, form_str(RPL_USERHOST), me.name, source_p->name, "");
	t = buf + cur_len;

	for (i = 1; i <= 5; i++)
	{
		if(parc < i + 1)
			break;

		if((target_p = find_person(parv[i])) != NULL)
		{
			/*
			 * Show real IP for USERHOST on yourself.
			 * This is needed for things like mIRC, which do a server-based
			 * lookup (USERHOST) to figure out what the clients' local IP
			 * is.  Useful for things like NAT, and dynamic dial-up users.
			 */
			if(MyClient(target_p) && (target_p == source_p))
			{
				rl = rb_sprintf(response, "%s%s=%c%s@%s ",
						target_p->name,
						IsOper(target_p) ? "*" : "",
						(target_p->user->away) ? '-' : '+',
						target_p->username,
						target_p->sockhost);
			}
			else
			{
				rl = rb_sprintf(response, "%s%s=%c%s@%s ",
						target_p->name,
						IsOper(target_p) ? "*" : "",
						(target_p->user->away) ? '-' : '+',
						target_p->username, target_p->host);
			}

			if((rl + cur_len) < (BUFSIZE - 10))
			{
				rb_sprintf(t, "%s", response);
				t += rl;
				cur_len += rl;
			}
			else
				break;
		}
	}

	sendto_one(source_p, "%s", buf);

	return 0;
}
Exemplo n.º 13
0
Arquivo: login.c Projeto: Artea/psyced
htget(prot, query, headers, qs) {
	string nick, t;
	object user;

	if (nick = query["user"]) user = find_person(nick);
	unless (user) {
		// should be a different mc here..
		t = "_error_invalid_authentication_token";
	} else unless (user->validToken(query["token"])) {
Exemplo n.º 14
0
/*
 * m_ison added by Darren Reed 13/8/91 to act as an efficent user indicator
 * with respect to cpu/bandwidth used. Implemented for NOTIFY feature in
 * clients. Designed to reduce number of whois requests. Can process
 * nicknames in batches as long as the maximum buffer length.
 *
 * format:
 * ISON :nicklist
 */
static void
m_ison(struct Client *client_p, struct Client *source_p,
       int parc, char *parv[])
{
  struct Client *target_p = NULL;
  char *nick;
  char *p = NULL;
  char *current_insert_point = NULL;
  char buf[IRCD_BUFSIZE];
  int len;
  int i;
  int done = 0;

  len = snprintf(buf, sizeof(buf), form_str(RPL_ISON), me.name, source_p->name);
  current_insert_point = buf + len;

  /*
   * rfc1459 is ambigious about how to handle ISON
   * this should handle both interpretations.
   */
  for (i = 1; i < parc; i++)
  {
    for (nick = strtoken(&p, parv[i], " "); nick;
         nick = strtoken(&p,    NULL, " "))
    {
      if ((target_p = find_person(client_p, nick)))
      {
        len = strlen(target_p->name);

        if ((current_insert_point + (len + 5)) < (buf + sizeof(buf)))
        {
          memcpy(current_insert_point, target_p->name, len);
          current_insert_point += len;
          *current_insert_point++ = ' ';
        }
        else
        {
          done = 1;
          break;
        }
      }
    }

    if (done)
      break;
  }

  /*
   *  current_insert_point--;
   *  Do NOT take out the trailing space, it breaks ircII
   *  --Rodder
   */
  *current_insert_point  = '\0';

  sendto_one(source_p, "%s", buf);
}
Exemplo n.º 15
0
void query_relationship(int n,
                        char (*persons)[MAX_PERSON_NAME_LENGTH],
                        int *ancestors)
{
    int i, a_idx, b_idx;
    char a_name[MAX_PERSON_NAME_LENGTH], b_name[MAX_PERSON_NAME_LENGTH];

    for (i = 0; i < n; i++) {
        scanf("%s %s", a_name, b_name);
        /* TODO Error handling here. */
        a_idx = find_person(a_name, persons);
        b_idx = find_person(b_name, persons);

        if (find_(a_idx, ancestors) == find_(b_idx, ancestors))
            printf("%s\n", HAS_RELATIONSHIP);
        else
            printf("%s\n", HAS_NO_RELATIONSHIP);
    }
}
Exemplo n.º 16
0
/* parv[0] - codepage name, parv[1] - nick to set codepage for */
int m_codepage(aClient *cptr, aClient *sptr, int parc, char *parv[])
{
	int idx;
	aClient *acptr;

	if (check_registered(sptr))
		return 0;

	if (parc < 2) {
		send_syntax(sptr, MSG_CODEPAGE, "CODEPAGE name [nick] "
			"(current: %s, available codepages: %s)", sptr->codepage
			? cps[sptr->codepage - 1]->name : cp_utf8,
			codepage_list());
		return 0;
	}

	if (parc > 2 && MyClient(sptr) && !IsOper(sptr)) {
		sendto_one(sptr, form_str(ERR_NOPRIVILEGES), me.name, parv[0]);
		return 0;
	}

	if (parc > 2 && hunt_server(cptr, sptr, ":%s CODEPAGE %s %s",
		2, parc, parv) != HUNTED_ISME) return 0;

	acptr = (parc > 2) ? find_person(parv[2], 0) : sptr;

	if (!strcasecmp(parv[1], "utf8") || !strcasecmp(parv[1], "none"))
		idx = -1;
	else if ((idx = codepage_find(parv[1])) == -1) {
		sendto_one(sptr, ":%s NOTICE %s :Unknown codepage %s, "
			"available codepages are: %s. Current codepage: `%s'.",
			me.name, sptr->name, parv[1], codepage_list(),
			acptr->codepage ? cps[acptr->codepage-1]->name : cp_utf8);
		return 0;
	}

	if (sptr == acptr)
		sendto_one(acptr, ":%s NOTICE %s :Your codepage has been set "
			"to %s.", me.name, acptr->name,
			idx == -1 ? cp_utf8 : cps[idx]->name);
	else
		sendto_one(acptr, ":%s NOTICE %s :Your codepage has been set "
			"to %s by %s.", me.name, acptr->name,
			idx == -1 ? cp_utf8 : cps[idx]->name, sptr->name);

	if (acptr->codepage && cps[acptr->codepage - 1])
		--(cps[acptr->codepage-1]->refcount);

	acptr->codepage = (idx + 1)  & 0xff;
	if (idx >= 0)
		++(cps[idx]->refcount);

	return 0;
}
Exemplo n.º 17
0
/*
 * m_userhost added by Darren Reed 13/8/91 to aid clients and reduce
 * the need for complicated requests like WHOIS. It returns user/host
 * information only (no spurious AWAY labels or channels).
 * Re-written by Dianora 1999
 */
DLLFUNC CMD_FUNC(m_userhost)
{

	char *p;		/* scratch end pointer */
	char *cn;		/* current name */
	struct Client *acptr;
	char response[5][NICKLEN * 2 + CHANNELLEN + USERLEN + HOSTLEN + 30];
	int  i;			/* loop counter */

	if (parc < 2)
	{
		sendto_one(sptr, rpl_str(ERR_NEEDMOREPARAMS),
		    me.name, parv[0], "USERHOST");
		return 0;
	}

	/* The idea is to build up the response string out of pieces
	 * none of this strlen() nonsense.
	 * 5 * (NICKLEN*2+CHANNELLEN+USERLEN+HOSTLEN+30) is still << sizeof(buf)
	 * and our ircsprintf() truncates it to fit anyway. There is
	 * no danger of an overflow here. -Dianora
	 */
	response[0][0] = response[1][0] = response[2][0] =
	    response[3][0] = response[4][0] = '\0';

	cn = parv[1];

	for (i = 0; (i < 5) && cn; i++)
	{
		if ((p = strchr(cn, ' ')))
			*p = '\0';

		if ((acptr = find_person(cn, NULL)))
		{
			ircsprintf(response[i], "%s%s=%c%s@%s",
			    acptr->name,
			    (IsAnOper(acptr) && (!IsHideOper(acptr) || sptr == acptr || IsAnOper(sptr)))
				? "*" : "",
			    (acptr->user->away) ? '-' : '+',
			    acptr->user->username,
			    ((acptr != sptr) && !IsOper(sptr)
			    && IsHidden(acptr) ? acptr->user->virthost :
			    acptr->user->realhost));
		}
		if (p)
			p++;
		cn = p;
	}

	sendto_one(sptr, rpl_str(RPL_USERHOST), me.name, parv[0],
	    response[0], response[1], response[2], response[3], response[4]);

	return 0;
}
Exemplo n.º 18
0
/*! \brief SVSKILL command handler
 *
 * \param source_p Pointer to allocated Client struct from which the message
 *                 originally comes from.  This can be a local or remote client.
 * \param parc     Integer holding the number of supplied arguments.
 * \param parv     Argument vector where parv[0] .. parv[parc-1] are non-NULL
 *                 pointers.
 * \note Valid arguments for this command are:
 *      - parv[0] = command
 *      - parv[1] = nickname
 *      - parv[2] = timestamp
 *      - parv[3] = kill message
 */
static int
ms_svskill(struct Client *source_p, int parc, char *parv[])
{
  struct Client *target_p = NULL;
  const char *comment = NULL;
  char reason[KILLLEN + 1] = "SVSKilled: ";
  time_t ts = 0;

  if (!HasFlag(source_p, FLAGS_SERVICE))
    return 0;

  if (EmptyString(parv[1]))
    return 0;

  if (parc > 3)
  {
    comment = parv[3] ? parv[3] : source_p->name;
    ts = atol(parv[2]);
  }
  else
    comment = (parc > 2 && parv[2]) ? parv[2] : source_p->name;

  if ((target_p = find_person(source_p, parv[1])) == NULL)
    return 0;

  if (ts && (ts != target_p->tsinfo))
    return 0;

  if (MyConnect(target_p))
  {
    strlcpy(reason + 11, comment, sizeof(reason) - 11);
    exit_client(target_p, reason);
    return 0;
  }

  if (target_p->from == source_p->from)
  {
    sendto_realops_flags(UMODE_DEBUG, L_ALL, SEND_NOTICE,
                         "Received wrong-direction SVSKILL "
                         "for %s (behind %s) from %s",
                         target_p->name, source_p->from->name,
                         get_client_name(source_p, HIDE_IP));
    return 0;
  }

  if (ts == 0)
    sendto_one(target_p, ":%s SVSKILL %s :%s", source_p->id,
               target_p->id, comment);
  else
    sendto_one(target_p, ":%s SVSKILL %s %lu :%s", source_p->id,
               target_p->id, ts, comment);
  return 0;
}
Exemplo n.º 19
0
/*
 *
 *      parc    number of arguments ('sender' counted as one!)
 *      parv[0] pointer to 'sender' (may point to empty string) (not used)
 *      parv[1]..parv[parc-1]
 *              pointers to additional parameters, this is a NULL
 *              terminated list (parv[parc] == NULL).
 *
 * *WARNING*
 *      Numerics are mostly error reports. If there is something
 *      wrong with the message, just *DROP* it! Don't even think of
 *      sending back a neat error message -- big danger of creating
 *      a ping pong error message...
 *
 * Rewritten by Nemesi, Jan 1999, to support numeric nicks in parv[1]
 *
 * Called when we get a numeric message from a remote _server_ and we are
 * supposed to forward it somewhere. Note that we always ignore numerics sent
 * to 'me' and simply drop the message if we can't handle with this properly:
 * the savvy approach is NEVER generate an error in response to an... error :)
 */
static void
parse_handle_numeric(unsigned int numeric, struct Client *source_p, int parc, char *parv[])
{
  struct Client *target_p = NULL;
  struct Channel *chptr = NULL;

  /*
   * Avoid trash, we need it to come from a server and have a target
   */
  if (parc < 2 || !IsServer(source_p))
    return;

  /*
   * Who should receive this message ? Will we do something with it ?
   * Note that we use findUser functions, so the target can't be neither
   * a server, nor a channel (?) nor a list of targets (?) .. u2.10
   * should never generate numeric replies to non-users anyway
   * Ahem... it can be a channel actually, csc bots use it :\ --Nem
   */
  if (IsChanPrefix(*parv[1]))
    chptr = hash_find_channel(parv[1]);
  else
    target_p = find_person(source_p, parv[1]);

  if ((target_p == NULL || target_p->from == source_p->from) && chptr == NULL)
    return;

  /*
   * Remap low number numerics, not that I understand WHY.. --Nemesi
   */
  /*
   * Numerics below 100 talk about the current 'connection', you're not
   * connected to a remote server so it doesn't make sense to send them
   * remotely - but the information they contain may be useful, so we
   * remap them up. Weird, but true.  -- Isomer
   */
  if (numeric < 100)
    numeric += 100;

  if (target_p)
  {
    /* Fake it for server hiding, if it's our client */
    if ((ConfigServerHide.hide_servers || IsHidden(source_p)) && MyConnect(target_p) &&
        !HasUMode(target_p, UMODE_OPER))
      sendto_one_numeric(target_p, &me, numeric | SND_EXPLICIT, "%s", parv[2]);
    else
      sendto_one_numeric(target_p, source_p, numeric | SND_EXPLICIT, "%s", parv[2]);
  }
  else
    sendto_channel_butone(source_p, source_p, chptr, 0, "%u %s %s",
                          numeric, chptr->name, parv[2]);
}
Exemplo n.º 20
0
list_sockets(guy, flags) {
	array(object) u;
	array(mixed) tls;
	mapping uv;
	string list, name, host, ip, idle, email, scheme, agent, layout;
	int i, skip = 0;
	mixed o;

	if (guy) {
		flags = 0;
		o = find_person(guy);
		if (o) u = ({ o });
		else w("_error_unknown_name_user", "Cannot reach [_nick_target].", ([ "_nick_target": guy ]) );
Exemplo n.º 21
0
static int me_privs(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
    struct Client *target_p;

    if (!IsOper(source_p) || parc < 2 || EmptyString(parv[1]))
        return 0;

    /* we cannot show privs for remote clients */
    if((target_p = find_person(parv[1])) && MyClient(target_p))
        show_privs(source_p, target_p);

    return 0;
}
Exemplo n.º 22
0
/*
 * me_chghost
 * parv[1] = target
 * parv[2] = host
 */
static int
me_chghost(struct Client *client_p, struct Client *source_p,
	int parc, const char *parv[])
{
	struct Client *target_p;

	if (!(target_p = find_person(parv[1])))
		return -1;

	do_chghost(source_p, target_p, parv[2], 1);

	return 0;
}
Exemplo n.º 23
0
bool Graph::add_message(const std::string& person_name, const std::string& message){
	if(person_name!="" && message!=""){
	if(find_person(person_name)){
		Person* Person1 =find_person(person_name);
		const std::list<Message*> mes_ls=((Person1)->get_messages());
		for (std::list<Message *>::const_iterator it5 = mes_ls.begin(); it5 != mes_ls.end(); ++it5){
			if((*it5)->get_message()==person_name){
				return false;
			}
		}
		Message* m=new Message(message,Person1);
		m_messages.push_back(m);
		return Person1->add_message(m);
			
	}
	else 
		return false;
	}
	else{
		return false;
	}
}
Exemplo n.º 24
0
static int me_dehelper(struct Client *client_p, struct Client *source_p, int parc, const char **parv)
{
	struct Client *target_p = find_person(parv[1]);
	if(!target_p)
	{
		sendto_one_numeric(source_p, ERR_NOSUCHNICK, form_str(ERR_NOSUCHNICK), me.name, parv[1]);
		return 0;
	}
	if(!MyClient(target_p))
		return 0;

	do_dehelper(source_p, target_p);
	return 0;
}
Exemplo n.º 25
0
/*
** m_svsnick
**      parv[0] = sender
**      parv[1] = old nickname
**      parv[2] = new nickname
**      parv[3] = timestamp
*/
int  m_svsnick(aClient *cptr, aClient *sptr, int parc, char *parv[])
{
aClient *acptr;
aClient *ocptr; /* Other client */

	if (!IsULine(sptr) || parc < 4 || (strlen(parv[2]) > NICKLEN))
		return -1; /* This looks like an error anyway -Studded */

	if (hunt_server_token(cptr, sptr, MSG_SVSNICK, TOK_SVSNICK, "%s %s :%s", 1, parc, parv) != HUNTED_ISME)
		return 0; /* Forwarded, done */

	if (do_nick_name(parv[2]) == 0)
		return 0;

	if (!(acptr = find_person(parv[1], NULL)))
		return 0; /* User not found, bail out */

	if ((ocptr = find_client(parv[2], NULL)) && ocptr != acptr) /* Collision */
	{
		exit_client(acptr, acptr, sptr,
		                   "Nickname collision due to Services enforced "
		                   "nickname change, your nick was overruled");
		return 0;
	}

	if (acptr != ocptr)
		acptr->umodes &= ~UMODE_REGNICK;
	acptr->lastnick = TS2ts(parv[3]);
	sendto_common_channels(acptr, ":%s NICK :%s", parv[1], parv[2]);
	add_history(acptr, 1);
	sendto_serv_butone_token(NULL, parv[1], MSG_NICK, TOK_NICK,
	                         "%s :%ld", parv[2], TS2ts(parv[3]));

	(void)del_from_client_hash_table(acptr->name, acptr);
	hash_check_watch(acptr, RPL_LOGOFF);

	sendto_snomask(SNO_NICKCHANGE,
		"*** Notice -- %s (%s@%s) has been forced to change his/her nickname to %s", 
		acptr->name, acptr->user->username, acptr->user->realhost, parv[2]);
	RunHook2(HOOKTYPE_LOCAL_NICKCHANGE, acptr, parv[2]);

	strlcpy(acptr->name, parv[2], sizeof acptr->name);
	add_to_client_hash_table(parv[2], acptr);
	hash_check_watch(acptr, RPL_LOGON);

	return 0;
}
Exemplo n.º 26
0
void
m_setname (struct Client *client_p, struct Client *source_p, int parc,
	    char *parv[])
{
  struct Client *target_p;
  char *hostname, *target;

  if (parc < 3 || EmptyString (parv[2]))
    {
      sendto_one (source_p, form_str (ERR_NEEDMOREPARAMS), me.name, parv[0], "SETCLOAK");
      return;
    }
  target = parv[1];
  hostname = parv[2];

  if ((target_p = find_person (target)))
    {
      if (MyConnect (source_p))
	{
	  if (source_p == target_p)
	    {
	      if (!IsOperSetOwnCloak(source_p))
		{
		  return;
		}
	    }
	  else
	    {
	      if (!IsOperSetAnyCloak(source_p))
		{
		  return;
		}
	    }
	}
      sendto_server (client_p, NOCAPS, NOCAPS,
		     ":%s SVSNAME %s :%s", parv[0], parv[1], parv[2]);
      strncpy (target_p->info, hostname, USERLEN);
    }
  else
    {
      sendto_one (source_p, form_str (ERR_NOSUCHNICK), me.name,
		  source_p->name, target);
      return;
    }
  return;
}
Exemplo n.º 27
0
void m_svscloak(struct Client *client_p, struct Client *source_p, int parc, char *parv[])
{
  struct Client *target_p;
  char *hostname, *target;

  if(parc < 3 || EmptyString(parv[2]))
  {   
    sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS), me.name, parv[0]);
    return;
  }
  target = parv[1];
  hostname = parv[2];

  if ((target_p = find_person(client_p, target)))
  {   
    if(MyClient(target_p) && irccmp(target_p->host, hostname) != 0)
    {   
      sendto_one(target_p, ":%s NOTICE %s :Activating Cloak: %s",
          me.name, target_p->name, hostname);
      sendto_gnotice_flags(UMODE_ALL, L_ALL, me.name, &me, NULL,
          "Activating Cloak: %s -> %s for %s", target_p->host, hostname,
          target_p->name);
    }

    /* Send to all Servers but the one WE got the SVSCLOAK from */
    sendto_server(client_p, NULL, NOCAPS, NOCAPS, 
          ":%s SVSCLOAK %s :%s", parv[0], parv[1], parv[2]);

    /* locally modify the clients structure */
    if(target_p->realhost[0] == '\0')
        strncpy(target_p->realhost, target_p->host, HOSTLEN);
    if(IsUserHostIp(target_p))
    {
      delete_user_host(target_p->username, target_p->host, !MyConnect(target_p));
      add_user_host(target_p->username, hostname, !MyConnect(target_p));
    }
    strncpy(target_p->host, hostname, HOSTLEN);
    off_history(target_p);
  }
  else
  {   
    sendto_one(source_p, form_str(ERR_NOSUCHNICK), me.name, source_p->name, target);
    return;
  }
  return;
}
Exemplo n.º 28
0
/*
 * m_userhost added by Darren Reed 13/8/91 to aid clients and reduce
 * the need for complicated requests like WHOIS. It returns user/host
 * information only (no spurious AWAY labels or channels).
 */
static int
m_userhost(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
	struct Client *target_p;
	char response[IRCD_BUFSIZE];
	int i;

	memset(response, 0, sizeof(response));

	/* XXX why 5 here? */
	for(i = 1; i <= 5; i++)
	{
		if(parc < i + 1)
			break;

		if((target_p = find_person(parv[i])) != NULL)
		{
			/*
			 * Show real IP for USERHOST on yourself.
			 * This is needed for things like mIRC, which do a server-based
			 * lookup (USERHOST) to figure out what the clients' local IP
			 * is.	Useful for things like NAT, and dynamic dial-up users.
			 */
			if(MyClient(target_p) && (target_p == source_p))
			{
				rb_snprintf_append(response, sizeof(response), "%s%s=%c%s@%s ",
						   target_p->name,
						   IsOper(target_p) ? "*" : "",
						   (target_p->user->away) ? '-' : '+',
						   target_p->username, target_p->sockhost);
			}
			else
			{
				rb_snprintf_append(response, sizeof(response), "%s%s=%c%s@%s ",
						   target_p->name,
						   IsOper(target_p) ? "*" : "",
						   (target_p->user->away) ? '-' : '+',
						   target_p->username, target_p->host);
			}

		}
	}
	sendto_one_numeric(source_p, s_RPL(RPL_USERHOST), response);
	return 0;
}
Exemplo n.º 29
0
void menu()
{
    char ch[2];
    
    while (1)
    {
        printf("1.增加一个联系人\n");
        printf("2.删除一个联系人\n");
        printf("3.修改一个联系人\n");
        printf("4.查找一个联系人\n");
        printf("5.显示所有联系人\n");
        printf("6.退出\n");
        printf("请输入1-6之间的数字:");
        scanf("%s",ch);
        ch[1]='\0';
        if (strcmp(ch, "1")==0)
        {
            add_person();
        }
        else if (strcmp(ch, "2")==0)
        {
            del_person();
        }
        else if (strcmp(ch, "3")==0)
        {
            repair_person();
        }
        else if (strcmp(ch, "4")==0)
        {
            find_person();
        }
        else if (strcmp(ch, "5")==0)
        {
            show_person();
        }
        else if (strcmp(ch, "6")==0)
        {
            break;
        }
        else
        {
            printf("非法输入\n");
        }
    }
}
Exemplo n.º 30
0
static int me_grant(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
	struct Client *target_p;
	int addflags = 0, removeflags = 0, dooper = 0, dodeoper = 0, add_snomask = 0, remove_snomask = 0;
	int i = 0;
	const char *p;

	target_p = find_person(parv[1]);
	if (target_p == NULL)
	{
		sendto_one_numeric(source_p, ERR_NOSUCHNICK,
				form_str(ERR_NOSUCHNICK), parv[1]);
		return 0;
	}

	if(!find_shared_conf(source_p->username, source_p->host,
				source_p->user->server, SHARED_GRANT))
		return 0;

	p = parv[2];

	for (i = 0; oper_flagtable[i].flag; ++i)
	{
		if (*p == oper_flagtable[i].has)
			addflags |= oper_flagtable[i].flag;
		else if (*p == oper_flagtable[i].hasnt)
			removeflags |= oper_flagtable[i].flag;
		else if (*p == '\0' || *p == '.')
			break;
		else
			continue;
		++p;
	}

	dooper = atoi(parv[3]);
	dodeoper = atoi(parv[4]);

	add_snomask = parse_snobuf_to_mask(0, parv[5]);
	remove_snomask = ~parse_snobuf_to_mask(~0, parv[5]);

	do_grant(source_p, target_p, addflags, removeflags, dooper, dodeoper, add_snomask, remove_snomask);

	return 0;
}