On 01/22/2012 10:43 AM, Bruce Dubbs wrote: > Dean Takemori wrote: >> lfs/lib/services/init-functions defines statusproc() with this snippit >> to process arguments: >> >> while true; do >> case "${1}" in >> >> -p) >> pidfile="${2}" >> shift 2 >> ;; >> esac >> done >> >> >> Isn't this broken? > What's broken? Can you give an example of how it breaks? > > -- Bruce I think this might carry over from the original so the problem dates back to me or possibly even Nathan and Alex. I didn't look. At any rate, the problem is that there is no error checking. I don't believe that statusproc() is intended to check multiple processes from multiple executables (multiple processes from one executable yes). For the -p case, you should verify that $2 is a valid file, and that $3 is executable or undefined, and add a * case, that $1 is executable and $2 = "-p" && shift 1;. If any of the above are false, a return value of 2 should fit the LSB spec with optional error message "Error: invalid or excessive argument(s)". A case could be made that $3 in the -p case or $1 in the * case not being executable should return a value of 5, but I'm not sure that value should apply here. I didn't look to see if the executable is evaluated later in the function, but the function should most definitely have argument handling for excessive arguments in the while loop.
http://refspecs.linuxfoundation.org/LSB_4.1.0/LSB-Core-generic/LSB-Core-generic/iniscrptact.html -- DJ Lucas -- This message has been scanned for viruses and dangerous content, and is believed to be clean. -- http://linuxfromscratch.org/mailman/listinfo/lfs-dev FAQ: http://www.linuxfromscratch.org/faq/ Unsubscribe: See the above information page