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%
|
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}/../../..
|
DOC_PREFIX?= ${.CURDIR}/../../..
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,6 @@
|
||||||
<!DOCTYPE article PUBLIC "-//FreeBSD//DTD DocBook V4.1-Based Extension//EN" [
|
<!DOCTYPE article PUBLIC "-//FreeBSD//DTD DocBook V4.1-Based Extension//EN" [
|
||||||
<!ENTITY % man PUBLIC "-//FreeBSD//ENTITIES DocBook Manual Page Entities//EN">
|
<!ENTITY % man PUBLIC "-//FreeBSD//ENTITIES DocBook Manual Page Entities//EN">
|
||||||
%man;
|
%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>
|
<title id="pam-sample-appl.title">Sample PAM application</title>
|
||||||
|
|
||||||
<para>The following is a minimal implementation of &man.su.1;
|
<para>The following is a minimal implementation of &man.su.1;
|
||||||
using PAM. The conversation function has been omitted for
|
using PAM. Note that it uses the Linux-PAM-specific
|
||||||
simplicity.</para>
|
<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>
|
||||||
|
|
||||||
<appendix id="pam-sample-module">
|
<appendix id="pam-sample-module">
|
||||||
|
|
|
@ -1,57 +1,49 @@
|
||||||
<!--
|
/*-
|
||||||
- Copyright (c) 2002 Networks Associates Technologies, Inc.
|
* Copyright (c) 2002 Networks Associates Technologies, Inc.
|
||||||
- All rights reserved.
|
* All rights reserved.
|
||||||
-
|
*
|
||||||
- This software was developed for the FreeBSD Project by ThinkSec AS and
|
* This software was developed for the FreeBSD Project by ThinkSec AS and
|
||||||
- NAI Labs, the Security Research Division of Network Associates, Inc.
|
* NAI Labs, the Security Research Division of Network Associates, Inc.
|
||||||
- under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the
|
* under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the
|
||||||
- DARPA CHATS research program.
|
* DARPA CHATS research program.
|
||||||
-
|
*
|
||||||
- Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
- modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
- are met:
|
* are met:
|
||||||
- 1. Redistributions of source code must retain the above copyright
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
- notice, this list of conditions and the following disclaimer.
|
* notice, this list of conditions and the following disclaimer.
|
||||||
- 2. Redistributions in binary form must reproduce the above copyright
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
- notice, this list of conditions and the following disclaimer in the
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
- documentation and/or other materials provided with the distribution.
|
* documentation and/or other materials provided with the distribution.
|
||||||
- 3. The name of the author may not be used to endorse or promote
|
* 3. The name of the author may not be used to endorse or promote
|
||||||
- products derived from this software without specific prior written
|
* products derived from this software without specific prior written
|
||||||
- permission.
|
* permission.
|
||||||
-
|
*
|
||||||
- THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||||
- ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
- ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||||
- FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
- OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
- HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
- LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
* 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
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
- SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
-
|
*
|
||||||
- $FreeBSD$
|
* $FreeBSD$
|
||||||
-->
|
*/
|
||||||
|
|
||||||
<programlisting>#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
|
|
||||||
#include <err.h>
|
#include <err.h>
|
||||||
#include <ctype.h>
|
#include <stdio.h>
|
||||||
#include <stdio.h>
|
#include <syslog.h>
|
||||||
#include <stdlib.h>
|
#include <unistd.h>
|
||||||
#include <string.h>
|
|
||||||
#include <termios.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
#include <security/pam_appl.h>
|
#include <security/pam_appl.h>
|
||||||
|
#include <security/pam_misc.h>
|
||||||
extern int
|
|
||||||
converse(int n,
|
|
||||||
const struct pam_message **msg,
|
|
||||||
struct pam_response **resp,
|
|
||||||
void *data);
|
|
||||||
|
|
||||||
static pam_handle_t *pamh;
|
static pam_handle_t *pamh;
|
||||||
static struct pam_conv pamc;
|
static struct pam_conv pamc;
|
||||||
|
@ -91,14 +83,14 @@ main(int argc, char *argv[])
|
||||||
argc -= optind;
|
argc -= optind;
|
||||||
argv += optind;
|
argv += optind;
|
||||||
|
|
||||||
if (argc > 0)
|
if (argc > 0)
|
||||||
user = *argv;
|
user = *argv;
|
||||||
else
|
else
|
||||||
user = "root";
|
user = "root";
|
||||||
|
|
||||||
/* initialize PAM */
|
/* initialize PAM */
|
||||||
pamc.conv = &converse;
|
pamc.conv = &misc_conv;
|
||||||
pam_start("su", user, &pamc, &pamh);
|
pam_start("su", user, &pamc, &pamh);
|
||||||
|
|
||||||
/* set some items */
|
/* set some items */
|
||||||
gethostname(hostname, sizeof hostname);
|
gethostname(hostname, sizeof hostname);
|
||||||
|
@ -131,7 +123,7 @@ main(int argc, char *argv[])
|
||||||
err(1, "execvp()");
|
err(1, "execvp()");
|
||||||
default:
|
default:
|
||||||
/* parent: wait for child to exit */
|
/* parent: wait for child to exit */
|
||||||
waitpid(pid, &status, 0);
|
waitpid(pid, &status, 0);
|
||||||
if (WIFEXITED(status))
|
if (WIFEXITED(status))
|
||||||
status = WEXITSTATUS(status);
|
status = WEXITSTATUS(status);
|
||||||
else
|
else
|
||||||
|
@ -143,4 +135,4 @@ main(int argc, char *argv[])
|
||||||
check("pam_end", pam_end(pamh, 0));
|
check("pam_end", pam_end(pamh, 0));
|
||||||
|
|
||||||
exit(status);
|
exit(status);
|
||||||
}</programlisting>
|
}
|
Loading…
Reference in a new issue