Forum: CFEngine Help
Subject: Permission for directory using variables
Author: josephvj
Link to topic: https://cfengine.com/forum/read.php?3,24720,24720#msg-24720

Hi,
It would be great if anyone can help me on this. I'm about to create a user 
along with his/her .ssh directory, but I'm unable to set the permission on the 
users's .ssh directory. Script is executed as 'root' and so the ownership/group 
of his/her .ssh dir: is set to as root instead of the user.

bundle agent manage_users
{
vars:
  # Users to create
  "users"  string => "Test User";
  "users"       string => "1000";
  "users"       string => "100";
  "users"      string => "/home/testuser";
  "users"     string => "/bin/bash";
  "users"     string => "-m";

methods:
  "users"   usebundle => create_users("manage_users.users");
  "users"   usebundle => create_ssh_dir("manage_users.users");
}

bundle agent create_ssh_dir(user)
{
vars:
        "index" slist => getindices("$(user)");
files:
       linux::
               "$($(user)[$(index)])/.ssh/"
               perms => mog("700","$(index)","$(index)"),
               move_obstructions => "true",
               create => "true";
}

body perms mog(mode,user,group)
{
owners => { "$(user)" };
groups => { "$(group)" };
mode   => "$(mode)";
}

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

Reply via email to