Beispiel #1
0
static void TestUserDeletion(void)
{
    LE_ASSERT(user_Delete(USER_NAME) == LE_OK);
    LE_ASSERT(user_Delete(APP_USER_NAME) == LE_OK);

    LE_ASSERT(user_GetIDs(USER_NAME, NULL, NULL) == LE_NOT_FOUND);

    char buf[100];
    LE_ASSERT(user_GetName(Uid, buf, sizeof(buf)) == LE_NOT_FOUND);

    LE_ASSERT(user_GetAppName(AppUid, buf, sizeof(buf)) == LE_NOT_FOUND);
}
//--------------------------------------------------------------------------------------------------
void userAddRemove_Remove
(
    const char* appName
)
//--------------------------------------------------------------------------------------------------
{
    le_result_t result;

    char userName[256] = "app";

    result = le_utf8_Append(userName, appName, sizeof(userName), NULL);
    LE_FATAL_IF(result != LE_OK, "App name '%s' is too long.", appName);

    LE_INFO("Deleting user '%s' for application '%s'.",
            userName,
            appName);

    result = user_Delete(userName);

    if (result == LE_OK)
    {
        printf("Deleted user '%s'.\n", userName);

        // TODO: Remove from supplementary groups.

        exit(EXIT_SUCCESS);
    }
    else if (result == LE_NOT_FOUND)
    {
        // TODO: Verify groups have been cleaned of this user.

        printf("User '%s' doesn't exist.\n", userName);

        exit(EXIT_SUCCESS);
    }
    else
    {
        fprintf(stderr,
                "** ERROR: user_Delete() failed for user '%s'.\n",
                userName);
    }

    exit(EXIT_FAILURE);
}