示例#1
0
/* ARGSUSED1 */
static void
print_comb(struct sadb_comb *comb, struct sadb_msg *msg)
{
	printf("\t\tauth %s min %u max %u\n"
	    "\t\tenc %s min %u max %u\n"
	    "\t\taddtime hard %llu soft %llu\n"
	    "\t\tusetime hard %llu soft %llu",
	    lookup_name(auth_types, comb->sadb_comb_auth),
	    comb->sadb_comb_auth_minbits,
	    comb->sadb_comb_auth_maxbits,
	    lookup_name(enc_types, comb->sadb_comb_encrypt),
	    comb->sadb_comb_encrypt_minbits,
	    comb->sadb_comb_encrypt_maxbits,
	    comb->sadb_comb_soft_addtime,
	    comb->sadb_comb_hard_addtime,
	    comb->sadb_comb_soft_usetime,
	    comb->sadb_comb_hard_usetime);
#if 0
	    comb->sadb_comb_flags,
	    comb->sadb_comb_reserved,
	    comb->sadb_comb_soft_allocations,
	    comb->sadb_comb_hard_allocations,
	    comb->sadb_comb_soft_bytes,
	    comb->sadb_comb_hard_bytes,
#endif
}
示例#2
0
文件: lsa.c 项目: AlexSteel/wine
/* Adds domain info to referenced domain list.
   Domain list is stored as plain buffer, layout is:

       LSA_REFERENCED_DOMAIN_LIST,
       LSA_TRUST_INFORMATION array,
       domain data array of
           {
               domain name data (WCHAR buffer),
               SID data
           }

   Parameters:
       list   [I]  referenced list pointer
       domain [I]  domain name string
       data   [IO] pointer to domain data array
*/
static LONG lsa_reflist_add_domain(LSA_REFERENCED_DOMAIN_LIST *list, LSA_UNICODE_STRING *domain, char **data)
{
    ULONG sid_size = 0,domain_size = 0;
    BOOL handled = FALSE;
    SID_NAME_USE use;
    LONG i;

    for (i = 0; i < list->Entries; i++)
    {
        /* try to reuse index */
        if ((list->Domains[i].Name.Length == domain->Length) &&
            (!strncmpiW(list->Domains[i].Name.Buffer, domain->Buffer, (domain->Length / sizeof(WCHAR)))))
        {
            return i;
        }
    }

    /* no matching domain found, store name */
    list->Domains[list->Entries].Name.Length = domain->Length;
    list->Domains[list->Entries].Name.MaximumLength = domain->MaximumLength;
    list->Domains[list->Entries].Name.Buffer = (WCHAR*)*data;
    memcpy(list->Domains[list->Entries].Name.Buffer, domain->Buffer, domain->MaximumLength);
    *data += domain->MaximumLength;

    /* get and store SID data */
    list->Domains[list->Entries].Sid = *data;
    lookup_name(domain, NULL, &sid_size, NULL, &domain_size, &use, &handled);
    domain_size = 0;
    lookup_name(domain, list->Domains[list->Entries].Sid, &sid_size, NULL, &domain_size, &use, &handled);
    *data += sid_size;

    return list->Entries++;
}
示例#3
0
文件: lsa.c 项目: dvdhoo/wine
static INT build_domain(PLSA_REFERENCED_DOMAIN_LIST currentList, PLSA_UNICODE_STRING domain)
{
    ULONG count;
    ULONG sid_size = 0,domain_size = 0;
    BOOL handled = FALSE;
    SID_NAME_USE use;

    for (count = 0; count < currentList->Entries; count ++)
    {
        if ((currentList->Domains[count].Name.Length == domain->Length) &&
            (strncmpiW(currentList->Domains[count].Name.Buffer,domain->Buffer,(domain->Length / sizeof(WCHAR))) == 0))
        {
            HeapFree(GetProcessHeap(),0,domain->Buffer);
            return count;
        }
    }

    if (currentList->Entries > 0)
        currentList->Domains = HeapReAlloc(GetProcessHeap(),0,currentList->Domains, (currentList->Entries + 1) * sizeof(LSA_TRUST_INFORMATION));
    else
        currentList->Domains = HeapAlloc(GetProcessHeap(),0,sizeof(LSA_TRUST_INFORMATION));

    currentList->Domains[currentList->Entries].Name = *domain;

    lookup_name( domain, NULL, &sid_size, NULL, &domain_size, &use, &handled );
    domain_size = 0;
    currentList->Domains[currentList->Entries].Sid = HeapAlloc(GetProcessHeap(),0,sid_size);
    lookup_name( domain, currentList->Domains[currentList->Entries].Sid, &sid_size, NULL, &domain_size, &use, &handled );

    currentList->Entries++;
    return currentList->Entries-1;
}
示例#4
0
文件: lookup_sid.c 项目: gojdic/samba
bool lookup_name_smbconf(TALLOC_CTX *mem_ctx,
		 const char *full_name, int flags,
		 const char **ret_domain, const char **ret_name,
		 DOM_SID *ret_sid, enum lsa_SidType *ret_type)
{
	char *qualified_name;
	const char *p;

	/* NB. No winbindd_separator here as lookup_name needs \\' */
	if ((p = strchr_m(full_name, *lp_winbind_separator())) != NULL) {

		/* The name is already qualified with a domain. */

		if (*lp_winbind_separator() != '\\') {
			char *tmp;

			/* lookup_name() needs '\\' as a separator */

			tmp = talloc_strdup(mem_ctx, full_name);
			if (!tmp) {
				return false;
			}
			tmp[p - full_name] = '\\';
			full_name = tmp;
		}

		return lookup_name(mem_ctx, full_name, flags,
				ret_domain, ret_name,
				ret_sid, ret_type);
	}

	/* Try with our own SAM name. */
	qualified_name = talloc_asprintf(mem_ctx, "%s\\%s",
				get_global_sam_name(),
				full_name );
	if (!qualified_name) {
		return false;
	}

	if (lookup_name(mem_ctx, qualified_name, flags,
				ret_domain, ret_name,
				ret_sid, ret_type)) {
		return true;
	}
	
	/* Finally try with "Unix Users" or "Unix Group" */
	qualified_name = talloc_asprintf(mem_ctx, "%s\\%s",
				flags & LOOKUP_NAME_GROUP ?
					unix_groups_domain_name() :
					unix_users_domain_name(),
				full_name );
	if (!qualified_name) {
		return false;
	}

	return lookup_name(mem_ctx, qualified_name, flags,
				ret_domain, ret_name,
				ret_sid, ret_type);
}
示例#5
0
static int
lookup_parameter(char *module_name, char *parameter_name)
{
    char buffer[1024];

    if (module_name != NULL)
    {
        sprintf(buffer, "%s_%s", module_name, parameter_name);

        return lookup_name(buffer);
    }
    else
        return lookup_name(parameter_name);
}
示例#6
0
static char *
alg_by_ext(u_int8_t ext_type, u_int8_t id)
{
	switch (ext_type) {
	case SADB_EXT_SUPPORTED_ENCRYPT:
		return lookup_name(enc_types, id);
	case SADB_EXT_SUPPORTED_AUTH:
		return lookup_name(auth_types, id);
	case SADB_X_EXT_SUPPORTED_COMP:
		return lookup_name(comp_types, id);
	default:
		return "unknown";
	}
}
static const char *
lookup_uname(void *data, uid_t uid)
{
	struct name_cache *uname_cache = (struct name_cache *)data;
	return (lookup_name(uname_cache,
		    &lookup_uname_helper, (id_t)uid));
}
示例#8
0
文件: file.c 项目: HarryR/sanos
static struct inode *truncate_existing(struct filsys *fs, char *name, int len)
{
  struct inode *inode;
  vfs_ino_t ino;

