Changeset 152 in openpam for trunk


Ignore:
Timestamp:
May 27, 2002, 6:23:03 PM (17 years ago)
Author:
Dag-Erling Smørgrav
Message:

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

Location:
trunk
Files:
40 deleted
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/MANIFEST

    r149 r152  
    11#
    2 # $P4: //depot/projects/openpam/MANIFEST#9 $
     2# $P4: //depot/projects/openpam/MANIFEST#10 $
    33#
    44CREDITS
     
    1515doc/Makefile
    1616doc/man/Makefile
     17doc/man/openpam.3
    1718doc/man/openpam_borrow_cred.3
    1819doc/man/openpam_free_data.3
     
    2324doc/man/openpam_set_option.3
    2425doc/man/openpam_ttyconv.3
    25 doc/man/pam.3
    2626doc/man/pam_acct_mgmt.3
    2727doc/man/pam_authenticate.3
  • trunk/dist.sh

    r118 r152  
    11#!/bin/sh
    22#
    3 # $P4: //depot/projects/openpam/dist.sh#3 $
     3# $P4: //depot/projects/openpam/dist.sh#4 $
    44#
    55
     
    99distname="openpam-${release}"
    1010
     11make cleandir
     12make cleandir
     13(cd doc/man && make openpam.3)
    1114install -d -m 0755 "${distname}"
    1215grep -v '^#' MANIFEST | while read file; do
     
    1417    install -c -m 0644 "${file}" "${distname}/${file}"
    1518done
    16 tar zcf "/tmp/${distname}.tar.gz" "${distname}"
     19tar zcf "${distname}.tar.gz" "${distname}"
    1720rm -rf "${distname}"
     21make cleandir
  • trunk/doc/man/Makefile

    r148 r152  
    3232# SUCH DAMAGE.
    3333#
    34 # $P4: //depot/projects/openpam/doc/man/Makefile#8 $
     34# $P4: //depot/projects/openpam/doc/man/Makefile#9 $
    3535#
    3636
    37 MAN              =
    38 MAN             += openpam_borrow_cred.3
    39 MAN             += openpam_free_data.3
    40 MAN             += openpam_get_option.3
    41 MAN             += openpam_log.3
    42 MAN             += openpam_nullconv.3
    43 MAN             += openpam_restore_cred.3
    44 MAN             += openpam_set_option.3
    45 MAN             += openpam_ttyconv.3
    46 MAN             += pam.3
    47 MAN             += pam_acct_mgmt.3
    48 MAN             += pam_authenticate.3
    49 MAN             += pam_chauthtok.3
    50 MAN             += pam_close_session.3
    51 MAN             += pam_end.3
    52 MAN             += pam_error.3
    53 MAN             += pam_get_authtok.3
    54 MAN             += pam_get_data.3
    55 MAN             += pam_get_item.3
    56 MAN             += pam_get_user.3
    57 MAN             += pam_getenv.3
    58 MAN             += pam_getenvlist.3
    59 MAN             += pam_info.3
    60 MAN             += pam_open_session.3
    61 MAN             += pam_prompt.3
    62 MAN             += pam_putenv.3
    63 MAN             += pam_set_data.3
    64 MAN             += pam_set_item.3
    65 MAN             += pam_setcred.3
    66 MAN             += pam_setenv.3
    67 MAN             += pam_sm_acct_mgmt.3
    68 MAN             += pam_sm_authenticate.3
    69 MAN             += pam_sm_chauthtok.3
    70 MAN             += pam_sm_close_session.3
    71 MAN             += pam_sm_open_session.3
    72 MAN             += pam_sm_setcred.3
    73 MAN             += pam_start.3
    74 MAN             += pam_strerror.3
    75 MAN             += pam_verror.3
    76 MAN             += pam_vinfo.3
    77 MAN             += pam_vprompt.3
     37GENDOC           = ${.CURDIR}/../../misc/gendoc.pl
    7838
    79 generate:
    80         (cd ${.CURDIR} && perl -w ../../misc/gendoc.pl ../../lib/*.c >pam.3)
     39CMAN             =
     40CMAN            += openpam_borrow_cred.3
     41CMAN            += openpam_free_data.3
     42CMAN            += openpam_get_option.3
     43CMAN            += openpam_log.3
     44CMAN            += openpam_nullconv.3
     45CMAN            += openpam_restore_cred.3
     46CMAN            += openpam_set_option.3
     47CMAN            += openpam_ttyconv.3
     48CMAN            += pam_acct_mgmt.3
     49CMAN            += pam_authenticate.3
     50CMAN            += pam_chauthtok.3
     51CMAN            += pam_close_session.3
     52CMAN            += pam_end.3
     53CMAN            += pam_error.3
     54CMAN            += pam_get_authtok.3
     55CMAN            += pam_get_data.3
     56CMAN            += pam_get_item.3
     57CMAN            += pam_get_user.3
     58CMAN            += pam_getenv.3
     59CMAN            += pam_getenvlist.3
     60CMAN            += pam_info.3
     61CMAN            += pam_open_session.3
     62CMAN            += pam_prompt.3
     63CMAN            += pam_putenv.3
     64CMAN            += pam_set_data.3
     65CMAN            += pam_set_item.3
     66CMAN            += pam_setcred.3
     67CMAN            += pam_setenv.3
     68CMAN            += pam_sm_acct_mgmt.3
     69CMAN            += pam_sm_authenticate.3
     70CMAN            += pam_sm_chauthtok.3
     71CMAN            += pam_sm_close_session.3
     72CMAN            += pam_sm_open_session.3
     73CMAN            += pam_sm_setcred.3
     74CMAN            += pam_start.3
     75CMAN            += pam_strerror.3
     76CMAN            += pam_verror.3
     77CMAN            += pam_vinfo.3
     78CMAN            += pam_vprompt.3
     79
     80MAN              = ${CMAN}
     81MAN             += openpam.3
     82MLINKS           = openpam.3 pam.3
     83
     84CLEANFILES      += ${CMAN} openpam.3
     85
     86.for man in ${CMAN}
     87${man}: ${.CURDIR}/../../lib/${man:R}.c ${GENDOC}
     88        perl -w ${GENDOC} ${.CURDIR}/../../lib/${man:R}.c
     89.endfor
     90
     91openpam.3: ${CMAN} ${GENDOC}
     92        perl -w ${GENDOC} -s ${CMAN}
    8193
    8294.include <bsd.prog.mk>
  • trunk/misc/gendoc.pl

    r144 r152  
    3333# SUCH DAMAGE.
    3434#
    35 # $P4: //depot/projects/openpam/misc/gendoc.pl#14 $
     35# $P4: //depot/projects/openpam/misc/gendoc.pl#15 $
    3636#
    3737
    3838use strict;
    3939use Fcntl;
     40use Getopt::Std;
    4041use POSIX qw(strftime);
    4142use vars qw($COPYRIGHT $TODAY %FUNCTIONS %PAMERR);
     43
     44$COPYRIGHT = ".\\\"-
     45.\\\" Copyright (c) 2002 Networks Associates Technology, Inc.
     46.\\\" All rights reserved.
     47.\\\"
     48.\\\" This software was developed for the FreeBSD Project by ThinkSec AS and
     49.\\\" NAI Labs, the Security Research Division of Network Associates, Inc.
     50.\\\" under DARPA/SPAWAR contract N66001-01-C-8035 (\"CBOSS\"), as part of the
     51.\\\" DARPA CHATS research program.
     52.\\\"
     53.\\\" Redistribution and use in source and binary forms, with or without
     54.\\\" modification, are permitted provided that the following conditions
     55.\\\" are met:
     56.\\\" 1. Redistributions of source code must retain the above copyright
     57.\\\"    notice, this list of conditions and the following disclaimer.
     58.\\\" 2. Redistributions in binary form must reproduce the above copyright
     59.\\\"    notice, this list of conditions and the following disclaimer in the
     60.\\\"    documentation and/or other materials provided with the distribution.
     61.\\\" 3. The name of the author may not be used to endorse or promote
     62.\\\"    products derived from this software without specific prior written
     63.\\\"    permission.
     64.\\\"
     65.\\\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
     66.\\\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     67.\\\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     68.\\\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
     69.\\\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     70.\\\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     71.\\\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     72.\\\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     73.\\\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     74.\\\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     75.\\\" SUCH DAMAGE.
     76.\\\"
     77.\\\" \$" . "P4" . "\$
     78.\\\"";
    4279
    4380%PAMERR = (
     
    92129    if ($fn !~ m,\.c$,) {
    93130        warn("$fn: not C source, ignoring\n");
    94         return;
     131        return undef;
    95132    }
    96133
     
    100137    close(FILE);
    101138
    102     return if ($source =~ m/^ \* NOPARSE\s*$/m);
    103 
    104     if (!defined($COPYRIGHT) && $source =~ m,^(/\*-\n.*?)\s*\*/,s) {
    105         $COPYRIGHT = $1;
    106         $COPYRIGHT =~ s,^.\*,.\\\",gm;
    107         $COPYRIGHT =~ s,(\$(?:)P4).*?\$,$1\$,;
    108         $COPYRIGHT .= "\n.\\\"";
    109     }
     139    return undef
     140        if ($source =~ m/^ \* NOPARSE\s*$/m);
     141
    110142    $func = $fn;
    111143    $func =~ s,^(?:.*/)?([^/]+)\.c$,$1,;
    112144    if ($source !~ m,\n \* ([\S ]+)\n \*/\n\n([\S ]+)\n$func\((.*?)\)\n\{,s) {
    113145        warn("$fn: can't find $func\n");
    114         return;
     146        return undef;
    115147    }
    116148    ($descr, $type, $args) = ($1, $2, $3);
     
    232264
    233265    $FUNCTIONS{$func} = {
     266        'source'        => $fn,
    234267        'name'          => $func,
    235268        'descr'         => $descr,
     
    250283        $FUNCTIONS{$func}->{'openpam'} = 1;
    251284    }
     285    expand_errors($FUNCTIONS{$func});
     286    return $FUNCTIONS{$func};
    252287}
    253288
     
    257292
    258293    my %errors;
     294    my $ref;
     295    my $fn;
    259296
    260297    if (defined($func->{'recursed'})) {
     
    274311            # treat negations separately
    275312        } elsif (m/^=([a-z_]+)$/) {
    276             if (!defined($FUNCTIONS{$1})) {
    277                 warn("$func->{'name'}(): reference to unknown $1()\n");
     313            $ref = $1;
     314            if (!defined($FUNCTIONS{$ref})) {
     315                $fn = $func->{'source'};
     316                $fn =~ s/$func->{'name'}/$ref/;
     317                parse_source($fn);
     318            }
     319            if (!defined($FUNCTIONS{$ref})) {
     320                warn("$func->{'name'}(): reference to unknown $ref()\n");
    278321                next;
    279322            }
    280             foreach (expand_errors($FUNCTIONS{$1})) {
     323            foreach (@{$FUNCTIONS{$ref}->{'errors'}}) {
    281324                $errors{$_} = 1;
    282325            }
     
    291334    }
    292335    delete($func->{'recursed'});
    293     return (sort(keys(%errors)));
     336    $func->{'errors'} = [ sort(keys(%errors)) ];
    294337}
    295338
     
    333376.Bl -tag -width 18n
    334377";
    335         my @errors = expand_errors($func);
     378        my @errors = @{$func->{'errors'}};
    336379        warn("$func->{'name'}(): no error specification\n")
    337380            unless(@errors);
     
    388431}
    389432
     433sub readproto($) {
     434    my $fn = shift;             # File name
     435
     436    local *FILE;
     437    my %func;
     438
     439    sysopen(FILE, $fn, O_RDONLY)
     440        or die("$fn: open(): $!\n");
     441    while (<FILE>) {
     442        if (m/^\.Nm ((?:open)?pam_.*?)\s*$/) {
     443            $func{'Nm'} = $func{'Nm'} || $1;
     444        } elsif (m/^\.Ft (\S.*?)\s*$/) {
     445            $func{'Ft'} = $func{'Ft'} || $1;
     446        } elsif (m/^\.Fn (\S.*?)\s*$/) {
     447            $func{'Fn'} = $func{'Fn'} || $1;
     448        }
     449    }
     450    close(FILE);
     451    if ($func{'Nm'}) {
     452        $FUNCTIONS{$func{'Nm'}} = \%func;
     453    } else {
     454        warn("No function found\n");
     455    }
     456}
     457
    390458sub gensummary() {
    391459
     460    local *FILE;
    392461    my $func;
    393462
    394     print "$COPYRIGHT
     463    sysopen(FILE, "openpam.3", O_RDWR|O_CREAT|O_TRUNC)
     464        or die("openpam.3: $!\n");
     465
     466    print FILE "$COPYRIGHT
    395467.Dd $TODAY
    396468.Dt PAM 3
     
    398470.Sh NAME
    399471";
    400     my @funcs = sort(keys(%FUNCTIONS));
    401     while ($func = shift(@funcs)) {
    402         next if (defined($FUNCTIONS{$func}->{'nolist'}));
    403         print ".Nm $func". (@funcs ? " ,\n" : "\n");
    404     }
    405     print ".Nd Pluggable Authentication Modules Library
     472    foreach $func (sort(keys(%FUNCTIONS))) {
     473        print FILE ".Nm $FUNCTIONS{$func}->{'Nm'}\n";
     474    }
     475    print FILE ".Nd Pluggable Authentication Modules Library
    406476.Sh LIBRARY
    407477.Lb libpam
     
    410480";
    411481    foreach $func (sort(keys(%FUNCTIONS))) {
    412         next if (defined($FUNCTIONS{$func}->{'nolist'}));
    413         print ".Ft $FUNCTIONS{$func}->{'type'}\n";
    414         print ".Fn $func $FUNCTIONS{$func}->{'args'}\n";
    415     }
    416     print ".Sh DESCRIPTION
     482        print FILE ".Ft $FUNCTIONS{$func}->{'Ft'}\n";
     483        print FILE ".Fn $FUNCTIONS{$func}->{'Fn'}\n";
     484    }
     485    print FILE ".Sh DESCRIPTION
    417486.Sh RETURN VALUES
    418487The following return codes are defined in the
     
    422491";
    423492    foreach (sort(keys(%PAMERR))) {
    424         print ".It Bq Er $_\n$PAMERR{$_}.\n";
    425     }
    426     print ".El
     493        print FILE ".It Bq Er $_\n$PAMERR{$_}.\n";
     494    }
     495    print FILE ".El
    427496.Sh SEE ALSO
    428497";
    429498    foreach $func (sort(keys(%FUNCTIONS))) {
    430         next if (defined($FUNCTIONS{$func}->{'nolist'}));
    431         print ".Xr $func 3 ,\n";
    432     }
    433     print ".Xr pam.conf 5
     499        print FILE ".Xr $func 3 ,\n";
     500    }
     501    print FILE ".Xr pam.conf 5
    434502.Sh STANDARDS
    435503.Rs
     
    444512.Pq Dq CBOSS ,
    445513as part of the DARPA CHATS research program.
    446 "
     514";
     515    close(FILE);
     516}
     517
     518sub usage() {
     519
     520    print(STDERR "usage: gendoc [-s] source [...]\n");
     521    exit(1);
    447522}
    448523
    449524MAIN:{
     525    my %opts;
     526
     527    usage()
     528        unless (@ARGV && getopts("s", \%opts));
    450529    $TODAY = strftime("%B %e, %Y", localtime(time()));
    451530    $TODAY =~ s,\s+, ,g;
    452     foreach my $fn (@ARGV) {
    453         parse_source($fn);
    454     }
    455     foreach my $func (values(%FUNCTIONS)) {
    456         gendoc($func);
    457     }
    458     gensummary();
    459 }
     531    if ($opts{'s'}) {
     532        foreach my $fn (@ARGV) {
     533            readproto($fn);
     534        }
     535        gensummary();
     536    } else {
     537        foreach my $fn (@ARGV) {
     538            my $func = parse_source($fn);
     539            gendoc($func)
     540                if (defined($func));
     541        }
     542    }
     543    exit(0);
     544}
Note: See TracChangeset for help on using the changeset viewer.