コード例 #1
0
/**
 * Scheduling Checks
 *
 * @param icem    ICE Media object
 */
void icem_conncheck_schedule_check(struct icem *icem)
{
	struct ice_candpair *cp;

	/* Find the highest priority pair in that check list that is in the
	   Waiting state. */
	cp = icem_candpair_find_st(&icem->checkl, 0, ICE_CANDPAIR_WAITING);
	if (cp) {
		do_check(cp);
		return;
	}

	/* If there is no such pair: */

	/* Find the highest priority pair in that check list that is in
	   the Frozen state. */
	cp = icem_candpair_find_st(&icem->checkl, 0, ICE_CANDPAIR_FROZEN);
	if (cp) { /* If there is such a pair: */

		/* Unfreeze the pair.
		   Perform a check for that pair, causing its state to
		   transition to In-Progress. */
		do_check(cp);
		return;
	}

	/* If there is no such pair: */

	/* Terminate the timer for that check list. */

#if 0
	icem->state = ICE_CHECKLIST_COMPLETED;
#endif
}
コード例 #2
0
ファイル: bbslogin.c プロジェクト: lytsing/ytht
static char *
check_multi(char *id, int uid)
{
	int i, uent;
	int h;
	if (uid <= 0 || uid > MAXUSERS)
		return NULL;
	if (strcasecmp(id, "guest")) {
		//这种算法, wwwlogin必须限制登录窗口数目, 否则
		//上线名单会被轻易冲爆
		for (i = 0; i < 6; i++) {
			uent = uindexshm->user[uid - 1][i] - 1;
			if (uent < 0)
				continue;
			if (do_check(uent, uid))
				return makeurlbase(uent, uid);
		}
		return NULL;
	} else {
		h = utmp_iphash(realfromhost);
		uent = shm_utmp->guesthash_head[h];
		while (uent != 0) {
			if (do_check(uent - 1, uid))
				return makeurlbase(uent - 1, uid);
			uent = shm_utmp->guesthash_next[uent];
		}
	}
	return NULL;
}
コード例 #3
0
int test_main(int, char*[])
{
    do_check(0);
    do_check(0.0);
    do_check(1);
    do_check(1.5);
    do_check(0.5);
    return 0;
}
コード例 #4
0
short process_cmd(void) {
    char cmd[4];
    short ret = 0;

    RECV(STDIN, cmd, sizeof(cmd));

    if (0 == memcmp((void *)CMD_BUY, cmd, sizeof(CMD_BUY))) {
    	ret = do_buy();
    } else if (0 == memcmp((void *)CMD_CHECK, cmd, sizeof(CMD_CHECK))) {
    	ret = do_check();
    } else if (0 == memcmp((void *)CMD_ADD, cmd, sizeof(CMD_ADD))) {
    	ret = do_add();
    } else if (0 == memcmp((void *)CMD_RM, cmd, sizeof(CMD_RM))) {
    	ret = do_rm();
    } else if (0 == memcmp((void *)CMD_UPDATE, cmd, sizeof(CMD_UPDATE))) {
    	ret = do_update();
    } else if (0 == memcmp((void *)CMD_ONSALE, cmd, sizeof(CMD_ONSALE))) {
    	ret = do_onsale();
    } else if (0 == memcmp((void *)CMD_NOSALE, cmd, sizeof(CMD_NOSALE))) {
    	ret = do_nosale();
    } else if (0 == memcmp((void *)CMD_LIST, cmd, sizeof(CMD_LIST))) {
    	ret = do_list();
    } else if (0 == memcmp((void *)CMD_QUIT, cmd, sizeof(CMD_QUIT))) {
    	ret = -2;
    } else {
    	ret = -1;
    }

	return ret;
}
コード例 #5
0
ファイル: connection.cpp プロジェクト: Wang-OuYang/xxsocket
void connection::do_read_content(void)
{
    auto self(shared_from_this());
    // bytes_transferred never grater than sizeof(buffer_)
    socket_.async_read_some(boost::asio::buffer(buffer_),strand_.wrap(
        [this, self](boost::system::error_code ec, std::size_t bytes_transferred)
    {
        // LOG_TRACE_ALL("read data, thread id:%u", this_thread() );
        if (!ec)
        {
            timestamp_ = time(NULL);

            total_bytes_received_ += bytes_transferred;

            // check http package size
            if(total_bytes_received_ > max_http_package_size) {
                reply_ = reply::stock_reply(reply::bad_request);
                do_write();

                LOG_TRACE("too long http request from client: %s:u", this->get_address(), port_);
                return;
            }

            this->request_.content.append(buffer_.data(), bytes_transferred);

            do_check();
        }
        else
        {
            LOG_TRACE("peer interrupt ahead of time, detail:%s", ec.message().c_str());
            
            connection_manager_.stop(shared_from_this());
        }
    }) );
}
コード例 #6
0
void HealthChecker::main_thread_function()
{
  struct timespec end_wait;
  struct timespec now;
  clock_gettime(CLOCK_MONOTONIC, &now);
  end_wait.tv_sec = now.tv_sec + 60;
  end_wait.tv_nsec = now.tv_nsec;
  pthread_mutex_lock(&_condvar_lock);
  while (true)
  {
    pthread_cond_timedwait(&_condvar, &_condvar_lock, &end_wait);

    // If we wake up and find the terminate flag is set, don't run a
    // check and break out of the infinite loop
    if (_terminate)
    {
      break;
    }
    
    clock_gettime(CLOCK_MONOTONIC, &now);

    // If pthread_cond_timedwait waited for the correct amount of
    // time, run a check and advance the end time.
    if ((now.tv_sec > end_wait.tv_sec) || ((now.tv_sec == end_wait.tv_sec) && (now.tv_nsec >= end_wait.tv_nsec)))
    {
      do_check();
      end_wait.tv_sec += 60;
    }
  }
  pthread_mutex_unlock(&_condvar_lock);
}
コード例 #7
0
ファイル: abrt-polkit.c プロジェクト: xsulca00/abrt
PolkitResult polkit_check_authorization_dname(const char *dbus_name, const char *action_id)
{
    glib_init();

    PolkitSubject *subject = polkit_system_bus_name_new(dbus_name);
    return do_check(subject, action_id);
}
コード例 #8
0
ファイル: gconf-defaults.c プロジェクト: BARGAN/gconf
void
gconf_defaults_can_set_system (GConfDefaults          *mechanism,
			       const char            **includes,
			       DBusGMethodInvocation  *context)
{
	do_check (mechanism, FALSE, includes, context);
}
コード例 #9
0
ファイル: test20.c プロジェクト: AgamAgarwal/minix
int main(int argc, char *argv[])
{
  int i;

  sync();
  /* If we have to check things, call do_check(). */
  if (strcmp(argv[0], "DO CHECK") == 0) exit(do_check());

  /* Get the path of the executable. */
  strcpy(executable, "../");
  strcat(executable, argv[0]);

  start(20);
  superuser = (geteuid() == 0);

  for (i = 0; i < ITERATIONS; i++) {
	test20a();
	test20b();
	test20c();
	test20d();
  }
  quit();

  return(-1);	/* Unreachable */
}
コード例 #10
0
ファイル: gconf-defaults.c プロジェクト: BARGAN/gconf
void
gconf_defaults_can_set_mandatory (GConfDefaults          *mechanism,
			          const char            **includes,
			          DBusGMethodInvocation  *context)
{
	do_check (mechanism, TRUE, includes, context);
}
コード例 #11
0
void do_check(int i)
{
    std::cout << "Checking type char with value " << i << std::endl;
    check_val(static_cast<char>(i));
    std::cout << "Checking type unsigned char with value " << i << std::endl;
    check_val(static_cast<unsigned char>(i));
    std::cout << "Checking type signed char with value " << i << std::endl;
    check_val(static_cast<signed char>(i));
    std::cout << "Checking type short with value " << i << std::endl;
    check_val(static_cast<short>(i));
    std::cout << "Checking type unsigned short with value " << i << std::endl;
    check_val(static_cast<unsigned short>(i));
    std::cout << "Checking type int with value " << i << std::endl;
    check_val(static_cast<int>(i));
    std::cout << "Checking type unsigned int with value " << i << std::endl;
    check_val(static_cast<unsigned int>(i));
    std::cout << "Checking type long with value " << i << std::endl;
    check_val(static_cast<long>(i));
    std::cout << "Checking type unsigned long with value " << i << std::endl;
    check_val(static_cast<unsigned long>(i));
#ifdef BOOST_HAS_LONG_LONG
    std::cout << "Checking type long long with value " << i << std::endl;
    check_val(static_cast<long long>(i));
    std::cout << "Checking type unsigned long long with value " << i << std::endl;
    check_val(static_cast<unsigned long long>(i));
#elif defined(BOOST_HAS_MS_INT64)
    std::cout << "Checking type __int64 with value " << i << std::endl;
    check_val(static_cast<__int64>(i));
    std::cout << "Checking type unsigned __int64 with value " << i << std::endl;
    check_val(static_cast<unsigned __int64>(i));
#endif
    do_check(static_cast<double>(i));
}
コード例 #12
0
ファイル: trigcmd.c プロジェクト: cornytrace/DPKG-for-Android
int
main(int argc, const char *const *argv)
{
	int uf;
	const char *badname;
	enum trigdef_updateflags tduf;

	setlocale(LC_ALL, "");
	bindtextdomain(PACKAGE, LOCALEDIR);
	textdomain(PACKAGE);

	dpkg_set_progname("dpkg-trigger");
	standard_startup();
	myopt(&argv, cmdinfos, printforhelp);

	admindir = dpkg_db_set_dir(admindir);

	setvbuf(stdout, NULL, _IONBF, 0);

	if (f_check) {
		if (*argv)
			badusage(_("--%s takes no arguments"),
			         "check-supported");
		do_check();
	}

	if (!*argv || argv[1])
		badusage(_("takes one argument, the trigger name"));

	badname = parse_awaiter_package();
	if (badname)
		ohshit(_("illegal awaited package name '%.250s': %.250s"),
		       bypackage, badname);

	activate = argv[0];
	badname = trig_name_is_illegal(activate);
	if (badname)
		badusage(_("invalid trigger name `%.250s': %.250s"),
		         activate, badname);

	trigdef_set_methods(&tdm_add);

	tduf = tduf_nolockok;
	if (!f_noact)
		tduf |= tduf_write | tduf_writeifempty;
	uf = trigdef_update_start(tduf);
	if (uf >= 0) {
		trigdef_parse();
		if (!done_trig)
			trigdef_update_printf("%s %s\n", activate, bypackage);
		trigdef_process_done();
	}

	standard_shutdown();

	return 0;
}
コード例 #13
0
ファイル: cxx3.C プロジェクト: jkkm/prelink
int
main ()
{
  A x;
  if (x.a () != 1)
    abort ();
  do_check (check, &x);
  return 0;
}
コード例 #14
0
ファイル: abrt-polkit.c プロジェクト: xsulca00/abrt
PolkitResult polkit_check_authorization_pid(pid_t pid, const char *action_id)
{
    glib_init();

    PolkitSubject *subject = polkit_unix_process_new_for_owner(pid,
            /*use start_time from /proc*/0,
            /*use uid from /proc*/ -1);

    return do_check(subject, action_id);
}
コード例 #15
0
ファイル: relnot.c プロジェクト: dylex/pidgin
/**************************************************************************
 * Plugin stuff
 **************************************************************************/
