> > > If only strlen(refhost) bytes are copied from refhost then they don't
> > > include the terminating null. It should strlen(refhost) + 1, or strcpy
> > > should be used.
> > >
> > > A rebuilt 2.2.1 with the patch from the '2.2.1 broken HostRange again?'
> > > thread on Mon Jun 25 21:51:47 CEST 2007 which worked yesterday stopped
> > > working today. It was when I saw strange characters in the debug output
> > > that I suspected what I found.
> >
> > Can you reproduce this behavior? Have you verified that
> > using strcpy() works for you??
>
> Yes.
>
> > It seems that both refbase and refhost are CF_MAXVARSIZE
> > in size and and refhost is guaranteed to be null terminated.
>
> refhost may be, but the problem is that refbase isn't. sp could be
> pointing anywhere after these two statements:
>
> strncpy(refbase,refhost,strlen(refhost));
> sp = refbase + strlen(refbase) - 1;
Again, I think refbase and refhost are CF_MAXVARSIZE in size and
refhost is guaranteed to be null terminated so strlen(refbase) +
strlen(refbase) - 1 should always point to a null.
> Printing strlen(refbase) after the copy gives numbers that are not
> always the length of the hostname.
If this is the case, then why does HostRange seem to work for
everyone else??
Would you please add...
Debug("SRDEBUG2 strlen(refhost) is %d and strlen(refbase) is %d\n",
strlen(refhost),strlen(refbase));
and post the output of...
#!/path/to/your/new/cfagent -d --inform --no-splay --no-lock --file
control: actionsequence = ( shellcommands )
groups: hostmatch = ( HostRange(your-hostrange-basename-here,1-32) )
shellcommands: hostmatch:: "/bin/echo hostname does match"
shellcommands: !hostmatch:: "/bin/echo hostname does not match"
piped to grep SRDEBUG?
steve
- - -
PS: I'm not try to be difficult--I'm just very curious and unable to
reproduce your results.
_______________________________________________
Bug-cfengine mailing list
[email protected]
https://cfengine.org/mailman/listinfo/bug-cfengine