import grp
import pwd


def _get_user_groups(user_name):
    """
    Get a list of groups for the user ``user_name``.
    """
    groups = [g.gr_name for g in grp.getgrall() if user_name in g.gr_mem]
    gid = pwd.getpwnam(user_name).pw_gid
    groups.append(grp.getgrgid(gid).gr_name)

    return groups