help-cfengine
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Problem with passing arguments to methods


From: Grzegorz Marszałek
Subject: Problem with passing arguments to methods
Date: Thu, 14 Apr 2005 23:35:37 +0200

Hello!

I'm trying do write a method, which will then proceed differently based
on parameter passed to it. The problem is that I cannot define class
based on string in variable, BUT, which is funny but confusing, I CAN
use this variable in editfiles section without problems! It seems, that
arguments passed to methods are created AFTER classes section was
evaluated. Any ideas, what to do about that? Passing class to method
possibly would solve my problem of course, but then whole idea of using
methods in my system (I'd like to use them, because they could very
clearly isolate some components - ie.: to play with Kerberos you have
one method, and you can play with it only via parameters defined by
desiger of module). Of course I can use few methods as well, but still
this strange behaviour of cfengine is at best confusing...

My configuration looks like this:
cfagent.conf:
---
control:
  IfElapsed = ( 0 )
  actionsequence = ( methods )

methods:

  TestMethod(doit)

    action=method.cfm
    returnvars=null
    returnclasses=null
    server=localhost
---
method.cfm:
---
control:

  MethodName = ( TestMethod )
  MethodParameters = ( arg1 )
  IfElapsed = ( 0 )
  actionsequence = ( editfiles )

classes:

  ParameterClass = ( Regcmp(.*doit.*,${arg1}) )

editfiles:
  any::
  { /tmp/somefile
    AutoCreate
    EmptyEntireFilePlease
    InsertLine "var1 = ${arg1}"
  }

  ParameterClass::
  { /tmp/somefile2
    AutoCreate
    AppendIfNoSuchLine "Class was defined"
  }

alerts:
  ReturnVariables(null)
  ReturnClasses(null)
---

And /tmp/somefiles2 is never created. But if I define variable locally
in control section of method, and assign to in string "doit" (ie.: arg1
= ( doit ) ) everything works like it suppose to work.

Here is a diagnostic output from cfengine:
Setting cfengine new port to 5308
Setting cfengine old port to 5308
Reference time set to Thu Apr 14 23:33:22 2005

GNU Configuration Engine - 
2.1.13
Free Software Foundation 1994-
Donated by Mark Burgess, Faculty of Engineering,
Oslo University College, 0254 Oslo, Norway

------------------------------------------------------------------------

Host name is: soulless
Operating System Type is linux
Operating System Release is 2.6.11-grsec-server-p4-grsec-mppe
Architecture = i686


Using internal soft-class linux for host linux

The time is now Thu Apr 14 23:33:22 2005


------------------------------------------------------------------------

Additional hard class defined as: 32_bit
Additional hard class defined as:
linux_2_6_11_grsec_server_p4_grsec_mppe
Additional hard class defined as: linux_i686
Additional hard class defined as:
linux_i686_2_6_11_grsec_server_p4_grsec_mppe
Additional hard class defined as:
linux_i686_2_6_11_grsec_server_p4_grsec_mppe__1_Tue_Mar_8_18_45_20_CET_2005

GNU autoconf class from compile time: compiled_on_linux_gnu

Address given by nameserver: 192.168.1.254
Interface 1: eth0
Interface 2: lo
Trying to locate my IPv6 address
Found IPv6 address addr:
Found IPv6 address fe80::206:29ff:fe29:6f57
Found IPv6 address addr:
Looking for environment from cfenvd...

Unable to detect environment from cfenvd

cfengine:: No preconfiguration file

$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
 * (Changing context state to: main) *
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

---------------------------------------------------------------------
Loading persistent classes
---------------------------------------------------------------------

 Persistent class
rpc_in_localhost_localhost_TestMethod_Reply_MD5_a134711b3d3439d3015a45ce3e6681da_MD5_a134711b3d3439d3015a45ce3e6681da
 expired
---------------------------------------------------------------------
Loaded persistent memory
---------------------------------------------------------------------

