Moin,

I use the following recipe to set the root password.

bundle agent pass
{

vars:

  "users" slist => { "root" };

files:

  "/var/cfengine/ppkeys/pw.txt"

    copy_from => mycopy("$(g.keydir)/$(sys.fqhost)-root.txt","$(g.srv");

  "/tmp/master.passwd"
       
    edit_line => set_passwd(@(pass.users));

}

bundle edit_line set_passwd(user)
{
  vars:

   "gotpw" int => 
readstringarray("pw","$(sys.workdir)/ppkeys/pw.txt","#[^\n]*",":","20","2000");
  
  field_edits:
   
    "$(user):.*"

      edit_field => col(":","2","$(pw[$(user)][1])","set");
}

body edit_field col(split,col,newval,method)
{
field_separator => "$(split)";
select_field    => "$(col)";
value_separator  => ",";
field_value     => "$(newval)";
field_operation => "$(method)";
extend_fields => "true";
}

The original line is 

root::0:0::0:0:Charlie &:/root:/bin/csh

I expected:

root:pwhash:0:0::0:0:Charlie &:/root:/bin/csh

But I got:

root:pwhash:0:0:0:0:Charlie &:/root:/bin/csh

I'm not sure if this is a bug or a missconfiguration.

If I use a line like:

root::0:0:x:0:0:Charlie &:/root:/bin/csh

I've got:

root:pwhash:0:x:0:0:Charlie &:/root:/bin/csh

Why are the columns removed?

Many thanks
Matthias

_______________________________________________
Help-cfengine mailing list
Help-cfengine@cfengine.org
https://cfengine.org/mailman/listinfo/help-cfengine

Reply via email to