Skip to content

Commit

Permalink
[image] Redact password from URIs displayed by imgfetch()
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Brown committed Feb 17, 2009
1 parent 6de4db5 commit 3206e47
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/usr/imgmgmt.c
Expand Up @@ -43,17 +43,28 @@
*/
int imgfetch ( struct image *image, const char *uri_string,
int ( * image_register ) ( struct image *image ) ) {
char uri_string_redacted[ strlen ( uri_string ) + 3 /* "***" */
+ 1 /* NUL */ ];
struct uri *uri;
const char *password;
int rc;

if ( ! ( uri = parse_uri ( uri_string ) ) )
return -ENOMEM;

image_set_uri ( image, uri );

/* Redact password portion of URI, if necessary */
password = uri->password;
if ( password )
uri->password = "***";
unparse_uri ( uri_string_redacted, sizeof ( uri_string_redacted ),
uri );
uri->password = password;

if ( ( rc = create_downloader ( &monojob, image, image_register,
LOCATION_URI, uri ) ) == 0 )
rc = monojob_wait ( uri_string );
rc = monojob_wait ( uri_string_redacted );

uri_put ( uri );
return rc;
Expand Down

0 comments on commit 3206e47

Please sign in to comment.