Looking for environment from cfenvd...

Unable to detect environment from cfenvd

Manually overidden relative path (./cfagent.conf)
Looking for an input file ./cfagent.conf
Finished with ./cfagent.conf

Accepted domain name: undefined.domain


Defined Classes = ( 192_168_1 192_168_1_254 32_bit April Day14 Hr23
Hr23_Q3 Min30_35 Min33 Q3 Thursday Yr2005 addr_ any cfengine_2
cfengine_2_1 cfengine_2_1_13 compiled_on_linux_gnu debian debian_3
debian_3_1 fe80__206_29ff_fe29_6f57 i686 ipv4_192 ipv4_192_168
ipv4_192_168_1 ipv4_192_168_1_254 linux
linux_2_6_11_grsec_server_p4_grsec_mppe linux_i686
linux_i686_2_6_11_grsec_server_p4_grsec_mppe
linux_i686_2_6_11_grsec_server_p4_grsec_mppe__1_Tue_Mar_8_18_45_20_CET_2005 
net_iface_eth0 net_iface_lo soulless soulless_lanet_net_pl )

Negated Classes = ( )

Installable classes = ( )

Global expiry time for locks: 120 minutes

Global anti-spam elapse time: 0 minutes

Extensions which should not be directories = ( )
Suspicious filenames to be warned about = ( )
LogDirectory = /var/lib/cfengine2
Loaded /var/lib/cfengine2/ppkeys/localhost.priv
Loaded /var/lib/cfengine2/ppkeys/localhost.pub
Checksum database is /var/lib/cfengine2/checksum.db
Reference time set to Thu Apr 14 23:33:22 2005


*********************************************************************
 Main Tree Sched: methods pass 1 @ Thu Apr 14 23:33:22 2005
*********************************************************************

---------------------------------------------------------------------
Dispatching new methods
---------------------------------------------------------------------


Dispatch method localhost:TestMethod to /var/lib/cfengine2/rpc_in
---------------------------------------------------------------------
Evaluating incoming methods that policy accepts...
---------------------------------------------------------------------