  ino = lookup_name(fs, DFS_INODE_ROOT, name, len);
  if (ino == -1) return NULL;
  
  inode = get_inode(fs, ino);
  if (!inode) return NULL;

  if (VFS_S_ISDIR(inode->desc->mode))
  {
    release_inode(inode);
    return NULL;
  }

  if (truncate_inode(inode, 0) < 0)
  {
    release_inode(inode);
    return NULL;
  }
  inode->desc->size = 0;
  mark_inode_dirty(inode);

  return inode;
}
示例#9
0
文件: dir.c 项目: HarryR/sanos
int dfs_opendir(struct file *filp, char *name)
{
  struct filsys *fs;
  int len;
  vfs_ino_t ino;
  struct inode *inode;

  fs = (struct filsys *) filp->fs->data;
  len = strlen(name);

  ino = lookup_name(fs, DFS_INODE_ROOT, name, len);
  if (ino == -1) return -1;
  
  inode = get_inode(fs, ino);
  if (!inode) return -1;

  if (!VFS_S_ISDIR(inode->desc->mode))
  {
    release_inode(inode);
    return -1;
  }

  filp->data = inode;
  return 0;
}
示例#10
0
static char *clanlog_player(int cn,char *ptr,int *pID,int *prepeat)
{
	char name[80];
	int len,ID;

	while (isspace(*ptr)) ptr++;

	for (len=0; len<75; len++) {
		if (!*ptr || isspace(*ptr)) break;
		name[len]=*ptr++;
	}
	if (len<1 || len>70) {
		log_char(cn,LOG_SYSTEM,0,"Invalid name");
		return NULL;
	}
	name[len]=0;

	ID=lookup_name(name,NULL);
	if (!ID) { 	
		if (prepeat) *prepeat=1;
	} else {
		if (prepeat) *prepeat=0;
		if (pID) *pID=ID;		
	}

	return ptr;
}
示例#11
0
文件: except.c 项目: qiyao/xcc
static tree
get_eh_info ()
{
  /* Look for the pointer pushed in push_eh_info.  */
  tree t = lookup_name (get_identifier ("__exception_info"), 0);
  return build_indirect_ref (t, NULL_PTR);
}
示例#12
0
/**
 * Return the DNS name of the client.
 *
 * The name is statically cached so that repeated lookups are quick,
 * so there is a limit of one lookup per customer.
 *
 * If anything goes wrong, including the name->addr->name check, then
 * we just use "UNKNOWN", so you can use that value in hosts allow
 * lines.
 *
 * After translation from sockaddr to name we do a forward lookup to
 * make sure nobody is spoofing PTR records.
 **/
char *client_name(int fd)
{
	static char name_buf[100];
	static char port_buf[100];
	static int initialised;
	struct sockaddr_storage ss;
	socklen_t ss_len;

	if (initialised)
		return name_buf;

	strlcpy(name_buf, default_name, sizeof name_buf);
	initialised = 1;

	memset(&ss, 0, sizeof ss);

	if (am_server) {	/* daemon over --rsh mode */
		char *addr = client_addr(fd);
		struct addrinfo hint, *answer;
		int err;

		memset(&hint, 0, sizeof hint);

#ifdef AI_NUMERICHOST
		hint.ai_flags = AI_NUMERICHOST;
#endif
		hint.ai_socktype = SOCK_STREAM;

		if ((err = getaddrinfo(addr, NULL, &hint, &answer)) != 0) {
			rprintf(FLOG, "malformed address %s: %s\n",
			        addr, gai_strerror(err));
			return name_buf;
		}

		switch (answer->ai_family) {
		case AF_INET:
			ss_len = sizeof (struct sockaddr_in);
			memcpy(&ss, answer->ai_addr, ss_len);
			break;
#ifdef INET6
		case AF_INET6:
			ss_len = sizeof (struct sockaddr_in6);
			memcpy(&ss, answer->ai_addr, ss_len);
			break;
#endif
		default:
			exit_cleanup(RERR_SOCKETIO);
		}
		freeaddrinfo(answer);
	} else {
		ss_len = sizeof ss;
		client_sockaddr(fd, &ss, &ss_len);
	}

	if (lookup_name(fd, &ss, ss_len, name_buf, sizeof name_buf,
			port_buf, sizeof port_buf) == 0)
		check_name(fd, &ss, name_buf, sizeof name_buf);

	return name_buf;
}
示例#13
0
/* ARGSUSED1 */
static void
print_cred(struct sadb_ext *ext, struct sadb_msg *msg)
{
	struct sadb_x_cred *x_cred = (struct sadb_x_cred *)ext;
	printf("type %s",
	    lookup_name(cred_types, x_cred->sadb_x_cred_type));
}
示例#14
0
static const char *
lookup_gname(void *data, int64_t gid)
{
    struct name_cache *gname_cache = (struct name_cache *)data;
    return (lookup_name(gname_cache,
                        &lookup_gname_helper, (id_t)gid));
}
示例#15
0
文件: name.cpp 项目: antkar/syncpp
	gc::Local<const NameInfo> register_name(const std::string& str) {
		StdStringKey key(str);
		gc::Local<const NameInfo> info = lookup_name(key);
		if (!!info) return info;

		StringLoc name = gc::create<String>(str);
		return do_register_name(name);
	}
