diff options
author | des <des@FreeBSD.org> | 2013-09-07 19:43:39 +0000 |
---|---|---|
committer | des <des@FreeBSD.org> | 2013-09-07 19:43:39 +0000 |
commit | 6a7561b73b9720ce6c6c63e7cff8fd554aecd847 (patch) | |
tree | ab3f4f3f8107b85839f39cd0f0a7d63082287b66 /contrib/openpam/misc | |
parent | f16777c9dcab2b9b5f7a058133fd4c8c7d947a8e (diff) | |
parent | 338d7c2adbde6bf877c1224d39c4fa8fa056147d (diff) | |
download | FreeBSD-src-6a7561b73b9720ce6c6c63e7cff8fd554aecd847.zip FreeBSD-src-6a7561b73b9720ce6c6c63e7cff8fd554aecd847.tar.gz |
Update to OpenPAM Nummularia.
Diffstat (limited to 'contrib/openpam/misc')
-rw-r--r-- | contrib/openpam/misc/gendoc.pl | 203 |
1 files changed, 91 insertions, 112 deletions
diff --git a/contrib/openpam/misc/gendoc.pl b/contrib/openpam/misc/gendoc.pl index 4ce2d39..c09f907 100644 --- a/contrib/openpam/misc/gendoc.pl +++ b/contrib/openpam/misc/gendoc.pl @@ -33,52 +33,17 @@ # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # -# $Id: gendoc.pl 599 2012-04-14 15:06:41Z des $ +# $Id: gendoc.pl 736 2013-09-07 12:52:42Z des $ # use strict; -use locale; +use warnings; +use open qw(:utf8); +use utf8; use Fcntl; use Getopt::Std; -use POSIX qw(locale_h strftime); -use vars qw($COPYRIGHT %AUTHORS $TODAY %FUNCTIONS %PAMERR); - -$COPYRIGHT = ".\\\"- -.\\\" Copyright (c) 2001-2003 Networks Associates Technology, Inc. -.\\\" Copyright (c) 2004-2011 Dag-Erling Smørgrav -.\\\" All rights reserved. -.\\\" -.\\\" This software was developed for the FreeBSD Project by ThinkSec AS and -.\\\" Network Associates Laboratories, 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. -.\\\" -.\\\" \$" . "Id" . "\$ -.\\\""; +use POSIX qw(strftime); +use vars qw(%AUTHORS $TODAY %FUNCTIONS %PAMERR); %AUTHORS = ( THINKSEC => "developed for the @@ -87,7 +52,12 @@ Project by ThinkSec AS and Network Associates Laboratories, the Security Research Division of Network Associates, Inc.\\& under DARPA/SPAWAR contract N66001-01-C-8035 .Pq Dq CBOSS , -as part of the DARPA CHATS research program.", +as part of the DARPA CHATS research program. +.Pp +The OpenPAM library is maintained by +.An Dag-Erling Sm\\(/orgrav Aq des\@des.no .", + UIO => "developed for the University of Oslo by +.An Dag-Erling Sm\\(/orgrav Aq des\@des.no .", DES => "developed by .An Dag-Erling Sm\\(/orgrav Aq des\@des.no .", ); @@ -142,6 +112,7 @@ sub parse_source($) { my $customrv; my $deprecated; my $experimental; + my $version; my %xref; my @errors; my $author; @@ -159,6 +130,10 @@ sub parse_source($) { return undef if ($source =~ m/^ \* NOPARSE\s*$/m); + if ($source =~ m/(\$Id:[^\$]+\$)/) { + $version = $1; + } + $author = 'THINKSEC'; if ($source =~ s/^ \* AUTHOR\s+(\w*)\s*$//m) { $author = $1; @@ -196,7 +171,7 @@ sub parse_source($) { next unless (m/^ \*\s+(!?PAM_[A-Z_]+|=[a-z_]+)\s*$/); push(@errors, $1); } - ++$xref{3}->{'pam_strerror'}; + ++$xref{3}->{pam_strerror}; } $argnames = $args; @@ -290,7 +265,7 @@ sub parse_source($) { $man .= ".Bl -tag -width 18n\n"; $intaglist = 1; } - s/^\.It =([A-Z][A-Z_]+)$/.It Dv $1/gs; + s/^\.It [=;]([A-Za-z][0-9A-Za-z_]+)$/.It Dv $1/gs; $man .= "$_\n"; next; } elsif (($inlist || $intaglist) && m/^\S/) { @@ -318,16 +293,16 @@ sub parse_source($) { s/\s*=($func)\b\s*/\n.Fn $1\n/gs; s/\s*=($argnames)\b\s*/\n.Fa $1\n/gs; s/\s*=(struct \w+(?: \*)?)\b\s*/\n.Vt $1\n/gs; - s/\s*:([a-z_]+)\b\s*/\n.Va $1\n/gs; - s/\s*;([a-z_]+)\b\s*/\n.Dv $1\n/gs; - s/\s*=!([a-z_]+)\b\s*/\n.Xr $1 3\n/gs; - while (s/\s*=([a-z_]+)\b\s*/\n.Xr $1 3\n/s) { + s/\s*:([a-z][0-9a-z_]+)\b\s*/\n.Va $1\n/gs; + s/\s*;([a-z][0-9a-z_]+)\b\s*/\n.Dv $1\n/gs; + s/\s*=!([a-z][0-9a-z_]+)\b\s*/\n.Xr $1 3\n/gs; + while (s/\s*=([a-z][0-9a-z_]+)\b\s*/\n.Xr $1 3\n/s) { ++$xref{3}->{$1}; } s/\s*\"(?=\w)/\n.Do\n/gs; s/\"(?!\w)\s*/\n.Dc\n/gs; - s/\s*=([A-Z][A-Z_]+)\b\s*(?![\.,:;])/\n.Dv $1\n/gs; - s/\s*=([A-Z][A-Z_]+)\b([\.,:;]+)\s*/\n.Dv $1 $2\n/gs; + s/\s*=([A-Z][0-9A-Z_]+)\b\s*(?![\.,:;])/\n.Dv $1\n/gs; + s/\s*=([A-Z][0-9A-Z_]+)\b([\.,:;]+)\s*/\n.Dv $1 $2\n/gs; s/\s*{([A-Z][a-z] .*?)}\s*/\n.$1\n/gs; $man .= "$_\n"; } @@ -353,6 +328,7 @@ sub parse_source($) { $FUNCTIONS{$func} = { 'source' => $fn, + 'version' => $version, 'name' => $func, 'descr' => $descr, 'type' => $type, @@ -366,10 +342,10 @@ sub parse_source($) { 'experimental' => $experimental, }; if ($source =~ m/^ \* NODOC\s*$/m) { - $FUNCTIONS{$func}->{'nodoc'} = 1; + $FUNCTIONS{$func}->{nodoc} = 1; } if ($source !~ m/^ \* XSSO \d/m) { - $FUNCTIONS{$func}->{'openpam'} = 1; + $FUNCTIONS{$func}->{openpam} = 1; } expand_errors($FUNCTIONS{$func}); return $FUNCTIONS{$func}; @@ -383,16 +359,16 @@ sub expand_errors($) { my $ref; my $fn; - if (defined($func->{'recursed'})) { - warn("$func->{'name'}(): loop in error spec\n"); + if (defined($$func{recursed})) { + warn("$$func{name}(): loop in error spec\n"); return qw(); } - $func->{'recursed'} = 1; + $$func{recursed} = 1; - foreach (@{$func->{'errors'}}) { + foreach (@{$$func{errors}}) { if (m/^(PAM_[A-Z_]+)$/) { if (!defined($PAMERR{$1})) { - warn("$func->{'name'}(): unrecognized error: $1\n"); + warn("$$func{name}(): unrecognized error: $1\n"); next; } $errors{$1} = 1; @@ -401,28 +377,28 @@ sub expand_errors($) { } elsif (m/^=([a-z_]+)$/) { $ref = $1; if (!defined($FUNCTIONS{$ref})) { - $fn = $func->{'source'}; - $fn =~ s/$func->{'name'}/$ref/; + $fn = $$func{source}; + $fn =~ s/$$func{name}/$ref/; parse_source($fn); } if (!defined($FUNCTIONS{$ref})) { - warn("$func->{'name'}(): reference to unknown $ref()\n"); + warn("$$func{name}(): reference to unknown $ref()\n"); next; } - foreach (@{$FUNCTIONS{$ref}->{'errors'}}) { + foreach (@{$FUNCTIONS{$ref}->{errors}}) { $errors{$_} = 1; } } else { - warn("$func->{'name'}(): invalid error specification: $_\n"); + warn("$$func{name}(): invalid error specification: $_\n"); } } - foreach (@{$func->{'errors'}}) { + foreach (@{$$func{errors}}) { if (m/^!(PAM_[A-Z_]+)$/) { delete($errors{$1}); } } - delete($func->{'recursed'}); - $func->{'errors'} = [ sort(keys(%errors)) ]; + delete($$func{recursed}); + $$func{errors} = [ sort(keys(%errors)) ]; } sub dictionary_order($$) { @@ -457,59 +433,63 @@ sub gendoc($) { my $mdoc; my $fn; - return if defined($func->{'nodoc'}); + return if defined($$func{nodoc}); - $mdoc = "$COPYRIGHT -.Dd $TODAY -.Dt " . uc($func->{'name'}) . " 3 + $$func{source} =~ m/([^\/]+)$/; + $mdoc = ".\\\" Generated from $1 by gendoc.pl\n"; + if ($$func{version}) { + $mdoc .= ".\\\" $$func{version}\n"; + } + $mdoc .= ".Dd $TODAY +.Dt " . uc($$func{name}) . " 3 .Os .Sh NAME -.Nm $func->{'name'} -.Nd $func->{'descr'} +.Nm $$func{name} +.Nd $$func{descr} .Sh LIBRARY .Lb libpam .Sh SYNOPSIS .In sys/types.h "; - if ($func->{'args'} =~ m/\bFILE \*\b/) { + if ($$func{args} =~ m/\bFILE \*\b/) { $mdoc .= ".In stdio.h\n"; } $mdoc .= ".In security/pam_appl.h "; - if ($func->{'name'} =~ m/_sm_/) { + if ($$func{name} =~ m/_sm_/) { $mdoc .= ".In security/pam_modules.h\n"; } - if ($func->{'name'} =~ m/openpam/) { + if ($$func{name} =~ m/openpam/) { $mdoc .= ".In security/openpam.h\n"; } - $mdoc .= ".Ft \"$func->{'type'}\" -.Fn $func->{'name'} $func->{'args'} + $mdoc .= ".Ft \"$$func{type}\" +.Fn $$func{name} $$func{args} .Sh DESCRIPTION "; - if (defined($func->{'deprecated'})) { + if (defined($$func{deprecated})) { $mdoc .= ".Bf Sy\n" . "This function is deprecated and may be removed " . "in a future release without further warning.\n"; - if ($func->{'deprecated'}) { - $mdoc .= "The\n.Fn $func->{'deprecated'}\nfunction " . + if ($$func{deprecated}) { + $mdoc .= "The\n.Fn $$func{deprecated}\nfunction " . "may be used to achieve similar results.\n"; } $mdoc .= ".Ef\n.Pp\n"; } - if ($func->{'experimental'}) { + if ($$func{experimental}) { $mdoc .= ".Bf Sy\n" . "This function is experimental and may be modified or removed " . - "in a future release without further warning.\n"; + "in a future release without prior warning.\n"; $mdoc .= ".Ef\n.Pp\n"; } - $mdoc .= "$func->{'man'}\n"; - my @errors = @{$func->{'errors'}}; - if ($func->{'customrv'}) { + $mdoc .= "$$func{man}\n"; + my @errors = @{$$func{errors}}; + if ($$func{customrv}) { # leave it - } elsif ($func->{'type'} eq "int" && @errors) { + } elsif ($$func{type} eq "int" && @errors) { $mdoc .= ".Sh RETURN VALUES The -.Fn $func->{'name'} +.Fn $$func{name} function returns one of the following values: .Bl -tag -width 18n "; @@ -517,28 +497,28 @@ function returns one of the following values: $mdoc .= ".It Bq Er $_\n$PAMERR{$_}.\n"; } $mdoc .= ".El\n"; - } elsif ($func->{'type'} eq "int") { + } elsif ($$func{type} eq "int") { $mdoc .= ".Sh RETURN VALUES The -.Fn $func->{'name'} +.Fn $$func{name} function returns 0 on success and -1 on failure. "; - } elsif ($func->{'type'} =~ m/\*$/) { + } elsif ($$func{type} =~ m/\*$/) { $mdoc .= ".Sh RETURN VALUES The -.Fn $func->{'name'} +.Fn $$func{name} function returns .Dv NULL on failure. "; - } elsif ($func->{'type'} ne "void") { - warn("$func->{'name'}(): no error specification\n"); + } elsif ($$func{type} ne "void") { + warn("$$func{name}(): no error specification\n"); } - $mdoc .= ".Sh SEE ALSO\n" . genxref($func->{'xref'}); + $mdoc .= ".Sh SEE ALSO\n" . genxref($$func{xref}); $mdoc .= ".Sh STANDARDS\n"; - if ($func->{'openpam'}) { + if ($$func{openpam}) { $mdoc .= "The -.Fn $func->{'name'} +.Fn $$func{name} function is an OpenPAM extension. "; } else { @@ -550,10 +530,10 @@ function is an OpenPAM extension. } $mdoc .= ".Sh AUTHORS The -.Fn $func->{'name'} +.Fn $$func{name} function and this manual page were\n"; - $mdoc .= $AUTHORS{$func->{'author'} // 'THINKSEC_DARPA'} . "\n"; - $fn = "$func->{'name'}.3"; + $mdoc .= $AUTHORS{$$func{author} // 'THINKSEC_DARPA'} . "\n"; + $fn = "$$func{name}.3"; if (open(FILE, ">", $fn)) { print(FILE $mdoc); close(FILE); @@ -572,16 +552,16 @@ sub readproto($) { or die("$fn: open(): $!\n"); while (<FILE>) { if (m/^\.Nm ((?:open)?pam_.*?)\s*$/) { - $func{'Nm'} = $func{'Nm'} || $1; + $func{Nm} = $func{Nm} || $1; } elsif (m/^\.Ft (\S.*?)\s*$/) { - $func{'Ft'} = $func{'Ft'} || $1; + $func{Ft} = $func{Ft} || $1; } elsif (m/^\.Fn (\S.*?)\s*$/) { - $func{'Fn'} = $func{'Fn'} || $1; + $func{Fn} = $func{Fn} || $1; } } close(FILE); - if ($func{'Nm'}) { - $FUNCTIONS{$func{'Nm'}} = \%func; + if ($func{Nm}) { + $FUNCTIONS{$func{Nm}} = \%func; } else { warn("No function found\n"); } @@ -600,7 +580,7 @@ sub gensummary($) { $page =~ m/(\w+)$/; $upage = uc($1); - print FILE "$COPYRIGHT + print FILE ".\\\" Generated by gendoc.pl .Dd $TODAY .Dt $upage 3 .Os @@ -608,7 +588,7 @@ sub gensummary($) { "; my @funcs = sort(keys(%FUNCTIONS)); while ($func = shift(@funcs)) { - print FILE ".Nm $FUNCTIONS{$func}->{'Nm'}"; + print FILE ".Nm $FUNCTIONS{$func}->{Nm}"; print FILE " ," if (@funcs); print FILE "\n"; @@ -623,8 +603,8 @@ sub gensummary($) { print FILE ".In security/openpam.h\n"; } foreach $func (sort(keys(%FUNCTIONS))) { - print FILE ".Ft $FUNCTIONS{$func}->{'Ft'}\n"; - print FILE ".Fn $FUNCTIONS{$func}->{'Fn'}\n"; + print FILE ".Ft $FUNCTIONS{$func}->{Ft}\n"; + print FILE ".Fn $FUNCTIONS{$func}->{Fn}\n"; } while (<STDIN>) { if (m/^\.Xr (\S+)\s*(\d)\s*$/) { @@ -647,7 +627,7 @@ The following return codes are defined by print FILE ".Sh SEE ALSO "; if ($page eq 'pam') { - ++$xref{3}->{'openpam'}; + ++$xref{3}->{openpam}; } foreach $func (keys(%FUNCTIONS)) { ++$xref{3}->{$func}; @@ -684,17 +664,16 @@ MAIN:{ usage() unless (@ARGV && getopts("op", \%opts)); - setlocale(LC_ALL, "en_US.UTF-8"); $TODAY = strftime("%B %e, %Y", localtime(time())); $TODAY =~ s,\s+, ,g; - if ($opts{'o'} || $opts{'p'}) { + if ($opts{o} || $opts{p}) { foreach my $fn (@ARGV) { readproto($fn); } gensummary('openpam') - if ($opts{'o'}); + if ($opts{o}); gensummary('pam') - if ($opts{'p'}); + if ($opts{p}); } else { foreach my $fn (@ARGV) { my $func = parse_source($fn); |