summaryrefslogtreecommitdiffstats
path: root/src/usr
diff options
context:
space:
mode:
authorMichael Brown2014-02-25 16:29:00 +0100
committerMichael Brown2014-02-27 14:32:58 +0100
commitc165e8d1fc03c12549e222c65505fe954a199d77 (patch)
treec2674439744e316b03173dc98a75fb83726af1b4 /src/usr
parent[uri] Refactor URI parsing and formatting (diff)
downloadipxe-c165e8d1fc03c12549e222c65505fe954a199d77.tar.gz
ipxe-c165e8d1fc03c12549e222c65505fe954a199d77.tar.xz
ipxe-c165e8d1fc03c12549e222c65505fe954a199d77.zip
[image] Ensure every image has a fully resolved URI
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/usr')
-rw-r--r--src/usr/imgmgmt.c32
1 files changed, 20 insertions, 12 deletions
diff --git a/src/usr/imgmgmt.c b/src/usr/imgmgmt.c
index 1f1f6904..18cabbbc 100644
--- a/src/usr/imgmgmt.c
+++ b/src/usr/imgmgmt.c
@@ -48,13 +48,6 @@ int imgdownload ( struct uri *uri, struct image **image ) {
char *uri_string_redacted;
int rc;
- /* Allocate image */
- *image = alloc_image ( uri );
- if ( ! *image ) {
- rc = -ENOMEM;
- goto err_alloc_image;
- }
-
/* Construct redacted URI */
password = uri->password;
if ( password )
@@ -63,12 +56,25 @@ int imgdownload ( struct uri *uri, struct image **image ) {
uri->password = password;
if ( ! uri_string_redacted ) {
rc = -ENOMEM;
- goto err_uri;
+ goto err_uri_string;
+ }
+
+ /* Resolve URI */
+ uri = resolve_uri ( cwuri, uri );
+ if ( ! uri ) {
+ rc = -ENOMEM;
+ goto err_resolve_uri;
+ }
+
+ /* Allocate image */
+ *image = alloc_image ( uri );
+ if ( ! *image ) {
+ rc = -ENOMEM;
+ goto err_alloc_image;
}
/* Create downloader */
- if ( ( rc = create_downloader ( &monojob, *image, LOCATION_URI,
- uri ) ) != 0 ) {
+ if ( ( rc = create_downloader ( &monojob, *image ) ) != 0 ) {
printf ( "Could not start download: %s\n", strerror ( rc ) );
goto err_create_downloader;
}
@@ -86,10 +92,12 @@ int imgdownload ( struct uri *uri, struct image **image ) {
err_register_image:
err_monojob_wait:
err_create_downloader:
- free ( uri_string_redacted );
- err_uri:
image_put ( *image );
err_alloc_image:
+ uri_put ( uri );
+ err_resolve_uri:
+ free ( uri_string_redacted );
+ err_uri_string:
return rc;
}