Ejemplo n.º 1
0
hpx::future<hpx::id_type> node_client::get_child_client(integer ci) {
	if (get_gid() != hpx::invalid_id) {
		return hpx::async<typename node_server::get_child_client_action>(get_gid(), ci);
	} else {
		return hpx::make_ready_future(hpx::invalid_id);
	}
}
Ejemplo n.º 2
0
hpx::future<hpx::id_type> node_client::get_child_client(const geo::octant& ci) {
	if (get_gid() != hpx::invalid_id) {
		return hpx::async<typename node_server::get_child_client_action>(get_gid(), ci);
	} else {
		auto tmp = hpx::invalid_id;
		return hpx::make_ready_future < hpx::id_type > (std::move(tmp));
	}
}
Ejemplo n.º 3
0
static int db_getattr(backend_store_interface* i, const char* rel_path, struct stat* stbuf) {
	int ret = 0;

	logger_logf(LOG(i), "rel_path = %s", rel_path);

	memset(stbuf, 0, sizeof(struct stat));

    if(strcmp(rel_path, "/") == 0) {
        stbuf->st_mode = S_IFDIR | 0755;
        stbuf->st_nlink = 2;
        logger_logf(LOG(i), "slash");
    } else if (file_exists(rel_path)) {
    	stbuf->st_mode = get_mode(rel_path);
    	stbuf->st_nlink = 1;
    	stbuf->st_uid = get_uid(rel_path);
    	stbuf->st_gid = get_gid(rel_path);
    	stbuf->st_size = get_size(rel_path);
    	stbuf->st_blksize = 4096;
    	stbuf->st_atim.tv_sec = get_access_time(rel_path);
    	stbuf->st_mtim.tv_sec = get_modification_time(rel_path);
    	stbuf->st_ctim.tv_sec = get_status_change_time(rel_path);
    } else {
    	ret = -ENOENT;
    	logger_logf(LOG(i), "-ENOENT");
    }

	return ret;
}
Ejemplo n.º 4
0
static int db_can_write_to_directory(backend_store_interface* i, const char* rel_path) {
	size_t end = strlen(rel_path) - 1;
	char dir_path[end + 2];
	strncpy(dir_path, rel_path, end + 2);

	logger_logf(LOG(i), "rel_path = %s, dir_path = %s", rel_path, dir_path);

	/* Need to make sure user can write to all directories above this one */
	while (end > 0) {
		while (dir_path[end] != '/') {
			--end;
		}
		dir_path[end] = '\0';
		if (end == 0) {
			break;
		}

		long dir_mode = get_mode(dir_path);
		long dir_uid = get_uid(dir_path);
		long dir_gid = get_gid(dir_path);

		int can_user_write_to_dir = fuse_get_context()->uid == dir_uid && (dir_mode & S_IWUSR);
		int can_grp_write_to_dir = is_user_in_group(i, dir_gid) && (dir_mode & S_IWGRP);

		if (!can_user_write_to_dir && !can_grp_write_to_dir) {
			return 0;
		}

		--end;
	}

	return 1;
}
Ejemplo n.º 5
0
    lazy_ostream& streaming_operator_sync(T const& subject, Lock& l)
    { // {{{
        // apply the subject to the local stream
        data->stream << subject;

        // If the buffer isn't empty, send it to the destination.
        if (!data->out_buffer.data_->empty())
        {
            // Create the next buffer/stream.
            data_type* next = new data_type;

            // Swap the current buffer for the next one.
            boost::swap(next, data);

            // Unlock the mutex before we cleanup.
            l.unlock();

            // Perform the write operation, then destroy the old buffer and
            // stream.
            this->base_type::write_sync(get_gid(), next->out_buffer);

            delete next;
            next = 0;
        }

        return *this;
    } // }}}
