openpam_free_envlist.c revision 296373
1295373Sdteske/*-
2295373Sdteske * Copyright (c) 2005-2011 Dag-Erling Sm��rgrav
3295373Sdteske * All rights reserved.
4295373Sdteske *
5295373Sdteske * Redistribution and use in source and binary forms, with or without
6295373Sdteske * modification, are permitted provided that the following conditions
7295373Sdteske * are met:
8295373Sdteske * 1. Redistributions of source code must retain the above copyright
9295373Sdteske *    notice, this list of conditions and the following disclaimer.
10295373Sdteske * 2. Redistributions in binary form must reproduce the above copyright
11295373Sdteske *    notice, this list of conditions and the following disclaimer in the
12295373Sdteske *    documentation and/or other materials provided with the distribution.
13295373Sdteske * 3. The name of the author may not be used to endorse or promote products
14295373Sdteske *    derived from this software without specific prior written permission.
15295373Sdteske *
16295373Sdteske * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17295373Sdteske * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18295373Sdteske * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19295373Sdteske * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20295373Sdteske * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21295373Sdteske * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22295373Sdteske * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23295373Sdteske * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24295373Sdteske * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25295373Sdteske * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26295373Sdteske *
27295373Sdteske * $Id: openpam_free_envlist.c 648 2013-03-05 17:54:27Z des $
28295373Sdteske */
29295373Sdteske
30295373Sdteske#ifdef HAVE_CONFIG_H
31295373Sdteske# include "config.h"
32295373Sdteske#endif
33295373Sdteske
34295373Sdteske#include <stdlib.h>
35295373Sdteske
36295400Sdteske#include <security/pam_appl.h>
37295400Sdteske
38295400Sdteske#include "openpam_impl.h"
39295373Sdteske
40295400Sdteske/*
41295400Sdteske * OpenPAM extension
42295373Sdteske *
43295373Sdteske * Free an environment list
44295373Sdteske */
45295373Sdteske
46295373Sdteskevoid
47295373Sdteskeopenpam_free_envlist(char **envlist)
48295373Sdteske{
49295373Sdteske	char **env;
50295373Sdteske
51295373Sdteske	ENTER();
52295373Sdteske	if (envlist == NULL)
53295373Sdteske		RETURNV();
54295373Sdteske	for (env = envlist; *env != NULL; ++env)
55295373Sdteske		FREE(*env);
56295373Sdteske	FREE(envlist);
57295373Sdteske	RETURNV();
58295373Sdteske}
59295373Sdteske
60295373Sdteske/*
61295373Sdteske * Error codes:
62295373Sdteske */
63295373Sdteske
64295373Sdteske/**
65295373Sdteske * The =openpam_free_envlist function is a convenience function which
66295373Sdteske * frees all the environment variables in an environment list, and the
67295373Sdteske * list itself.
68295373Sdteske * It is suitable for freeing the return value from =pam_getenvlist.
69295373Sdteske *
70295373Sdteske * AUTHOR DES
71295373Sdteske */
72295373Sdteske