FreeBSD/lib/libpam/modules/pam_ssh/pam_ssh.c
/*
 * Parses a line from ssh-agent's output.
 */
Parses a line from ssh-agent's output.
Parses a line from ssh - agent ' s output .
static void
pam_ssh_process_agent_output(pam_handle_t *pamh, FILE *f)
{
	char *line, *p, *key, *val;
	size_t len;
	while ((line = fgetln(f, &len)) != NULL) {
		if (len < 4 || strncmp(line, "SSH_", 4) != 0)
			continue;
		for (p = key = line; p < line + len; ++p)
			if (*p == '=')
				break;
		if (p == line + len || *p != '=')
			continue;
		*p = '\0';
		for (val = ++p; p < line + len; ++p)
			if (*p == ';')
				break;
		if (p == line + len || *p != ';')
			continue;
		*p = '\0';
		openpam_log(PAM_LOG_DEBUG, "got %s: %s", key, val);
		pam_setenv(pamh, key, val, 1);
	}
}
static void pam_ssh_process_agent_output ( pam_handle_t * pamh , FILE * f ) { char * line , * p , * key , * val ; size_t len ; while ( ( line = fgetln ( f , & len ) ) != NULL ) { if ( len < 4 || strncmp ( line , " " , 4 ) != 0 ) continue ; for ( p = key = line ; p < line + len ; ++ p ) if ( * p == ' ' ) break ; if ( p == line + len || * p != ' ' ) continue ; * p = ' \0 ' ; for ( val = ++ p ; p < line + len ; ++ p ) if ( * p == ' ' ) break ; if ( p == line + len || * p != ' ' ) continue ; * p = ' \0 ' ; openpam_log ( PAM_LOG_DEBUG , " " , key , val ) ; pam_setenv ( pamh , key , val , 1 ) ; } }
Parses a line from ssh-agent's output.
Parses a line from ssh - agent ' s output .
/* find equal sign at end of key */ /* find semicolon at end of value */ /* store key-value pair in environment */