Forum: CFEngine Help
Subject: read password hash from file
Author: tuibelgium
Link to topic: https://cfengine.com/forum/read.php?3,22971,22971#msg-22971

Hi

I want to read a password hash from af file in the format:

user1:hash1
user2:hash2
...

Here is the code I use: 

vars:
        "users" slist => {"user1","user2","user3","user4","user5"};

files:
        "/tmp/shadow"
                edit_line => set_shadow_values("$(users)");

The set_shadow_values is in a library file.

bundle edit_line set_shadow_values(user)
{
vars:
        "pwd_array" int => 
readstringarray("pwd","/my/shadow.txt","#[^\n]*",":","10","4000");   

reports:
        linux::
                "$(pwd[$(user)][1])";


 I added report to view the value for $(pwd[$(user)][1])
The report gives me this:

R: hash1
R: $(pwd[1])
R: $(pwd[1])
R: $(pwd[1])
R: $(pwd[1])

How does it come it only works for the first user?

_______________________________________________
Help-cfengine mailing list
[email protected]
https://cfengine.org/mailman/listinfo/help-cfengine

Reply via email to