1*0d9d0fd8Schristos.\" $NetBSD: openpam_subst.3,v 1.10 2023/06/30 21:46:20 christos Exp $ 244269bb5Schristos.\" 38fa0fefeSchristos.\" Generated from openpam_subst.c by gendoc.pl 4*0d9d0fd8Schristos.Dd June 27, 2023 544269bb5Schristos.Dt OPENPAM_SUBST 3 644269bb5Schristos.Os 744269bb5Schristos.Sh NAME 844269bb5Schristos.Nm openpam_subst 944269bb5Schristos.Nd substitute PAM item values in a string 1044269bb5Schristos.Sh SYNOPSIS 1144269bb5Schristos.In sys/types.h 1244269bb5Schristos.In security/pam_appl.h 1344269bb5Schristos.In security/openpam.h 1444269bb5Schristos.Ft "int" 1544269bb5Schristos.Fn openpam_subst "const pam_handle_t *pamh" "char *buf" "size_t *bufsize" "const char *template" 1644269bb5Schristos.Sh DESCRIPTION 1744269bb5SchristosThe 18e1b25b17Schristos.Fn openpam_subst 1944269bb5Schristosfunction expands a string, substituting PAM item 2044269bb5Schristosvalues for all occurrences of specific substitution codes. 2144269bb5SchristosThe 2244269bb5Schristos.Fa template 2344269bb5Schristosargument points to the initial string. 2444269bb5SchristosThe result is stored in the buffer pointed to by the 2544269bb5Schristos.Fa buf 2644269bb5Schristosargument; the 2744269bb5Schristos.Fa bufsize 2844269bb5Schristosargument specifies the size of that buffer. 2944269bb5SchristosThe actual size of the resulting string, including the terminating NUL 3044269bb5Schristoscharacter, is stored in the location pointed to by the 3144269bb5Schristos.Fa bufsize 3244269bb5Schristosargument. 3344269bb5Schristos.Pp 3444269bb5SchristosIf 3544269bb5Schristos.Fa buf 3644269bb5Schristosis NULL, or if the buffer is too small to hold the expanded 3744269bb5Schristosstring, 3844269bb5Schristos.Fa bufsize 3944269bb5Schristosis updated to reflect the amount of space required to 4044269bb5Schristoshold the entire string, and 41e1b25b17Schristos.Fn openpam_subst 4244269bb5Schristosreturns 4344269bb5Schristos.Dv PAM_TRY_AGAIN . 4444269bb5Schristos.Pp 4544269bb5SchristosIf 46e1b25b17Schristos.Fn openpam_subst 4744269bb5Schristosfails for any other reason, the 4844269bb5Schristos.Fa bufsize 4944269bb5Schristosargument is 5044269bb5Schristosuntouched, but part of the buffer may still have been overwritten. 5144269bb5Schristos.Pp 5244269bb5SchristosSubstitution codes are introduced by a percent character and correspond 5344269bb5Schristosto PAM items: 5444269bb5Schristos.Bl -tag -width 18n 5544269bb5Schristos.It \&%H 5644269bb5SchristosReplaced by the current value of the 5744269bb5Schristos.Dv PAM_RHOST 5844269bb5Schristositem. 5944269bb5Schristos.It \&%h 6044269bb5SchristosReplaced by the current value of the 6144269bb5Schristos.Dv PAM_HOST 6244269bb5Schristositem. 6344269bb5Schristos.It \&%s 6444269bb5SchristosReplaced by the current value of the 6544269bb5Schristos.Dv PAM_SERVICE 6644269bb5Schristositem. 6744269bb5Schristos.It \&%t 6844269bb5SchristosReplaced by the current value of the 6944269bb5Schristos.Dv PAM_TTY 7044269bb5Schristositem. 7144269bb5Schristos.It \&%U 7244269bb5SchristosReplaced by the current value of the 7344269bb5Schristos.Dv PAM_RUSER 7444269bb5Schristositem. 7544269bb5Schristos.It \&%u 7644269bb5SchristosReplaced by the current value of the 7744269bb5Schristos.Dv PAM_USER 7844269bb5Schristositem. 7944269bb5Schristos.El 8044269bb5Schristos.Sh RETURN VALUES 8144269bb5SchristosThe 82e1b25b17Schristos.Fn openpam_subst 8344269bb5Schristosfunction returns one of the following values: 8444269bb5Schristos.Bl -tag -width 18n 854cb4af11Schristos.It Bq Er PAM_SUCCESS 864cb4af11SchristosSuccess. 874cb4af11Schristos.It Bq Er PAM_BAD_ITEM 884cb4af11SchristosUnrecognized or restricted item. 8944269bb5Schristos.It Bq Er PAM_TRY_AGAIN 9044269bb5SchristosTry again. 9144269bb5Schristos.El 9244269bb5Schristos.Sh SEE ALSO 9344269bb5Schristos.Xr pam 3 , 9444269bb5Schristos.Xr pam_get_authtok 3 , 9544269bb5Schristos.Xr pam_get_item 3 , 9644269bb5Schristos.Xr pam_get_user 3 , 9744269bb5Schristos.Xr pam_strerror 3 9844269bb5Schristos.Sh STANDARDS 9944269bb5SchristosThe 100e1b25b17Schristos.Fn openpam_subst 10144269bb5Schristosfunction is an OpenPAM extension. 10244269bb5Schristos.Sh AUTHORS 10344269bb5SchristosThe 104e1b25b17Schristos.Fn openpam_subst 105e1b25b17Schristosfunction and this manual page were 106e1b25b17Schristosdeveloped by 107a5684d07Swiz.An Dag-Erling Sm\(/orgrav Aq Mt des@des.no . 108