Package: cfengine2
Version: 2.1.14-1sarge1
Severity: normal
(cc-ing [email protected], which I'm not subscribed to. mailing list
people: I hope you don't mind all the stuff in this email that's designed
for Debian's bug-tracking system...)
Run this and cfagent will segfault. If you echo > /tmp/crashme.dat first, it
won't crash, because CURRENTLINEPTR in edittools.c:DoEditFile() won't be NULL.
(I haven't run it under gdb, but it's pretty obvious it gets its value from
filestart, and presumably it's NULL on empty or nonexistant files).
------ cf.crashme -------
#!/usr/sbin/cfagent -I -f
control:
actionsequence = ( editfiles )
# turn off enforced-wait for testing
IfElapsed = ( 0 )
# only give cfengine 1 minute before breaking locks and killing
ExpireAfter = ( 1 )
editfiles:
any::
{ /tmp/crashme.dat
Backup "single"
AutoCreate
AppendIfNoSuchLine "Hello"
# LocateLineMatching ".*"
# segfaults when done without a preceding LocateLineMatching!
ReplaceLineWith "$(date)"
}
-------------------------
The reference manual doesn't define the behaviour for empty files, but
whatever happens, a segfault is never the right behaviour.
I actually ran into this bug while making toy files to learn how cfengine
worked. There are some not totally unreasonable cases, such as Appending a
line to a previously empty or nonexistant file, and then replacing it
(because it's now line 1, right? And the reference manual says the file
pointer starts out pointing to line 1.)
What I was expecting was:
--- 1st ---
the date
--- 2nd ---
the new date
Hello
It was very off-putting to have cfagent segfaulting on me while I was
trying to wrap my head around it :( And I still haven't found a good way to
use list variables with editfiles commands, to e.g. put all the internal IPs
in my cluster into /etc/hosts.equiv. But that's not related to this bug, so
I'd better not try to cram too much into this email...
-- System Information:
Debian Release: 3.1
APT prefers unstable
APT policy: (500, 'unstable')
Architecture: i386 (i686)
Kernel: Linux 2.4.27-om20041102-tab
Locale: LANG=en_CA, LC_CTYPE=en_CA (charmap=ISO-8859-1)
Versions of packages cfengine2 depends on:
ii debconf 1.4.30.13 Debian configuration management sy
ii debianutils 2.8.4 Miscellaneous utilities specific t
ii libc6 2.3.2.ds1-22 GNU C Library: Shared libraries an
ii libdb4.2 4.2.52-18 Berkeley v4.2 Database Libraries [
ii libssl0.9.7 0.9.7e-3 SSL shared libraries
ii perl 5.8.4-8 Larry Wall's Practical Extraction
-- debconf information excluded
--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]