1.\" $NetBSD: openpam_subst.3,v 1.2 2011/12/25 22:27:55 christos Exp $ 2.\" 3.\"- 4.\" Copyright (c) 2001-2003 Networks Associates Technology, Inc. 5.\" Copyright (c) 2004-2011 Dag-Erling Smørgrav 6.\" All rights reserved. 7.\" 8.\" This software was developed for the FreeBSD Project by ThinkSec AS and 9.\" Network Associates Laboratories, the Security Research Division of 10.\" Network Associates, Inc. under DARPA/SPAWAR contract N66001-01-C-8035 11.\" ("CBOSS"), as part of the DARPA CHATS research program. 12.\" 13.\" Redistribution and use in source and binary forms, with or without 14.\" modification, are permitted provided that the following conditions 15.\" are met: 16.\" 1. Redistributions of source code must retain the above copyright 17.\" notice, this list of conditions and the following disclaimer. 18.\" 2. Redistributions in binary form must reproduce the above copyright 19.\" notice, this list of conditions and the following disclaimer in the 20.\" documentation and/or other materials provided with the distribution. 21.\" 3. The name of the author may not be used to endorse or promote 22.\" products derived from this software without specific prior written 23.\" permission. 24.\" 25.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 26.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 27.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 28.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 29.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 30.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 31.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 32.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 34.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 35.\" SUCH DAMAGE. 36.\" 37.\" Id 38.\" 39.Dd December 18, 2011 40.Dt OPENPAM_SUBST 3 41.Os 42.Sh NAME 43.Nm openpam_subst 44.Nd substitute PAM item values in a string 45.Sh LIBRARY 46.Lb libpam 47.Sh SYNOPSIS 48.In sys/types.h 49.In security/pam_appl.h 50.In security/openpam.h 51.Ft "int" 52.Fn openpam_subst "const pam_handle_t *pamh" "char *buf" "size_t *bufsize" "const char *template" 53.Sh DESCRIPTION 54The 55.Nm 56function expands a string, substituting PAM item 57values for all occurrences of specific substitution codes. 58The 59.Fa template 60argument points to the initial string. 61The result is stored in the buffer pointed to by the 62.Fa buf 63argument; the 64.Fa bufsize 65argument specifies the size of that buffer. 66The actual size of the resulting string, including the terminating NUL 67character, is stored in the location pointed to by the 68.Fa bufsize 69argument. 70.Pp 71If 72.Fa buf 73is NULL, or if the buffer is too small to hold the expanded 74string, 75.Fa bufsize 76is updated to reflect the amount of space required to 77hold the entire string, and 78.Nm 79returns 80.Dv PAM_TRY_AGAIN . 81.Pp 82If 83.Nm 84fails for any other reason, the 85.Fa bufsize 86argument is 87untouched, but part of the buffer may still have been overwritten. 88.Pp 89Substitution codes are introduced by a percent character and correspond 90to PAM items: 91.Bl -tag -width 18n 92.It \&%H 93Replaced by the current value of the 94.Dv PAM_RHOST 95item. 96.It \&%h 97Replaced by the current value of the 98.Dv PAM_HOST 99item. 100.It \&%s 101Replaced by the current value of the 102.Dv PAM_SERVICE 103item. 104.It \&%t 105Replaced by the current value of the 106.Dv PAM_TTY 107item. 108.It \&%U 109Replaced by the current value of the 110.Dv PAM_RUSER 111item. 112.It \&%u 113Replaced by the current value of the 114.Dv PAM_USER 115item. 116.El 117.Pp 118.Sh RETURN VALUES 119The 120.Nm 121function returns one of the following values: 122.Bl -tag -width 18n 123.It Bq Er PAM_SYSTEM_ERR 124System error. 125.It Bq Er PAM_TRY_AGAIN 126Try again. 127.El 128.Sh SEE ALSO 129.Xr pam 3 , 130.Xr pam_get_authtok 3 , 131.Xr pam_get_item 3 , 132.Xr pam_get_user 3 , 133.Xr pam_strerror 3 134.Sh STANDARDS 135The 136.Nm 137function is an OpenPAM extension. 138.Sh AUTHORS 139The 140.Nm 141function and this manual page were developed for the 142.Fx 143Project by 144.An Dag-Erling Sm\(/orgrav Aq des@FreeBSD.org . 145