Add openpam_free_envlist(). I'm tired of freeing them by hand.
git-svn-id: svn+ssh://svn.openpam.org/svn/openpam/trunk@289 185d5e19-27fe-0310-9dcf-9bff6b9f3609
This commit is contained in:
parent
7adc56bb5f
commit
9d0dd0c39b
4 changed files with 72 additions and 1 deletions
|
@ -35,6 +35,7 @@ MMAN = \
|
||||||
OMAN = \
|
OMAN = \
|
||||||
openpam_borrow_cred.3 \
|
openpam_borrow_cred.3 \
|
||||||
openpam_free_data.3 \
|
openpam_free_data.3 \
|
||||||
|
openpam_free_envlist.3 \
|
||||||
openpam_get_option.3 \
|
openpam_get_option.3 \
|
||||||
openpam_log.3 \
|
openpam_log.3 \
|
||||||
openpam_nullconv.3 \
|
openpam_nullconv.3 \
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* $P4: //depot/projects/openpam/include/security/openpam.h#27 $
|
* $P4: //depot/projects/openpam/include/security/openpam.h#28 $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _SECURITY_OPENPAM_H_INCLUDED
|
#ifndef _SECURITY_OPENPAM_H_INCLUDED
|
||||||
|
@ -60,6 +60,9 @@ openpam_free_data(pam_handle_t *_pamh,
|
||||||
void *_data,
|
void *_data,
|
||||||
int _status);
|
int _status);
|
||||||
|
|
||||||
|
void
|
||||||
|
openpam_free_envlist(char **_envlist);
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
openpam_get_option(pam_handle_t *_pamh,
|
openpam_get_option(pam_handle_t *_pamh,
|
||||||
const char *_option);
|
const char *_option);
|
||||||
|
|
|
@ -11,6 +11,7 @@ libpam_la_SOURCES = \
|
||||||
openpam_dynamic.c \
|
openpam_dynamic.c \
|
||||||
openpam_findenv.c \
|
openpam_findenv.c \
|
||||||
openpam_free_data.c \
|
openpam_free_data.c \
|
||||||
|
openpam_free_envlist.c \
|
||||||
openpam_get_option.c \
|
openpam_get_option.c \
|
||||||
openpam_load.c \
|
openpam_load.c \
|
||||||
openpam_log.c \
|
openpam_log.c \
|
||||||
|
|
66
lib/openpam_free_envlist.c
Normal file
66
lib/openpam_free_envlist.c
Normal file
|
@ -0,0 +1,66 @@
|
||||||
|
/*-
|
||||||
|
* Copyright (c) 2005 Dag-Erling Coïdan Smørgrav
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer
|
||||||
|
* in this position and unchanged.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. The name of the author may not be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* $P4: //depot/projects/openpam/lib/openpam_free_envlist.c#1 $
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include <security/pam_appl.h>
|
||||||
|
|
||||||
|
#include "openpam_impl.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* OpenPAM extension
|
||||||
|
*
|
||||||
|
* Free an environment list
|
||||||
|
*/
|
||||||
|
|
||||||
|
void
|
||||||
|
openpam_free_envlist(char **envlist)
|
||||||
|
{
|
||||||
|
char **env;
|
||||||
|
|
||||||
|
ENTER();
|
||||||
|
if (envlist == NULL)
|
||||||
|
RETURNV();
|
||||||
|
for (env = envlist; *env != NULL; ++env)
|
||||||
|
free(*env);
|
||||||
|
free(envlist);
|
||||||
|
RETURNV();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Error codes:
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The =openpam_free_envlist function is a convenience function which
|
||||||
|
* frees all the environment variables in an environment list, and the
|
||||||
|
* list itself.
|
||||||
|
* It is suitable for freeing the return value from =pam_getenvlist.
|
||||||
|
*/
|
Loading…
Reference in a new issue