Esempio n. 1
0
int main(int argc, char *argv[])
{
    char *path;
    gid_t gids[] = { TEST_SGID };

    diod_log_init (argv[0]);

    assert (geteuid () == 0);

    /* clear supplemental groups */
    _setgroups (0, NULL);
    msg ("supplemental groups cleared");

    assert (geteuid () == 0);
    path = create_file (0, TEST_SGID, 0440);

    change_fsid (0, 0, TEST_UID, TEST_GID);
    assert (!read_file (path));

    change_fsid (TEST_UID, TEST_GID, TEST_UID, TEST_SGID);
    assert (read_file (path));

    change_fsid (TEST_UID, TEST_SGID, TEST_UID, TEST_GID);
    assert (!read_file (path));

    /* set TEST_SGID in supplemental groups */
    _setgroups (1, gids);
    msg ("%d added to supplemental groups", gids[0]);
    assert (read_file (path));

    /* clear supplemental groups */
    _setgroups (0, NULL);
    msg ("supplemental groups cleared");
    assert (!read_file (path));

    /* clean up */
    change_fsid (TEST_UID, TEST_GID, 0, 0);
    _unlink (path);

    msg ("test complete");
    exit (0);
}
Esempio n. 2
0
File: tsuppgrp.c Progetto: 8l/diod
static void *proc2 (void *a)
{
    gid_t g[] = { TEST_GID };

    wait_state (S1);
    show_groups ("task2");

    msg ("task2: setgroups %d", TEST_GID);
    _setgroups (1, g);
    show_groups ("task2");
    change_state (S2);

    wait_state (S3);
    show_groups ("task2");
    change_state (S4);
    return NULL;
}
Esempio n. 3
0
File: tsuppgrp.c Progetto: 8l/diod
int main(int argc, char *argv[])
{
    pthread_t t1, t2;

    diod_log_init (argv[0]);

    assert (geteuid () == 0);

    msg ("task0: setgroups (NULL)");
    _setgroups (0, NULL);
    show_groups ("task0");

    _create (&t1, proc1, NULL);
    _create (&t2, proc2, NULL);

    _join (t2, NULL);
    _join (t1, NULL);

    show_groups ("task0");
    
    exit (0);
}