Ejemplo n.º 6
0
void
nest::weight_recorder::calibrate()
{
  if ( kernel().event_delivery_manager.get_off_grid_communication()
    and not device_.is_precise_times_user_set() )
  {
    device_.set_precise_times( true );
    std::string msg = String::compose(
      "Precise neuron models exist: the property precise_times "
      "of the %1 with gid %2 has been set to true",
      get_name(),
      get_gid() );

    if ( device_.is_precision_user_set() )
    {
      // if user explicitly set the precision, there is no need to do anything.
      msg += ".";
    }
    else
    {
      // it makes sense to increase the precision if precise models are used.
      device_.set_precision( 15 );
      msg += ", precision has been set to 15.";
    }

    LOG( M_INFO, "weight_recoder::calibrate", msg );
  }

  device_.calibrate();
}
Ejemplo n.º 7
0
 hpx::lcos::future<std::size_t>
 solve_board_async(list_type const& list, std::size_t size,
     std::size_t level, std::size_t col)
 {
     return this->base_type::solve_board_async
         (get_gid(), list, size, level, col);
 }
Ejemplo n.º 8
0
static struct service_listener *
service_create_file_listener(struct service *service,
			     enum service_listener_type type,
			     const struct file_listener_settings *set,
			     const char **error_r)
{
	struct service_listener *l;
	const char *set_name;
	gid_t gid;

	l = p_new(service->list->pool, struct service_listener, 1);
	l->service = service;
	l->type = type;
	l->fd = -1;
	l->set.fileset.set = set;
	l->name = strrchr(set->path, '/');
	if (l->name != NULL)
		l->name++;
	else
		l->name = set->path;

	if (get_uidgid(set->user, &l->set.fileset.uid, &gid, error_r) < 0)
		set_name = "user";
	else if (get_gid(set->group, &l->set.fileset.gid, error_r) < 0)
		set_name = "group";
	else
		return l;

	*error_r = t_strdup_printf(
		"%s (See service %s { %s_listener %s { %s } } setting)",
		*error_r, service->set->name,
		type == SERVICE_LISTENER_UNIX ? "unix" : "fifo",
		set->path, set_name);
	return NULL;
}
Ejemplo n.º 9
0
int
set_gid_root (void)
{
#if (defined (DOES_UID))
#   if (defined (__UTYPE_HPUX) || defined (__UTYPE_BEOS))
    return (setgid (get_gid (EFFECTIVE_ID)));
#   elif (defined (__OS2__))            /*  OS/2 only supports one UID       */
    return (0);
#   elif (defined (__VMS__))            /*  No setgid under OpenVMS          */
    return (0);
#   else
    return (setegid (get_gid (EFFECTIVE_ID)));
#   endif
#else
    return (0);
#endif
}
Ejemplo n.º 10
0
/*
 * process_flags - perform command line argument setting
 *
 *	process_flags() interprets the command line arguments and sets the
 *	values that the user will be created with accordingly. The values
 *	are checked for sanity.
 */
static void process_flags (int argc, char **argv)
{
	int c;
	static struct option long_options[] = {
		{"gid",        required_argument, NULL, 'g'},
		{"help",       no_argument,       NULL, 'h'},
		{"new-name",   required_argument, NULL, 'n'},
		{"non-unique", no_argument,       NULL, 'o'},
		{"password",   required_argument, NULL, 'p'},
		{"root",       required_argument, NULL, 'R'},
		{NULL, 0, NULL, '\0'}
	};
	while ((c = getopt_long (argc, argv, "g:hn:op:R:",
		                 long_options, NULL)) != -1) {
		switch (c) {
		case 'g':
			gflg = true;
			if (   (get_gid (optarg, &group_newid) == 0)
			    || (group_newid == (gid_t)-1)) {
				fprintf (stderr,
				         _("%s: invalid group ID '%s'\n"),
				         Prog, optarg);
				exit (E_BAD_ARG);
			}
			break;
		case 'h':
			usage (E_SUCCESS);
			break;
		case 'n':
			nflg = true;
			group_newname = optarg;
			break;
		case 'o':
			oflg = true;
			break;
		case 'p':
			group_passwd = optarg;
			pflg = true;
			break;
		case 'R': /* no-op, handled in process_root_flag () */
			break;
		default:
			usage (E_USAGE);
		}
	}

	if (oflg && !gflg) {
		usage (E_USAGE);
	}

	if (optind != (argc - 1)) {
		usage (E_USAGE);
	}

	group_name = argv[argc - 1];
}
Ejemplo n.º 11
0
/**
 * Is the user allowed to see ("ascertain") if the passed file exists?
 * If not, then they shouldn't see it when they "ls"
 *
 * You can ascertain the existence of a file if you have have privileges to read it
 */
