usr.bin/ssh/auth.c
/*
 * Given a template and a passwd structure, build a filename
 * by substituting % tokenised options. Currently, %% becomes '%',
 * %h becomes the home directory and %u the username.
 *
 * This returns a buffer allocated by xmalloc.
 */
Given a template and a passwd structure, build a filename
by substituting % tokenised options.

This returns a buffer allocated by xmalloc.
Given a template and a passwd structure build a filename by substituting % tokenised options . This returns a buffer allocated by xmalloc .
char *
expand_authorized_keys(const char *filename, struct passwd *pw)
{
	char *file, ret[PATH_MAX];
	int i;
	file = percent_expand(filename, "h", pw->pw_dir,
	    "u", pw->pw_name, (char *)NULL);
	if (*file == '/')
		return (file);
	i = snprintf(ret, sizeof(ret), "%s/%s", pw->pw_dir, file);
	if (i < 0 || (size_t)i >= sizeof(ret))
		fatal("expand_authorized_keys: path too long");
	free(file);
	return (xstrdup(ret));
}
char * expand_authorized_keys ( const char * filename , struct passwd * pw ) { char * file , ret [ PATH_MAX ] ; int i ; file = percent_expand ( filename , " " , pw -> pw_dir , " " , pw -> pw_name , ( char * ) NULL ) ; if ( * file == ' ' ) return ( file ) ; i = snprintf ( ret , sizeof ( ret ) , " " , pw -> pw_dir , file ) ; if ( i < 0 || ( size_t ) i >= sizeof ( ret ) ) fatal ( " " ) ; free ( file ) ; return ( xstrdup ( ret ) ) ; }
Given a template and a passwd structure, build a filename
 by substituting % tokenised options.
Given a template and a passwd structure build a filename by substituting % tokenised options .
/*
	 * Ensure that filename starts anchored. If not, be backward
	 * compatible and prepend the '%h/'
	 */