Bug report:
The function list_menu() beginning on line 60 could potentially clobber a file. It could also leave a file hanging around if GrubEd gets killed without having a chance to clean up after itself. The problem is the redirection to avail. If a file named avail already exists, it will be overwritten, then deleted.
I suggest inserting the following before line 62:
Code:
avail="/tmp/GrubEd-avail-$(date +"%Y%m%d%H%M%S%N")"
and replacing all subsequent occurances of avail with $avail. Using this filename will accomplish several things: 1) it's canonical to put temp files in /tmp. 2) If GrubEd dies an untimely death, the residual file will automatically deleted on reboot (when /tmp is cleaned). 3) It's extremely unlikely that any files will get clobbered. (A paranoid version would also make sure that the file doesn't exist before writing it.) 4) Because the filename includes a timestamp, it prevents symlink attacks.
Perhaps it would also be best to use absolute paths in $G_MENU and friends (line 490 ff)? That would obviate the need to cd to the proper directory, and be a little more robust, IMHO.
I also suggest changing line 493 to
Code:
P_FILE="/tmp/GrubEd-patch-$(date +"%Y%m%d%H%M%S%N")"
for the same reasons as stated above.
Bookmarks