]> git.ozlabs.org Git - petitboot/blobdiff - discover/paths.c
ui/ncurses: Display current ipmi bootdev settings
[petitboot] / discover / paths.c
index aa977fdba1f3d0bcbdbf84356a854877c202a17d..0d414ebaac0833a075b0f65532734e1620e46649 100644 (file)
@@ -1,4 +1,6 @@
-#define _GNU_SOURCE
+#if defined(HAVE_CONFIG_H)
+#include "config.h"
+#endif
 
 #include <assert.h>
 #include <string.h>
@@ -46,15 +48,17 @@ char *join_paths(void *alloc_ctx, const char *a, const char *b)
 
 static char *local_name(void *ctx)
 {
-       char *tmp, *ret;
+       char *ret, tmp[] = "/tmp/pb-XXXXXX";
+       int fd;
 
-       tmp = tempnam(NULL, "pb-");
+       fd = mkstemp(tmp);
 
-       if (!tmp)
+       if (fd < 0)
                return NULL;
 
+       close(fd);
+
        ret = talloc_strdup(ctx, tmp);
-       free(tmp);
 
        return ret;
 }
@@ -82,7 +86,7 @@ static void load_url_process_exit(struct process *process)
 
        if (result->status == LOAD_CANCELLED) {
                load_url_result_cleanup_local(result);
-       } else if (process->exit_status == 0) {
+       } else if (process_exit_ok(process)) {
                result->status = LOAD_OK;
        } else {
                result->status = LOAD_ERROR;
@@ -127,7 +131,10 @@ static void load_process_to_local_file(struct load_task *task,
                task->result->status = rc ? LOAD_ERROR : LOAD_ASYNC;
        } else {
                rc = process_run_sync(task->process);
-               task->result->status = rc ? LOAD_ERROR : LOAD_OK;
+               if (rc || !process_exit_ok(task->process))
+                       task->result->status = LOAD_ERROR;
+               else
+                       task->result->status = LOAD_OK;
                process_release(task->process);
                task->process = NULL;
        }
@@ -218,6 +225,7 @@ static enum tftp_type check_tftp_type(void *ctx)
        process->path = pb_system_apps.tftp;
        process->argv = argv;
        process->keep_stdout = true;
+       process->add_stderr = true;
        process_run_sync(process);
 
        if (!process->stdout_buf || process->stdout_len == 0) {
@@ -302,8 +310,9 @@ static void load_wget(struct load_task *task, int flags)
                pb_system_apps.wget,
                "-O",
                NULL, /* 2: local file */
-               NULL,
-               NULL,
+               NULL, /* 3 (optional): --quiet */
+               NULL, /* 4 (optional): --no-check-certificate */
+               NULL, /* 5: URL */
                NULL,
        };
        int i;