Looking at method (TestMethod) from (localhost) intended for exec on
(localhost) with arghash MD5=a134711b3d3439d3015a45ce3e6681da
Found a local approval to execute this method (TestMethod) on behalf of
sender localhost if (any)
Trying /var/lib/cfengine2/bin/cfagent
-f /var/lib/cfengine2/modules/method.cfm -v -Z
MD5=a134711b3d3439d3015a45ce3e6681da 
cfengine:: Executing method /var/lib/cfengine2/bin/cfagent
-f /var/lib/cfengine2/modules/method.cfm -v -Z
MD5=a134711b3d3439d3015a45ce3e6681da ...(uid=-1,gid=-1)
cfengine::TestMethod: Setting cfengine new port to 5308
cfengine::TestMethod: Setting cfengine old port to 5308
cfengine::TestMethod: Reference time set to Thu Apr 14 23:33:22 2005
cfengine::TestMethod: GNU Configuration Engine - 
cfengine::TestMethod: 2.1.13
cfengine::TestMethod: Free Software Foundation 1994-
cfengine::TestMethod: Donated by Mark Burgess, Faculty of Engineering,
cfengine::TestMethod: Oslo University College, 0254 Oslo, Norway
cfengine::TestMethod:
------------------------------------------------------------------------
cfengine::TestMethod: Host name is: soulless
cfengine::TestMethod: Operating System Type is linux
cfengine::TestMethod: Operating System Release is
2.6.11-grsec-server-p4-grsec-mppe
cfengine::TestMethod: Architecture = i686
cfengine::TestMethod: Using internal soft-class linux for host linux
cfengine::TestMethod: The time is now Thu Apr 14 23:33:22 2005
cfengine::TestMethod:
------------------------------------------------------------------------
cfengine::TestMethod: Additional hard class defined as: 32_bit
cfengine::TestMethod: Additional hard class defined as:
linux_2_6_11_grsec_server_p4_grsec_mppe
cfengine::TestMethod: Additional hard class defined as: linux_i686
cfengine::TestMethod: Additional hard class defined as:
linux_i686_2_6_11_grsec_server_p4_grsec_mppe
cfengine::TestMethod: Additional hard class defined as:
linux_i686_2_6_11_grsec_server_p4_grsec_mppe__1_Tue_Mar_8_18_45_20_CET_2005
cfengine::TestMethod: GNU autoconf class from compile time:
compiled_on_linux_gnu
cfengine::TestMethod: Address given by nameserver: 192.168.1.254
cfengine::TestMethod: Interface 1: eth0
cfengine::TestMethod: Interface 2: lo
cfengine::TestMethod: Trying to locate my IPv6 address
cfengine::TestMethod: Found IPv6 address addr:
cfengine::TestMethod: Found IPv6 address fe80::206:29ff:fe29:6f57
cfengine::TestMethod: Found IPv6 address addr:
cfengine::TestMethod: Looking for environment from cfenvd...
cfengine::TestMethod: Unable to detect environment from cfenvd
cfengine::TestMethod: cfengine:: No preconfiguration file
cfengine::TestMethod:
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
cfengine::TestMethod:  * (Changing context state to: main) *
cfengine::TestMethod:
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
cfengine::TestMethod:
---------------------------------------------------------------------
cfengine::TestMethod: Loading persistent classes
cfengine::TestMethod:
---------------------------------------------------------------------
cfengine::TestMethod:
---------------------------------------------------------------------
cfengine::TestMethod: Loaded persistent memory
cfengine::TestMethod:
---------------------------------------------------------------------
cfengine::TestMethod: Looking for environment from cfenvd...
cfengine::TestMethod: Unable to detect environment from cfenvd
cfengine::TestMethod: Manually overidden relative path
(/var/lib/cfengine2/modules/method.cfm)
cfengine::TestMethod: Looking for an input
file /var/lib/cfengine2/modules/method.cfm
cfengine::TestMethod:
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
cfengine::TestMethod:  * (Changing context state to: private-method) *
cfengine::TestMethod:
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
cfengine::TestMethod: This is a method with return value list: (null)
cfengine::TestMethod: This is a method with return class list: null
cfengine::TestMethod: Finished
with /var/lib/cfengine2/modules/method.cfm
cfengine::TestMethod: Accepted domain name: undefined.domain
cfengine::TestMethod: Defined Classes = ( 192_168_1 192_168_1_254 32_bit
April Day14 Hr23 Hr23_Q3 Min30_35 Min33 Q3 Thursday Yr2005 addr_ any
cfengine_2 cfengine_2_1 cfengine_2_1_13 compiled_on_linux_gnu debian
debian_3 debian_3_1 fe80__206_29ff_fe29_6f57 i686 ipv4_192 ipv4_192_168
ipv4_192_168_1 ipv4_192_168_1_254 linux
linux_2_6_11_grsec_server_p4_grsec_mppe linux_i686
linux_i686_2_6_11_grsec_server_p4_grsec_mppe
linux_i686_2_6_11_grsec_server_p4_grsec_mppe__1_Tue_Mar_8_18_45_20_CET_2005 
net_iface_eth0 net_iface_lo soulless soulless_lanet_net_pl )
cfengine::TestMethod: Negated Classes = ( )
cfengine::TestMethod: Installable classes = ( )
cfengine::TestMethod: Global expiry time for locks: 120 minutes
cfengine::TestMethod: Global anti-spam elapse time: 0 minutes
cfengine::TestMethod: Extensions which should not be directories = ( )
cfengine::TestMethod: Suspicious filenames to be warned about = ( )
cfengine::TestMethod:
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
cfengine::TestMethod: +
cfengine::TestMethod: + This is a private method: TestMethod
cfengine::TestMethod: +
cfengine::TestMethod: + Method argument prototype = ( )
cfengine::TestMethod: +
cfengine::TestMethod:
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
cfengine::TestMethod: Looking for a data package for this method
(MD5=a134711b3d3439d3015a45ce3e6681da)
cfengine::TestMethod: Child is looking for its bundle: TestMethod
cfengine::TestMethod: Setting transmitted variable arg1 = ( doit )
cfengine::TestMethod: LogDirectory = /var/lib/cfengine2
cfengine::TestMethod: Loaded /var/lib/cfengine2/ppkeys/localhost.priv
cfengine::TestMethod: Loaded /var/lib/cfengine2/ppkeys/localhost.pub
cfengine::TestMethod: Checksum database
is /var/lib/cfengine2/checksum.db
cfengine::TestMethod: Reference time set to Thu Apr 14 23:33:22 2005
cfengine::TestMethod:
*********************************************************************
cfengine::TestMethod:  Main Tree Sched: editfiles pass 1 @ Thu Apr 14
23:33:22 2005
cfengine::TestMethod:
*********************************************************************
cfengine::TestMethod: Begin editing /tmp/somefile
cfengine::TestMethod: Emptying entire file
cfengine::TestMethod: Appending [var1 = doit]
cfengine::TestMethod: End editing /tmp/somefile
cfengine::TestMethod: 
.....................................................................
cfengine::TestMethod:
---------------------------------------------------------------------
cfengine::TestMethod: Alerts
cfengine::TestMethod:
---------------------------------------------------------------------
cfengine::TestMethod:
---------------------------------------------------------------------
cfengine::TestMethod: Method reply message
cfengine::TestMethod:
---------------------------------------------------------------------
cfengine::TestMethod: DispatchMethodReply()
cfengine::TestMethod: Checking whether to define any classes ...
cfengine::TestMethod: Not defining return class null
cfengine::TestMethod: ++++++++++++++++++++++++++++++++++++++++
cfengine::TestMethod: Summary of objects involved
cfengine::TestMethod: ++++++++++++++++++++++++++++++++++++++++
cfengine::TestMethod:     global
cfengine::TestMethod:     main
cfengine::TestMethod:     private-method
cfengine:: Finished local method /var/lib/cfengine2/bin/cfagent
-f /var/lib/cfengine2/modules/method.cfm -v -Z
MD5=a134711b3d3439d3015a45ce3e6681da  processing
---------------------------------------------------------------------
Fetching replies to finished methods
---------------------------------------------------------------------

