Skip to content

Commit

Permalink
Finished copying the MAC prefix file to honeyd added
Browse files Browse the repository at this point in the history
CLI Path override	#51
  • Loading branch information
Rami Rashid authored and Rami Rashid committed Jan 7, 2013
1 parent 5b88581 commit 023459e
Show file tree
Hide file tree
Showing 33 changed files with 100 additions and 342 deletions.
32 changes: 10 additions & 22 deletions analyze.c
Expand Up @@ -109,10 +109,9 @@ port_key_extract(struct keycount *keycount, void **pkey, size_t *pkeylen)
{
if ((*pkey = calloc(1, sizeof(uint16_t))) == NULL)
{
syslog(LOG_ERR, "%s: calloc");
syslog(LOG_ERR, "calloc");
exit(EXIT_FAILURE);
}
//err(1, "%s: calloc");
memcpy(*pkey, keycount->key, sizeof(uint16_t));
*pkeylen = sizeof(uint16_t);
}
Expand All @@ -130,10 +129,9 @@ spammer_key_extract(struct keycount *keycount, void **pkey, size_t *pkeylen)
{
if ((*pkey = calloc(1, keycount->keylen)) == NULL)
{
syslog(LOG_ERR, "%s: calloc");
syslog(LOG_ERR, "calloc");
exit(EXIT_FAILURE);
}
//err(1, "%s: calloc");
memcpy(*pkey, keycount->key, keycount->keylen);
*pkeylen = keycount->keylen;
}
Expand All @@ -151,10 +149,9 @@ country_key_extract(struct keycount *keycount, void **pkey, size_t *pkeylen)
{
if ((*pkey = calloc(1, keycount->keylen)) == NULL)
{
syslog(LOG_ERR, "%s: calloc, failed to allocate the pkey");
syslog(LOG_ERR, "calloc, failed to allocate the pkey");
exit(EXIT_FAILURE);
}
//err(1, "%s: calloc");
memcpy(*pkey, keycount->key, keycount->keylen);
*pkeylen = keycount->keylen;
}
Expand Down Expand Up @@ -192,10 +189,9 @@ aux_create(void)

if ((aux = calloc(1, sizeof(struct aux))) == NULL)
{
syslog(LOG_ERR, "%s: calloc failed to allocate aux");
syslog(LOG_ERR, "%s: calloc failed to allocate aux",__func__);
exit(EXIT_FAILURE);
}
//err(1, "%s: calloc");
SPLAY_INIT(&aux->tree);
TAILQ_INIT(&aux->queue);
aux->limit = 100000; /* Make better at some point */
Expand Down Expand Up @@ -245,10 +241,9 @@ aux_enter(struct aux *aux, uint32_t value)
} else {
if ((key = calloc(1, sizeof(struct auxkey))) == NULL)
{
syslog(LOG_ERR, "%s: calloc failed to allocate key");
syslog(LOG_ERR, "%s: calloc failed to allocate key",__func__);
exit(EXIT_FAILURE);
}
//err(1, "%s: calloc");
}
key->value = tmp.value;

Expand All @@ -267,10 +262,9 @@ os_key_extract(struct keycount *keycount, void **pkey, size_t *pkeylen)

if ((*pkey = strdup(key)) == NULL)
{
syslog(LOG_ERR, "%s: strdup");
syslog(LOG_ERR, "%s: strdup",__func__);
exit(EXIT_FAILURE);
}
//err(1, "%s: strdup");
*pkeylen = strlen(key) + 1;
}

Expand Down Expand Up @@ -439,7 +433,6 @@ analyze_country_enter(const struct addr *addr, const struct addr *dst)
syslog(LOG_ERR, "%s: failed to calloc state", __func__);
exit(EXIT_FAILURE);
}
//err(1, "%s: calloc", __func__);

state->src = *addr;
state->dst = *dst;
Expand Down Expand Up @@ -587,7 +580,6 @@ report_create(struct kctree *kctree,
syslog(LOG_ERR, "%s: calloc", __func__);
exit(EXIT_FAILURE);
}
//err(1, "%s: calloc", __func__);

SPLAY_INIT(tree);

