diff options
author | Michael Brown | 2011-01-28 01:24:05 +0100 |
---|---|---|
committer | Michael Brown | 2011-01-28 01:25:40 +0100 |
commit | 3ed849bbf2922b8726f468ef01d9b5e511e83f71 (patch) | |
tree | 12ce40a14687a4b5c59d5eaf4a30d97c9c5132f2 /src/usr | |
parent | [settings] Generalise expand_command() to expand_settings() (diff) | |
download | ipxe-3ed849bbf2922b8726f468ef01d9b5e511e83f71.tar.gz ipxe-3ed849bbf2922b8726f468ef01d9b5e511e83f71.tar.xz ipxe-3ed849bbf2922b8726f468ef01d9b5e511e83f71.zip |
[autoboot] Allow setting expansions in filename and root-path
Allow the DHCP filename and root-path to contain settings expansions,
such as
http://boot.ipxe.org/demo/boot.php?mac=${mac:hexhyp}
Originally-implemented-by: Jarrod Johnson <jarrod.b.johnson@gmail.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/usr')
-rw-r--r-- | src/usr/autoboot.c | 42 |
1 files changed, 32 insertions, 10 deletions
diff --git a/src/usr/autoboot.c b/src/usr/autoboot.c index e7d6787a..91f1c6e8 100644 --- a/src/usr/autoboot.c +++ b/src/usr/autoboot.c @@ -230,7 +230,9 @@ static void close_all_netdevs ( void ) { */ struct uri * fetch_next_server_and_filename ( struct settings *settings ) { struct in_addr next_server; - char filename[256]; + char buf[256]; + char *filename; + struct uri *uri; /* Fetch next-server setting */ fetch_ipv4_setting ( settings, &next_server_setting, &next_server ); @@ -239,11 +241,20 @@ struct uri * fetch_next_server_and_filename ( struct settings *settings ) { /* Fetch filename setting */ fetch_string_setting ( settings, &filename_setting, - filename, sizeof ( filename ) ); - if ( filename[0] ) - printf ( "Filename: %s\n", filename ); + buf, sizeof ( buf ) ); + if ( buf[0] ) + printf ( "Filename: %s\n", buf ); + + /* Expand filename setting */ + filename = expand_settings ( buf ); + if ( ! filename ) + return NULL; - return parse_next_server_and_filename ( next_server, filename ); + /* Parse next server and filename */ + uri = parse_next_server_and_filename ( next_server, filename ); + + free ( filename ); + return uri; } /** @@ -253,15 +264,26 @@ struct uri * fetch_next_server_and_filename ( struct settings *settings ) { * @ret uri URI, or NULL on failure */ static struct uri * fetch_root_path ( struct settings *settings ) { - char root_path[256]; + char buf[256]; + char *root_path; + struct uri *uri; /* Fetch root-path setting */ fetch_string_setting ( settings, &root_path_setting, - root_path, sizeof ( root_path ) ); - if ( root_path[0] ) - printf ( "Root path: %s\n", root_path ); + buf, sizeof ( buf ) ); + if ( buf[0] ) + printf ( "Root path: %s\n", buf ); + + /* Expand filename setting */ + root_path = expand_settings ( buf ); + if ( ! root_path ) + return NULL; - return parse_uri ( root_path ); + /* Parse root path */ + uri = parse_uri ( root_path ); + + free ( root_path ); + return uri; } /** |