Exemplo n.º 1
0
/* search the DDC transfer a user wants to resume */
unsigned int t_find_resume(const char *nick, const char *filename, const char *localport, const char *bytes, char *token)
{
  char *sendnamestr;
  transfer *guess;
  transfer *tr;
  off_t len;

  guess = NULL;
  for (tr = irlist_get_head(&gdata.trans);
       tr;
       tr = irlist_get_next(tr)) {
    if ((tr->tr_status != TRANSFER_STATUS_LISTENING) && (tr->tr_status != TRANSFER_STATUS_RESUME))
      continue;
    if (strcasecmp(tr->caps_nick, nick))
      continue;

    /* the filename can be converted */
    if (guess == NULL)
      guess = tr;
    if (strcasestr(tr->xpack->file, filename))
      break;
    if (tr->con.localport == atoi(localport))
      break;
  }
  if (tr == NULL) {
    if (guess != NULL) {
      outerror(OUTERROR_TYPE_WARN,
               "Guessed transfer that %s on %s tried to resume!",
               nick, gnetwork->name);
      outerror(OUTERROR_TYPE_WARN,
               "resume trying %s, %s, %d",
               nick, filename, atoi(localport));
      tr = guess;
    } else {
      t_find_debug(nick, filename, localport);
      return 1;
    }
  }
  len = atoull(bytes);
  if (len >= tr->xpack->st_size) {
    notice(nick, "You can't resume the transfer at a point greater than the size of the file");
    ioutput(OUT_S|OUT_L|OUT_D, COLOR_YELLOW,
            "XDCC [%02i:%s on %s]: Resume attempted beyond end of file ( %" LLPRINTFMT "d >= %" LLPRINTFMT "d )",
            tr->id, tr->nick, gnetwork->name, len,
            tr->xpack->st_size);
    return 1;
  }
  t_setresume(tr, bytes);
  sendnamestr = getsendname(filename);
  if ((tr->tr_status == TRANSFER_STATUS_RESUME) && (token != NULL)) {
    privmsg_fast(nick, IRC_CTCP "DCC ACCEPT %s %s %s %s" IRC_CTCP, sendnamestr, localport, bytes, token); /* NOTRANSLATE */
  } else {
    privmsg_fast(nick, IRC_CTCP "DCC ACCEPT %s %s %s" IRC_CTCP, sendnamestr, localport, bytes); /* NOTRANSLATE */
  }
  mydelete(sendnamestr);
  ioutput(OUT_S|OUT_L|OUT_D, COLOR_YELLOW,
          "XDCC [%02i:%s on %s]: Resumed at %" LLPRINTFMT "dK", tr->id,
          tr->nick, gnetwork->name, tr->startresume/1024);
  return 0;
}
Exemplo n.º 2
0
bool AviLayer::init(Context *scr) {
  func("AviLayer::init");
  avi_dirty = paused = false;
  marker_in = marker_out = slow_frame = slow_frame_s = 0;
  play_speed = 1;
  _quality = 1;

  
  _ci = (CodecInfo *)CodecInfo::match(fccDIV3);
  //  CodecInfo::Get(_ci, avm::CodecInfo::Video, avm::CodecInfo::Decode, fcc);
  //  Creators::SetCodecAttr
  //    (*_ci, (const char*)"Quality", (const char*)_quality);
  func("biBitCount %i biClrUsed %i biClrImportant %i",
       bh.biBitCount,bh.biClrUsed,bh.biClrImportant);
  if(bh.biBitCount!=32) {
    act("Movie file decoding produces %ibit colorspace images",bh.biBitCount);
    act("assuming YUV420 planar colorspace format, using software conversion");
    yuvcc = true;
  }

  _init(scr,labs(bh.biWidth),labs(bh.biHeight),32); //bh.biBitCount);

  if(yuvcc) buffer = malloc(geo.size*2);

  /* fill up first frame */
  while(_stream->ReadFrame(true)<0)
    _stream->Seek(1);

  _img = _stream->GetFrame(false);

  notice("AviLayer :: w[%u] h[%u] bpp[%u] size[%u]",
	 geo.w,geo.h,geo.bpp,geo.size);
  
  return true;
}
Exemplo n.º 3
0
	CmdResult Handle(User* user, const Params& parameters) override
	{
		Channel* channel = ServerInstance->FindChan(parameters[0]);
		if (!channel)
		{
			user->WriteNumeric(Numerics::NoSuchChannel(parameters[0]));
			return CMD_FAILURE;
		}
		unsigned int cm = channel->GetPrefixValue(user);
		if (cm < HALFOP_VALUE)
		{
			user->WriteNumeric(ERR_CHANOPRIVSNEEDED, channel->name, "You do not have permission to set bans on this channel");
			return CMD_FAILURE;
		}

		TimedBan T;
		unsigned long duration;
		if (!InspIRCd::Duration(parameters[1], duration))
		{
			user->WriteNotice("Invalid ban time");
			return CMD_FAILURE;
		}
		unsigned long expire = duration + ServerInstance->Time();
		std::string mask = parameters[2];
		bool isextban = ((mask.size() > 2) && (mask[1] == ':'));
		if (!isextban && !InspIRCd::IsValidMask(mask))
			mask.append("!*@*");

		if (IsBanSet(channel, mask))
		{
			user->WriteNotice("Ban already set");
			return CMD_FAILURE;
		}

		Modes::ChangeList setban;
		setban.push_add(ServerInstance->Modes.FindMode('b', MODETYPE_CHANNEL), mask);
		// Pass the user (instead of ServerInstance->FakeClient) to ModeHandler::Process() to
		// make it so that the user sets the mode themselves
		ServerInstance->Modes.Process(user, channel, NULL, setban);
		if (ServerInstance->Modes.GetLastChangeList().empty())
		{
			user->WriteNotice("Invalid ban mask");
			return CMD_FAILURE;
		}

		T.mask = mask;
		T.expire = expire + (IS_REMOTE(user) ? 5 : 0);
		T.chan = channel;
		TimedBanList.push_back(T);

		const std::string addban = user->nick + " added a timed ban on " + mask + " lasting for " + InspIRCd::DurationString(duration) + ".";
		// If halfop is loaded, send notice to halfops and above, otherwise send to ops and above
		PrefixMode* mh = ServerInstance->Modes.FindPrefixMode('h');
		char pfxchar = (mh && mh->name == "halfop") ? mh->GetPrefix() : '@';

		ClientProtocol::Messages::Privmsg notice(ServerInstance->FakeClient, channel, addban, MSG_NOTICE);
		channel->Write(ServerInstance->GetRFCEvents().privmsg, notice, pfxchar);
		ServerInstance->PI->SendChannelNotice(channel, pfxchar, addban);
		return CMD_SUCCESS;
	}
