Message ID | 20170928100932.13342-1-christian.storm@siemens.com |
---|---|
State | Accepted |
Headers | show |
Series | installer: extract/remove scripts respecting SCRIPTS_DIR_SUFFIX | expand |
On 28/09/2017 12:09, Christian Storm wrote: > Patch 97e3f8a "tmpdir: make use of get_tmpdir()" expects > to find scripts in $TMPDIR/SCRIPTS_DIR_SUFFIX/ > However, scripts are still extracted to $TMPDIR/ > > Fix extraction of scripts to $TMPDIR/SCRIPTS_DIR_SUFFIX/ > Fix removal of scripts from $TMPDIR/SCRIPTS_DIR_SUFFIX/ > > Signed-off-by: Christian Storm <christian.storm@siemens.com> > Reported-by: Arun Sooraj PS <arunsoorajj@gmail.com> > --- > corelib/installer.c | 11 ++++++++--- > 1 file changed, 8 insertions(+), 3 deletions(-) > > diff --git a/corelib/installer.c b/corelib/installer.c > index 6c6271c..5bdf4f0 100644 > --- a/corelib/installer.c > +++ b/corelib/installer.c > @@ -257,9 +257,14 @@ int install_images(struct swupdate_cfg *sw, int fdsw, int fromfile) > > /* Extract all scripts, preinstall scripts must be run now */ > if (fromfile) { > - ret = extract_script(fdsw, &sw->scripts, TMPDIR); > + char* TMPDIR_SCRIPTS = alloca(strlen(TMPDIR)+strlen(SCRIPTS_DIR_SUFFIX)+1); > + if (sprintf(TMPDIR_SCRIPTS, "%s%s", TMPDIR, SCRIPTS_DIR_SUFFIX) < 0) { > + ERROR("preparing script extraction path failed!"); > + return -1; > + } > + ret = extract_script(fdsw, &sw->scripts, TMPDIR_SCRIPTS); > if (ret) { > - ERROR("extracting script to TMPDIR failed"); > + ERROR("extracting script to %s failed", TMPDIR_SCRIPTS); > return ret; > } > } > @@ -414,7 +419,7 @@ void cleanup_files(struct swupdate_cfg *software) { > } > LIST_FOREACH(img, &software->scripts, next) { > if (img->fname[0]) { > - if (snprintf(fn, sizeof(fn), "%s%s", TMPDIR, > + if (snprintf(fn, sizeof(fn), "%s%s%s", TMPDIR, SCRIPTS_DIR_SUFFIX, > img->fname) >= (int)sizeof(fn)) { > ERROR("Path too long: %s%s", TMPDIR, img->fname); > } > Applied to -master, thanks ! Best regards, Stefano Babic
diff --git a/corelib/installer.c b/corelib/installer.c index 6c6271c..5bdf4f0 100644 --- a/corelib/installer.c +++ b/corelib/installer.c @@ -257,9 +257,14 @@ int install_images(struct swupdate_cfg *sw, int fdsw, int fromfile) /* Extract all scripts, preinstall scripts must be run now */ if (fromfile) { - ret = extract_script(fdsw, &sw->scripts, TMPDIR); + char* TMPDIR_SCRIPTS = alloca(strlen(TMPDIR)+strlen(SCRIPTS_DIR_SUFFIX)+1); + if (sprintf(TMPDIR_SCRIPTS, "%s%s", TMPDIR, SCRIPTS_DIR_SUFFIX) < 0) { + ERROR("preparing script extraction path failed!"); + return -1; + } + ret = extract_script(fdsw, &sw->scripts, TMPDIR_SCRIPTS); if (ret) { - ERROR("extracting script to TMPDIR failed"); + ERROR("extracting script to %s failed", TMPDIR_SCRIPTS); return ret; } } @@ -414,7 +419,7 @@ void cleanup_files(struct swupdate_cfg *software) { } LIST_FOREACH(img, &software->scripts, next) { if (img->fname[0]) { - if (snprintf(fn, sizeof(fn), "%s%s", TMPDIR, + if (snprintf(fn, sizeof(fn), "%s%s%s", TMPDIR, SCRIPTS_DIR_SUFFIX, img->fname) >= (int)sizeof(fn)) { ERROR("Path too long: %s%s", TMPDIR, img->fname); }
Patch 97e3f8a "tmpdir: make use of get_tmpdir()" expects to find scripts in $TMPDIR/SCRIPTS_DIR_SUFFIX/ However, scripts are still extracted to $TMPDIR/ Fix extraction of scripts to $TMPDIR/SCRIPTS_DIR_SUFFIX/ Fix removal of scripts from $TMPDIR/SCRIPTS_DIR_SUFFIX/ Signed-off-by: Christian Storm <christian.storm@siemens.com> Reported-by: Arun Sooraj PS <arunsoorajj@gmail.com> --- corelib/installer.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)