示例#1
0
void		exec_get_request(char *entry, int sock)
{
	char		**cmd;
	char		*ret;
	int			fd;
	long		size;

	cmd = split_entry(entry);
	if ((fd = open(cmd[1], O_RDONLY)) == -1)
	{
		ret = ft_strjoin_tw("\033[31mERROR\033[0m	get server: can't open "
						, cmd[1], "\n");
		send_ret(ret, sock);
	}
	else
	{
		ret = ft_strdup("OK");
		send_ret(ret, sock);
		size = get_file_size(fd);
		exec_get_command(sock, fd, size);
		close(fd);
	}
	free(ret);
	ft_tabdel(&cmd);
}
示例#2
0
void
IpVerify::fill_table(PermTypeEntry * pentry, char * list, bool allow)
{
    assert(pentry);

	NetStringList * whichHostList = new NetStringList();
    UserHash_t * whichUserHash = new UserHash_t(1024, compute_host_hash);

    StringList slist(list);
	char *entry, * host, * user;
	slist.rewind();
	while ( (entry=slist.next()) ) {
		if (!*entry) {
			// empty string?
			slist.deleteCurrent();
			continue;
		}
		split_entry(entry, &host, &user);
		ASSERT( host );
		ASSERT( user );

			// If this is a hostname, get all IP addresses for it and
			// add them to the list.  This ensures that if we are given
			// a cname, we do the right thing later when trying to match
			// this record with the official hostname.
		StringList host_addrs;
		ExpandHostAddresses(host,&host_addrs);
		host_addrs.rewind();

		char const *host_addr;
		while( (host_addr=host_addrs.next()) ) {
			MyString hostString(host_addr);
			StringList * userList = 0;
				// add user to user hash, host to host list
			if (whichUserHash->lookup(hostString, userList) == -1) {
				whichUserHash->insert(hostString, new StringList(user)); 
				whichHostList->append(hostString.Value());
			}
			else {
				userList->append(user);
			}
		}

		free(host);
		free(user);
	}

    if (allow) {
        pentry->allow_hosts = whichHostList;
        pentry->allow_users  = whichUserHash;
    }
    else {
        pentry->deny_hosts = whichHostList;
        pentry->deny_users = whichUserHash;
    }
}
示例#3
0
int
read_tcapbuf(char *buf, Terminfo * info, char *Errbuf, int Errbuflen)
{
   errbuf = Errbuf;
   errbuflen = Errbuflen;
   errcode = 0;

   split_entry(info, buf);

   return 0;
}
示例#4
0
/*
 * Scans through the index range and splits/truncates entries that overlap
 * with the one indexed by keep_idx. Returns the total lifetime of the symbols
 * found to overlap.
 * Returns ULONG_MAX on error.
 */
static unsigned long long eliminate_overlaps(int start_idx, int end_idx,
					 int keep_idx)
{
	unsigned long long retval;
	struct jitentry const * keep = entries_address_ascending[keep_idx];
	struct jitentry * e;
	unsigned long long start_addr_keep = keep->vma;
	unsigned long long end_addr_keep = keep->vma + keep->code_size;
	unsigned long long start_addr_entry, end_addr_entry;
	int i;
	unsigned long long min_start = keep->life_start;
	unsigned long long max_end = keep->life_end;

	for (i = start_idx; i <= end_idx; i++) {
		if (i == keep_idx)
			continue;
		e = entries_address_ascending[i];
		start_addr_entry = e->vma;
		end_addr_entry = e->vma + e->code_size;
		if (debug) {
			if (!(start_addr_entry <= end_addr_entry)) {
				verbprintf(debug, "assert failed:"
					   " start_addr_entry <="
					   " end_addr_entry\n");
				retval = ULONG_MAX;
				goto out;
			}
			if (!(start_addr_keep <= end_addr_keep)) {
				verbprintf(debug, "assert failed: "
					   "start_addr_keep <="
					   " end_addr_keep\n");
				retval = ULONG_MAX;
				goto out;
			}
		}
		if (start_addr_entry < end_addr_keep &&
		    end_addr_entry > start_addr_keep) {
			if (e->life_start < min_start)
				min_start = e->life_start;
			if (e->life_end > max_end)
				max_end = e->life_end;
			split_entry(e, keep);
		}
	}
	retval = max_end - min_start;
out:
	return retval;
}
示例#5
0
void		exec_put_request(char *entry, int sock)
{
	char		**cmd;
	char		*ret;
	int			fd;

	cmd = split_entry(entry);
	if ((fd = open(cmd[1], O_WRONLY | O_TRUNC | O_CREAT, 0644)) == -1)
	{
		ret = ft_strjoin_tw("\033[31mERROR\033[0m	get server: can't create "
						, cmd[1], "\n");
		send_ret(ret, sock);
	}
	else
	{
		ret = ft_strdup("OK");
		send_ret(ret, sock);
		exec_put_command(sock, fd);
		close(fd);
	}
	free(ret);
	ft_tabdel(&cmd);
}
示例#6
0
int
read_tcap(int Fnum, char **Fnames, int tnum, Terminfo * infos, char *Errbuf, int Errbuflen)
{
    int i, r = 0;

    char buf[TBUFSIZE];

    Terminfo *info;

    fnum = Fnum;
    fnames = Fnames;
    errbuf = Errbuf;
    errbuflen = Errbuflen;
    errcode = 0;

    for (i = 0; i < tnum; ++i)
    {
        info = infos + i;

        match_count = 0;
        r = tgetent(buf, info->name, 0);
        if (r < 0 && errcode)
            return -1;

        if (!r || !match_count)
        {
            snprintf(Errbuf, Errbuflen, "no termcap entry for terminal '%s'", info->name);
            return -1;
        }

        split_entry(info, buf);

    }

    return 0;
}