Re: Secure_cp with regex

"'[email protected]' via help-cfengine" <[email protected]>
Newsgroups gmane.comp.sysutils.cfengine.general
Message-ID <[email protected]>
Can you reply with at least one example?

I would expect you have something like a files promise with a copy_from body

https://docs.cfengine.com/docs/3.15/reference-promise-types-files.html#copy_from

paired with a file_select body to choose your files

https://docs.cfengine.com/docs/3.15/reference-promise-types-files.html#file_select

And we have a by_name body in masterfiles in lib/packages.cf

Setting up I do this:

```
# touch /var/cfengine/data/client_1_md5_5454eez4r6e4rez46r4ez6.txt
# touch /var/cfengine/data/client_2_md5_0316046ezaea4654re654.txt
# touch /var/cfengine/data/client_3_md5_5454eez4r6e4rez46r4ez6.txt
```

So I would expect you might try policy like the following. I put it in my 
services/main.cf just to test.

```
bundle agent main
{
 files:
    "/tmp/client_stuff/."
      create => "true";
    "/tmp/client_stuff"
      copy_from => secure_cp("$(sys.workdir)/data", "$(sys.policy_hub)"),
      depth_search => recurse(inf),
      file_select => by_name("client_.*_md5_5454eez4r6e4rez46r4ez6.txt");
}
```

Maybe you don't want to serve the files from $(sys.workdir)/data? That is 
accessible by default in controls/cf_serverd.cf.

```
           "$(def.dir_data)/"
           handle => "server_access_grant_access_data",
           shortcut => "data",
           comment => "Grant access to data directory",
           if => isdir( "$(def.dir_data)/" ),
           admit => { @(def.acl) };
```

So if you wanted to share /tmp/data you would have to add something like

```
"/tmp/data"
  if => isdir("/tmp/data/"),
  admit => { @(def.acl) };
```

Let us know if that helps and what other questions you have.

Cheers,
Craig Comstock
CFEngineer/Digger

On Wednesday, June 23, 2021 at 10:35:15 AM UTC-5 [email protected] wrote:

> I am looking for a solution to copy a file in secure_cp, by selecting 
> files on the cfengine server with a regex....
>
> For example:
> on cfengine sever i have files 
> client_1_md5_5454eez4r6e4rez46r4ez6.txt
> client_2_md5_0316046ezaea4654re654.txt
> client_3_md5_5454eez4r6e4rez46r4ez6.txt
> ...
>
> I want to copy on my client all files corresponding to this regex :
> client_(.*)_md5_5454eez4r6e4rez46r4ez6.txt
>
> I tried multiple solutions without success... :(
>
> Is there any solution to do this rules?
> Thanks for your help
>
>

-- 
You received this message because you are subscribed to the Google Groups "help-cfengine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/help-cfengine/eca0a090-23a2-44bd-ba6e-1a2a92c2114en%40googlegroups.com.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.