Exemplo n.º 4
0
static void
g_help(struct Luser *lptr, int ac, char **av)

{
  if (ac >= 2)
    {
      char str[MAXLINE];
      struct Command *cptr;

      for (cptr = globalcmds; cptr->cmd; ++cptr)
        if (!irccmp(av[1], cptr->cmd))
          break;

      if (cptr->cmd)
        if ((cptr->level == LVL_ADMIN) &&
            !(IsValidAdmin(lptr)))
          {
            notice(n_MemoServ, lptr->nick,
                   "No help available on \002%s\002",
                   av[1]);
            return;
          }

      ircsprintf(str, "%s", av[1]);

      GiveHelp(n_Global, lptr->nick, str, NODCC);
    }
  else
    GiveHelp(n_Global, lptr->nick, NULL, NODCC);
} /* g_help() */
Exemplo n.º 5
0
int do_invite(User * u, Channel *c, char *nick) {
	ChannelInfo *ci = c->ci;

	if (!nick)
		noticeLang(ci->bi->nick, u, LANG_INVITE_SYNTAX);

	else {
		if (check_access(u, ci, CA_OPDEOP)	&& check_access(u, ci, CA_OPDEOPME)) {
			User *u2;

			if ((u2 = finduser(nick))) {
				if (stricmp(u2->nick, u->nick) != 0) {
					if (!is_on_chan(c, u2)) {
						anope_cmd_invite(ci->bi->nick, ci->name, u2->nick);
						notice(ci->bi->nick, ci->name, "%s was invited to the channel.", u2->nick);
					} else
						noticeLang(ci->bi->nick, u, LANG_INVITE_IS_ON);
				} else
					noticeLang(ci->bi->nick, u, LANG_INVITE_YOURSELF);
			} else
				noticeLang(ci->bi->nick, u, LANG_INVITE_NO_USER);
		} else
			notice_lang(ci->bi->nick, u, PERMISSION_DENIED);
	}

	return MOD_CONT;
}
Exemplo n.º 6
0
	void OnBackgroundTimer(time_t curtime) override
	{
		timedbans expired;
		for (timedbans::iterator i = TimedBanList.begin(); i != TimedBanList.end();)
		{
			if (curtime > i->expire)
			{
				expired.push_back(*i);
				i = TimedBanList.erase(i);
			}
			else
				++i;
		}

		for (timedbans::iterator i = expired.begin(); i != expired.end(); i++)
		{
			std::string mask = i->mask;
			Channel* cr = i->chan;
			{
				const std::string expiry = "*** Timed ban on " + cr->name + " expired.";
				// If halfop is loaded, send notice to halfops and above, otherwise send to ops and above
				PrefixMode* mh = ServerInstance->Modes.FindPrefixMode('h');
				char pfxchar = (mh && mh->name == "halfop") ? mh->GetPrefix() : '@';

				ClientProtocol::Messages::Privmsg notice(ClientProtocol::Messages::Privmsg::nocopy, ServerInstance->FakeClient, cr, expiry, MSG_NOTICE);
				cr->Write(ServerInstance->GetRFCEvents().privmsg, notice, pfxchar);
				ServerInstance->PI->SendChannelNotice(cr, pfxchar, expiry);

				Modes::ChangeList setban;
				setban.push_remove(ServerInstance->Modes.FindMode('b', MODETYPE_CHANNEL), mask);
				ServerInstance->Modes.Process(ServerInstance->FakeClient, cr, NULL, setban);
			}
		}
	}