示例#16
0
/* ARGSUSED1 */
static void
print_ident(struct sadb_ext *ext, struct sadb_msg *msg)
{
	struct sadb_ident *ident = (struct sadb_ident *)ext;

	printf("type %s id %llu: %s",
	    lookup_name(identity_types, ident->sadb_ident_type),
	    ident->sadb_ident_id, (char *)(ident + 1));
}
示例#17
0
static void
print_sa(struct sadb_ext *ext, struct sadb_msg *msg)
{
	struct sadb_sa *sa = (struct sadb_sa *)ext;

	if (msg->sadb_msg_satype == SADB_X_SATYPE_IPCOMP)
		printf("cpi 0x%8.8x comp %s\n",
		    ntohl(sa->sadb_sa_spi),
		    lookup_name(comp_types, sa->sadb_sa_encrypt));
	else
		printf("spi 0x%8.8x auth %s enc %s\n",
		    ntohl(sa->sadb_sa_spi),
		    lookup_name(auth_types, sa->sadb_sa_auth),
		    lookup_name(enc_types, sa->sadb_sa_encrypt));
	printf("\t\tstate %s replay %u flags %u",
	    lookup_name(states, sa->sadb_sa_state),
	    sa->sadb_sa_replay, sa->sadb_sa_flags);
}
示例#18
0
const Waypoint &
Waypoints::check_exists_or_append(const Waypoint &waypoint)
{
  const Waypoint* found = lookup_name(waypoint.name);
  if (found && found->IsCloseTo(waypoint.location, fixed(100))) {
    return *found;
  }

  return append(waypoint);
}
示例#19
0
文件: name.cpp 项目: antkar/syncpp
	gc::Local<const NameInfo> register_name(
		const StringIterator& start_pos,
		const StringIterator& end_pos)
	{
		GCPtrStringKey key = start_pos.get_string_key(end_pos);
		gc::Local<const NameInfo> info = lookup_name(key);
		if (!!info) return info;

		StringLoc name = start_pos.get_string(end_pos);
		return do_register_name(name);
	}
