From 489432d354d88049afe4af54c29965d382d67f7a Mon Sep 17 00:00:00 2001 From: Sergey Poznyakoff Date: Fri, 8 Jan 2016 15:31:17 +0200 Subject: 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. --- ident/ident.c | 20 +++++++++++++++----- ident/ident.h | 4 ++-- ident/pam.c | 4 ++-- ident/provider.c | 12 ++++++------ ident/system.c | 6 ++++-- 5 files changed, 29 insertions(+), 17 deletions(-) (limited to 'ident') diff --git a/ident/ident.c b/ident/ident.c index dbf3f9b..75d51fa 100644 --- a/ident/ident.c +++ b/ident/ident.c @@ -1,5 +1,5 @@ /* 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 @@ -19,10 +19,20 @@ 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; } diff --git a/ident/ident.h b/ident/ident.h index 313926c..c262f58 100644 --- a/ident/ident.h +++ b/ident/ident.h @@ -1,5 +1,5 @@ /* 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 @@ -15,7 +15,7 @@ along with GNU Pies. If not, see . */ #include -#include "xalloc.h" +#include #include "libpies.h" #include "grecs.h" #include "identity.h" diff --git a/ident/pam.c b/ident/pam.c index 7302242..96ac02c 100644 --- a/ident/pam.c +++ b/ident/pam.c @@ -1,5 +1,5 @@ /* 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 @@ -183,7 +183,7 @@ 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; diff --git a/ident/provider.c b/ident/provider.c index dd7fc3d..8b9f076 100644 --- a/ident/provider.c +++ b/ident/provider.c @@ -1,5 +1,5 @@ /* 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 @@ -27,7 +27,7 @@ idmech_copy (void *a, void *b) pies_identity_mechanism_t mb = b; *ma = *mb; - ma->name = xstrdup (mb->name); + ma->name = grecs_strdup (mb->name); return 0; } @@ -38,14 +38,14 @@ pies_identity_mechanism_register (pies_identity_mechanism_t mech) 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; @@ -135,8 +135,8 @@ pies_config_provider (struct grecs_node *node) 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; diff --git a/ident/system.c b/ident/system.c index dcfe7a2..086eb85 100644 --- a/ident/system.c +++ b/ident/system.c @@ -1,5 +1,5 @@ /* 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 @@ -60,7 +60,9 @@ system_authenticate (pies_identity_provider_t pr, pies_identity_t id, 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; -- cgit v1.2.1