~lightdm-team/lightdm/1.2

« back to all changes in this revision

Viewing changes to tests/src/test-runner.c

  • Committer: Robert Ancell
  • Date: 2012-03-20 05:11:28 UTC
  • Revision ID: robert.ancell@canonical.com-20120320051128-3pz5ies6mxx2pdik
Call initgroups before pam_setcred - this allows pam_setcred to change group membership correctly

Show diffs side-by-side

added added

removed removed

Lines of Context:
838
838
static void
839
839
load_passwd_file ()
840
840
{
841
 
    gchar *data, **lines;
 
841
    gchar *path, *data, **lines;
842
842
    int i;
843
843
 
844
 
    g_file_get_contents (g_getenv ("LIGHTDM_TEST_PASSWD_FILE"), &data, NULL, NULL);
 
844
    path = g_build_filename (g_getenv ("LIGHTDM_TEST_ROOT"), "etc", "passwd", NULL);
 
845
    g_file_get_contents (path, &data, NULL, NULL);
 
846
    g_free (path);
845
847
    lines = g_strsplit (data, "\n", -1);
846
848
    g_free (data);
847
849
 
1179
1181
{
1180
1182
    GMainLoop *loop;
1181
1183
    gchar *greeter = NULL, *script_name, *config_file, *path, *path1, *path2, *ld_preload, *ld_library_path, *home_dir;
1182
 
    GString *passwd_data;
 
1184
    GString *passwd_data, *group_data;
1183
1185
    GSource *status_source;
1184
1186
    gchar cwd[1024];
1185
1187
    GError *error = NULL;
1288
1290
        quit (EXIT_FAILURE);
1289
1291
    }
1290
1292
    g_chmod (temp_dir, 0755);
 
1293
    g_setenv ("LIGHTDM_TEST_ROOT", temp_dir, TRUE);
1291
1294
 
1292
1295
    /* Set up a skeleton file system */
1293
1296
    g_mkdir_with_parents (g_strdup_printf ("%s/etc", temp_dir), 0755);
1311
1314
    g_free (greeter);
1312
1315
 
1313
1316
    home_dir = g_build_filename (temp_dir, "home", NULL);
1314
 
    g_setenv ("LIGHTDM_TEST_HOME_DIR", home_dir, TRUE);
1315
1317
 
1316
1318
    /* Make fake users */
1317
1319
    struct
1372
1374
        {"multi-info-prompt","password", TRUE,  "Multi Info Prompt",  NULL,  NULL, NULL,          NULL,          1022},
1373
1375
        /* This account uses two factor authentication */
1374
1376
        {"two-factor",       "password", TRUE,  "Two Factor",         NULL,  NULL, NULL,          NULL,          1023},
 
1377
        /* This account has a special group */
 
1378
        {"group-member",     "password", TRUE,  "Group Member",       NULL,  NULL, NULL,          NULL,          1024},
1375
1379
        {NULL,               NULL,       FALSE, NULL,                 NULL,  NULL, NULL,          NULL,             0}
1376
1380
    };
1377
1381
    passwd_data = g_string_new ("");
 
1382
    group_data = g_string_new ("");
1378
1383
    int i;
1379
1384
    for (i = 0; users[i].user_name; i++)
1380
1385
    {
1425
1430
 
1426
1431
        g_key_file_free (dmrc_file);
1427
1432
 
 
1433
        /* Add passwd file entry */
1428
1434
        g_string_append_printf (passwd_data, "%s:%s:%d:%d:%s:%s/home/%s:/bin/sh\n", users[i].user_name, users[i].password, users[i].uid, users[i].uid, users[i].real_name, temp_dir, users[i].user_name);
 
1435
 
 
1436
        /* Add group file entry */
 
1437
        g_string_append_printf (group_data, "%s:x:%d:%s\n", users[i].user_name, users[i].uid, users[i].user_name);
1429
1438
    }
1430
 
    path = g_build_filename (temp_dir, "passwd", NULL);
1431
 
    g_setenv ("LIGHTDM_TEST_PASSWD_FILE", path, TRUE);
 
1439
    path = g_build_filename (temp_dir, "etc", "passwd", NULL);
1432
1440
    g_file_set_contents (path, passwd_data->str, -1, NULL);
1433
1441
    g_free (path);
1434
1442
    g_string_free (passwd_data, TRUE);
1435
1443
 
 
1444
    /* Add an extra test group */
 
1445
    g_string_append_printf (group_data, "test-group:x:111:\n");
 
1446
 
 
1447
    path = g_build_filename (temp_dir, "etc", "group", NULL);
 
1448
    g_file_set_contents (path, group_data->str, -1, NULL);
 
1449
    g_free (path);
 
1450
    g_string_free (group_data, TRUE);
 
1451
 
1436
1452
    /* Start D-Bus services */
1437
1453
    if (!g_key_file_get_boolean (config, "test-runner-config", "disable-console-kit", NULL))
1438
1454
        start_console_kit_daemon ();