#135 opengis/scripts/genbind removes all user’s files

PyXB 1.1.4
closed
None
fixed
Code
major
PyXB 1.1.3
defect
2012-06-12
2012-05-10
Yuri Khan
No

The script to generate opengis bindings is very dangerous if used carelessly.

Line 2 tests the variable PYXB_ROOT for emptiness and assigns to it a hardcoded value referring to /home/pab. Line 4 then depends on a file ${PYXB_ROOT}/maintainer/bundlesupport.sh to define other useful variables, notably SCHEMA_DIR and RAW_DIR. Lines 9–13 are supposed to change to ${SCHEMA_DIR} and delete the remaining files before regenerating them.

However, if /home/pab is not there (as would be the case on the machine of an unsuspecting user who decided to test the development version), or is inaccessible, or the expected files are missing, ${SCHEMA_DIR} ends up expanding to an empty string. Line 10 changes to the user’s home directory and line 12 proceeds to remove any and all files and subdirectories it can reach. I lost my collection of helper scripts in ~/bin, my (not very important) ~/Documents and a good chunk of ~/Downloads before I realized something very wrong is going on and hit ^C.

As a fix, I strongly suggest including set -e as the second line of each shell script (the first being the shebang line, #!/bin/sh) and structuring the scripts so that expected errors are suitably suppressed with ||:.

Discussion

  • Peter A. Bigot

    Peter A. Bigot - 2012-05-10
    • status changed from new to assigned

    Sorry for the trouble. I'll add some failsafe code to the maintainer scripts before the next release.

     
  • Peter A. Bigot

    Peter A. Bigot - 2012-06-12
    • status changed from assigned to closed
    • resolution set to fixed

    commit ad1fa6f3c62e2e5caf2bdd03311e9b7b4f5fa833
    Author: Peter A. Bigot <pabigot@…>
    Date: Tue Jun 12 18:20:33 2012 -0500

    trac/135: opengis/scripts/genbind removes all user files

    Added recommended checks to all genbind scripts, and further checks to
    bundlesupport.sh.

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks