Check if a user in group exists

17 views
Skip to first unread message

alexa...@gmail.com

unread,
Feb 14, 2022, 3:57:53 PM2/14/22
to help-cfengine
Hello!
I have hard coded for add a user in group. How to check by 'ifvarclass' (or any), that a user in group exist and don't run the command 'usermod'?
command:
  "/usr/sbin/usermod -a -G $(group_index)  $(user_index)";

vratislav...@northern.tech

unread,
Feb 16, 2022, 8:58:04 AM2/16/22
to help-c...@googlegroups.com
Makes me think we could extend the userexists() function to take a group name as an optional
argument.

Without it, I think the best option is to use regline() on /etc/group.

--
Vratislav
Reply all
Reply to author
Forward
0 new messages