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:
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
|
@ -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}/../../..
|
||||
|
||||
|
|
|
@ -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">
|
||||
|
|
|
@ -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 <sys/param.h>
|
||||
#include <sys/wait.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/wait.h>
|
||||
|
||||
#include <err.h>
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <termios.h>
|
||||
#include <unistd.h>
|
||||
#include <err.h>
|
||||
#include <stdio.h>
|
||||
#include <syslog.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <security/pam_appl.h>
|
||||
|
||||
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 > 0)
|
||||
if (argc > 0)
|
||||
user = *argv;
|
||||
else
|
||||
user = "root";
|
||||
|
||||
/* initialize PAM */
|
||||
pamc.conv = &converse;
|
||||
pam_start("su", user, &pamc, &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, &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>
|
||||
}
|
Loading…
Reference in a new issue