示例#20
0
/* ARGSUSED1 */
void
pfkey_monitor_sa(struct sadb_msg *msg, int opts)
{
	int		 i;

	setup_extensions(msg);

	printf("%s: satype %s vers %u len %u seq %u pid %u\n",
	    lookup_name(msg_types, msg->sadb_msg_type),
	    lookup_name(sa_types, msg->sadb_msg_satype),
	    msg->sadb_msg_version, msg->sadb_msg_len,
	    msg->sadb_msg_seq,
	    msg->sadb_msg_pid);
	if (msg->sadb_msg_errno)
		printf("\terrno %u: %s\n", msg->sadb_msg_errno,
		    strerror(msg->sadb_msg_errno));
	for (i = 0; i <= SADB_EXT_MAX; i++)
		if (extensions[i])
			print_ext(extensions[i], msg);
	fflush(stdout);
}
示例#21
0
int rtmon_read_event(struct rtmon_t *rtmon) {
  struct sockaddr_nl nladdr;
  struct msghdr msg;
  struct iovec iov[2];
  struct nlmsghdr nlh;
  char buffer[65536];
  int ret;

  iov[0].iov_base = (void *)&nlh;
  iov[0].iov_len = sizeof(nlh);
  iov[1].iov_base = (void *)buffer;
  iov[1].iov_len = sizeof(buffer);

  msg.msg_name = (void *)&(nladdr);
  msg.msg_namelen = sizeof(nladdr);
  msg.msg_iov = iov;
  msg.msg_iovlen = sizeof(iov)/sizeof(iov[0]);

  ret = recvmsg(rtmon->fd, &msg, 0);

  if (ret < 0) {
    return ret;
  }

  syslog(LOG_DEBUG, "Type: %i (%s)",(nlh.nlmsg_type),lookup_name(typenames,nlh.nlmsg_type));

#define FLAG(x) if (nlh.nlmsg_flags & x) printf(" %s",#x)
  FLAG(NLM_F_REQUEST);
  FLAG(NLM_F_MULTI);
  FLAG(NLM_F_ACK);
  FLAG(NLM_F_ECHO);
  FLAG(NLM_F_REPLACE);
  FLAG(NLM_F_EXCL);
  FLAG(NLM_F_CREATE);
  FLAG(NLM_F_APPEND);
#undef FLAG

  syslog(LOG_DEBUG, "Seq : %i Pid : %i",nlh.nlmsg_seq,nlh.nlmsg_pid);

  rtmon_discover_ifaces(rtmon);
  rtmon_discover_routes(rtmon);

  if (_options.debug) {
    rtmon_print_ifaces(rtmon, 1);
    rtmon_print_routes(rtmon, 1);
  }

  rtmon_check_updates(rtmon);

  return 0;
}
示例#22
0
static void
print_proto(struct sadb_ext *ext, struct sadb_msg *msg)
{
	struct sadb_protocol *proto = (struct sadb_protocol *)ext;

	/* overloaded */
	if (msg->sadb_msg_type == SADB_X_GRPSPIS)
		printf("satype %s flags %u",
		    lookup_name(sa_types, proto->sadb_protocol_proto),
		    proto->sadb_protocol_flags);
	else
		printf("proto %u flags %u",
		    proto->sadb_protocol_proto, proto->sadb_protocol_flags);
}
示例#23
0
文件: conf-load.c 项目: jet9/robdns
int
confload_toplevel(struct ConfParse *parse, void *data, const struct CF_Child *node)
{
    struct Configuration *cfg = (struct Configuration *)data;

    if (node->token_count == 0)
        return 0;

    switch (lookup_name(node)) {
    case S_ACL:
        load_acl(cfg, parse, node);
        break;
    case S_INCLUDE:
        {
            struct CF_Token token = confparse_node_gettoken(parse, node, 1);
            char *filename;
            
            if (filename_is_absolute(token.name))
                filename = filename_combine("", token.name);
            else
                filename = filename_combine(cfg->options.directory, token.name);
            token.name = filename;
            token.name_length = (unsigned)strlen(filename);
            confload_configuration(cfg, filename, &token);
            free(filename);
        }
        break;
    case S_KEY:
        conf_load_key(cfg, parse, node);
        break;
    case S_OPTIONS:
        load_options(cfg, parse, node);
        break;

    case S_ZONE:
        conf_load_zone(cfg, parse, node);
        break;
                    
    default:
        //print_node(parse, stdout, node, 0);
        {
            struct CF_Token value = confparse_node_gettoken(parse, node, 0);
            CONF_OPTION_UNKNOWN(parse, &value);
        }
        break;
    }

    return 0;
}
示例#24
0
/* ARGSUSED1 */
static void
print_flow(struct sadb_ext *ext, struct sadb_msg *msg)
{
	struct sadb_protocol *proto = (struct sadb_protocol *)ext;
	char *dir = "unknown";

	switch (proto->sadb_protocol_direction) {
	case IPSP_DIRECTION_IN:
		dir = "in";
		break;
	case IPSP_DIRECTION_OUT:
		dir = "out";
		break;
	}
	printf("type %s direction %s",
	    lookup_name(flow_types, proto->sadb_protocol_proto), dir);
}
示例#25
0
/* convert a single name to a sid in a domain */
static NTSTATUS name_to_sid(struct winbindd_domain *domain,
			    TALLOC_CTX *mem_ctx,
			    const char *domain_name,
			    const char *name,
			    DOM_SID *sid,
			    enum lsa_SidType *type)
{
	DEBUG(10, ("Finding name %s\n", name));

