diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2016-01-08 15:31:17 +0200 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2016-01-08 16:17:35 +0200 |
commit | 489432d354d88049afe4af54c29965d382d67f7a (patch) | |
tree | 84725496a92564824f75f0a2edd5a595411ffab2 | |
parent | 3325fed2895f079486b88c65409c73153fec306f (diff) | |
download | pies-489432d354d88049afe4af54c29965d382d67f7a.tar.gz pies-489432d354d88049afe4af54c29965d382d67f7a.tar.bz2 |
Uniformly use grecs memory management functions.
* gnulib.modules: Remove unneded modules.
* ident/ident.h: Remove xalloc.h, include errno.h
* ident/ident.c: Use standard allocation functions instead of x*
* ident/pam.c: Remove.
* ident/provider.c: Remove.
* ident/system.c: Remove.
* src/meta.c: Remove.
* src/Makefile.am: Remove meta.c
* src/progman.c: Use grecs_* allocation functions instead of x*.
(notify): Use wordsplit to expand variables within message.
Rename variables: program-name to program_name;
canonical-program-name to canonical_program_name.
* doc/pies.texi: Update.
* src/depmap.c: Use grecs_* allocation functions instead of x*.
(depmap_end): New function.
* src/diag.c (logmsg_vprintf): Use grecs_txtacc instead of obstack.
* src/pies.h (depmap_end): New proto.
Remove unused includes.
* src/acl.c: Use grecs_* allocation functions instead of x*.
* src/ctl.c: Likewise.
* src/inetd.c: Likewise.
* src/limits.c: Likewise.
* src/meta1gram.y: Likewise.
* src/meta1lex.l: Likewise.
* src/pies.c: Likewise.
* src/socket.c: Likewise.
* src/sysvinit.c: Likewise.
* src/userprivs.c: Likewise.
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | doc/pies.texi | 10 | ||||
-rw-r--r-- | gnulib.modules | 3 | ||||
-rw-r--r-- | ident/ident.c | 20 | ||||
-rw-r--r-- | ident/ident.h | 4 | ||||
-rw-r--r-- | ident/pam.c | 4 | ||||
-rw-r--r-- | ident/provider.c | 12 | ||||
-rw-r--r-- | ident/system.c | 6 | ||||
-rw-r--r-- | src/Makefile.am | 1 | ||||
-rw-r--r-- | src/acl.c | 22 | ||||
-rw-r--r-- | src/ctl.c | 48 | ||||
-rw-r--r-- | src/depmap.c | 14 | ||||
-rw-r--r-- | src/diag.c | 48 | ||||
-rw-r--r-- | src/inetd.c | 44 | ||||
-rw-r--r-- | src/limits.c | 4 | ||||
-rw-r--r-- | src/meta.c | 127 | ||||
-rw-r--r-- | src/meta1gram.y | 20 | ||||
-rw-r--r-- | src/meta1lex.l | 24 | ||||
-rw-r--r-- | src/pies.c | 28 | ||||
-rw-r--r-- | src/pies.h | 21 | ||||
-rw-r--r-- | src/progman.c | 218 | ||||
-rw-r--r-- | src/socket.c | 4 | ||||
-rw-r--r-- | src/sysvinit.c | 60 | ||||
-rw-r--r-- | src/userprivs.c | 12 |
24 files changed, 360 insertions, 395 deletions
@@ -1,6 +1,7 @@ +/ABOUT-NLS /ABOUT-NLS~ *.a *.la *.lo *.o *.tar.* diff --git a/doc/pies.texi b/doc/pies.texi index 46e1b91..7ad5008 100644 --- a/doc/pies.texi +++ b/doc/pies.texi @@ -1678,14 +1678,14 @@ Subject: ftpd exited with code 76 The table below lists all available variables and their expansions: @float Table, notification-variables @caption{Notification Variables} @multitable @columnfractions 0.5 0.5 @headitem Variable @tab Expansion -@item canonical-program-name @tab @samp{pies} -@item program-name @tab Program name of the @command{pies} binary. +@item canonical_program_name @tab @samp{pies} +@item program_name @tab Program name of the @command{pies} binary. @item package @tab Package name (@samp{Pies}). @item instance @tab Instance name (@pxref{instances}). @item version @tab Package version (@value{VERSION}). @item component @tab Name of the terminated component. @item termination @tab Termination cause (see below). @item retcode @tab Component exit code (or signal number, if exited @@ -1709,13 +1709,13 @@ versions. If @code{message} statement is not given, the following default message is used instead: @smallexample From: <> -X-Agent: $@{canonical-program-name@} ($@{package@} $@{version@}) +X-Agent: $@{canonical_program_name@} ($@{package@} $@{version@}) Subject: Component $@{component@} $@{termination@} $@{retcode@}. @end smallexample @end deffn @cindex mailer @@ -2296,21 +2296,21 @@ is used to configure @command{pies} behavior for some exit codes. # incorrectly used or misconfigured. return-code (EX_USAGE, EX_CONFIG) @{ action disable; notify "root"; message <<- EOT From: Pies <> - X-Agent: $@{canonical-program-name@} ($@{package@} $@{version@}) + X-Agent: $@{canonical_program_name@} ($@{package@} $@{version@}) Subject: Component $@{component@} disabled. Component "$@{component@}" has terminated with code $@{retcode@}, which means it encountered some configuration problem. I will not restart it automatically. Please fix its configuration and restart it manually at your earliest convenience. - To restart, run ``$@{program-name@} -R $@{component@}'' + To restart, run ``$@{program_name@} -R $@{component@}'' --- Wuff-wuff, Pies EOT; @} diff --git a/gnulib.modules b/gnulib.modules index 2612e75..9e9d255 100644 --- a/gnulib.modules +++ b/gnulib.modules @@ -6,12 +6,9 @@ c-ctype c-strcase configmake fprintftime gettext inttostr inttypes -obstack progname quotearg sysexits -xalloc -xvasprintf diff --git a/ident/ident.c b/ident/ident.c index dbf3f9b..75d51fa 100644 --- a/ident/ident.c +++ b/ident/ident.c @@ -1,8 +1,8 @@ /* This file is part of GNU Pies. - Copyright (C) 2015 Sergey Poznyakoff + Copyright (C) 2015-2016 Sergey Poznyakoff GNU Pies is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. @@ -16,16 +16,26 @@ #include "ident.h" pies_identity_t pies_identity_create (char const *user) { - pies_identity_t id = xmalloc (sizeof (*id)); - id->provider = NULL; - id->username = xstrdup (user); - id->data = NULL; + pies_identity_t id = malloc (sizeof (*id)); + if (id) + { + id->provider = NULL; + id->data = NULL; + id->username = strdup (user); + if (!id) + { + int ec = errno; + free (id); + errno = ec; + id = NULL; + } + } return id; } int pies_authenticate (pies_identity_provider_t pr, pies_identity_t id, char const *passwd) diff --git a/ident/ident.h b/ident/ident.h index 313926c..c262f58 100644 --- a/ident/ident.h +++ b/ident/ident.h @@ -1,8 +1,8 @@ /* This file is part of GNU Pies. - Copyright (C) 2015 Sergey Poznyakoff + Copyright (C) 2015-2016 Sergey Poznyakoff GNU Pies is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. @@ -12,13 +12,13 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Pies. If not, see <http://www.gnu.org/licenses/>. */ #include <config.h> -#include "xalloc.h" +#include <errno.h> #include "libpies.h" #include "grecs.h" #include "identity.h" struct pies_identity { diff --git a/ident/pam.c b/ident/pam.c index 7302242..96ac02c 100644 --- a/ident/pam.c +++ b/ident/pam.c @@ -1,8 +1,8 @@ /* This file is part of GNU Pies. - Copyright (C) 2015 Sergey Poznyakoff + Copyright (C) 2015-2016 Sergey Poznyakoff GNU Pies is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. @@ -180,13 +180,13 @@ static struct grecs_keyword pam_kw[] = { }; static int configure (struct grecs_node *node, pies_identity_provider_t provider) { int i; - struct pam_identity_provider_data *data = xcalloc (1, sizeof (*data)); + struct pam_identity_provider_data *data = grecs_calloc (1, sizeof (*data)); provider->data = data; for (i = 0; pam_kw[i].ident; i++) pam_kw[i].varptr = data; if (grecs_tree_process (node->down, pam_kw)) { //FIXME: memory leak diff --git a/ident/provider.c b/ident/provider.c index dd7fc3d..8b9f076 100644 --- a/ident/provider.c +++ b/ident/provider.c @@ -1,8 +1,8 @@ /* This file is part of GNU Pies. - Copyright (C) 2015 Sergey Poznyakoff + Copyright (C) 2015-2016 Sergey Poznyakoff GNU Pies is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. @@ -24,31 +24,31 @@ static int idmech_copy (void *a, void *b) { pies_identity_mechanism_t ma = a; pies_identity_mechanism_t mb = b; *ma = *mb; - ma->name = xstrdup (mb->name); + ma->name = grecs_strdup (mb->name); return 0; } int pies_identity_mechanism_register (pies_identity_mechanism_t mech) { int install; if (!idmech_symtab) { - idmech_symtab = grecs_symtab_create (sizeof(*mech), + idmech_symtab = grecs_symtab_create (sizeof (*mech), NULL, NULL, idmech_copy, NULL, NULL); if (!idmech_symtab) - grecs_alloc_die(); + grecs_alloc_die (); } install = 1; if (!grecs_symtab_lookup_or_install (idmech_symtab, mech, &install)) abort (); return !install; @@ -132,14 +132,14 @@ pies_config_provider (struct grecs_node *node) if (!mp) { grecs_error (&p->locus, 0, "no such mechanism"); return 1; } - prov = xcalloc (1, sizeof (*prov)); - prov->name = xstrdup (name); + prov = grecs_calloc (1, sizeof (*prov)); + prov->name = grecs_strdup (name); prov->mech = mp; prov->locus = node->locus; if (mp->configure && mp->configure (node, prov)) { grecs_error (&node->locus, 0, "provider configration failed"); diff --git a/ident/system.c b/ident/system.c index dcfe7a2..086eb85 100644 --- a/ident/system.c +++ b/ident/system.c @@ -1,8 +1,8 @@ /* This file is part of GNU Pies. - Copyright (C) 2015 Sergey Poznyakoff + Copyright (C) 2015-2016 Sergey Poznyakoff GNU Pies is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. @@ -57,13 +57,15 @@ system_authenticate (pies_identity_provider_t pr, pies_identity_t id, } } #endif if (strcmp (crypt (passwd, encrypted_pass), encrypted_pass) == 0) { - struct system_identity_data *data = xmalloc (sizeof (*data)); + struct system_identity_data *data = malloc (sizeof (*data)); + if (!data) + return -1; data->gid = pwd->pw_gid; id->data = data; return 0; } return -1; } diff --git a/src/Makefile.am b/src/Makefile.am index 01149c6..a2400fb 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -22,13 +22,12 @@ pies_SOURCES = \ ctl.c\ depmap.c\ diag.c\ inetd.c\ inetd-bi.c\ limits.c\ - meta.c\ meta1gram.y\ meta1lex.l\ pies.c\ progman.c\ socket.c\ sysdep.c\ @@ -1,8 +1,8 @@ /* This file is part of GNU Pies - Copyright (C) 2009-2013 Sergey Poznyakoff + Copyright (C) 2009-2016 Sergey Poznyakoff GNU Pies is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. @@ -108,14 +108,14 @@ acl_free_entry (void *p) free (ent); } pies_acl_t pies_acl_create (const char *name, grecs_locus_t *locus) { - pies_acl_t acl = xmalloc (sizeof (acl[0])); - acl->name = name ? xstrdup (name) : NULL; + pies_acl_t acl = grecs_malloc (sizeof (acl[0])); + acl->name = name ? grecs_strdup (name) : NULL; grecs_locus_copy (&acl->locus, locus); acl->list = grecs_list_create (); acl->list->free_entry = acl_free_entry; return acl; } @@ -128,13 +128,13 @@ pies_acl_free (pies_acl_t acl) free (acl); } static struct pies_sockaddr * create_acl_sockaddr (int family, int len) { - struct pies_sockaddr *p = xzalloc (sizeof (*p)); + struct pies_sockaddr *p = grecs_zalloc (sizeof (*p)); p->salen = len; p->sa.sa_family = family; return p; } /* allow|deny [all|authenticated|group <grp: list>|user <usr: list>] @@ -366,24 +366,24 @@ _parse_group (struct acl_entry *entry, size_t argc, grecs_value_t **argv) grecs_error (&entry->locus, 0, _("expected identity list, but found end of statement")); return 1; } if (argv[0]->type == GRECS_TYPE_STRING) { - entry->names = xcalloc (2, sizeof (entry->names[0])); - entry->names[0] = xstrdup (argv[0]->v.string); + entry->names = grecs_calloc (2, sizeof (entry->names[0])); + entry->names[0] = grecs_strdup (argv[0]->v.string); entry->names[1] = NULL; } else { size_t i; struct grecs_list_entry *ep; - entry->names = xcalloc (argv[0]->v.list->count + 1, - sizeof (entry->names[0])); + entry->names = grecs_calloc (argv[0]->v.list->count + 1, + sizeof (entry->names[0])); for (i = 0, ep = argv[0]->v.list->head; ep; ep = ep->next, ++i) - entry->names[i] = xstrdup (ep->data); + entry->names[i] = grecs_strdup (ep->data); entry->names[i] = NULL; } argc--; argv++; } return _parse_sub_acl (entry, argc, argv); @@ -401,13 +401,13 @@ _parse_acl (struct acl_entry *entry, size_t argc, grecs_value_t **argv) } int parse_acl_line (grecs_locus_t *locus, int allow, pies_acl_t acl, grecs_value_t *value) { - struct acl_entry *entry = xzalloc (sizeof (*entry)); + struct acl_entry *entry = grecs_zalloc (sizeof (*entry)); grecs_locus_copy (&entry->locus, locus); entry->allow = allow; if (value) switch (value->type) @@ -739,13 +739,13 @@ pies_acl_install (pies_acl_t acl) acl_hasher, acl_compare, acl_copy, NULL, acl_free); if (!acl_table) - xalloc_die (); + grecs_alloc_die (); } ret = grecs_symtab_lookup_or_install (acl_table, acl, &install); if (!ret) { @@ -13,13 +13,12 @@ You should have received a copy of the GNU General Public License along with GNU Pies. If not, see <http://www.gnu.org/licenses/>. */ #include "pies.h" #include "prog.h" -#include "xvasprintf.h" #include "identity.h" #include "base64.h" #include "json.h" struct control control; @@ -52,17 +51,20 @@ ctlbuf_free (struct ctlbuf *buf) free (buf->base); } static void ctlbuf_alloc (struct ctlbuf *buf, size_t s) { - while (buf->level + s >= buf->size) + size_t minsize = buf->level + s; + while (minsize >= buf->size) { if (buf->size == 0) buf->size = CTLBUFSIZE; - buf->base = x2realloc (buf->base, &buf->size); + else + buf->size *= CTLBUFSIZE; + buf->base = grecs_realloc (buf->base, buf->size); } } static void ctlbuf_write (struct ctlbuf *buf, char const *str, size_t n) { @@ -412,26 +414,28 @@ output_reset (struct output *out) static int output_set_header (struct output *out, char const *name, char const *fmt, ...) { int install = 1; struct http_header key, *ret; va_list ap; - + size_t len = 0; + key.name = (char *) name; key.value = NULL; ret = grecs_symtab_lookup_or_install (out->headers, &key, &install); if (!ret) { logmsg (LOG_ERR, _("cannot install output header: %s"), strerror (errno)); return 1; } if (!install) free (ret->value); va_start (ap, fmt); - ret->value = xvasprintf (fmt, ap); + ret->value = NULL; + grecs_vasprintf (&ret->value, &len, fmt, ap); va_end (ap); return 0; } static struct json_value * json_reply_create (void) @@ -441,19 +445,20 @@ json_reply_create (void) static void json_object_set_string (struct json_value *obj, char const *name, char const *fmt, ...) { va_list ap; - char *s; + char *s = NULL; + size_t l = 0; va_start (ap, fmt); - s = xvasprintf (fmt, ap); + grecs_vasprintf (&s, &l, fmt, ap); va_end (ap); json_object_set (obj, name, json_new_string (s)); - free (s); + grecs_free (s); } static void json_object_set_number (struct json_value *obj, char const *name, double val) { json_object_set (obj, name, json_new_number (val)); @@ -483,13 +488,13 @@ struct ctlio static struct ctlio * ctlio_create (void) { struct ctlio *io; - io = xmalloc (sizeof (*io)); + io = grecs_malloc (sizeof (*io)); input_init (&io->input); output_init (&io->output); io->state = identity_provider_list ? CTL_INITIAL_STATE : CTL_ADMIN_STATE; io->action = ACTION_CONT; ctlbuf_init (&io->obuf); return io; @@ -578,20 +583,21 @@ static void ctlio_reply (struct ctlio *io, int code, const char *fmt, ...) { io->code = code; if (fmt) { va_list ap; - char *str; - + char *str = NULL; + size_t len = 0; + va_start (ap, fmt); - str = xvasprintf (fmt, ap); + grecs_vasprintf (&str, &len, fmt, ap); va_end (ap); io->output.reply = json_error_reply_create (str); - free (str); + grecs_free (str); } else io->output.reply = json_error_reply_create (http_text (code)); } static void @@ -601,16 +607,17 @@ ctlio_print (struct ctlio *io, const char *text) } static void ctlio_printf (struct ctlio *io, const char *fmt, ...) { va_list ap; - char *str; + char *str = NULL; + size_t len = 0; va_start (ap, fmt); - str = xvasprintf (fmt, ap); + grecs_vasprintf (&str, &len, fmt, ap); va_end (ap); ctlio_print (io, str); free (str); } static void @@ -730,12 +737,19 @@ try_auth (struct prog *prog, void *data) static int do_auth (struct ctlio *io, char const *name, char const *pass) { struct grecs_list_entry *ep; pies_identity_t id = pies_identity_create (name); int new_state = CTL_INITIAL_STATE; + + if (!id) + { + logmsg (LOG_AUTH, _("%s: can't authenticate: %s"), + name, strerror (errno)); + return -1; + } for (ep = identity_provider_list->head; ep; ep = ep->next) { pies_identity_provider_t provider = ep->data; char const *pname = pies_identity_provider_name (provider); @@ -812,17 +826,17 @@ ctlio_authenticate (struct ctlio *io) { int result; char *user; char *passwd; size_t s = p - data; - user = xmalloc (s + 1); + user = grecs_malloc (s + 1); memcpy (user, data, s); user[s] = 0; - passwd = xmalloc (datalen - s); + passwd = grecs_malloc (datalen - s); memcpy (passwd, p + 1, datalen - s - 1); passwd[datalen - s - 1] = 0; free(data); result = do_auth (io, user, passwd); diff --git a/src/depmap.c b/src/depmap.c index ac02fdc..e4533e8 100644 --- a/src/depmap.c +++ b/src/depmap.c @@ -1,8 +1,8 @@ /* This file is part of GNU Pies. - Copyright (C) 2008-2013 Sergey Poznyakoff + Copyright (C) 2008-2013, 2016 Sergey Poznyakoff GNU Pies is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. @@ -87,14 +87,14 @@ struct pies_depmap }; pies_depmap_t depmap_alloc (size_t count) { size_t size = (count + BITS_PER_WORD - 1) / BITS_PER_WORD; - pies_depmap_t dmap = xzalloc (sizeof (*dmap) - 1 - + count * size * sizeof (unsigned)); + pies_depmap_t dmap = grecs_zalloc (sizeof (*dmap) - 1 + + count * size * sizeof (unsigned)); dmap->nrows = count; dmap->rowlen = size; return dmap; } pies_depmap_t @@ -150,13 +150,19 @@ depmap_next (pies_depmap_t dmap, pies_depmap_pos_t pos) } size_t depmap_first (pies_depmap_t dmap, enum pies_depmap_direction dir, size_t coord, pies_depmap_pos_t *ppos) { - pies_depmap_pos_t pos = xmalloc (sizeof *pos); + pies_depmap_pos_t pos = grecs_malloc (sizeof *pos); *ppos = pos; pos->dir = dir; pos->coord[!pos->dir] = coord; pos->coord[pos->dir] = -1; return depmap_next (dmap, pos); } + +void +depmap_end (pies_depmap_pos_t pos) +{ + grecs_free (pos); +} @@ -12,13 +12,12 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Pies. If not, see <http://www.gnu.org/licenses/>. */ #include "pies.h" -#include "xvasprintf.h" unsigned debug_level; int source_info_option; int diag_output = DIAG_TO_STDERR; void @@ -100,45 +99,48 @@ debug_msg (const char *fmt, ...) va_start (ap, fmt); vlogmsg (LOG_DEBUG, fmt, ap); va_end (ap); } -static struct obstack log_stk; -static int log_stk_init; void logmsg_vprintf (int prio, const char *fmt, va_list ap) { - char *str, *p; - - str = xvasprintf (fmt, ap); + char *p, *t, *str; + static char *buf = NULL; + static size_t len = 0; + static struct grecs_txtacc *log_acc; - if (!log_stk_init) + if (grecs_vasprintf (&buf, &len, fmt, ap)) { - obstack_init (&log_stk); - log_stk_init = 1; + logmsg (LOG_CRIT, _("out of memory trying to log a message")); + return; } - for (p = str; *p; ) + if (!log_acc) + log_acc = grecs_txtacc_create (); + + str = buf; + + while (str) { - size_t len = strcspn (p, "\n"); - if (len) - obstack_grow (&log_stk, p, len); - p += len; - if (*p) + p = strchr (str, '\n'); + if (p) { - char *msg; - - obstack_1grow (&log_stk, 0); - msg = obstack_finish (&log_stk); - logmsg (prio, "%s", msg); - obstack_free (&log_stk, msg); - p++; + *p++ = 0; + if (!*p) + p = NULL; + grecs_txtacc_grow_char (log_acc, 0); + t = grecs_txtacc_finish (log_acc, 0); + logmsg (prio, "%s", t); + grecs_txtacc_free_string (log_acc, t); } + else + grecs_txtacc_grow_string (log_acc, str); + str = p; } - free (str); } void logmsg_printf (int prio, const char *fmt, ...) { va_list ap; diff --git a/src/inetd.c b/src/inetd.c index 4a55ad5..3eb4470 100644 --- a/src/inetd.c +++ b/src/inetd.c @@ -61,19 +61,19 @@ static char * mktag (const char *address, const char *service) { char *str; if (address) { - str = xmalloc (strlen (address) + 1 + strlen (service) + 1); + str = grecs_malloc (strlen (address) + 1 + strlen (service) + 1); strcpy (str, address); strcat (str, ":"); strcat (str, service); } else - str = xstrdup (service); + str = grecs_strdup (service); return str; } static int inetd_conf_file (const char *file) @@ -134,13 +134,13 @@ inetd_conf_file (const char *file) free (dfl_address); if (len == 2 && ws.ws_wordv[IFLD_SERVICE][0] == '*') dfl_address = NULL; else { - dfl_address = xmalloc (len); + dfl_address = grecs_malloc (len); memcpy (dfl_address, ws.ws_wordv[IFLD_SERVICE], len-1); dfl_address[len-1] = 0; } continue; } } @@ -190,25 +190,31 @@ inetd_conf_file (const char *file) continue; } url = NULL; } else { + char *s = NULL; + size_t l = 0; + int rc; + /* Create URL from protocol and service fields. */ - str = xasprintf ("inet+%s://%s:%s", - ws.ws_wordv[IFLD_PROTOCOL], - address ? address : "0.0.0.0", - service); - if (pies_url_create (&url, str)) + if (grecs_asprintf (&s, &l, "inet+%s://%s:%s", + ws.ws_wordv[IFLD_PROTOCOL], + address ? address : "0.0.0.0", + service)) + grecs_alloc_die (); + rc = pies_url_create (&url, s); + free (s); + if (rc) { /* FIXME: Better error message */ logmsg (LOG_ERR, "%s:%lu: %s", file, line_no, _("invalid socket address")); continue; } - free (str); } /* Parse wait/nowait field */ str = strchr (ws.ws_wordv[IFLD_WAIT], '.'); if (str) { @@ -271,37 +277,37 @@ inetd_conf_file (const char *file) comp->flags = builtin->flags; } else comp->flags = flags; if (ISCF_TCPMUX (comp->flags)) comp->tcpmux = mktag (address, "tcpmux"); - comp->service = xstrdup (service); - comp->privs.user = xstrdup (user); /* FIXME: memory leak */ + comp->service = grecs_strdup (service); + comp->privs.user = grecs_strdup (user); /* FIXME: memory leak */ if (group) { comp->privs.groups = grecs_list_create (); comp->privs.groups->free_entry = listel_dispose; - grecs_list_append (comp->privs.groups, xstrdup (group)); + grecs_list_append (comp->privs.groups, grecs_strdup (group)); } - comp->program = xstrdup (ws.ws_wordv[IFLD_SERVER_PATH]); + comp->program = grecs_strdup (ws.ws_wordv[IFLD_SERVER_PATH]); if (ws.ws_wordc > IFLD_MIN_COUNT) { size_t i, j; comp->argc = ws.ws_wordc - IFLD_MIN_COUNT; - comp->argv = xcalloc (comp->argc + 1, sizeof (comp->argv[0])); + comp->argv = grecs_calloc (comp->argc + 1, sizeof (comp->argv[0])); for (i = IFLD_SERVER_ARGS, j = 0; i < ws.ws_wordc; i++, j++) - comp->argv[j] = xstrdup (ws.ws_wordv[i]); + comp->argv[j] = grecs_strdup (ws.ws_wordv[i]); } else { comp->argc = 1; - comp->argv = xcalloc (comp->argc + 1, sizeof (comp->argv[0])); - comp->argv[0] = xstrdup (comp->program); + comp->argv = grecs_calloc (comp->argc + 1, sizeof (comp->argv[0])); + comp->argv[0] = grecs_strdup (comp->program); } if (progman_lookup_component (comp->tag) == NULL) register_prog (comp); } @@ -338,13 +344,13 @@ inetd_conf_dir (const char *name) namelen = strlen (name); namebufsize = namelen; if (name[namelen-1] != '/') namebufsize++; namebufsize += NAME_INIT_ALLOC; - namebuf = xmalloc (namebufsize); + namebuf = grecs_malloc (namebufsize); memcpy (namebuf, name, namelen); if (name[namelen-1] != '/') namebuf[namelen++] = 0; while ((ent = readdir (dir))) { @@ -359,13 +365,13 @@ inetd_conf_dir (const char *name) else if (S_ISREG (st.st_mode) || S_ISLNK (st.st_mode)) { size_t len = strlen (ent->d_name); if (namelen + len >= namebufsize) { namebufsize = namelen + len + 1; - namebuf = xrealloc (namebuf, namebufsize); + namebuf = grecs_realloc (namebuf, namebufsize); } strcpy (namebuf + namelen, ent->d_name); errs |= inetd_conf_file (namebuf); } } free (namebuf); diff --git a/src/limits.c b/src/limits.c index 6dadd6c..a2c8ad9 100644 --- a/src/limits.c +++ b/src/limits.c @@ -1,8 +1,8 @@ /* This file is part of GNU Pies. - Copyright (C) 2008, 2009, 2010, 2013 Sergey Poznyakoff + Copyright (C) 2008-2010, 2013, 2016 Sergey Poznyakoff GNU Pies is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. @@ -191,13 +191,13 @@ getlimit (char **ptr, rlim_t *rlim, int mul) (negative = high priority) */ int parse_limits (limits_record_t *plrec, char *str, char **endp) { int c; - struct limits_rec *lrec = xmalloc (sizeof (*lrec)); + struct limits_rec *lrec = grecs_malloc (sizeof (*lrec)); *plrec = lrec; lrec->set = 0; while ((c = *str++)) { if (c == ' ' || c == '\t') continue; diff --git a/src/meta.c b/src/meta.c deleted file mode 100644 index fcd7f8b..0000000 --- a/src/meta.c +++ /dev/null @@ -1,127 +0,0 @@ -/* This file is part of GNU Pies. - Copyright (C) 2008, 2009, 2010, 2013 Sergey Poznyakoff - - GNU Pies is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3, or (at your opt |