Revert "Replace the g_random_int() with the getrandom()" 46/298846/1
authorilho kim <ilho159.kim@samsung.com>
Thu, 14 Sep 2023 06:58:52 +0000 (15:58 +0900)
committerilho kim <ilho159.kim@samsung.com>
Thu, 14 Sep 2023 06:58:58 +0000 (15:58 +0900)
This reverts commit 49237995dcd62a496ee6753ed65977ac1bb1cabe.
Because the current kernel doesn't support the getrandom

Change-Id: Idcaed8e41887be15e46f0fbcbd36686b6331f2ec

plugin/app2sd/server/app2sd_internals_utils.c

index 494db6d..678ace0 100644 (file)
@@ -25,7 +25,6 @@
 #include <dirent.h>
 #include <glib.h>
 #include <storage-internal.h>
-#include <sys/random.h>
 
 #include "app2sd_internals.h"
 
@@ -355,14 +354,6 @@ char *_app2sd_generate_password(void)
                "!\"#$%&()*+,-./0123456789:;<=>?@ABCDE" \
                "FGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~";
        int i;
-       ssize_t s;
-       unsigned int rand_nums[PASSWD_LEN];
-
-       s = getrandom(rand_nums, sizeof(rand_nums), 0);
-       if (s < 0) {
-               _E("Failed to read random data errno : %d", errno);
-               return NULL;
-       }
 
        /* include null byte */
        passwd = (char *)malloc(sizeof(char) * (PASSWD_LEN + 1));
@@ -372,7 +363,7 @@ char *_app2sd_generate_password(void)
        }
 
        for (i = 0; i < PASSWD_LEN; i++)
-               passwd[i] = charset[rand_nums[i] % ASCII_PASSWD_CHAR];
+               passwd[i] = charset[g_random_int() % ASCII_PASSWD_CHAR];
        passwd[i] = '\0';
 
        return passwd;