Expand All @@ -602,10 +594,9 @@ report_create(struct kctree *kctree,
report = calloc(1, sizeof(struct report));
if (report == NULL)
{
syslog(LOG_ERR, "%s: calloc");
syslog(LOG_ERR, "%s: calloc",__func__);
exit(EXIT_FAILURE);
}
//err(1, "%s: calloc");
report->key = tmp.key;
report->keylen = tmp.keylen;
SPLAY_INSERT(reporttree, tree, report);
Expand Down Expand Up @@ -683,9 +674,8 @@ analyze_print_port_report()

if ((filtered_tree = calloc(1, sizeof(struct reporttree))) == NULL)
{
syslog(LOG_ERR, "%s: calloc failed to allocate filtered_tree");
syslog(LOG_ERR, "%s: calloc failed to allocate filtered_tree",__func__);
exit(EXIT_FAILURE);
//err(1, "%s: calloc");
}
SPLAY_INIT(filtered_tree);

Expand Down Expand Up @@ -737,10 +727,9 @@ analyze_print_spammer_report()

if ((filtered_tree = calloc(1, sizeof(struct reporttree))) == NULL)
{
syslog(LOG_ERR, "%s: calloc failed to allocate filtered_tree" );
syslog(LOG_ERR, "%s: calloc failed to allocate filtered_tree",__func__ );
exit(EXIT_FAILURE);
}
//err(1, "%s: calloc");
SPLAY_INIT(filtered_tree);

/*
Expand Down Expand Up @@ -791,10 +780,9 @@ analyze_print_country_report()

if ((filtered_tree = calloc(1, sizeof(struct reporttree))) == NULL)
{
syslog(LOG_ERR, "%s: calloc failed to initialize failed tree");
syslog(LOG_ERR, "%s: calloc failed to initialize failed tree",__func__);
exit(EXIT_FAILURE);
}
//err(1, "%s: calloc");
SPLAY_INIT(filtered_tree);

/*
Expand Down
1 change: 0 additions & 1 deletion arp.c
Expand Up @@ -243,7 +243,6 @@ arp_find(struct addr *addr)
} else {
syslog(LOG_ERR, "%s: lookup for unsupported address type", __func__);
exit(EXIT_FAILURE);
//errx(1, "%s: lookup for unsupported address type", __func__);
}

return (res);
Expand Down
11 changes: 1 addition & 10 deletions command.c
Expand Up @@ -396,23 +396,20 @@ cmd_fork(struct tuple *hdr, struct command *cmd, struct template *tmpl,
TRACE_RESET(pair[0], close(pair[0]));
if (dup2(pair[1], fileno(stdout)) == -1)
{
syslog(LOG_ERR, "dup2 failed to copy descriptor");
syslog(LOG_ERR, "%s: dup2 failed to copy descriptor",__func__);
exit(EXIT_FAILURE);
}
//err(1, "%s: dup2", __func__);
if (dup2(pair[1], fileno(stdin)) == -1)
{
syslog(LOG_ERR, "%s: dup2", __func__);
exit(EXIT_FAILURE);
}
//err(1, "%s: dup2", __func__);
TRACE_RESET(pair[0], close(perr[0]));
if (dup2(perr[1], fileno(stderr)) == -1)
{
syslog(LOG_ERR, "%s: dup2", __func__);
exit(EXIT_FAILURE);
}
//err(1, "%s: dup2", __func__);

TRACE_RESET(pair[1], close(pair[1]));
TRACE_RESET(perr[1], close(perr[1]));
Expand All @@ -424,7 +421,6 @@ cmd_fork(struct tuple *hdr, struct command *cmd, struct template *tmpl,
syslog(LOG_ERR, "%s: execv(%s)", __func__, execcmd);
exit(EXIT_FAILURE);
}
//err(1, "%s: execv(%s)", __func__, execcmd);

/* NOT REACHED */
}
Expand Down Expand Up @@ -552,21 +548,18 @@ cmd_subsystem(struct template *tmpl, struct subsystem *sub,
syslog(LOG_ERR, "%s: dup(%d): no magic failed to duplicate the pair", __func__, pair[1]);
exit(EXIT_FAILURE);
}
//err(1, "%s: dup(%d): no magic", __func__, pair[1]);
snprintf(magic_buf, sizeof(magic_buf), "%d", magic_fd);
setenv(SUBSYSTEM_MAGICFD, magic_buf, 1);
if (dup2(fileno(stderr), fileno(stdout)) == -1)
{
syslog(LOG_ERR, "%s: dup2", __func__);
exit(EXIT_FAILURE);
}
//err(1, "%s: dup2", __func__);
if (dup2(fileno(stderr), fileno(stdin)) == -1)
{
syslog(LOG_ERR, "%s: dup2", __func__);
exit(EXIT_FAILURE);
}
//err(1, "%s: dup2", __func__);