	if ( !lookup_name( mem_ctx, name, LOOKUP_NAME_ALL, 
		NULL, NULL, sid, type ) )
	{
		return NT_STATUS_NONE_MAPPED;
	}

	return NT_STATUS_OK;
}
示例#26
0
static void checkBufCB( TokenType type, Info *info, void *_node )
{
    a_helpnode  *node = _node;

    if( type == TK_PLAIN_LINK || type == TK_GOOFY_LINK ) {
        if( nameBufLen <= info->u.link.topic_len ) {
            HelpMemFree( nameBuf );
            nameBuf = HelpMemAlloc( info->u.link.topic_len + 1 );
            nameBufLen = info->u.link.topic_len + 1;
        }
        memcpy( nameBuf, info->u.link.topic, info->u.link.topic_len );
        nameBuf[ info->u.link.topic_len ] = '\0';
        if( info->u.link.hfname_len == 0 ) {
            lookup_name( node, nameBuf );
        }
    }
}
示例#27
0
int ignore_cmd(int cn,char *name)
{
	int coID;

	if (!name || !*name) {
		list_ignore(cn);
		return 1;
	}

	coID=lookup_name(name,NULL);
	if (coID==0) return 0;
	if (coID==-1) { log_char(cn,LOG_SYSTEM,0,"No player by that name."); return 1; }

	ignore(cn,coID);

        return 1;
}
示例#28
0
static bool do_parse_line(
    const char *file_name, int line_number, const char *line_buffer,
    const struct config_entry *config_table, size_t config_size, bool *seen)
{
    const char *string = line_buffer;
    skip_whitespace(&string);
    if (*string == '\0'  ||  *string == '#')
        /* Empty line or comment, can just ignore. */
        return true;

    /* We'll report all errors on this line against file name and line. */
    push_error_handling();

    /* A valid definition is
     *
     *  name<opt-whitespace>=<opt-whitespace><parse><opt-whitespace>
     *
     * The optional whitespace which our parser doesn't support makes the parse
     * a lot more long winded than it otherwise ought to be. */
    char name[NAME_LENGTH];
    size_t ix = 0;
    bool ok =
        parse_name(&string, name, NAME_LENGTH)  &&
        DO_(skip_whitespace(&string))  &&
        parse_char(&string, '=')  &&
        DO_(skip_whitespace(&string))  &&
        lookup_name(name, config_table, config_size, &ix)  &&
        config_table[ix].parser(&string, config_table[ix].result)  &&
        DO_(skip_whitespace(&string))  &&
        parse_eos(&string);

    /* Report parse error. */
    char *error = pop_error_handling(!ok);
    if (!ok)
        print_error("Error parsing %s, line %d, offset %zd: %s",
            file_name, line_number, string - line_buffer, error);
    free(error);

    return ok &&
        /* Perform post parse validation. */
        TEST_OK_(!seen[ix],
            "Parameter %s repeated on line %d", name, line_number)  &&
        DO_(seen[ix] = true);
}
示例#29
0
void 
Waypoints::add_takeoff_point(const GeoPoint& location,
                             const fixed terrain_alt)
{
  // remove old one first
  const Waypoint *old_takeoff_point = lookup_name(_T("(takeoff)"));
  if (old_takeoff_point != NULL)
    erase(*old_takeoff_point);

  const Waypoint *nearest_landable = get_nearest_landable(location,
                                                          fixed(5000));
  if (!nearest_landable) {
    // now add new and update database
    Waypoint new_waypoint = generate_takeoff_point(location, terrain_alt);
    append(new_waypoint);
  }

  optimise();
}
示例#30
0
文件: file.c 项目: HarryR/sanos
static struct inode *open_existing(struct filsys *fs, char *name, int len)
{
  struct inode *inode;
  vfs_ino_t ino;

  ino = lookup_name(fs, DFS_INODE_ROOT, name, len);
  if (ino == -1) return NULL;
  
  inode = get_inode(fs, ino);
  if (!inode) return NULL;

  if (VFS_S_ISDIR(inode->desc->mode))
  {
    release_inode(inode);
    return NULL;
  }

  return inode;
}