colord icon indicating copy to clipboard operation
colord copied to clipboard

Ugly way of creating temp directory

Open bigon opened this issue 5 years ago • 1 comments

Hey,

Looking at https://github.com/hughsie/colord/blob/master/lib/colord/cd-test-private.c#L2010, I see the following code

        /* create test directory */
        root = g_strdup_printf ("/tmp/colord-%c%c%c%c",
                                g_random_int_range ('a', 'z'),
                                g_random_int_range ('a', 'z'),
                                g_random_int_range ('a', 'z'),
                                g_random_int_range ('a', 'z'));
        rc = g_mkdir_with_parents (root, 0777);

Two things

  1. making the directory 0777 is IMHO no nice (and insecure)
  2. Why not use g_dir_make_tmp () or g_get_tmp_dir () so one can override the TMPDIR if needed

There are more occurance of using 0777: https://github.com/hughsie/colord/blob/master/lib/colord/cd-test-private.c#L2058

bigon avatar Mar 21 '20 08:03 bigon

Get_tmp_dir would be great

hughsie avatar Mar 21 '20 08:03 hughsie