#include "paths.h"
#include "user-event.h"
+static const char *pxelinux_prefix = "pxelinux.cfg/";
+
struct pxe_parser_info {
struct discover_boot_option *opt;
const char *default_name;
static int pxe_parse(struct discover_context *dc)
{
+ struct pb_url *pxe_base_url, *url;
struct pxe_parser_info *parser_info;
char **pxe_conf_files, **filename;
- struct pb_url *conf_url, *url;
struct conf_context *conf;
bool complete_url;
int len, rc;
parser_info = talloc_zero(conf, struct pxe_parser_info);
conf->parser_info = parser_info;
- conf_url = user_event_parse_conf_url(dc, dc->event, &complete_url);
- if (!conf_url)
+ dc->conf_url = user_event_parse_conf_url(dc, dc->event, &complete_url);
+ if (!dc->conf_url)
goto out_conf;
if (complete_url) {
/* we have a complete URL; use this and we're done. */
- dc->conf_url = conf_url;
rc = parser_request_url(dc, dc->conf_url, &buf, &len);
if (rc)
goto out_conf;
rc = -1;
+ pxe_base_url = pb_url_join(dc, dc->conf_url, pxelinux_prefix);
+ if (!pxe_base_url)
+ goto out_pxe_conf;
+
for (filename = pxe_conf_files; *filename; filename++) {
- url = pb_url_join(dc, conf_url, *filename);
+ url = pb_url_join(dc, pxe_base_url, *filename);
if (!url)
- goto out_pxe_conf;
+ continue;
rc = parser_request_url(dc, url, &buf, &len);
if (!rc) /* found one, just break */
talloc_free(url);
}
+ talloc_free(pxe_base_url);
+
/* No configuration file found on the boot server */
if (rc)
goto out_pxe_conf;
- dc->conf_url = url;
-
- talloc_free(conf_url);
talloc_free(pxe_conf_files);
}
struct discover_boot_option *opt;
struct discover_context *ctx;
- test_read_conf_embedded_url(test, "tftp://host/dir/C0A8");
+ test_read_conf_embedded_url(test, "tftp://host/dir/pxelinux.cfg/C0A8");
test_set_event_source(test);
test_set_event_param(test->ctx->event, "bootfile", "dir/pxe");
struct discover_context *ctx;
test_read_conf_embedded_url(test,
- "tftp://host/dir/01-12-34-56-78-9a-bc");
+ "tftp://host/dir/pxelinux.cfg/01-12-34-56-78-9a-bc");
test_set_event_source(test);
test_set_event_param(test->ctx->event, "bootfile", "dir/pxe");
struct discover_context *ctx;
test_read_conf_embedded_url(test,
- "tftp://host/path/to/01-12-34-56-78-9a-bc");
+ "tftp://host/path/to/pxelinux.cfg/"
+ "01-12-34-56-78-9a-bc");
test_set_event_source(test);
test_set_event_param(test->ctx->event, "mac", "12:34:56:78:9a:bc");
check_resolved_url_resource(opt->boot_image,
"tftp://host/path/to/./kernel");
- check_resolved_url_resource(opt->initrd, "tftp://host/initrd");
+ check_resolved_url_resource(opt->initrd,
+ "tftp://host/initrd");
}
struct discover_boot_option *opt;
struct discover_context *ctx;
- test_read_conf_embedded_url(test, "tftp://host/path/to/C0A8");
+ test_read_conf_embedded_url(test,
+ "tftp://host/path/to/pxelinux.cfg/C0A8");
test_set_event_source(test);
test_set_event_param(test->ctx->event, "ip", "192.168.0.1");
check_resolved_url_resource(opt->boot_image,
"tftp://host/path/to/./kernel");
- check_resolved_url_resource(opt->initrd, "tftp://host/initrd");
+ check_resolved_url_resource(opt->initrd,
+ "tftp://host/initrd");
}