On Thursday 06 October 2005 16:36, Jason Kim wrote:
> > What is your suggested resolution of the problem?
>
> I propose: a) querying cfagent for the correct VUQNAME/VDOMAIN from within
> GetCfStuff (it already queries for VFQNAME) instead of using calls to
> GetNameInfo(), and b) possibly making the 'domain' variable mandatory
> within all cfagent confs. My reasoning for this is that according to my
> tests, cfagent will always come to the correct name/domain conclusions _as
> long as_ a 'domain' var is set, regardless of whether or not the hostname
> is fully qualified or not.
>
> One possible issue with this is that GetNameInfo() seems to set certain
> classes as a side effect, and I'm not sure whether this behavior is
> required in cfexecd. I didn't see any obvious need for it, but I'm sure I
> don't know the code as well as you...
>
I've patched cfexecd from the latest subversion code and tested it using both
qualified and unqualified hostnames, it's been working fine for a few hours
now. The patch wasn't as invasive as I'd originally feared, but it does
affect GetCfStuff() and ScheduleRun() functions.
-JayKim
Index: src/cfexecd.c
===================================================================
--- src/cfexecd.c (revision 140)
+++ src/cfexecd.c (working copy)
@@ -244,9 +244,8 @@
strncpy(VLOGDIR,CFWORKDIR,CF_BUFSIZE-1);
VCANONICALFILE = strdup(CanonifyName(VINPUTFILE));
-GetNameInfo();
-strcpy(VUQNAME,VSYSNAME.nodename);
+GetCfStuff();
MAILTO[0] = '\0';
MAILFROM[0] = '\0';
@@ -411,7 +410,7 @@
/* Do not init variables here, in case we can use previous values. */
-snprintf(cfcom,CF_BUFSIZE-1,"%s/bin/cfagent -Q smtpserver,sysadm,fqhost,ipaddress,EmailMaxLines,EmailFrom,EmailTo -D from_cfexecd",CFWORKDIR);
+snprintf(cfcom,CF_BUFSIZE-1,"%s/bin/cfagent -Q smtpserver,sysadm,fqhost,host,domain,ipaddress,EmailMaxLines,EmailFrom,EmailTo -D from_cfexecd",CFWORKDIR);
if ((pp=cfpopen(cfcom,"r")) == NULL)
{
@@ -449,6 +448,20 @@
continue;
}
+ if (strcmp(name,"host") == 0)
+ {
+ Debug("%s/%s\n",name,content);
+ strncpy(VUQNAME,content,CF_MAXVARSIZE-1);
+ continue;
+ }
+
+ if (strcmp(name,"domain") == 0)
+ {
+ Debug("%s/%s\n",name,content);
+ strncpy(VDOMAIN,content,CF_MAXVARSIZE-1);
+ continue;
+ }
+
if (strcmp(name,"ipaddress") == 0)
{
Debug("%s/%s\n",name,content);
@@ -496,7 +509,7 @@
cfpclose(pp);
-Debug("Got(to:%s,serv:%s,host:%s,ip:%s,max:%d,from:%s)\n",MAILTO,VMAILSERVER,VFQNAME,VIPADDRESS,MAXLINES,MAILFROM);
+Debug("Got(to:%s,serv:%s,fqhost:%s,host:%s,domain:%s,ip:%s,max:%d,from:%s)\n",MAILTO,VMAILSERVER,VFQNAME,VUQNAME,VDOMAIN,VIPADDRESS,MAXLINES,MAILFROM);
/* Now get schedule */
@@ -563,16 +576,12 @@
Verbose("Waking up the agent at %s ~ %s \n",timekey,ip->name);
DeleteItemList(VHEAP);
VHEAP = NULL;
- GetNameInfo();
- strcpy(VUQNAME,VSYSNAME.nodename);
return true;
}
}
DeleteItemList(VHEAP);
VHEAP = NULL;
-GetNameInfo();
-strcpy(VUQNAME,VSYSNAME.nodename);
return false;
}
_______________________________________________
Bug-cfengine mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/bug-cfengine