TRACE_RESET(pair[1], close(pair[1]));

Expand All @@ -578,14 +571,12 @@ cmd_subsystem(struct template *tmpl, struct subsystem *sub,
syslog(LOG_ERR, "%s: setenv", __func__);
exit(EXIT_FAILURE);
}
//err(1, "%s: setenv", __func__);

if (execv(execcmd, argv) == -1)
{
syslog(LOG_ERR, "%s: execv(%s)", __func__, execcmd);
exit(EXIT_FAILURE);
}
//err(1, "%s: execv(%s)", __func__, execcmd);

/* NOT REACHED */
}
Expand Down
34 changes: 6 additions & 28 deletions config.c
Expand Up @@ -133,15 +133,12 @@ config_read(char *config)
syslog(LOG_ERR, "fopen(%s)",config);
exit(EXIT_FAILURE);
}
//err(1, "fopen(%s)", config);
if (parse_configuration(fp, config) == -1 &&
!honeyd_ignore_parse_errors)
{
syslog(LOG_ERR, "parsing configuration file failed");
syslog(LOG_ERR, "%s: parsing configuration file failed",__func__);
exit(EXIT_FAILURE);
}
//errx(1, "parsing configuration file failed");
//use this to test whether the error goes to the syslog or not
fclose(fp);
}

Expand Down Expand Up @@ -201,10 +198,9 @@ template_list_glob(struct evbuffer *buffer, const char *pattern)

if ((tmp = evbuffer_new()) == NULL)
{
syslog(LOG_ERR, "%s: malloc");
syslog(LOG_ERR, "%s: malloc",__func__);
exit(EXIT_FAILURE);
}
//err(1, "%s: malloc");

SPLAY_FOREACH(tmpl, templtree, &templates) {
/* Ignore it if it does not match */
Expand Down Expand Up @@ -282,7 +278,6 @@ template_create(const char *name)
syslog(LOG_ERR, "%s: calloc",__func__);
exit(EXIT_FAILURE);
}
//err(1, "%s: calloc", __func__);

tmpl->name = strdup(name);

Expand Down Expand Up @@ -434,7 +429,6 @@ port_action_clone(struct action *dst, const struct action *src)
syslog(LOG_ERR, "%s: strdup",__func__);
exit(EXIT_FAILURE);
}
//err(1, "%s: strdup", __func__);
}

if (src->aitop != NULL) {
Expand All @@ -450,15 +444,13 @@ port_action_clone(struct action *dst, const struct action *src)
syslog(LOG_ERR, "%s: getnameinfo", __func__);
exit(EXIT_FAILURE);
}
//err(1, "%s: getnameinfo", __func__);
nport = atoi(port);
dst->aitop = cmd_proxy_getinfo(addr, ai->ai_socktype, nport);
if (dst->aitop == NULL)
{
syslog(LOG_ERR, "%s: cmd_proxy_getinfo failed", __func__);
exit(EXIT_FAILURE);
}
//errx(1, "%s: cmd_proxy_getinfo failed", __func__);
}
}

Expand Down Expand Up @@ -533,7 +525,6 @@ port_insert(struct template *tmpl, int proto, int number,
syslog(LOG_ERR, "%s: calloc", __func__);
exit(EXIT_FAILURE);
}
//err(1, "%s: calloc", __func__);

TAILQ_INIT(&port->pending);
port->sub = NULL;
Expand Down Expand Up @@ -583,7 +574,6 @@ template_insert_subsystem(struct template *tmpl, struct subsystem *sub)
syslog(LOG_ERR, "%s: malloc", __func__);
exit(EXIT_FAILURE);
}
//err(1, "%s: malloc", __func__);

container->sub = sub;
TAILQ_INSERT_TAIL(&tmpl->subsystems, container, next);
Expand All @@ -603,11 +593,9 @@ template_remove_subsystem(struct template *tmpl, struct subsystem *sub)