Exemplo n.º 7
0
static int load_public_key(RSA **pkey)
{
	/* Load public key */
	BIO *in;
	struct stat st;

	if (stat(PUBLIC_KEY_FILE, &st) == -1 && errno == ENOENT) {
#ifdef CONFIG_USER_NETFLASH_CRYPTO_OPTIONAL
		notice("WARNING: can't open public key file %s",
			PUBLIC_KEY_FILE);
		return 0;
#else
		error("can't open public key file %s", PUBLIC_KEY_FILE);
		exit(BAD_PUB_KEY);
#endif
	}
	in = BIO_new(BIO_s_file());
	if (in == NULL) {
		error("cannot allocate a bio structure");
		exit(BAD_DECRYPT);
	}
	if (BIO_read_filename(in, PUBLIC_KEY_FILE) <= 0) {
		error("cannot open public key file");
		exit(BAD_PUB_KEY);
	}
	*pkey = PEM_read_bio_RSA_PUBKEY(in, NULL, NULL, NULL);
	if (*pkey == NULL) {
		error("cannot read public key");
		exit(BAD_PUB_KEY);
	}
	return 1;
}
Exemplo n.º 8
0
/*
 * es_help()
 *
 *  Give lptr help on command av[1]
 */
static void es_help(struct Luser *lptr, int ac, char **av)
{
    if (ac >= 2)
    {
        char str[MAXLINE];
        struct Command *sptr;

        for (sptr = seencmds; sptr->cmd; sptr++)
            if (!irccmp(av[1], sptr->cmd))
                break;

        if (sptr->cmd)
            if ((sptr->level == LVL_ADMIN) &&
                    !(IsValidAdmin(lptr)))
            {
                notice(n_SeenServ, lptr->nick,
                       "No help available on \002%s\002",
                       av[1]);
                return ;
            }

        ircsprintf(str, "%s", av[1]);

        GiveHelp(n_SeenServ, lptr->nick, str, NODCC);
    }
    else
        GiveHelp(n_SeenServ, lptr->nick, NULL, NODCC);
} /* es_help() */
Exemplo n.º 9
0
void VideoLayer::pause() {
  if(paused)
    paused=false;
  else
    paused=true;
  notice("pause : %s",(paused)?"on":"off");
}
Exemplo n.º 10
0
void check_crypto_v2(const struct check_opt *opt)
{
	if (opt->dochecksum)
		chksum();
	if (opt->doversion || opt->dohardwareversion || opt->doremoveversion)
		check_version_info(0, opt->doversion, opt->dohardwareversion,
				opt->doremoveversion, 1);
	/*
	 * Modern signed image support is backward compatible, so we don't
	 * do the crypto check until this point. (That is we have stripped
	 * of old style 16bit checksum and the product/version information).
	 * We also leave the sign structures on the image data, so they get
	 * written to flash as well. However, if it is a gzipped image, we
	 * will need to trim off the signature before we decompress.
	 */
	if (opt->dochecksum) {
		int cryptorc = check_crypto_signature();
		/*
		 * If there is SHA256 or crypto info, there should also be an extra
		 * copy of the version info just before it. (ie. a signed/checksummed
		 * copy.) If we care about version info (and there's a crypto header
		 * present), check this stuff too.
		 */
		if ((opt->doversion || opt->dohardwareversion) && cryptorc == CRYPTO_CHECK_OK) {
			int rc = check_version_info(fb_meta_len(), opt->doversion, opt->dohardwareversion, 0, 0);
			if (rc == 5)
				notice("Warning: no signed version information present in image.");
		}
	}
}
Exemplo n.º 11
0
static void ctcp_version_handler(sourceinfo_t *si, char *cmd, char *args)
{
	char ver[BUFSIZE];

	get_version_string(ver, sizeof(ver));
	notice(si->service->nick, si->su->nick, "\001VERSION %s\001", ver);
}
Exemplo n.º 12
0
void PlaybackLoader<PlaybackTabImp>::OnComplete()
{
	if ( m_parent == NULL ) return;
	wxCommandEvent notice( PlaybacksLoadedEvt, 1 );
	((wxEvtHandler*)m_parent)->ProcessEvent( notice );
	m_thread_loader = 0; // the thread object deleted itself
}
Exemplo n.º 13
0
Arquivo: lbcd.c Projeto: rra/lbcd
/*
 * Handle an incoming request.  Most of the work is done by lbcd_pack_info,
 * but this handles creating the header and sending the reply packet.
 */
