How to list users by role?

Neither the CLI nor the Web UI seem to have any way of listing users by role, and it seems the role is missing in /usr/local/hestia/bin/v-list-user as well.

So it would be nice to have some way to list by role or at least show the role in the aforementioned command so it can be obtained via scripts, for security auditing.

Hello @xeruf,

You could open a request on github or if you are in a hurry, you can modify v-list-users yourself, here an example to show the user’s role:


# diff -u v-list-users v-list-users-with-role
--- v-list-users        2023-07-31 21:05:07.000000000 +0200
+++ v-list-users-with-role      2023-08-05 01:53:57.536584833 +0200
@@ -56,6 +56,7 @@
         "CONTACT": "'$CONTACT'",
         "CRON_REPORTS": "'$CRON_REPORTS'",
         "RKEY": "'$RKEY'",
+        "ROLE": "'$ROLE'",
         "SUSPENDED": "'$SUSPENDED'",
         "SUSPENDED_USERS": "'$SUSPENDED_USERS'",
         "SUSPENDED_WEB": "'$SUSPENDED_WEB'",
@@ -94,14 +95,14 @@
 
 # SHELL list function
 shell_list() {
-       echo "USER   PKG   WEB   DNS   MAIL   DB   DISK   BW   SPND   DATE"
-       echo "----   ---   ---   ---   ---    --   ----   --   ----   ----"
+       echo "USER   ROLE   PKG   WEB   DNS   MAIL   DB   DISK   BW   SPND   DATE"
+       echo "----   ----   ---   ---   ---   ---    --   ----   --   ----   ----"
        while read USER; do
                if [ ! -f "$HESTIA/data/users/$USER/user.conf" ]; then
                        continue
                fi
                source_conf "$HESTIA/data/users/$USER/user.conf"
-               echo -n "$USER $PACKAGE $U_WEB_DOMAINS $U_DNS_DOMAINS $U_MAIL_DOMAINS"
+               echo -n "$USER $ROLE $PACKAGE $U_WEB_DOMAINS $U_DNS_DOMAINS $U_MAIL_DOMAINS"
                echo " $U_DATABASES $U_DISK $U_BANDWIDTH $SUSPENDED $DATE"
        done < <(grep '@' /etc/passwd | cut -f1 -d:)
 }
2 Likes

Thanks for pointing out this omission in v-list-users, this should be corrected in the next release of HestiaCP.

2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.