import re


def safe_name(name):
    """
    Converts IAM user names to UNIX user names

    1) Illegal IAM username characters are removed
    2) +/=/,/@ are converted to plus/equals/comma/at
    """
    # IAM users only allow [\w+=,.@-]
    name = re.sub(r'[^\w+=,.@-]+', '', name)
    name = re.sub(r'[+]', 'plus', name)
    name = re.sub(r'[=]', 'equals', name)
    name = re.sub(r'[,]', 'comma', name)
    name = re.sub(r'[@]', 'at', name)
    return name