Instead of having a marked-up copy of the source code, keep a compilable

copy, and use an <inlinegraphic> to suck it into the article.

Suggested by:	hrs
This commit is contained in:
Dag-Erling Smørgrav 2002-01-20 22:52:51 +00:00
parent a24fa9bc27
commit 820352acae
Notes: svn2git 2020-12-08 03:00:23 +00:00
svn path=/head/; revision=11766
3 changed files with 60 additions and 68 deletions

View file

@ -9,7 +9,12 @@ INSTALL_ONLY_COMPRESSED?=
JADEFLAGS+= -V %generate-article-toc%
SRCS= article.sgml
SRCS= article.sgml pam_app.c
CLEANFILES+= pam_app.c
pam_app.c: su.c
perl -ne 'print unless m|^[/ ]\*|' su.c >${.TARGET}
DOC_PREFIX?= ${.CURDIR}/../../..

View file

@ -1,14 +1,6 @@
<!DOCTYPE article PUBLIC "-//FreeBSD//DTD DocBook V4.1-Based Extension//EN" [
<!ENTITY % man PUBLIC "-//FreeBSD//ENTITIES DocBook Manual Page Entities//EN">
%man;
<!ENTITY % freebsd PUBLIC "-//FreeBSD//ENTITIES DocBook Miscellaneous
FreeBSD Entities//EN"> %freebsd;
<!ENTITY % newsgroups PUBLIC "-//FreeBSD//ENTITIES DocBook Newsgroup Entities//EN"> %newsgroups;
<!ENTITY % authors PUBLIC "-//FreeBSD//ENTITIES DocBook Author Entities//EN">
%authors;
<!ENTITY % mailing-lists PUBLIC "-//FreeBSD//ENTITIES DocBook Mailing List Entities//EN"> %mailing-lists;
<!ENTITY % not.published "IGNORE">
<!ENTITY pam-sample-app SYSTEM "pam-sample-app.sgml">
]>
<!--
@ -826,10 +818,13 @@ sshd password required pam_permit.so</programlisting>
<title id="pam-sample-appl.title">Sample PAM application</title>
<para>The following is a minimal implementation of &man.su.1;
using PAM. The conversation function has been omitted for
simplicity.</para>
using PAM. Note that it uses the Linux-PAM-specific
<function>misc_conv</function> conversation function, which is
prototyped in <filename
class="headerfile">security/pam_misc.h</filename>.</para>
&pam-sample-app;
<programlisting><inlinegraphic fileref="pam_app.c"
format="linespecific"></programlisting>
</appendix>
<appendix id="pam-sample-module">

View file

@ -1,57 +1,49 @@
<!--
- Copyright (c) 2002 Networks Associates Technologies, 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.
-
- $FreeBSD$
-->
/*-
* Copyright (c) 2002 Networks Associates Technologies, 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.
*
* $FreeBSD$
*/
<programlisting>#include &lt;sys/param.h&gt;
#include &lt;sys/wait.h&gt;
#include <sys/param.h>
#include <sys/wait.h>
#include &lt;err.h&gt;
#include &lt;ctype.h&gt;
#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;string.h&gt;
#include &lt;termios.h&gt;
#include &lt;unistd.h&gt;
#include <err.h>
#include <stdio.h>
#include <syslog.h>
#include <unistd.h>
#include &lt;security/pam_appl.h&gt;
extern int
converse(int n,
const struct pam_message **msg,
struct pam_response **resp,
void *data);
#include <security/pam_appl.h>
#include <security/pam_misc.h>
static pam_handle_t *pamh;
static struct pam_conv pamc;
@ -91,14 +83,14 @@ main(int argc, char *argv[])
argc -= optind;
argv += optind;
if (argc &gt; 0)
if (argc > 0)
user = *argv;
else
user = "root";
/* initialize PAM */
pamc.conv = &amp;converse;
pam_start("su", user, &amp;pamc, &amp;pamh);
pamc.conv = &misc_conv;
pam_start("su", user, &pamc, &pamh);
/* set some items */
gethostname(hostname, sizeof hostname);
@ -131,7 +123,7 @@ main(int argc, char *argv[])
err(1, "execvp()");
default:
/* parent: wait for child to exit */
waitpid(pid, &amp;status, 0);
waitpid(pid, &status, 0);
if (WIFEXITED(status))
status = WEXITSTATUS(status);
else
@ -143,4 +135,4 @@ main(int argc, char *argv[])
check("pam_end", pam_end(pamh, 0));
exit(status);
}</programlisting>
}