]> git.ozlabs.org Git - petitboot/commitdiff
discover/pxe: Fix prefix autodetection when bootfile is in the root dir
authorJeremy Kerr <jk@ozlabs.org>
Thu, 27 Feb 2014 03:39:41 +0000 (11:39 +0800)
committerJeremy Kerr <jk@ozlabs.org>
Thu, 27 Feb 2014 05:24:24 +0000 (13:24 +0800)
Currently, if the bootfile doesn't contain a directory, the path we use
for config file resolution will use the bootfile as the first component
of path.

For example, if bootfile is:

  pxelinux.0

the config files requested will be:

  pxelinux.0/<mac>
  pxelinux.0/<ips>
  pxelinux.0/default

For cases where bootfile is a single file, we need to use a blank
prefix.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
discover/user-event.c

index 1e366ee387c6cad138998c2686d6ae0ef0832a51..cf7f20c599bbefdac3c004834dc75966500a7a4b 100644 (file)
@@ -290,8 +290,9 @@ struct pb_url *user_event_parse_conf_url(struct discover_context *ctx,
                /* strip filename from the bootfile path, leaving only a
                 * directory */
                p = strrchr(basedir, '/');
                /* strip filename from the bootfile path, leaving only a
                 * directory */
                p = strrchr(basedir, '/');
-               if (p)
-                       *p = '\0';
+               if (!p)
+                       p = basedir;
+               *p = '\0';
 
                if (strlen(basedir))
                        url_str = talloc_asprintf_append(url_str, "%s/",
 
                if (strlen(basedir))
                        url_str = talloc_asprintf_append(url_str, "%s/",