static void
handle_lb_request(struct lbcd_config *config, struct request *request,
                  socket_type fd)
{
    struct lbcd_reply reply;
    size_t size, unused;
    ssize_t result;

    /* Log the request. */
    if (config->log)
        notice("request from %s (version %d)", request->source,
               request->protocol);

    /* Fill in reply header. */
    reply.h.version = htons(request->protocol);
    reply.h.id      = htons(request->id);
    reply.h.op      = htons(request->operation);
    reply.h.status  = htons(LBCD_STATUS_OK);

    /* Fill in reply. */
    lbcd_pack_info(&reply, request->protocol, request->services,
                   config->simple);

    /* Compute reply size (maximum packet minus unused service slots). */
    unused = LBCD_MAX_SERVICES - request->services->count;
    size = sizeof(reply) - unused * sizeof(struct lbcd_service);

    /* Send reply */
    result = sendto(fd, &reply, size, 0, request->addr, request->addrlen);
    if (result < 0 || (size_t) result != size)
        syswarn("client %s: cannot send reply", request->source);
}
Exemplo n.º 14
0
void ClusterAdapter::becomeSlave()
{
	notice("Become slave.");

//	state_ = State::Running;
//	schedulerRole_ = SchedulerRole::Slave;
}
Exemplo n.º 15
0
void mp_bundle_terminated()
{
	TDB_DATA key;

	bundle_terminating = 1;
	upper_layers_down(0);
	notice("Connection terminated.");
	print_link_stats();
	if (!demand) {
		remove_pidfiles();
		script_unsetenv("IFNAME");
	}

	lock_db();
	destroy_bundle();
	iterate_bundle_links(sendhup);
	key.dptr = blinks_id;
	key.dsize = strlen(blinks_id);
	tdb_delete(pppdb, key);
	unlock_db();

	new_phase(PHASE_DEAD);

	doing_multilink = 0;
	multilink_master = 0;
}
Exemplo n.º 16
0
/*
 * kern_return_t
 * bootstrap_parent(mach_port_t bootstrap_port,
 *		    mach_port_t *parent_port);
 *
 * Given a bootstrap subset port, return the parent bootstrap port.
 * If the specified bootstrap port is already the root subset,
 * MACH_PORT_NULL will be returned.
 *
 * Errors:
 *	Returns BOOTSTRAP_NOT_PRIVILEGED if the caller is not running
 *	with an effective user id of root (as determined by the security
 *	token in the message trailer).
 */