static gboolean
plugin_load(PurplePlugin *plugin)
{
	purple_signal_connect(purple_connections_get_handle(), "signed-on",
						plugin, PURPLE_CALLBACK(signed_on_cb), NULL);

	/* we don't check if we're offline */
	if(purple_connections_get_all())
		do_check();

	return TRUE;
}
コード例 #16
0
ファイル: trigcmd.c プロジェクト: guillemj/dpkg
int
main(int argc, const char *const *argv)
{
	const char *badname;
	enum trigdef_update_flags tduf;
	enum trigdef_update_status tdus;

	dpkg_locales_init(PACKAGE);
	dpkg_program_init("dpkg-trigger");
	dpkg_options_parse(&argv, cmdinfos, printforhelp);

	admindir = dpkg_db_set_dir(admindir);

	if (f_check) {
		if (*argv)
			badusage(_("--%s takes no arguments"),
			         "check-supported");
		return do_check();
	}

	if (!*argv || argv[1])
		badusage(_("takes one argument, the trigger name"));

	badname = parse_awaiter_package();
	if (badname)
		badusage(_("illegal awaited package name '%.250s': %.250s"),
		         bypackage, badname);

	fsys_hash_init();

	activate = argv[0];
	badname = trig_name_is_illegal(activate);
	if (badname)
		badusage(_("invalid trigger name '%.250s': %.250s"),
		         activate, badname);

	trigdef_set_methods(&tdm_add);

	tduf = TDUF_NO_LOCK_OK;
	if (!f_noact)
		tduf |= TDUF_WRITE | TDUF_WRITE_IF_EMPTY;
	tdus = trigdef_update_start(tduf);
	if (tdus >= 0) {
		trigdef_parse();
		if (!done_trig)
			trigdef_update_printf("%s %s\n", activate, bypackage);
		trigdef_process_done();
	}

	dpkg_program_done();

	return 0;
}
コード例 #17
0
/**************************************************************************
 * Plugin stuff
 **************************************************************************/
