Exemple #1
0
static int do_deowner(User * u)
{
    char *av[2];
    char *chan = strtok(NULL, " ");

    Channel *c;
    ChannelInfo *ci;
    struct u_chanlist *uc;

    if (!ircd->owner) {
        return MOD_CONT;
    }

    if (!chan) {
        av[0] = sstrdup(ircd->ownerunset);
        av[1] = GET_USER(u);

        /* Sets the mode to the user on every channels he is on. */

        for (uc = u->chans; uc; uc = uc->next) {
            if ((ci = uc->chan->ci) && !(ci->flags & CI_VERBOTEN)
                && is_founder(u, ci)) {
                anope_cmd_mode(whosends(ci), uc->chan->name, "%s %s",
                               av[0], GET_USER(u));
                chan_set_modes(s_ChanServ, uc->chan, 2, av, 1);
            }
        }

        free(av[0]);
        return MOD_CONT;
    }

    if (!(c = findchan(chan))) {
        notice_lang(s_ChanServ, u, CHAN_X_NOT_IN_USE, chan);
    } else if (!(ci = c->ci)) {
        notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, c->name);
    } else if (ci->flags & CI_VERBOTEN) {
        notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, ci->name);
    } else if (!is_founder(u, ci)) {
        notice_lang(s_ChanServ, u, ACCESS_DENIED);
    } else if (!is_on_chan(c, u)) {
        notice_lang(s_ChanServ, u, NICK_X_NOT_ON_CHAN, u->nick, c->name);
    } else {
        anope_cmd_mode(whosends(ci), c->name, "%s %s", ircd->ownerunset,
                       GET_USER(u));

        av[0] = sstrdup(ircd->ownerunset);
        av[1] = GET_USER(u);
        chan_set_modes(s_ChanServ, c, 2, av, 1);
        free(av[0]);
    }
    return MOD_CONT;
}
static ssize_t 
fpga_write (struct file* filep, const char* data, size_t count, loff_t* f_pos)
{
        struct fpga_sbihdr* sbihdr = filep->private_data;
        int                 bytes_left=count;
        int                 result;
        char                temp;

        /* Can't seek (pwrite) on fpga.  */
        if (*f_pos != filep->f_pos){
            return (-ESPIPE);
        }    


        /* Check access to the whole are in one go */
        if (!access_ok(VERIFY_READ,(const void*)data, count)){
            return (-EFAULT);
        }


        /*
         * We now lock against writes.
         */
        if (down_interruptible(&fpga_sem))
            return (-ERESTARTSYS);

        if (!sbihdr->fpos){
            result = place_fpga_into_configure_mode();
            if (result)
                return (result);
        }

        while (bytes_left){           
            GET_USER(temp, data);
            if (write_fpga_data_byte(sbihdr, temp)){
                MSG("pos=%d\n", sbihdr->fpos);
                return (-EILSEQ);
            }
            
            sbihdr->fpos++;
            data++;
            bytes_left--;
        }
        up(&fpga_sem);

        return (count);
}
Exemple #3
0
static int do_util(User * u, CSModeUtil * util)
{
    char *av[2];
    char *chan = strtok(NULL, " ");
    char *nick = strtok(NULL, " ");

    Channel *c;
    ChannelInfo *ci;
    User *u2;

    int is_same;

    if (!chan) {
        struct u_chanlist *uc;

        av[0] = util->mode;
        av[1] = u->nick;

        /* Sets the mode to the user on every channels he is on. */

        for (uc = u->chans; uc; uc = uc->next) {
            if ((ci = uc->chan->ci) && !(ci->flags & CI_VERBOTEN)
                && check_access(u, ci, util->levelself)) {
                anope_cmd_mode(whosends(ci), uc->chan->name, "%s %s",
                               util->mode, GET_USER(u));
                chan_set_modes(s_ChanServ, uc->chan, 2, av, 2);

                if (util->notice && ci->flags & util->notice)
                    notice(whosends(ci), uc->chan->name,
                           "%s command used for %s by %s", util->name,
                           u->nick, u->nick);
            }
        }

        return MOD_CONT;
    } else if (!nick) {
        nick = u->nick;
    }

    is_same = (nick == u->nick) ? 1 : (stricmp(nick, u->nick) == 0);

    if (!(c = findchan(chan))) {
        notice_lang(s_ChanServ, u, CHAN_X_NOT_IN_USE, chan);
    } else if (!(ci = c->ci)) {
        notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, c->name);
    } else if (ci->flags & CI_VERBOTEN) {
        notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, ci->name);
    } else if (is_same ? !(u2 = u) : !(u2 = finduser(nick))) {
        notice_lang(s_ChanServ, u, NICK_X_NOT_IN_USE, nick);
    } else if (is_same ? !check_access(u, ci, util->levelself) :
               !check_access(u, ci, util->level)) {
        notice_lang(s_ChanServ, u, ACCESS_DENIED);
    } else if (*util->mode == '-' && !is_same && (ci->flags & CI_PEACE)
               && (get_access(u2, ci) >= get_access(u, ci))) {
        notice_lang(s_ChanServ, u, PERMISSION_DENIED);
    } else if (*util->mode == '-' && is_protected(u2) && !is_same) {
        notice_lang(s_ChanServ, u, PERMISSION_DENIED);
    } else if (!is_on_chan(c, u2)) {
        notice_lang(s_ChanServ, u, NICK_X_NOT_ON_CHAN, u2->nick, c->name);
    } else {
        anope_cmd_mode(whosends(ci), c->name, "%s %s", util->mode,
                       GET_USER(u2));

        av[0] = util->mode;
        av[1] = GET_USER(u2);
        chan_set_modes(s_ChanServ, c, 2, av, 3);

        if (util->notice && ci->flags & util->notice)
            notice(whosends(ci), c->name, "%s command used for %s by %s",
                   util->name, u2->nick, u->nick);
    }
    return MOD_CONT;
}
Exemple #4
0
int m5249audio_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg)
{
	long	val;
	int	rc = 0;

#ifdef DEBUG
        printk("m5249audio_ioctl(cmd=%x,arg=%x)\n", (int) cmd, (int) arg);
#endif

	switch (cmd) {

	case SNDCTL_DSP_SPEED:
		rc = verify_area(VERIFY_READ, (void *) arg, sizeof(val));
		if (rc == 0) {
			GET_USER(val, (unsigned long *) arg);
			m5249audio_txdrain();
			m5249audio_speed = val;
			/* FIXME: adjust replay speed?? */
		}
		break;

	case SNDCTL_DSP_SAMPLESIZE:
		rc = verify_area(VERIFY_READ, (void *) arg, sizeof(val));
		if (rc == 0) {
			GET_USER(val, (unsigned long *) arg);
			m5249audio_txdrain();
			m5249audio_setsamplesize(val);
		}
		break;

	case SNDCTL_DSP_CHANNELS:
		rc = verify_area(VERIFY_READ, (void *) arg, sizeof(val));
		if (rc == 0) {
			GET_USER(val, (unsigned long *) arg);
			m5249audio_txdrain();
			m5249audio_stereo = ((val == 1) ? 0 : 1);
		}
		break;

	case SNDCTL_DSP_STEREO:
		rc = verify_area(VERIFY_READ, (void *) arg, sizeof(val));
		if (rc == 0) {
			GET_USER(val, (unsigned long *) arg);
			m5249audio_txdrain();
			m5249audio_stereo = val;
		}
		break;

	case SNDCTL_DSP_GETBLKSIZE:
		rc = verify_area(VERIFY_WRITE, (void *) arg, sizeof(long));
		if (rc == 0)
			PUT_USER(DMASIZE, (long *) arg);
		break;

	case SNDCTL_DSP_SYNC:
		m5249audio_txdrain();
		break;

	default:
		rc = -EINVAL;
		break;
	}

	return(rc);
}
Exemple #5
0
int do_sync(User *u, Channel *c) {
	struct c_userlist *cu, *next;
	/* Variables needed for building the cmd to remove voices.. */
	int count = 0, newac = 0;
	char modes[BUFSIZE], nicks[BUFSIZE], buf[BUFSIZE];
	char *end1, *end2;
	char **newav = scalloc(sizeof(char *) * 13, 1);
	end1 = modes;
	end2 = nicks;
	*end1 = 0;
	*end2 = 0;
	newav[newac] = c->name;
	newac++;

	if (!c->ci) {
		free(newav);
		return MOD_CONT;
	}

	if (ircdcap->tsmode) {
		snprintf(buf, BUFSIZE - 1, "%ld", (long int) time(NULL));
		newav[newac] = buf;
		newac++;
	}

	cu = c->users;
	while (cu) {
		/* We store the next user just in case current user ends up getting kicked off the channel. */
		next = cu->next;
		do_up_down(cu->user, c, "up", 0);

		/* We have to remove voices manually because the cores function doesn't care about that
		 * as it's not covered by secureops.. */
		if (chan_has_user_status(c, cu->user, CUS_VOICE) && !check_access(cu->user, c->ci, CA_AUTOVOICE)
				&& !check_access(cu->user, c->ci, CA_VOICEME) && !check_access(cu->user, c->ci, CA_VOICE)) {
			/* Add the user to the string to remove his voice.. */
			end1 += snprintf(end1, sizeof(modes) - (end1 - modes), "-v");
			end2 += snprintf(end2, sizeof(nicks) - (end2 - nicks), "%s ", GET_USER(cu->user));
			newav[newac+1] = GET_USER(cu->user);
			newac++;
			count++;

			/* Check whether the command hasn't grown too long yet.
			 * We don't allow more then 10 mode changes per command.. this should keep us safely below the 512 max length per cmd. */
			if (count == 10) {
				/* We've reached the maximum.. send the mode changes. */
				if (ircdcap->tsmode)
					newav[2] = modes;
				else
					newav[1] = modes;
				newac++;

				anope_cmd_mode(c->ci->bi->nick, c->name, "%s %s", modes, nicks);
				do_cmode(c->ci->bi->nick, newac, newav);

				/* Reset the buffer for the next set of changes.. */
				if (ircdcap->tsmode)
					newac = 2;
				else
					newac = 1;
				*end1 = 0;
				*end2 = 0;
				count = 0;
			}
		}

		cu = next;
	}

	/* If we still have some mode changes to send, do it now.. */
	if (count > 0) {
		if (ircdcap->tsmode)
			newav[2] = modes;
		else
			newav[1] = modes;
		newac++;

		anope_cmd_mode(c->ci->bi->nick, c->name, "%s %s", modes, nicks);
		do_cmode(c->ci->bi->nick, newac, newav);
	}

	noticeLang(c->ci->bi->nick, u, LANG_SYNC_DONE, c->name);

	free(newav);
	return MOD_CONT;
}