kern_return_t
x_bootstrap_parent(
	mach_port_t bootstrap_port,
	security_token_t sectoken,
	mach_port_t *parent_port)
{
	bootstrap_info_t *bootstrap;

	debug("Parent attempt for bootstrap %x", bootstrap_port);

	bootstrap = lookup_bootstrap_by_port(bootstrap_port);
	if (!bootstrap) { 
		debug("Parent attempt for bootstrap %x: invalid bootstrap",
		      bootstrap_port);
		return BOOTSTRAP_NOT_PRIVILEGED;
	}
	if (sectoken.val[0]) {
		notice("Bootstrap parent for bootstrap %x: invalid security token (%d)",
		       bootstrap_port, sectoken.val[0]);
		return BOOTSTRAP_NOT_PRIVILEGED;
	}
	debug("Returning bootstrap parent %x for bootstrap %x",
	      bootstrap->parent->bootstrap_port, bootstrap_port);
	*parent_port = bootstrap->parent->bootstrap_port;
	return BOOTSTRAP_SUCCESS;
}
Exemplo n.º 17
0
void JsParser::init() {
  //JSBool ret;
  stop_script=false;

  notice("Initializing %s", JS_GetImplementationVersion());

  // create a global execution context (used to evaluate commands on the fly
  // and for other internal operations
  global_runtime = new JsExecutionContext(this);

  /* Create a new runtime environment. */
  js_runtime = global_runtime->rt; // XXX - for retrocompatibilty
    if (!js_runtime) {
    return ; /* XXX should return int or ptr! */
  }

  /* Create a new context. */
  global_context = global_runtime->cx; // XXX - for retrocompatibilty

  /* if global_context does not have a value, end the program here */
    if (global_context == NULL) {
    return ;
  }

  global_object = global_runtime->obj;
  /** register SIGINT signal */
  //   signal(SIGINT, js_sigint_handler);
}
Exemplo n.º 18
0
void ClusterAdapter::becomeMaster()
{
	notice("Become master.");

//	state_ = State::Running;
//	schedulerRole_ = SchedulerRole::Master;
}
Exemplo n.º 19
0
Arquivo: mem.c Projeto: matrach/PRoot
/**
 * Allocate @size bytes in the @tracee's memory space.  This function
 * returns the address of the allocated memory in the @tracee's memory
 * space, otherwise 0 if an error occured.
 */
