lint and static module fixes

This commit is contained in:
christos 2011-12-25 23:18:56 +00:00
parent f5389e0d8c
commit 14a012c5ad
6 changed files with 129 additions and 22 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: openpam.h,v 1.2 2011/12/25 22:27:55 christos Exp $ */
/* $NetBSD: openpam.h,v 1.3 2011/12/25 23:18:56 christos Exp $ */
/*-
* Copyright (c) 2002-2003 Networks Associates Technology, Inc.
@ -321,11 +321,7 @@ struct pam_module {
# define PAM_SOEXT ".so"
#endif
#if defined(OPENPAM_STATIC_MODULES)
# if !defined(__GNUC__)
# error "Don't know how to build static modules on non-GNU compilers"
# endif
/* gcc, static linking */
#if (defined(__GNUC__) || defined(__PCC__)) && !defined(NO_STATIC_MODULES)
# include <sys/cdefs.h>
# ifdef __FreeBSD__
# include <linker_set.h>
@ -335,6 +331,7 @@ struct pam_module {
# define SET_DECLARE(a, b) __link_set_decl(a, b)
# define SET_FOREACH(a, b) __link_set_foreach(a, b)
# endif
# define OPENPAM_STATIC_MODULES
# define PAM_EXTERN static
# define PAM_MODULE_ENTRY(name) \
static char _pam_name[] = name PAM_SOEXT; \

View File

@ -1,4 +1,4 @@
/* $NetBSD: openpam_check_owner_perms.c,v 1.2 2011/12/25 22:27:55 christos Exp $ */
/* $NetBSD: openpam_check_owner_perms.c,v 1.3 2011/12/25 23:18:56 christos Exp $ */
/*-
* Copyright (c) 2011 Dag-Erling Smørgrav
@ -97,7 +97,8 @@ openpam_check_path_owner_perms(const char *path)
uid_t root, arbitrator;
char pathbuf[PATH_MAX];
struct stat sb;
int len, serrno;
size_t len;
int serrno;
root = 0;
arbitrator = geteuid();

View File

@ -1,4 +1,4 @@
/* $NetBSD: openpam_configure.c,v 1.2 2011/12/25 22:27:55 christos Exp $ */
/* $NetBSD: openpam_configure.c,v 1.3 2011/12/25 23:18:56 christos Exp $ */
/*-
* Copyright (c) 2001-2003 Networks Associates Technology, Inc.
@ -94,7 +94,7 @@ static int openpam_load_chain(pam_handle_t *, const char *, pam_facility_t);
* Allowed characters are all characters in the POSIX portable filename
* character set.
*/
static int
static size_t
parse_service_name(char **line, char **service)
{
char *b, *e;
@ -144,7 +144,7 @@ parse_facility_name(char **line)
if (e == b)
return ((pam_facility_t)-1);
for (i = 0; i < PAM_NUM_FACILITIES; ++i)
if (strlcmp(pam_facility_name[i], b, e - b) == 0)
if (strlcmp(pam_facility_name[i], b, (size_t)(e - b)) == 0)
break;
if (i == PAM_NUM_FACILITIES)
return ((pam_facility_t)-1);
@ -174,7 +174,7 @@ parse_include(char **line)
/* nothing */ ;
if (e == b)
return (0);
if (strlcmp("include", b, e - b) != 0)
if (strlcmp("include", b, (size_t)(e - b)) != 0)
return (0);
*line = e;
return (1);
@ -209,7 +209,7 @@ parse_control_flag(char **line)
if (e == b)
return ((pam_control_t)-1);
for (i = 0; i < PAM_NUM_CONTROL_FLAGS; ++i)
if (strlcmp(pam_control_flag_name[i], b, e - b) == 0)
if (strlcmp(pam_control_flag_name[i], b, (size_t)(e - b)) == 0)
break;
if (i == PAM_NUM_CONTROL_FLAGS)
return ((pam_control_t)-1);
@ -232,7 +232,7 @@ parse_control_flag(char **line)
* Allowed characters are all characters in the POSIX portable filename
* character set, plus the path separator (forward slash).
*/
static int
static size_t
parse_filename(char **line, char **filename)
{
char *b, *e;
@ -317,10 +317,10 @@ parse_option(char **line)
size += (ve - vb) + 1;
if ((option = malloc(size)) == NULL)
return (NULL);
strncpy(option, nb, ne - nb);
strncpy(option, nb, (size_t)(ne - nb));
if (ve > vb) {
option[ne - nb] = '=';
strncpy(option + (ne - nb) + 1, vb, ve - vb);
strncpy(option + (ne - nb) + 1, vb, (size_t)(ve - vb));
}
option[size - 1] = '\0';
*line = q ? ve + 1 : ve;
@ -364,7 +364,8 @@ openpam_parse_chain(pam_handle_t *pamh,
pam_control_t ctlf;
char *line, *str, *name;
char *option, **optv;
int len, lineno, ret;
size_t len;
int lineno, ret;
FILE *f;
if ((f = fopen(filename, "r")) == NULL) {
@ -602,7 +603,7 @@ openpam_configure(pam_handle_t *pamh,
openpam_log(PAM_LOG_ERROR,
"No required or binding component "
"in service %s, facility %s",
service, _pam_facility_name[PAM_AUTH]);
service, pam_facility_name[PAM_AUTH]);
goto load_err;
}
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: openpam_dispatch.c,v 1.2 2011/12/25 22:27:55 christos Exp $ */
/* $NetBSD: openpam_dispatch.c,v 1.3 2011/12/25 23:18:56 christos Exp $ */
/*-
* Copyright (c) 2002-2003 Networks Associates Technology, Inc.
@ -189,7 +189,7 @@ openpam_dispatch(pam_handle_t *pamh,
if (err == PAM_SUCCESS && nsuccess < 1) {
openpam_log(PAM_LOG_ERROR,
"all modules were unsuccessful for %s()",
_pam_sm_func_name[primitive]);
pam_sm_func_name[primitive]);
err = PAM_SYSTEM_ERR;
}
#endif

View File

@ -1,4 +1,4 @@
/* $NetBSD: pam_set_item.c,v 1.2 2011/12/25 22:27:56 christos Exp $ */
/* $NetBSD: pam_set_item.c,v 1.3 2011/12/25 23:18:56 christos Exp $ */
/*-
* Copyright (c) 2002-2003 Networks Associates Technology, Inc.
@ -42,6 +42,7 @@
#endif
#include <sys/param.h>
#include <sys/socket.h>
#include <stdlib.h>
#include <string.h>
@ -75,7 +76,7 @@ pam_set_item(pam_handle_t *pamh,
/* set once only, by pam_start() */
if (*slot != NULL)
RETURNC(PAM_SYSTEM_ERR);
/* fall through */
/*FALLTHROUGH*/
case PAM_USER:
case PAM_AUTHTOK:
case PAM_OLDAUTHTOK:

107
external/bsd/openpam/openpam2netbsd vendored Executable file
View File

@ -0,0 +1,107 @@
#! /bin/sh
#
# $NetBSD: openpam2netbsd,v 1.1 2011/12/25 23:18:56 christos Exp $
#
# Copyright (c) 2011 The NetBSD Foundation, Inc.
# 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.
# 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.
#
# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
# ``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 FOUNDATION OR CONTRIBUTORS
# 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.
#
# openpam2netbsd: convert an openpam source tree into a
# netbsd openp source tree, under src/dist,
#
# Rough instructions for importing new openp release:
#
# $ cd /some/where/temporary
# $ tar xpfz /new/openpam/release/tar/file
# $ sh /usr/src/external/bsd/openpam/openp2netbsd openpam-YYYYMMDD
# $ cd openpam-YYYYMMDD
# $ cvs -d cvs.netbsd.org:/cvsroot import -m "Import openpam-YYYYMMDD" src/external/bsd/openpam/dist OPENPAM flower-YYYYMMDD
# $ cd ../../../am-utils-6.x.y
# $ run ./configure
# merge newly generated config.h with /usr/src/usr.sbin/openp/include/config.h
# very carefully, since autoconfig seems to be broken (at least in 6.0.4)
# $ cd ..
# $ rm -r src am-utils-6.x.y
# $ cd /usr/src/usr.sbin/openp
# $ cvs commit -m "Updated autoconf generated files for am-utils 6.x.y."
#
# - check makefiles to see if any extra sources have been added.
# - update distrib/sets if necessary.
if [ $# -ne 1 ]; then echo "openp2netbsd src"; exit 1; fi
r=$1
case "$r" in
/*)
;;
*)
r=`/bin/pwd`/$r
;;
esac
cd $r
### Remove the $'s around RCS tags
cleantags $r
### Add our NetBSD RCS Id
find $r -type f -name '*.[chly]' -print | while read c; do
sed 1q < $c | grep -q '\$NetBSD' || (
echo "/* \$NetBSD\$ */" >/tmp/openp3n$$
echo "" >>/tmp/openp3n$$
cat $c >> /tmp/openp3n$$
mv /tmp/openp3n$$ $c && echo added NetBSD RCS tag to $c
)
done
find $r -type f -name '*.[0-9]' -print | while read m; do
sed 1q < $m | grep -q '\$NetBSD' || (
echo ".\\\" \$NetBSD\$" >/tmp/openp2m$$
echo ".\\\"" >>/tmp/openp2m$$
cat $m >> /tmp/openp2m$$
mv /tmp/openp2m$$ $m && echo added NetBSD RCS tag to $m
)
done
find $r -type f -name '*.texi' -print | while read t; do
sed "2 s/^/@c \$NetBSD\$\\
/" < $t > /tmp/openp4t$$
mv /tmp/openp4t$$ $t && echo added NetBSD RCS tag to $t
done
echo done
### Clean up any CVS directories that might be around.
echo "cleaning up CVS residue."
find $r -type d -name "CVS" -print | xargs rm -r
echo done
### Fixing file and directory permissions.
echo "Fixing file/directory permissions."
(
find $r -type f -print | xargs chmod u+rw,go+r
find $r -type d -print | xargs chmod u+rwx,go+rx
)
echo done
exit 0