- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
One of our clients' application's database works exactly this way. Every user-written script that is run must be logged against a "scripts" log table, where the name of the script must be of the format "yyyymmdd_scriptname_versionno_sprintno". The last entry in this table should give you the version number.
Fun fact: the application itself uses different version numbers than the database, so if you want to know if a certain instance of the database will be compatible with a certain version of the application, well, good luck.
Admin
That's still slightly better than looking in some random log file; databases are meant for data by definition.
Admin
Yes, in fact you're describing the most widespread implementation to maintain database schemas! That's for instance how Flyway works.
Admin
The only difference being that the log file is in a database instead of on the file server?
Admin
Additional fun:
Apparently, if a patch was installed and then uninstalled, this will ignore the uninstall and still keep the patch version in
$checkver
Admin
Or almost as bad, utterly fails to clean up old logs, leading to this crawling to a halt as it goes through everything else that's hanging around /var/log.
Admin
Well to be honest, there should not be that many different files there (some large files sure, but it is not looking in the content of the files). (On my Ubuntu system there is only 108 files, and that should not take that logn to go through)
However that may in some cases be a dangerous assumption, especially if there are other systems which uses this brain-dead scheme.... .
Admin
I really hope this doesn't attempt to list the directory by running the
ls
program and parsing its output...Oh wait, it does. :disappointed:
Admin
And added bonus, it does not appear to provide absolute path for the ls comand either (making it possible for someone to potentially alter the path environment and supplying a 'spare' ls command which does just a bit more than plain old ls does.....) (unless that MyOwn::System:: thing which is not familiar to me indeed does provide full path)
Admin
To be fair, don't a lot of shell scripts do
ls | cut
? Not that it's a good way, but it's not like there's no precedent for that...Admin
I'm trying to think why they're doing it. Unless they're just getting the filenames out of
ls -l
, which would be quite thoroughly retarded.Admin
Made that worse for you.
Admin
ls -laRt
would be worse.Admin
Eh, depends on how the loop is constructed on the
t
part, might not have any effect.R
truly is evil though, and I am now hitting myself for forgetting that you can do that.Admin
I threw the
t
in for giggles.Admin
Admin
As opposed to what? opendir/readdir?
We are talking about perl here! No one uses builtin functions when you can use MyOwn wrapper for a system command!
Admin
Yes it defines full path for /var/log, but NOT for /bin/ls
If you use -T in perl it will not let you do a system() or backtics unless you have explicitly set $PATH to a untaintet string as relying on the environment is potentially dangerous
Admin
TRWTF is not only PERL: that all those if's were not just done as a single incomprehensible Regexp match....very un-Perl-ish.