help-cfengine
[Top][All Lists]
Advanced

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

Determining user ID


From: Christopher Browne
Subject: Determining user ID
Date: Tue, 20 Dec 2005 22:12:18 GMT
User-agent: Gnus/5.1007 (Gnus v5.10.7) XEmacs/21.4.17 (Jumbo Shrimp, linux)

I've got a scenario where I'll need to run a cfengine script as
various users, and then do different actions based on the user name.
(No, no, can't use root; that is verboten by Powers That Be...)

For instance...  I have users pgonedatabaseuser,
pganotherdatabaseuser, pgyetanotherdatabaseuser.

I can write a nice tidy tidy section thus:

tidy:
  pgonedatabaseuser.onedatabase::
    /path/to/onedatabase
       pattern=pg_*.log
       age=$(pglogage)

  pganotherdatabaseuser.anotherdatabase::
    /path/to/anotherdatabase
       pattern=pg_*.log
       age=$(pglogage)

  pgyetanotherdatabaseuser.yetanotherdatabase::
    /path/to/yetanotherdatabase
       pattern=pg_*.log
       age=$(pglogage)

The trouble, at this point, is creating the
pgonedatabaseuser/pganotherdatabaseuser/pgyetanotherdatabaseuser
groups.

The best guess is something like:

control:
   tempusername = ( ExecResult(/usr/bin/whoami) )

groups:
   pgonedatabaseuser        = ( StrCmp(${tempusername}, "pgonedatabaseuser"))
   pganotherdatabaseuser    = ( StrCmp(${tempusername}, 
"pganotherdatabaseuser"))
   pgyetanotherdatabaseuser = ( StrCmp(${tempusername}, 
"pgyetanotherdatabaseuser"))

But apparently the groups are defined before tempusername gets defined.

There has got to be some better way that I'm not thinking of...
-- 
(reverse (concatenate 'string "ofni.sailifa.ac" "@" "enworbbc"))
<http://dba2.int.libertyrms.com/>
Christopher Browne
(416) 673-4124 (land)


reply via email to

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