if (container == NULL)
{
syslog(LOG_ERR, "%s: could not remove subsystem %p from %s", sub, tmpl->name);
syslog(LOG_ERR, "%s: could not remove subsystem %p from %s",__func__, sub, tmpl->name);
exit(EXIT_FAILURE);
}
//errx(1, "%s: could not remove subsystem %p from %s",
// sub, tmpl->name);

TAILQ_REMOVE(&tmpl->subsystems, container, next);

Expand All @@ -623,10 +611,9 @@ template_post_arp(struct template *tmpl, struct addr *ipaddr)
req = arp_new(tmpl->inter, NULL, NULL, ipaddr, tmpl->ethernet_addr);
if (req == NULL)
{
syslog(LOG_ERR, "%s: cannot create arp entry");
syslog(LOG_ERR, "%s: cannot create arp entry",__func__);
exit(EXIT_FAILURE);
}
//errx(1, "%s: cannot create arp entry");

req->flags |= ARP_INTERNAL;
req->owner = tmpl;
Expand Down Expand Up @@ -781,14 +768,12 @@ template_subsystem(struct template *tmpl, char *subsystem, int flags)
syslog(LOG_ERR, "%s: calloc", __func__);
exit(EXIT_FAILURE);
}
//err(1, "%s: calloc", __func__);

if ((sub->cmdstring = strdup(subsystem)) == NULL)
{
syslog(LOG_ERR, "%s: strdup", __func__);
exit(EXIT_FAILURE);
}
//err(1, "%s: strdup", __func__);

/* Initializes subsystem data structures */
TAILQ_INIT(&sub->ports);
Expand Down Expand Up @@ -849,10 +834,9 @@ template_subsystem_list_glob(struct evbuffer *buffer, const char *pattern)

if ((tmp = evbuffer_new()) == NULL)
{
syslog(LOG_ERR, "%s: malloc");
syslog(LOG_ERR, "%s: malloc",__func__);
exit(EXIT_FAILURE);
}
//err(1, "%s: malloc");

TAILQ_FOREACH(sub, &subsystems, next) {
/* Ignore it if it does not match */
Expand Down Expand Up @@ -922,7 +906,6 @@ template_insert_dynamic(struct template *tmpl, struct template *child,
syslog(LOG_ERR, "%s: calloc", __func__);
exit(EXIT_FAILURE);
}
//err(1, "%s: calloc", __func__);

if (condition != NULL)
*cond = *condition;
Expand All @@ -949,7 +932,6 @@ template_insert_dynamic(struct template *tmpl, struct template *child,
syslog(LOG_ERR, "%s: malloc", __func__);
exit(EXIT_FAILURE);
}
//err(1, "%s: malloc", __func__);

memcpy(cond->match_arg, condition->match_arg, cond->match_arglen);

Expand All @@ -969,7 +951,6 @@ template_get_dhcp_address(struct addr *addr)
syslog(LOG_ERR, "%s: out of temporary IP addresses", __func__);
exit(EXIT_FAILURE);
}
//errx(1, "%s: out of temporary IP addresses", __func__);

return (addr_aton(address, addr));
}
Expand Down Expand Up @@ -1012,11 +993,9 @@ template_subsystem_start(struct template *tmpl, struct subsystem *sub)
argv[2] = line;
if (cmd_subsystem(tmpl, sub, "/bin/sh", argv) == -1)
{
syslog(LOG_ERR, "%s: can not start subsystem \"%s\" for %s",sub->cmdstring,name);
syslog(LOG_ERR, "%s: can not start subsystem \"%s\" for %s",__func__ ,sub->cmdstring, name);
exit(EXIT_FAILURE);
}
//errx(1, "%s: can not start subsystem \"%s\" for %s",
// sub->cmdstring, name);

}

Expand Down Expand Up @@ -1126,7 +1105,6 @@ template_test_parse_error(char *line, struct evbuffer *evbuf)
p[off - 1] = '\0';
syslog(LOG_ERR, "parse_line \"%s\" failed: %s",line,p);
exit(EXIT_FAILURE);
//errx(1, "parse_line \"%s\" failed: %s", line, p);
}

#define MAKE_CONFIG(x) do { \
Expand Down

0 comments on commit 023459e

Please sign in to comment.