static gboolean
plugin_load(GaimPlugin *plugin)
{
	gaim_signal_connect(gaim_connections_get_handle(), "signed-on",
						plugin, GAIM_CALLBACK(signed_on_cb), NULL);

	/* we don't check if we're offline */
	if(gaim_connections_get_all())
		do_check();

	return TRUE;
}
コード例 #18
0
ファイル: tst-utmp.c プロジェクト: jameshilliard/WECB-BH-GPL
static int
do_test (int argc, char *argv[])
{
  int result = 0;

  utmpname (name);

  result |= do_init ();
  result |= do_check ();

  result |= simulate_login ("tty1", "erwin");
  result |= do_check ();

  result |= simulate_login ("ttyp1", "paul");
  result |= do_check ();

  result |= simulate_logout ("tty2");
  result |= do_check ();

  result |= simulate_logout ("ttyp0");
  result |= do_check ();

  result |= simulate_login ("ttyp2", "richard");
  result |= do_check ();

  result |= check_login ("tty1");
  result |= check_logout ("ttyp0");
  result |= check_id ("p1");
  result |= check_id ("2");
  result |= check_id ("si");
  result |= check_type (BOOT_TIME);
  result |= check_type (RUN_LVL);

  return result;
}
コード例 #19
0
ファイル: tolerance-test.c プロジェクト: Distrotech/pixman
int
main (int argc, const char *argv[])
{
    int i;
    int result = 0;

    if (argc == 2)
    {
	if (strcmp (argv[1], "--forever") == 0)
	{
	    uint32_t n;

	    prng_srand (time (0));

	    n = prng_rand();

	    for (;;)
		do_check (n++);
	}
        else
	{
	    do_check (strtol (argv[1], NULL, 0));
	}
    }
    else
    {
#ifdef USE_OPENMP
#       pragma omp parallel for default(none) reduction(|:result)
#endif
        for (i = 0; i < N_TESTS; ++i)
	{
	    if (!do_check (i))
		result |= 1;
	}
    }
    
    return result;
}
コード例 #20
0
int main (void)
{
    void *ctx = zmq_ctx_new ();
    assert (ctx);
    int rc;
   
    void *sb = zmq_socket (ctx, ZMQ_PULL);
    assert (sb);
  
    rc = zmq_bind (sb, "inproc://a");
    assert (rc == 0);

    msleep (SETTLE_TIME);
    void *sc = zmq_socket (ctx, ZMQ_PUSH);
  
    rc = zmq_connect (sc, "inproc://a");
    assert (rc == 0);


    // message bigger than vsm max
    do_check(sb,sc,100);

    // message smaller than vsm max
    do_check(sb,sc,10);

    rc = zmq_close (sc);
    assert (rc == 0);

    rc = zmq_close (sb);
    assert (rc == 0);

    rc = zmq_ctx_term (ctx);
    assert (rc == 0);

    return 0;
}
コード例 #21
0
ファイル: xs.c プロジェクト: alexbyk/perl-evo
static void xs_new(pTHX_ SV *cv) {
  dXSARGS;
  if (items < 1) croak("Usage: class, ref");

#ifndef MULTIPLICITY
  AV *slots = CvXSUBANY(cv).any_ptr;
#else
  MAGIC *mg = mg_findext(cv, PERL_MAGIC_ext, &ATTRS_TBL);
  AV *slots = (AV *)mg->mg_obj;
#endif

  SV *class = ST(0);
  HV *hash = newHV();
  SV *obj = sv_2mortal(newRV_noinc((SV *)hash)); // don't move to the end(leaks)

  SV **args;                                               // uniq args
  int args_count = args_to_uniq(&ST(1), items - 1, &args); // skip 1(class)

  int slots_count = av_top_index(slots) + 1;
  for (int i = 0; i < slots_count; i++) { // NEXT_SLOT:
    ECAslot *slot = sv2slot(av_fetch_or_croak(slots, i));

    // iterage args, null if matched
    for (int j = 0; j < args_count; j += 2) {
      SV *tmp = args[j];
      if (!tmp) continue; // already matched

      if (!sv_cmp(tmp, slot->key)) {
        if (slot->check) do_check(slot->check, args[j + 1], slot->key);
        hv_he_store_or_croak(hash, slot->key, args[j + 1]);
        args[j] = NULL;
        goto NEXT_SLOT;
        args[j] = NULL; // mark as consumed
      }
    }

    // slot not found in passed args, decide what to do
    if (slot->type == ECA_REQUIRED) {
      croak("Attribute \"%s\" is required", SvPV_nolen(slot->key));
    } else if (slot->type == ECA_DEFAULT) {
      hv_he_store_or_croak(hash, slot->key, slot->value);
    } else if (slot->type == ECA_DEFAULT_CODE) {
      invoke_and_store(class, slot->value, hash, slot->key);
    }

  NEXT_SLOT:; // simulate continue label
  }
コード例 #22
0
ファイル: seckey-cert.c プロジェクト: hlThai/gpg-TeslaRing
/****************
 * Check the secret key
 * Ask up to 3 (or n) times for a correct passphrase
 * If n is negative, disable the key info prompt and make n=abs(n)
 */
int
check_secret_key( PKT_secret_key *sk, int n )
{
    int rc = gpg_error (GPG_ERR_BAD_PASSPHRASE);
    int i,mode;

    if (sk && sk->is_protected && sk->protect.s2k.mode == 1002)
      return 0; /* Let the scdaemon handle this. */

    if(n<0)
      {
	n=abs(n);
	mode=1;
      }
    else
      mode=0;

    if( n < 1 )
	n = 3; /* Use the default value */

    for(i=0; i < n && gpg_err_code (rc) == GPG_ERR_BAD_PASSPHRASE; i++ ) {
        int canceled = 0;
        const char *tryagain = NULL;
	if (i) {
            tryagain = N_("Invalid passphrase; please try again");
            log_info (_("%s ...\n"), _(tryagain));
        }
	rc = do_check( sk, tryagain, mode, &canceled );
	if ( gpg_err_code (rc) == GPG_ERR_BAD_PASSPHRASE
             && is_status_enabled () ) {
	    u32 kid[2];
	    char buf[50];

	    keyid_from_sk( sk, kid );
	    sprintf(buf, "%08lX%08lX", (ulong)kid[0], (ulong)kid[1]);
	    write_status_text( STATUS_BAD_PASSPHRASE, buf );
	}
	if( have_static_passphrase() || canceled)
	    break;
    }

    if( !rc )
	write_status( STATUS_GOOD_PASSPHRASE );

    return rc;
}
コード例 #23
0
gint main (gint argc, gchar **argv)
{
	if (argc < 2)
		do_usage (argv[0]);

	camel_init (NULL, 0);

	if (!strcmp(argv[1], "compress"))
		return do_compress (argc, argv);
	else if (!strcmp(argv[1], "dump"))
		return do_dump (argc, argv);
	else if (!strcmp(argv[1], "info"))
		return do_info (argc, argv);
	else if (!strcmp(argv[1], "check"))
		return do_check (argc, argv);
	else if (!strcmp(argv[1], "perf"))
		return do_perf (argc, argv);

	do_usage (argv[0]);
	return 1;
}
コード例 #24
0
ファイル: op_chown.c プロジェクト: StephanU/fuse-ext2
int op_chown (const char *path, uid_t uid, gid_t gid)
{
	int rt;
	ext2_ino_t ino;
	struct ext2_inode inode;
	ext2_filsys e2fs = current_ext2fs();

	debugf("enter");
	debugf("path = %s", path);
	
	rt = do_check(path);
	if (rt != 0) {
		debugf("do_check(%s); failed", path);
		return rt;
	}

	rt = do_readinode(e2fs, path, &ino, &inode);
	if (rt) {
		debugf("do_readinode(%s, &ino, &vnode); failed", path);
		return rt;
	}
	
	if (uid != -1) {
		ext2_write_uid(&inode, uid);
	}
	if (gid != -1) {
		ext2_write_gid(&inode, gid);
	}

	rt = do_writeinode(e2fs, ino, &inode);
	if (rt) {
		debugf("do_writeinode(e2fs, ino, &inode); failed");
		return -EIO;
	}

	debugf("leave");
	return 0;
}
コード例 #25
0
ファイル: op_chmod.c プロジェクト: StephanU/fuse-ext2
int op_chmod (const char *path, mode_t mode)
{
	int rt;
	int mask;
	time_t tm;
	ext2_ino_t ino;
	struct ext2_inode inode;
	ext2_filsys e2fs = current_ext2fs();

	debugf("enter");
	debugf("path = %s 0%o", path, mode);

	rt = do_check(path);
	if (rt != 0) {
		debugf("do_check(%s); failed", path);
		return rt;
	}

	rt = do_readinode(e2fs, path, &ino, &inode);
	if (rt) {
		debugf("do_readinode(%s, &ino, &vnode); failed", path);
		return rt;
	}

	tm = e2fs->now ? e2fs->now : time(NULL);
	mask = S_IRWXU | S_IRWXG | S_IRWXO | S_ISUID | S_ISGID | S_ISVTX;
	inode.i_mode = (inode.i_mode & ~mask) | (mode & mask);
	inode.i_ctime = tm;

	rt = do_writeinode(e2fs, ino, &inode);
	if (rt) {
		debugf("do_writeinode(e2fs, ino, &inode); failed");
		return -EIO;
	}

	debugf("leave");
	return 0;
}
コード例 #26
0
int op_truncate(const char *path, off_t length)
{
	int rt;
	ext2_file_t efile;
	ext2_filsys e2fs = current_ext2fs();

	debugf("enter");
	debugf("path = %s", path);

	rt = do_check(path);
	if (rt != 0) {
		debugf("do_check(%s); failed", path);
		return rt;
	}
	efile = do_open(e2fs, path, O_WRONLY);
	if (efile == NULL) {
		debugf("do_open(%s); failed", path);
		return -ENOENT;
	}

	rt = ext2fs_file_set_size(efile, length);
	if (rt) {
		do_release(efile);
		debugf("ext2fs_file_set_size(efile, %d); failed", length);
		return rt;
	}

	rt = do_release(efile);
	if (rt != 0) {
		debugf("do_release(efile); failed");
		return rt;
	}

	debugf("leave");
	return 0;
}
コード例 #27
0
ファイル: checkpath.c プロジェクト: andrewgregory/openrc
int checkpath(int argc, char **argv)
{
	int opt;
	uid_t uid = geteuid();
	gid_t gid = getgid();
	mode_t mode = 0;
	struct passwd *pw = NULL;
	struct group *gr = NULL;
	inode_t type = inode_unknown;
	int retval = EXIT_SUCCESS;
	bool trunc = false;
	bool chowner = false;
	bool writable = false;
	bool selinux_on = false;

	while ((opt = getopt_long(argc, argv, getoptstring,
		    longopts, (int *) 0)) != -1)
	{
		switch (opt) {
		case 'D':
			trunc = true;
		case 'd':
			type = inode_dir;
			break;
		case 'F':
			trunc = true;
		case 'f':
			type = inode_file;
			break;
		case 'p':
			type = inode_fifo;
			break;
		case 'm':
			if (parse_mode(&mode, optarg) != 0)
				eerrorx("%s: invalid mode `%s'",
				    applet, optarg);
			break;
		case 'o':
			chowner = true;
			if (parse_owner(&pw, &gr, optarg) != 0)
				eerrorx("%s: owner `%s' not found",
				    applet, optarg);
			break;
		case 'W':
			writable = true;
			break;

		case_RC_COMMON_GETOPT
		}
	}

	if (optind >= argc)
		usage(EXIT_FAILURE);

	if (writable && type != inode_unknown)
		eerrorx("%s: -W cannot be specified along with -d, -f or -p", applet);

	if (pw) {
		uid = pw->pw_uid;
		gid = pw->pw_gid;
	}
	if (gr)
		gid = gr->gr_gid;

	if (selinux_util_open() == 1)
		selinux_on = true;

	while (optind < argc) {
		if (writable)
			exit(!is_writable(argv[optind]));
		if (do_check(argv[optind], uid, gid, mode, type, trunc, chowner, selinux_on))
			retval = EXIT_FAILURE;
		optind++;
	}

	if (selinux_on)
		selinux_util_close();

	return retval;
}
コード例 #28
0
int
main(int argc, char *argv[])
{
	START(argc, argv, "pmem_map_file");

	int fd;
	void *addr;
	size_t mlen;
	size_t *mlenp;
	const char *path;
	unsigned long long len;
	int flags;
	unsigned mode;
	int is_pmem;
	int *is_pmemp;
	int use_mlen;
	int use_is_pmem;
	int err_code;

	if (argc < 8)
		UT_FATAL("usage: %s path len flags mode use_mlen "
				"use_is_pmem err_code...", argv[0]);

	for (int i = 1; i + 6 < argc; i += 7) {
		path = argv[i];
		len = strtoull(argv[i + 1], NULL, 0);
		flags = parse_flags(argv[i + 2]);
		mode = STRTOU(argv[i + 3], NULL, 8);
		use_mlen = atoi(argv[i + 4]);
		use_is_pmem = atoi(argv[i + 5]);
		err_code = parse_err_code(argv[i + 6]);

		mlen = SIZE_MAX;
		if (use_mlen)
			mlenp = &mlen;
		else
			mlenp = NULL;

		if (use_is_pmem)
			is_pmemp = &is_pmem;
		else
			is_pmemp = NULL;

		UT_OUT("%s %lld %s %o %d %d %d",
			path, len, argv[i + 2], mode, use_mlen,
			use_is_pmem, err_code);

		addr = pmem_map_file(path, len, flags, mode, mlenp, is_pmemp);

		if (err_code != 0) {
			UT_ASSERTeq(errno, err_code);
		}

		if (addr == NULL) {
			UT_OUT("!pmem_map_file");
			continue;
		}

		if (use_mlen) {
			UT_ASSERTne(mlen, SIZE_MAX);
			UT_OUT("mapped_len %zu", mlen);
		} else {
			mlen = len;
		}

		if (addr) {
			/* is_pmem must be true for device DAX */
			int is_pmem_check = pmem_is_pmem(addr, mlen);
			UT_ASSERT(!is_dev_dax || is_pmem_check);

			/* check is_pmem returned from pmem_map_file */
			if (use_is_pmem)
				UT_ASSERTeq(is_pmem, is_pmem_check);

			if ((flags & PMEM_FILE_TMPFILE) == 0 && !is_dev_dax) {
				fd = OPEN(argv[i], O_RDWR);

				if (!use_mlen) {
					os_stat_t stbuf;
					FSTAT(fd, &stbuf);
					mlen = (size_t)stbuf.st_size;
				}

				if (fd != -1) {
					do_check(fd, addr, mlen);
					(void) CLOSE(fd);
				} else {
					UT_OUT("!cannot open file: %s",
							argv[i]);
				}
			} else {
				UT_ASSERTeq(pmem_unmap(addr, mlen), 0);
			}
		}
	}

	DONE(NULL);
}
コード例 #29
0
		result_type check(argument_type arg) const { return do_check(arg); }
コード例 #30
0
/*===========================================================================*
 *				main                                         *
 *===========================================================================*/
PUBLIC int main(int argc, char **argv)
{
/* This is the main routine of this service. The main loop consists of 
 * three major activities: getting new work, processing the work, and
 * sending the reply. The loop never terminates, unless a panic occurs.
 */
  message m;
  int result;                 

  /* SEF local startup. */
  env_setargs(argc, argv);
  sef_local_startup();

  /* Main loop - get work and do it, forever. */         
  while (TRUE) {              

      /* Wait for incoming message, sets 'callnr' and 'who'. */
      get_work(&m);

      if (is_notify(callnr)) {
          printf("DS: warning, got illegal notify from: %d\n", m.m_source);
          result = EINVAL;
          goto send_reply;
      }

      switch (callnr) {
      case DS_PUBLISH:
          result = do_publish(&m);
          break;
      case DS_RETRIEVE:
	  result = do_retrieve(&m);
	  break;
      case DS_RETRIEVE_LABEL:
	  result = do_retrieve_label(&m);
	  break;
      case DS_DELETE:
	  result = do_delete(&m);
	  break;
      case DS_SUBSCRIBE:
	  result = do_subscribe(&m);
	  break;
      case DS_CHECK:
	  result = do_check(&m);
	  break;
      case DS_SNAPSHOT:
	  result = do_snapshot(&m);
	  break;
      case GETSYSINFO:
	  result = do_getsysinfo(&m);
	  break;
      default: 
          printf("DS: warning, got illegal request from %d\n", m.m_source);
          result = EINVAL;
      }

send_reply:
      /* Finally send reply message, unless disabled. */
      if (result != EDONTREPLY) {
          m.m_type = result;  		/* build reply message */
	  reply(who_e, &m);		/* send it away */
      }
  }
  return(OK);				/* shouldn't come here */
}