Greetings. I seem to have found a bug in cf-agent. When connecting to
multiple hosts:

vars:

  hlist slist => { "hosta", "hostb" };

  files:

    "$(location)/$(hlist)"
        copy_from       => server_copy("$(location)","$(hlist)"),
        perms           => system("640"),
        depth_search    => recurse("inf"),
        action          => immediate;

Debugging the code, I tracked back the dump to the initial corruption -
cached server connections,  (CacheServerConnection:client_code.c):

for (rp = SERVERLIST; rp != NULL; rp=rp->next)
   {
   conn = (struct cfagent_connection *) rp->item;
   if (strcmp(ipname,conn->localip) == 0)
      {
      conn->sd = CF_COULD_NOT_CONNECT;
      return;
      }
   }

assigning conn = (struct cfagent_connection *) rp->item; messes up the
connection structure. I am not sure why this section of code is actually in
there, but the type casting seems to be causing some corruption. Note, that
it only happens on the second host (since SERVERLIST is NULL on the first
server).

debugging output:

stopped in CacheServerConnection at line 1238 in file
"/mnt/cfengine-3.0.1b5.patched/src/client_code.c" ($t1)
 1238   for (rp = SERVERLIST; rp != NULL; rp=rp->next)
(dbx) p *conn
(sd = 5, trust = 0, authenticated = 1, protoversion = 0, family = 2, localip
= "9.61.13.23", remoteip = "9.61.251.15", session_key = " ^Ub^H", error = 0)

(dbx) n
stopped in CacheServerConnection at line 1240 in file
"/mnt/cfengine-3.0.1b5.patched/src/client_code.c" ($t1)
 1240      conn = (struct cfagent_connection *)rp->item;
(dbx) p *(struct cfagent_connection *)rp->item
(sd = 538267672, trust = 538267384, authenticated = 0, protoversion = 0,
family = 0, localip = "", remoteip = "", session_key = "", error = 12131)
(dbx) n
stopped in CacheServerConnection at line 1241 in file
"/mnt/cfengine-3.0.1b5.patched/src/client_code.c" ($t1)
 1241      if (strcmp(ipname,conn->localip) == 0)
(dbx) p *conn
(sd = 538267672, trust = 538267384, authenticated = 0, protoversion = 0,
family = 0, localip = "", remoteip = "", session_key = "", error = 12131)

At this point, conn is really messed up.

(dbx) where
CacheServerConnection(conn = 0x20154fe8, server = "xxx"), line 1241 in
"client_code.c"
NewServerConnection(attr = (...), pp = 0x20154968), line 107 in
"client_code.c"
ScheduleCopyOperation(destination = "xxx", attr = (...), pp = 0x20154968),
line 177 in "files_operators.c"
VerifyFilePromise(path = "xxx", pp = 0x20154968), line 314 in
"files_interfaces.c"
FindFilePromiserObjects(pp = 0x20154968), line 61 in "verify_files.c"
FindAndVerifyFilesPromises(pp = 0x20154968), line 37 in "verify_files.c"
KeepAgentPromise(pp = 0x20154968), line 814 in "agent.c"
ExpandPromiseAndDo(agent = cf_agent, scopeid = "xxx", pp = 0x20153d38,
scalarvars = 0x20154598, listvars = 0x201545d8, fnptr = 0x20051f30), line
593 in "expand.c"
ExpandPromise(agent = cf_agent, scopeid = "xxx", pp = 0x2015d268, fnptr =
0x20051f30), line 115 in "expand.c"
ScheduleAgentOperations(bp = 0x2015cab8), line 670 in "agent.c"
KeepPromiseBundles(), line 634 in "agent.c"
KeepPromises(), line 273 in "agent.c"
main(argc = 2, argv = 0x2ff22a00), line 131 in "agent.c"

Thanks,
Matt
_______________________________________________
Bug-cfengine mailing list
Bug-cfengine@cfengine.org
https://cfengine.org/mailman/listinfo/bug-cfengine

Reply via email to