static int db_can_ascertain_existence(backend_store_interface* i, const char* rel_path) {
	logger_logf(LOG(i), "rel_path: %s", rel_path);

	//if world can read, return true no matter what
	if ((get_mode(rel_path) & S_IROTH) != 0) {
		return 1;
	}

	return (get_uid(rel_path) == fuse_get_context()->uid || is_user_in_group(i, get_gid(rel_path)));
}
Ejemplo n.º 12
0
void
nest::Subnet::set_label( std::string const l )
{
  // set the new label on all sibling threads
  for ( thread t = 0; t < network()->get_num_threads(); ++t )
  {
    Node* n = network()->get_node( get_gid(), t );
    Subnet* c = dynamic_cast< Subnet* >( n );
    assert( c );
    c->label_ = l;
  }
}
Ejemplo n.º 13
0
Archivo: files.c Proyecto: rixed/junkie
int chusergroup(const char * const path, const char * const user, const char * const group)
{
    uid_t uid = user && user[0] != '\0' ? get_uid(user) : (uid_t)-1;
    gid_t gid = group && group[0] != '\0' ? get_gid(group) : (gid_t)-1;

    if (-1 == chown(path, uid, gid)) {
        SLOG(LOG_ERR, "chown: %s (path=%s, user=%s, group=%s)", strerror(errno), path, user, group);
        return -1;
    }

    return 0;
}
Ejemplo n.º 14
0
void
nest::Subnet::set_label( std::string const l )
{
  // set the new label on all sibling threads
  for ( index t = 0; t < kernel().vp_manager.get_num_threads(); ++t )
  {
    Node* n = kernel().node_manager.get_node( get_gid(), t );
    Subnet* c = dynamic_cast< Subnet* >( n );
    assert( c );
    c->label_ = l;
  }
}
Ejemplo n.º 15
0
void
nest::sli_neuron::update( Time const& origin,
  const long_t from,
  const long_t to )
{
  assert(
    to >= 0 && ( delay ) from < kernel().connection_manager.get_min_delay() );
  assert( from < to );
  ( *state_ )[ names::t_origin ] = origin.get_steps();

  if ( state_->known( names::error ) )
  {
    std::string msg =
      String::compose( "Node %1 still has its error state set.", get_gid() );
    LOG( M_ERROR, "sli_neuron::update", msg.c_str() );
    LOG( M_ERROR,
      "sli_neuron::update",
      "Please check /calibrate and /update for errors" );
    kernel().simulation_manager.terminate();
    return;
  }

  for ( long_t lag = from; lag < to; ++lag )
  {
    ( *state_ )[ names::in_spikes ] =
      B_.in_spikes_.get_value( lag ); // in spikes arriving at right border
    ( *state_ )[ names::ex_spikes ] =
      B_.ex_spikes_.get_value( lag ); // ex spikes arriving at right border
    ( *state_ )[ names::currents ] = B_.currents_.get_value( lag );
    ( *state_ )[ names::t_lag ] = lag;

#pragma omp critical( sli_neuron )
    {
      execute_sli_protected( state_, names::update_node ); // call interpreter
    }

    bool spike_emission = false;
    if ( state_->known( names::spike ) )
      spike_emission = ( *state_ )[ names::spike ];

    // threshold crossing
    if ( spike_emission )
    {
      set_spiketime( Time::step( origin.get_steps() + lag + 1 ) );
      SpikeEvent se;
      kernel().event_delivery_manager.send( *this, se, lag );
    }

    B_.logger_.record_data( origin.get_steps() + lag );
  }
}
Ejemplo n.º 16
0
void
nest::sli_neuron::calibrate()
{
  B_.logger_.init();

  bool terminate = false;

  if ( !state_->known( names::calibrate ) )
  {
    std::string msg = String::compose(
      "Node %1 has no /calibrate function in its status dictionary.",
      get_gid() );
    LOG( M_ERROR, "sli_neuron::calibrate", msg.c_str() );
    terminate = true;
  }

  if ( !state_->known( names::update ) )
  {
    std::string msg = String::compose(
      "Node %1 has no /update function in its status dictionary. Terminating.",
      get_gid() );
    LOG( M_ERROR, "sli_neuron::calibrate", msg.c_str() );
    terminate = true;
  }

  if ( terminate )
  {
    kernel().simulation_manager.terminate();
    LOG( M_ERROR, "sli_neuron::calibrate", "Terminating." );
    return;
  }

#pragma omp critical( sli_neuron )
  {
    execute_sli_protected( state_, names::calibrate_node ); // call interpreter
  }
}
Ejemplo n.º 17
0
int
    ipr_uid_get_gid (
void)
{
    int
        gid;                            //  Return value

#   if (defined (DOES_UID))
    gid = get_gid (REAL_ID);
#   else
    gid = 0;
#   endif

    return (gid);
}
Ejemplo n.º 18
0
int
    ipr_uid_set_root_group (
void)
{
    int
        rc;                             //  Return value

#   if (defined (DOES_UID))
    rc = setegid (get_gid (EFFECTIVE_ID));
#   else
    rc = 0;
#   endif

    return (rc);
}
Ejemplo n.º 19
0
void
Node::set_status_base( const DictionaryDatum& dict )
{
  assert( dict.valid() );
  try
  {
    set_status( dict );
  }
  catch ( BadProperty& e )
  {
    throw BadProperty( String::compose(
      "Setting status of a '%1' with GID %2: %3", get_name(), get_gid(), e.message() ) );
  }

  updateValue< bool >( dict, names::frozen, frozen_ );
}
Ejemplo n.º 20
0
void
nest::spin_detector::get_status( DictionaryDatum& d ) const
{
  // get the data from the device
  device_.get_status( d );

  // if we are the device on thread 0, also get the data from the
  // siblings on other threads
  if ( get_thread() == 0 )
  {
    const SiblingContainer* siblings = kernel().node_manager.get_thread_siblings( get_gid() );
    std::vector< Node* >::const_iterator sibling;
    for ( sibling = siblings->begin() + 1; sibling != siblings->end(); ++sibling )
      ( *sibling )->get_status( d );
  }
}
Ejemplo n.º 21
0
perm_class_t get_perm_class(uid_t resource_uid, gid_t resource_gid)
{
	uid_t uid = get_effective_uid();
	gid_t gid = get_effective_gid();
	uid_t r_uid = get_uid();
	gid_t r_gid = get_gid();
	/* Are we root? */
	if ((uid == 0) && (gid == 0))
		return PERM_CLASS_OWNER; /* Root is almighty */
	/* Nope, perform checks */
	if ((resource_uid == uid) || (resource_uid == r_uid))
		return PERM_CLASS_OWNER;
	else if ((resource_gid == gid) || (resource_uid == r_gid))
		return PERM_CLASS_GROUP;
	else
		return PERM_CLASS_OTHER;
}
Ejemplo n.º 22
0
int main(void) {
  gid_t groups[32];
  int ngroups;
  gid_t this_group, other_group;
  int fd;

  this_group = getegid();
  atomic_printf("Current group is %d\n", this_group);

  ngroups = getgroups(ALEN(groups), groups);
  test_assert(ngroups > 0);

  other_group = groups[0];
  if (this_group == other_group && ngroups > 1) {
    other_group = groups[1];
  }
  if (this_group == other_group) {
    atomic_puts("WARNING: unable to properly test chown()");
  }

  fd = creat(DUMMY_FILENAME, 0600);
  test_assert(fd >= 0);
  atomic_printf("Group owner of %s is %d\n", DUMMY_FILENAME, get_gid(fd));
  test_assert(this_group == get_gid(fd));

  change_group(DUMMY_FILENAME, other_group);
  atomic_printf("  ... now owner is %d\n", get_gid(fd));
  test_assert(other_group == get_gid(fd));

  change_group_fd(fd, this_group);
  atomic_printf("  ... now back to original owner %d\n", get_gid(fd));
  test_assert(this_group == get_gid(fd));

  change_group_at(DUMMY_FILENAME, other_group);
  atomic_printf("  ... now owner is %d\n", get_gid(fd));
  test_assert(other_group == get_gid(fd));

  unlink(DUMMY_FILENAME);

  atomic_puts("EXIT-SUCCESS");

  return 0;
}
Ejemplo n.º 23
0
DictionaryDatum
Node::get_status_base()
{
  DictionaryDatum dict = get_status_dict_();

  assert( dict.valid() );

  // add information available for all nodes
  ( *dict )[ names::local ] = is_local();
  ( *dict )[ names::model ] = LiteralDatum( get_name() );

  // add information available only for local nodes
  if ( is_local() )
  {
    ( *dict )[ names::global_id ] = get_gid();
    ( *dict )[ names::frozen ] = is_frozen();
    ( *dict )[ names::node_uses_wfr ] = node_uses_wfr();
    ( *dict )[ names::thread ] = get_thread();
    ( *dict )[ names::vp ] = get_vp();
    if ( parent_ )
    {
      ( *dict )[ names::parent ] = parent_->get_gid();

      // LIDs are only sensible for nodes with parents.
      // Add 1 as we count lids internally from 0, but from
      // 1 in the user interface.
      ( *dict )[ names::local_id ] = get_lid() + 1;
    }
  }

  ( *dict )[ names::thread_local_id ] = get_thread_lid();
  ( *dict )[ names::supports_precise_spikes ] = is_off_grid();

  // This is overwritten with a corresponding value in the
  // base classes for stimulating and recording devices, and
  // in other special node classes
  ( *dict )[ names::element_type ] = LiteralDatum( names::neuron );

  // now call the child class' hook
  get_status( dict );

  assert( dict.valid() );
  return dict;
}
Ejemplo n.º 24
0
void
nest::spin_detector::calibrate()
{
  if ( !user_set_precise_times_ && kernel().event_delivery_manager.get_off_grid_communication() )
  {
    device_.set_precise( true, 15 );

    LOG( M_INFO,
      "spin_detector::calibrate",
      String::compose(
           "Precise neuron models exist: the property precise_times "
           "of the %1 with gid %2 has been set to true, precision has "
           "been set to 15.",
           get_name(),
           get_gid() ) );
  }

  device_.calibrate();
}
Ejemplo n.º 25
0
void file_info(char* fileName){
 
 
  struct stat buf;
  int ret = stat(fileName, &buf);
  
  if(S_ISDIR(buf.st_mode)) 
      printf("d");
  else
      printf("-");
  info(buf);
  
  nlink(buf);
  printf(" %s ",get_uid(buf));
  printf("%s ",get_gid(buf));
  get_size(buf);
  get_time(buf);
  printf("  %s ",fileName);
  printf("\n");
  
}
Ejemplo n.º 26
0
static int db_can_read(backend_store_interface* i, const char* rel_path) {
	logger_logf(LOG(i), "rel_path = %s", rel_path);

	if (!db_can_ascertain_existence(i, rel_path)) {
		return 0;
	}

	long mode = get_mode(rel_path);

	if (mode & S_IROTH) {
		return 1;
	}

	if (get_uid(rel_path) == fuse_get_context()->uid && (mode & S_IRUSR)) {
		return 1;
	}

	if (is_user_in_group(i, get_gid(rel_path)) && (mode & S_IRGRP)) {
		return 1;
	}

	return 0;
}
Ejemplo n.º 27
0
void
nest::volume_transmitter::update( const Time&, const long_t from, const long_t to )
{
  // spikes that arrive in this time slice are stored in spikecounter_
  double_t t_spike;
  double_t multiplicity;
  for ( long_t lag = from; lag < to; ++lag )
  {
    multiplicity = B_.neuromodulatory_spikes_.get_value( lag );
    if ( multiplicity > 0 )
    {
      t_spike = Time( Time::step( kernel().simulation_manager.get_slice_origin().get_steps() + lag
                        + 1 ) ).get_ms();
      B_.spikecounter_.push_back( spikecounter( t_spike, multiplicity ) );
    }
  }

  // all spikes stored in spikecounter_ are delivered to the target synapses
  if ( ( kernel().simulation_manager.get_slice_origin().get_steps() + to )
      % ( P_.deliver_interval_ * kernel().connection_builder_manager.get_min_delay() )
    == 0 )
  {
    double_t t_trig = Time( Time::step( kernel().simulation_manager.get_slice_origin().get_steps()
                              + to ) ).get_ms();

    if ( !B_.spikecounter_.empty() )
      kernel().connection_builder_manager.trigger_update_weight(
        get_gid(), B_.spikecounter_, t_trig );

    // clear spikecounter
    B_.spikecounter_.clear();

    // as with trigger_update_weight dopamine trace has been updated to t_trig, insert pseudo last
    // dopa spike at t_trig
    B_.spikecounter_.push_back( spikecounter( t_trig, 0.0 ) );
  }
}
Ejemplo n.º 28
0
int
headers_to_stat(GList *headers, struct stat *stbuf)
{
  GList *head = NULL,
        *next = NULL;

  head = g_list_first(headers);
  while(head != NULL) {
    next = head->next;
    HTTP_HEADER *header = head->data;

    // TODO: clean this up.
    if(strcmp(header->key, "x-amz-meta-uid") == 0)
      stbuf->st_uid = get_uid(header->value);
    else if(strcmp(header->key, "x-amz-meta-gid") == 0)
      stbuf->st_gid = get_gid(header->value);
    else if(strcmp(header->key, "x-amz-meta-ctime") == 0)
      stbuf->st_ctime = get_ctime(header->value);
    else if(strcmp(header->key, "x-amz-meta-mtime") == 0)
      stbuf->st_mtime = get_mtime(header->value);
    else if(strcmp(header->key, "x-amz-meta-rdev") == 0)
      stbuf->st_rdev = get_rdev(header->value);
    else if(strcmp(header->key, "Last-Modified") == 0 && stbuf->st_mtime == 0)
      stbuf->st_mtime = get_mtime(header->value);
    else if(strcmp(header->key, "x-amz-meta-mode") == 0)
      stbuf->st_mode = get_mode(header->value);
    else if(strcmp(header->key, "Content-Length") == 0)
      stbuf->st_size = get_size(header->value);
    else if(strcmp(header->key, "Content-Type") == 0)
      if(strstr(header->value, "x-directory"))
        stbuf->st_mode |= S_IFDIR;

    head = next;
  }

  return 0;
}
Ejemplo n.º 29
0
bool node_client::empty() const {
	return get_gid() == hpx::invalid_id;
}
Ejemplo n.º 30
0
 void clear_board(){
     return this->base_type::clear_board(get_gid());
 }