X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;f=ui%2Fcommon%2Floader.c;h=775f2111c281b25381906dc95c8c79b88087c446;hb=52b9db95764fcdee9195113d7df225634a19c9f4;hp=0fe62a0a6cfc715d403dda5bf7890d6448a7757c;hpb=35c5bcebf36d468705761930967a97f0fcbea665;p=petitboot diff --git a/ui/common/loader.c b/ui/common/loader.c index 0fe62a0..775f211 100644 --- a/ui/common/loader.c +++ b/ui/common/loader.c @@ -94,7 +94,7 @@ static char *pb_load_nfs(void *ctx, struct pb_url *url) *p++ = local; /* 7 */ *p++ = NULL; /* 8 */ - result = pb_run_cmd(argv); + result = pb_run_cmd(argv, 1, 0); talloc_free(opts); @@ -138,7 +138,7 @@ static char *pb_load_sftp(void *ctx, struct pb_url __attribute__((unused)) *url) *p++ = local; /* 4 */ *p++ = NULL; /* 5 */ - result = pb_run_cmd(argv); + result = pb_run_cmd(argv, 1, 0); if (result) goto fail; @@ -183,7 +183,7 @@ static char *pb_load_tftp(void *ctx, struct pb_url *url) *p++ = url->port; /* 8 */ *p++ = NULL; /* 9 */ - result = pb_run_cmd(argv); + result = pb_run_cmd(argv, 1, 0); if (!result) return local; @@ -203,7 +203,7 @@ static char *pb_load_tftp(void *ctx, struct pb_url *url) *p++ = local; /* 9 */ *p++ = NULL; /* 10 */ - result = pb_run_cmd(argv); + result = pb_run_cmd(argv, 1, 0); if (!result) return local; @@ -248,7 +248,7 @@ static char *pb_load_wget(void *ctx, struct pb_url *url, enum wget_flags flags) *p++ = "--no-check-certificate"; /* 6 */ *p++ = NULL; /* 7 */ - result = pb_run_cmd(argv); + result = pb_run_cmd(argv, 1, 0); if (result) goto fail; @@ -263,16 +263,22 @@ fail: /** * pb_load_file - Loads a remote file and returns the local file path. * @ctx: The talloc context to associate with the returned string. + * @remote: The remote file URL. + * @tempfile: An optional variable pointer to be set when a temporary local + * file is created. * * Returns the local file path in a talloc'ed character string on success, * or NULL on error. */ -char *pb_load_file(void *ctx, const char *remote) +char *pb_load_file(void *ctx, const char *remote, unsigned int *tempfile) { char *local; struct pb_url *url = pb_url_parse(NULL, remote); + if (tempfile) + *tempfile = 0; + if (!url) return NULL; @@ -280,19 +286,28 @@ char *pb_load_file(void *ctx, const char *remote) case pb_url_ftp: case pb_url_http: local = pb_load_wget(ctx, url, 0); + if (tempfile && local) + *tempfile = 1; break; case pb_url_https: - local = pb_load_wget(ctx, url, - wget_no_check_certificate); + local = pb_load_wget(ctx, url, wget_no_check_certificate); + if (tempfile && local) + *tempfile = 1; break; case pb_url_nfs: local = pb_load_nfs(ctx, url); + if (tempfile && local) + *tempfile = 1; break; case pb_url_sftp: local = pb_load_sftp(ctx, url); + if (tempfile && local) + *tempfile = 1; break; case pb_url_tftp: local = pb_load_tftp(ctx, url); + if (tempfile && local) + *tempfile = 1; break; default: local = talloc_strdup(ctx, url->full);