From owner-p4-projects Mon May 27 9:24:23 2002 Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 64C7F37B405; Mon, 27 May 2002 09:23:44 -0700 (PDT) Delivered-To: perforce@freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 3022837B404 for ; Mon, 27 May 2002 09:23:43 -0700 (PDT) Received: (from perforce@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id g4RGNgh75915 for perforce@freebsd.org; Mon, 27 May 2002 09:23:42 -0700 (PDT) (envelope-from des@freebsd.org) Date: Mon, 27 May 2002 09:23:42 -0700 (PDT) Message-Id: <200205271623.g4RGNgh75915@freefall.freebsd.org> X-Authentication-Warning: freefall.freebsd.org: perforce set sender to des@freebsd.org using -f From: Dag-Erling Smorgrav Subject: PERFORCE change 11976 for review To: Perforce Change Reviews Sender: owner-p4-projects@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG http://people.freebsd.org/~peter/p4db/chv.cgi?CH=11976 Change 11976 by des@des.at.des.thinksec.com on 2002/05/27 09:23:03 Revamp the man page generation process. Delete the generated man pages as they are now regenerated automatically by the distribution script. Sponsored by: DARPA, NAI Labs Affected files ... ... //depot/projects/openpam/MANIFEST#10 edit ... //depot/projects/openpam/dist.sh#4 edit ... //depot/projects/openpam/doc/man/Makefile#9 edit ... //depot/projects/openpam/doc/man/openpam_borrow_cred.3#6 delete ... //depot/projects/openpam/doc/man/openpam_free_data.3#6 delete ... //depot/projects/openpam/doc/man/openpam_get_option.3#10 delete ... //depot/projects/openpam/doc/man/openpam_log.3#11 delete ... //depot/projects/openpam/doc/man/openpam_nullconv.3#3 delete ... //depot/projects/openpam/doc/man/openpam_restore_cred.3#6 delete ... //depot/projects/openpam/doc/man/openpam_set_option.3#10 delete ... //depot/projects/openpam/doc/man/openpam_ttyconv.3#11 delete ... //depot/projects/openpam/doc/man/pam.3#16 delete ... //depot/projects/openpam/doc/man/pam_acct_mgmt.3#14 delete ... //depot/projects/openpam/doc/man/pam_authenticate.3#14 delete ... //depot/projects/openpam/doc/man/pam_chauthtok.3#14 delete ... //depot/projects/openpam/doc/man/pam_close_session.3#14 delete ... //depot/projects/openpam/doc/man/pam_end.3#14 delete ... //depot/projects/openpam/doc/man/pam_error.3#14 delete ... //depot/projects/openpam/doc/man/pam_get_authtok.3#16 delete ... //depot/projects/openpam/doc/man/pam_get_data.3#14 delete ... //depot/projects/openpam/doc/man/pam_get_item.3#15 delete ... //depot/projects/openpam/doc/man/pam_get_user.3#15 delete ... //depot/projects/openpam/doc/man/pam_getenv.3#14 delete ... //depot/projects/openpam/doc/man/pam_getenvlist.3#15 delete ... //depot/projects/openpam/doc/man/pam_info.3#14 delete ... //depot/projects/openpam/doc/man/pam_open_session.3#14 delete ... //depot/projects/openpam/doc/man/pam_prompt.3#15 delete ... //depot/projects/openpam/doc/man/pam_putenv.3#14 delete ... //depot/projects/openpam/doc/man/pam_set_data.3#14 delete ... //depot/projects/openpam/doc/man/pam_set_item.3#14 delete ... //depot/projects/openpam/doc/man/pam_setcred.3#15 delete ... //depot/projects/openpam/doc/man/pam_setenv.3#14 delete ... //depot/projects/openpam/doc/man/pam_sm_acct_mgmt.3#10 delete ... //depot/projects/openpam/doc/man/pam_sm_authenticate.3#10 delete ... //depot/projects/openpam/doc/man/pam_sm_chauthtok.3#10 delete ... //depot/projects/openpam/doc/man/pam_sm_close_session.3#10 delete ... //depot/projects/openpam/doc/man/pam_sm_open_session.3#10 delete ... //depot/projects/openpam/doc/man/pam_sm_setcred.3#10 delete ... //depot/projects/openpam/doc/man/pam_start.3#15 delete ... //depot/projects/openpam/doc/man/pam_strerror.3#14 delete ... //depot/projects/openpam/doc/man/pam_verror.3#12 delete ... //depot/projects/openpam/doc/man/pam_vinfo.3#12 delete ... //depot/projects/openpam/doc/man/pam_vprompt.3#12 delete ... //depot/projects/openpam/misc/gendoc.pl#15 edit Differences ... ==== //depot/projects/openpam/MANIFEST#10 (text+ko) ==== @@ -1,5 +1,5 @@ # -# $P4: //depot/projects/openpam/MANIFEST#9 $ +# $P4: //depot/projects/openpam/MANIFEST#10 $ # CREDITS HISTORY @@ -14,6 +14,7 @@ bin/su/su.c doc/Makefile doc/man/Makefile +doc/man/openpam.3 doc/man/openpam_borrow_cred.3 doc/man/openpam_free_data.3 doc/man/openpam_get_option.3 @@ -22,7 +23,6 @@ doc/man/openpam_restore_cred.3 doc/man/openpam_set_option.3 doc/man/openpam_ttyconv.3 -doc/man/pam.3 doc/man/pam_acct_mgmt.3 doc/man/pam_authenticate.3 doc/man/pam_chauthtok.3 ==== //depot/projects/openpam/dist.sh#4 (text+ko) ==== @@ -1,6 +1,6 @@ #!/bin/sh # -# $P4: //depot/projects/openpam/dist.sh#3 $ +# $P4: //depot/projects/openpam/dist.sh#4 $ # set -e @@ -8,10 +8,14 @@ release=$(date '+%Y%m%d') distname="openpam-${release}" +make cleandir +make cleandir +(cd doc/man && make openpam.3) install -d -m 0755 "${distname}" grep -v '^#' MANIFEST | while read file; do install -d -m 0755 "${distname}/$(dirname ${file})" install -c -m 0644 "${file}" "${distname}/${file}" done -tar zcf "/tmp/${distname}.tar.gz" "${distname}" +tar zcf "${distname}.tar.gz" "${distname}" rm -rf "${distname}" +make cleandir ==== //depot/projects/openpam/doc/man/Makefile#9 (text+ko) ==== @@ -31,52 +31,64 @@ # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # -# $P4: //depot/projects/openpam/doc/man/Makefile#8 $ +# $P4: //depot/projects/openpam/doc/man/Makefile#9 $ # -MAN = -MAN += openpam_borrow_cred.3 -MAN += openpam_free_data.3 -MAN += openpam_get_option.3 -MAN += openpam_log.3 -MAN += openpam_nullconv.3 -MAN += openpam_restore_cred.3 -MAN += openpam_set_option.3 -MAN += openpam_ttyconv.3 -MAN += pam.3 -MAN += pam_acct_mgmt.3 -MAN += pam_authenticate.3 -MAN += pam_chauthtok.3 -MAN += pam_close_session.3 -MAN += pam_end.3 -MAN += pam_error.3 -MAN += pam_get_authtok.3 -MAN += pam_get_data.3 -MAN += pam_get_item.3 -MAN += pam_get_user.3 -MAN += pam_getenv.3 -MAN += pam_getenvlist.3 -MAN += pam_info.3 -MAN += pam_open_session.3 -MAN += pam_prompt.3 -MAN += pam_putenv.3 -MAN += pam_set_data.3 -MAN += pam_set_item.3 -MAN += pam_setcred.3 -MAN += pam_setenv.3 -MAN += pam_sm_acct_mgmt.3 -MAN += pam_sm_authenticate.3 -MAN += pam_sm_chauthtok.3 -MAN += pam_sm_close_session.3 -MAN += pam_sm_open_session.3 -MAN += pam_sm_setcred.3 -MAN += pam_start.3 -MAN += pam_strerror.3 -MAN += pam_verror.3 -MAN += pam_vinfo.3 -MAN += pam_vprompt.3 +GENDOC = ${.CURDIR}/../../misc/gendoc.pl + +CMAN = +CMAN += openpam_borrow_cred.3 +CMAN += openpam_free_data.3 +CMAN += openpam_get_option.3 +CMAN += openpam_log.3 +CMAN += openpam_nullconv.3 +CMAN += openpam_restore_cred.3 +CMAN += openpam_set_option.3 +CMAN += openpam_ttyconv.3 +CMAN += pam_acct_mgmt.3 +CMAN += pam_authenticate.3 +CMAN += pam_chauthtok.3 +CMAN += pam_close_session.3 +CMAN += pam_end.3 +CMAN += pam_error.3 +CMAN += pam_get_authtok.3 +CMAN += pam_get_data.3 +CMAN += pam_get_item.3 +CMAN += pam_get_user.3 +CMAN += pam_getenv.3 +CMAN += pam_getenvlist.3 +CMAN += pam_info.3 +CMAN += pam_open_session.3 +CMAN += pam_prompt.3 +CMAN += pam_putenv.3 +CMAN += pam_set_data.3 +CMAN += pam_set_item.3 +CMAN += pam_setcred.3 +CMAN += pam_setenv.3 +CMAN += pam_sm_acct_mgmt.3 +CMAN += pam_sm_authenticate.3 +CMAN += pam_sm_chauthtok.3 +CMAN += pam_sm_close_session.3 +CMAN += pam_sm_open_session.3 +CMAN += pam_sm_setcred.3 +CMAN += pam_start.3 +CMAN += pam_strerror.3 +CMAN += pam_verror.3 +CMAN += pam_vinfo.3 +CMAN += pam_vprompt.3 + +MAN = ${CMAN} +MAN += openpam.3 +MLINKS = openpam.3 pam.3 + +CLEANFILES += ${CMAN} openpam.3 + +.for man in ${CMAN} +${man}: ${.CURDIR}/../../lib/${man:R}.c ${GENDOC} + perl -w ${GENDOC} ${.CURDIR}/../../lib/${man:R}.c +.endfor -generate: - (cd ${.CURDIR} && perl -w ../../misc/gendoc.pl ../../lib/*.c >pam.3) +openpam.3: ${CMAN} ${GENDOC} + perl -w ${GENDOC} -s ${CMAN} .include ==== //depot/projects/openpam/misc/gendoc.pl#15 (text+ko) ==== @@ -32,14 +32,51 @@ # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # -# $P4: //depot/projects/openpam/misc/gendoc.pl#14 $ +# $P4: //depot/projects/openpam/misc/gendoc.pl#15 $ # use strict; use Fcntl; +use Getopt::Std; use POSIX qw(strftime); use vars qw($COPYRIGHT $TODAY %FUNCTIONS %PAMERR); +$COPYRIGHT = ".\\\"- +.\\\" Copyright (c) 2002 Networks Associates Technology, Inc. +.\\\" All rights reserved. +.\\\" +.\\\" This software was developed for the FreeBSD Project by ThinkSec AS and +.\\\" NAI Labs, the Security Research Division of Network Associates, Inc. +.\\\" under DARPA/SPAWAR contract N66001-01-C-8035 (\"CBOSS\"), as part of the +.\\\" DARPA CHATS research program. +.\\\" +.\\\" 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. +.\\\" 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 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 AUTHOR 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. +.\\\" +.\\\" \$" . "P4" . "\$ +.\\\""; + %PAMERR = ( PAM_SUCCESS => "Success", PAM_OPEN_ERR => "Failed to load module", @@ -91,7 +128,7 @@ if ($fn !~ m,\.c$,) { warn("$fn: not C source, ignoring\n"); - return; + return undef; } sysopen(FILE, $fn, O_RDONLY) @@ -99,19 +136,14 @@ $source = join('', ); close(FILE); - return if ($source =~ m/^ \* NOPARSE\s*$/m); + return undef + if ($source =~ m/^ \* NOPARSE\s*$/m); - if (!defined($COPYRIGHT) && $source =~ m,^(/\*-\n.*?)\s*\*/,s) { - $COPYRIGHT = $1; - $COPYRIGHT =~ s,^.\*,.\\\",gm; - $COPYRIGHT =~ s,(\$(?:)P4).*?\$,$1\$,; - $COPYRIGHT .= "\n.\\\""; - } $func = $fn; $func =~ s,^(?:.*/)?([^/]+)\.c$,$1,; if ($source !~ m,\n \* ([\S ]+)\n \*/\n\n([\S ]+)\n$func\((.*?)\)\n\{,s) { warn("$fn: can't find $func\n"); - return; + return undef; } ($descr, $type, $args) = ($1, $2, $3); $descr =~ s,^([A-Z][a-z]),lc($1),e; @@ -231,6 +263,7 @@ } $FUNCTIONS{$func} = { + 'source' => $fn, 'name' => $func, 'descr' => $descr, 'type' => $type, @@ -249,6 +282,8 @@ if ($source !~ m/^ \* XSSO \d/m) { $FUNCTIONS{$func}->{'openpam'} = 1; } + expand_errors($FUNCTIONS{$func}); + return $FUNCTIONS{$func}; } sub expand_errors($); @@ -256,6 +291,8 @@ my $func = shift; # Ref to function hash my %errors; + my $ref; + my $fn; if (defined($func->{'recursed'})) { warn("$func->{'name'}(): loop in error spec\n"); @@ -273,11 +310,17 @@ } elsif (m/^!(PAM_[A-Z_]+)$/) { # treat negations separately } elsif (m/^=([a-z_]+)$/) { - if (!defined($FUNCTIONS{$1})) { - warn("$func->{'name'}(): reference to unknown $1()\n"); + $ref = $1; + if (!defined($FUNCTIONS{$ref})) { + $fn = $func->{'source'}; + $fn =~ s/$func->{'name'}/$ref/; + parse_source($fn); + } + if (!defined($FUNCTIONS{$ref})) { + warn("$func->{'name'}(): reference to unknown $ref()\n"); next; } - foreach (expand_errors($FUNCTIONS{$1})) { + foreach (@{$FUNCTIONS{$ref}->{'errors'}}) { $errors{$_} = 1; } } else { @@ -290,7 +333,7 @@ } } delete($func->{'recursed'}); - return (sort(keys(%errors))); + $func->{'errors'} = [ sort(keys(%errors)) ]; } sub gendoc($) { @@ -332,7 +375,7 @@ function returns one of the following values: .Bl -tag -width 18n "; - my @errors = expand_errors($func); + my @errors = @{$func->{'errors'}}; warn("$func->{'name'}(): no error specification\n") unless(@errors); foreach (@errors) { @@ -387,33 +430,59 @@ } } +sub readproto($) { + my $fn = shift; # File name + + local *FILE; + my %func; + + sysopen(FILE, $fn, O_RDONLY) + or die("$fn: open(): $!\n"); + while () { + if (m/^\.Nm ((?:open)?pam_.*?)\s*$/) { + $func{'Nm'} = $func{'Nm'} || $1; + } elsif (m/^\.Ft (\S.*?)\s*$/) { + $func{'Ft'} = $func{'Ft'} || $1; + } elsif (m/^\.Fn (\S.*?)\s*$/) { + $func{'Fn'} = $func{'Fn'} || $1; + } + } + close(FILE); + if ($func{'Nm'}) { + $FUNCTIONS{$func{'Nm'}} = \%func; + } else { + warn("No function found\n"); + } +} + sub gensummary() { + local *FILE; my $func; - print "$COPYRIGHT + sysopen(FILE, "openpam.3", O_RDWR|O_CREAT|O_TRUNC) + or die("openpam.3: $!\n"); + + print FILE "$COPYRIGHT .Dd $TODAY .Dt PAM 3 .Os .Sh NAME "; - my @funcs = sort(keys(%FUNCTIONS)); - while ($func = shift(@funcs)) { - next if (defined($FUNCTIONS{$func}->{'nolist'})); - print ".Nm $func". (@funcs ? " ,\n" : "\n"); + foreach $func (sort(keys(%FUNCTIONS))) { + print FILE ".Nm $FUNCTIONS{$func}->{'Nm'}\n"; } - print ".Nd Pluggable Authentication Modules Library + print FILE ".Nd Pluggable Authentication Modules Library .Sh LIBRARY .Lb libpam .Sh SYNOPSIS .In security/pam_appl.h "; foreach $func (sort(keys(%FUNCTIONS))) { - next if (defined($FUNCTIONS{$func}->{'nolist'})); - print ".Ft $FUNCTIONS{$func}->{'type'}\n"; - print ".Fn $func $FUNCTIONS{$func}->{'args'}\n"; + print FILE ".Ft $FUNCTIONS{$func}->{'Ft'}\n"; + print FILE ".Fn $FUNCTIONS{$func}->{'Fn'}\n"; } - print ".Sh DESCRIPTION + print FILE ".Sh DESCRIPTION .Sh RETURN VALUES The following return codes are defined in the .In security/pam_constants.h @@ -421,16 +490,15 @@ .Bl -tag -width 18n "; foreach (sort(keys(%PAMERR))) { - print ".It Bq Er $_\n$PAMERR{$_}.\n"; + print FILE ".It Bq Er $_\n$PAMERR{$_}.\n"; } - print ".El + print FILE ".El .Sh SEE ALSO "; foreach $func (sort(keys(%FUNCTIONS))) { - next if (defined($FUNCTIONS{$func}->{'nolist'})); - print ".Xr $func 3 ,\n"; + print FILE ".Xr $func 3 ,\n"; } - print ".Xr pam.conf 5 + print FILE ".Xr pam.conf 5 .Sh STANDARDS .Rs .%T \"X/Open Single Sign-On Service (XSSO) - Pluggable Authentication Modules\" @@ -443,17 +511,34 @@ N66001-01-C-8035 .Pq Dq CBOSS , as part of the DARPA CHATS research program. -" +"; + close(FILE); +} + +sub usage() { + + print(STDERR "usage: gendoc [-s] source [...]\n"); + exit(1); } MAIN:{ + my %opts; + + usage() + unless (@ARGV && getopts("s", \%opts)); $TODAY = strftime("%B %e, %Y", localtime(time())); $TODAY =~ s,\s+, ,g; - foreach my $fn (@ARGV) { - parse_source($fn); + if ($opts{'s'}) { + foreach my $fn (@ARGV) { + readproto($fn); + } + gensummary(); + } else { + foreach my $fn (@ARGV) { + my $func = parse_source($fn); + gendoc($func) + if (defined($func)); + } } - foreach my $func (values(%FUNCTIONS)) { - gendoc($func); - } - gensummary(); + exit(0); } To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe p4-projects" in the body of the message