Trace: file_select

file_select

back to Files page

file_select

List of parameters for the file_select portion of a copy_files operation in Cfengine 3.

To combine filters just use logical operators in the file_result handle, e.g.,
file_result => "leaf_name.!path_name.(search_owners|search_groups).ctime"

Item Values Description & Example
atimeirange [int,int] 0-2147483647Range of access times (atime) for acceptable files.
 body file_select used_recently {
 # files accessed within the last hour
 atime     => irange(ago(0,0,0,1,0,0),now);
 file_result => "atime";
 }
body file_select not_used_much {
 # files not accessed since 00:00 1/1/2000
 atime     => irange(on(2000,1,1,0,0,0),now);
 file_result => "!atime";
 }
ctimeirange [int,int] 0-2147483647Range of change times (ctime) for acceptable files.
body files_select example {
 ctime => irange(ago(1,0,0,0,0,0),now);
 file_result => "ctime";
 }
exec_regexstringMatches file if this regular expression matches any full line returned by the command. The regular expression must be used in conjunction with the exec_program: the programme must return exit status 0 and its entire output must match the regular expression (use “.*” to fill-in the gaps at the start and end).
body file_select example {
 exec_regex => "SPECIAL_LINE: .*";
 exec_program => "/path/test_program $(this.promiser)";
 file_result => "exec_program.exec_regex";
 }
exec_programstringExecute this command on each file; return a match if the exit status is zero.
body file_select example {
 exec_program => "/path/test_program $(this.promiser)";
 file_result => "exec_program";
 }
file_resultstringThis determines the files that will be returned by the file_select operation. Use one or more classes that are defined in this block, combined with logical operators such as AND (.), OR (|), or NOT (!).
file_typesplain, reg, symlink, dir, socket, fifo, door, char, blockList of acceptable file types. This limits the selection; if you do not specify file_types then all types are included.
body file_select filter {
 file_types => { "plain","symlink" };
 file_result => "file_types";
 }
issymlinktoslistList of regular expressions to match file objects.
body file_select example {
 issymlinkto => { "/etc/[^/]*", "/etc/init\.d/[a-z0-9]*" };
 }
leaf_nameslistList of regexes that match an acceptable file/node name (not the path name).
body file_select example {
 leaf_name => { "S[0-9]+[a-zA-Z]+", "K[0-9]+[a-zA-Z]+" };
 file_result => "leaf_name";
 }
mtimeirange [int,int] 0-2147483647Range of modification times (mtime) for acceptable files. The following example selects files modified more than one year ago (i.e., not in the given mtime range).
body files_select example {
 mtime => irange(ago(1,0,0,0,0,0),now);
 file_result => "!mtime";
 }
path_nameslistList of pathnames to search for files.
body file_select example {
 leaf_name => { "prog.pid", "prog.log" };
 path_name => { "/etc/.*", "/var/run/.*" };
 file_result => "leaf_name.path_name"
 }
search_groupsslistList of acceptable group names/IDs for the file, or regexes to match.
body file_select example {
 search_groups => { "users", "special_.*" };
 file_result => "group";
 }
search_modeslist [0-7 augorwx st,+-]+A list of mode masks for acceptable file permissions. Set it to “700” and you'll only get files that have a mode of 700. Set it to “g+w” and you'll only get group-writable files.
body file_select by_modes {
 search_mode => { "711" , "666" };
 file_result => "mode";
 }
search_ownersslistList of acceptable user names/IDs for the file, or regexes to match.
body file_select example {
 search_owners => { "mark", "jeang", "student_.*" };
 file_result => "owner";
 }
search_sizeirange [int,int] 0-infRange of acceptable file sizes.
body file_select example {
 search_size => irange("0","20k");
 file_result => "size";
 }