Looking at method (TestMethod:Reply) from (localhost) intended for exec
on (localhost) with arghash MD5=a134711b3d3439d3015a45ce3e6681da
Found a local approval to forward reply from local method
(TestMethod:Reply) to final destination sender localhost
New state
rpc_in_localhost_localhost_TestMethod_Reply_MD5_a134711b3d3439d3015a45ce3e6681da_MD5_a134711b3d3439d3015a45ce3e6681da
 with expiry 1578374912, policy 135678968
(Re)Set persistent state
rpc_in_localhost_localhost_TestMethod_Reply_MD5_a134711b3d3439d3015a45ce3e6681da_MD5_a134711b3d3439d3015a45ce3e6681da
 for 0 minutes
Opening bundle
localhost_localhost_TestMethod:Reply_MD5=a134711b3d3439d3015a45ce3e6681da
Setting variable TestMethod.null to null
---------------------------------------------------------------------
Alerts
---------------------------------------------------------------------



++++++++++++++++++++++++++++++++++++++++
Summary of objects involved
++++++++++++++++++++++++++++++++++++++++

    global
    main


-- 
Dyrektor Techniczny
Grzegorz Marszałek
LANet Sp. z o.o.

Attachment: signature.asc
Description: To jest część listu podpisana cyfrowo


reply via email to

[Prev in Thread] Current Thread [Next in Thread]