word_t alloc_mem(Tracee *tracee, ssize_t size)
{
	word_t stack_pointer;

	/* Get the current value of the stack pointer from the tracee's
	 * USER area. */
	stack_pointer = peek_reg(tracee, CURRENT, STACK_POINTER);

	/* Some ABIs specify an amount of bytes after the stack
	 * pointer that shall not be used by anything but the compiler
	 * (for optimization purpose).  */
	if (stack_pointer == peek_reg(tracee, ORIGINAL, STACK_POINTER))
		size += RED_ZONE_SIZE;

	/* Sanity check. */
	if (   (size > 0 && stack_pointer <= size)
	    || (size < 0 && stack_pointer >= ULONG_MAX + size)) {
		notice(tracee, WARNING, INTERNAL, "integer under/overflow detected in %s",
			__FUNCTION__);
		return 0;
	}

	/* Remember the stack grows downward. */
	stack_pointer -= size;

	/* Set the new value of the stack pointer in the tracee's USER
	 * area. */
	poke_reg(tracee, STACK_POINTER, stack_pointer);
	return stack_pointer;
}
Exemplo n.º 20
0
static void error_upload_start(const char *nick, const char *hostmask, const char *key, const char *msg)
{
  notice(nick, "DCC Send Denied, %s", msg);
  ioutput(OUT_S|OUT_L|OUT_D, COLOR_MAGENTA,
          "DCC Send Denied (%s) from %s on %s",
          key, hostmask, gnetwork->name);
}
Exemplo n.º 21
0
static int my_cs_help_appendtopic(User * u)
{
    moduleNoticeLang(s_ChanServ, u, LNG_APPENDTOPIC_SYNTAX);
    notice(s_ChanServ, u->nick, " ");
    moduleNoticeLang(s_ChanServ, u, LNG_CHAN_HELP_APPENDTOPIC);
    return MOD_STOP;
}
Exemplo n.º 22
0
static int msg_authstart(char *nick, char *host, struct userrec *u, char *par)
{
  if (!u)
    return 0;
  if (match_my_nick(nick))
    return BIND_RET_BREAK;
  if (u && u->bot)
    return BIND_RET_BREAK;

  if (!ischanhub()) {
    putlog(LOG_WARN, "*", STR("(%s!%s) !%s! Attempted AUTH? (I'm not a chathub (+c))"), nick, host, u->handle);
    return BIND_RET_BREAK;
  }

  putlog(LOG_CMDS, "*", STR("(%s!%s) !%s! AUTH?"), nick, host, u->handle);

  Auth *auth = Auth::Find(host);

  if (auth) {
    if (auth->Authed()) {
      notice(nick, "You are already authed.", DP_HELP);
      return 0;
    }
  } else
    auth = new Auth(nick, host, u);

  /* Send "auth." if they are recognized, otherwise "auth!" */
  auth->Status(AUTH_PASS);
  bd::String msg;
  msg = bd::String::printf(STR("auth%s %s"), u ? "." : "!", conf.bot->nick);
  privmsg(nick, msg.c_str(), DP_HELP);

  return BIND_RET_BREAK;
}
Exemplo n.º 23
0
static int msg_pls_auth(char *nick, char *host, struct userrec *u, char *par)
{
  if (strlen(auth_key) && get_user(&USERENTRY_SECPASS, u)) {
    if (match_my_nick(nick))
      return BIND_RET_BREAK;
    if (u && u->bot)
      return BIND_RET_BREAK;

    Auth *auth = Auth::Find(host);

    if (!auth || auth->Status() != AUTH_HASH)
      return BIND_RET_BREAK;

    if (!strcmp(auth->hash, par)) { /* good hash! */
      AuthFinish(auth);
    } else { /* bad hash! */
      char s[300] = "";

      putlog(LOG_CMDS, "*", STR("(%s!%s) !%s! failed +AUTH"), nick, host, u->handle);
      notice(nick, STR("Invalid hash."), DP_HELP);
      simple_snprintf(s, sizeof(s), "*!%s", host);
      addignore(s, origbotname, STR("Invalid auth hash."), now + (60 * ignore_time));
      delete auth;
    } 
    return BIND_RET_BREAK;
  }
  return BIND_RET_LOG;
}
Exemplo n.º 24
0
void MagRead::captureStart() {
	magDec = new MagDecode( this );
	connect( magDec, SIGNAL( cardRead( MagCard ) ), this, SLOT( cardRead( MagCard ) ) );
	connect( magDec, SIGNAL( errorMsg( QString ) ), this, SLOT( notice( QString ) ) );

	magDec->setThreshold( settings->value( "silenceThreshold" ).toInt() );
	magDec->setTimeOut( settings->value( "timeOut" ).toInt() );

	if( settings->value( "normAuto" ) == false )
		magDec->setNorm( settings->value( "norm" ).toInt() );
	
	magDec->setAlgorithm( settings->value( "algorithm" ).toString() );

	audioInput = 0;

	QList<QAudioDeviceInfo> inputDevices = QAudioDeviceInfo::availableDevices( QAudio::AudioInput );
	for( int i = 0; i < inputDevices.size(); i++ ) {
		if( inputDevices.at( i ).deviceName() == settings->value( "audioDevice" ) ) {
			audioInput = new QAudioInput( inputDevices.at( i ), audioFormat, this );
		}
	}

	if( audioInput == 0 )
		audioInput = new QAudioInput( audioFormat, this );


	magDec->start();
	audioInput->start( magDec );
}
Exemplo n.º 25
0
void
log_message(const char *fmt, ...)
{
	static struct varbuf log;
	static FILE *logfd = NULL;
	char time_str[20];
	time_t now;
	va_list args;

	if (!log_file)
		return;

	if (!logfd) {
		logfd = fopen(log_file, "a");
		if (!logfd) {
			notice(_("could not open log '%s': %s"),
			       log_file, strerror(errno));
			log_file = NULL;
			return;
		}
		setlinebuf(logfd);
		setcloexec(fileno(logfd), log_file);
	}

	va_start(args, fmt);
	varbuf_reset(&log);
	varbuf_vprintf(&log, fmt, args);
	va_end(args);

	time(&now);
	strftime(time_str, sizeof(time_str), "%Y-%m-%d %H:%M:%S",
	         localtime(&now));
	fprintf(logfd, "%s %s\n", time_str, log.buf);
}
Exemplo n.º 26
0
static void
info_spew(const char *debar, const char *dir, const char *const *argv)
{
  struct dpkg_error err;
  const char *component;
  struct varbuf controlfile = VARBUF_INIT;
  int fd;
  int re= 0;

  while ((component = *argv++) != NULL) {
    varbuf_reset(&controlfile);
    varbuf_printf(&controlfile, "%s/%s", dir, component);

    fd = open(controlfile.buf, O_RDONLY);
    if (fd >= 0) {
      if (fd_fd_copy(fd, 1, -1, &err) < 0)
        ohshit(_("cannot extract control file '%s' from '%s': %s"),
               controlfile.buf, debar, err.str);
      close(fd);
    } else if (errno == ENOENT) {
      notice(_("'%.255s' contains no control component '%.255s'"),
             debar, component);
      re++;
    } else {
      ohshite(_("open component `%.255s' (in %.255s) failed in an unexpected way"),
              component, dir);
    }
  }
  varbuf_destroy(&controlfile);

  if (re > 0)
    ohshit(P_("%d requested control component is missing",
              "%d requested control components are missing", re), re);
}
Exemplo n.º 27
0
int console_generator_selection(ContextPtr env, char *cmd) {
    GeneratorLayerPtr tmp = MakeShared<GeneratorLayer>();
    if(!tmp) return 0;

    ViewPortPtr screen = getSelectedScreen();
    if(!screen) {
        ::error("no screen currently selected");
        return 0;
    }
    const Geometry &geo = screen->getGeometry();
    if(!tmp->init(geo.getSize().x(), geo.getSize().y(), geo.getBpp())) {
        error("can't initialize generator layer");
        return 0;
    }
    // this is something specific to the generator layer
    // it needs this from the environment..
    tmp->register_generators(&env->getGenerators());

    if(!tmp->open(cmd)) {
        error("generator %s is not found", cmd);
        return 0;
    }

    screen->add_layer(tmp);

    notice("generator %s successfully created", tmp->getName().c_str());
    return 1;
}
Exemplo n.º 28
0
static void cs_fcmd_topic(char *origin, char *chan)
{
        char *topic = strtok(NULL, "");
        mychan_t *mc;
        channel_t *c;
        user_t *u;

        if (!topic)
        {
		notice(chansvs.nick, origin, STR_INSUFFICIENT_PARAMS, "!TOPIC");
		notice(chansvs.nick, origin, "Syntax: !TOPIC <topic>");
                return;
        }

        c = channel_find(chan);
        if (!c)
        {
		/* should not happen */
                return;
        }

        mc = mychan_find(chan);
        if (!mc)
        {
		/* also should not happen */
		notice(chansvs.nick, origin, "\2%s\2 is not registered.", chan);
                return;
        }

        u = user_find_named(origin);

        if (!chanacs_user_has_flag(mc, u, CA_TOPIC))
        {
                notice(chansvs.nick, origin, "You are not authorized to perform this operation.");
                return;
        }
        
        if (metadata_find(mc, METADATA_CHANNEL, "private:close:closer"))
	{
		notice(chansvs.nick, origin, "\2%s\2 is closed.", chan);
		return;
	}

	handle_topic(c, origin, CURRTIME, topic);
        topic_sts(chan, origin, CURRTIME, topic);
	logcommand(chansvs.me, u, CMDLOG_SET, "%s TOPIC", mc->name);
}
int nk_killOldClientConn(char *name)
{
	char cmdbuf[128];
	int  k=0, retval=0;
	u_char decode_name[50];

	for(k=0;ClientConn[k].SaveData == 1;k++)
	{
		nk_str_to_ascii(ClientConn[k].username, &decode_name);
		if(!strcmp(decode_name, name))
		{
			notice("ClientConn name [%s] and user name [%s] match", ClientConn[k].username, ClientConn[k].username);
			notice("this user [%s] Max Connection [%d] ", ClientConn[k].username, ClientStatus[UserIdx].MaxConn);
			
			/* MaxConn > 1 , kill the same MAC of connection */
			if(ClientStatus[UserIdx].MaxConn > 1)
			{
				if(strcmp(ClientConn[k].eth, remote_number))
					continue;
			}
			
			notice("this user [%s] mac[%s] ifname [%s] pid[%d]", ClientConn[k].username, ClientConn[k].eth, ClientConn[k].ifname, ClientConn[k].pid);
			
			/* Check the record is valid*/
			sprintf(cmdbuf,"/var/run/%s.pid",ClientConn[k].ifname);
			if(access(cmdbuf,F_OK) == 0)
			{
				/* valid , kill daemon */
				kill(ClientConn[k].pid, SIGTERM);
				retval = 1;
				goto freelink;
			}
			else
			{
				/* not valid, remove record */
				sprintf(cmdbuf, "echo \"%s\" > %s ", ClientConn[k].eth, NKPPPOE_FIFO1_IPC);
				system(cmdbuf);
				retval = 1;
				goto freelink;
			}
		}
	}
	retval = 0;

freelink:
    return retval;
}
Exemplo n.º 30
0
int console_filter_completion(ContextPtr env, char *cmd) {
    if(!cmd) return 0;

    // Find completions
    FilterPtr exactFilter;
    LinkList<Filter> retList;
    LinkList<Filter> &list = env->getFilters();
    std::string cmdString(cmd);
    std::transform(cmdString.begin(), cmdString.end(), cmdString.begin(), ::tolower);
    std::copy_if(list.begin(), list.end(), retList.begin(), [&] (FilterPtr filter) {
                     std::string name = filter->getName();
                     std::transform(name.begin(), name.end(), name.begin(), ::tolower);
                     if(name == cmdString) {
                         exactFilter = filter;
                     }
                     return name.compare(cmdString) == 0;
                 });

    if(retList.empty()) return 0;

    if(exactFilter != NULL) {
        ::notice("%s :: %s", exactFilter->getName().c_str(), exactFilter->getDescription().c_str());
        snprintf(cmd, MAX_CMDLINE, "%s", exactFilter->getName().c_str());
        return 1;
    }

    if(cmdString.empty()) {
        notice("List available filters");
    } else {
        notice("List available filters with \"%s\"", cmd);
    }

    int c = 0;
    char tmp[256];
    std::for_each(retList.begin(), retList.end(), [&] (FilterPtr f) {
                      if(c % 4 == 0) {
                          if(c != 0) {
                              ::act("%s", tmp);
                          }
                          tmp[0] = '\0';
                      }
                      strncat(tmp, "\t", sizeof(tmp) - 1);
                      strncat(tmp, f->getName().c_str(), sizeof(tmp) - 1);
                      ++c;
                  });
    return c;
}