mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-12-23 15:38:07 -08:00
Support cases when /sbin does not exist
This commit is contained in:
@@ -46,7 +46,7 @@ constexpr char ALPHANUM[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXY
|
||||
static bool seeded = false;
|
||||
static std::mt19937 gen;
|
||||
static std::uniform_int_distribution<int> dist(0, sizeof(ALPHANUM) - 2);
|
||||
void gen_rand_str(char *buf, int len, bool varlen) {
|
||||
int gen_rand_str(char *buf, int len, bool varlen) {
|
||||
if (!seeded) {
|
||||
if (access("/dev/urandom", F_OK) != 0)
|
||||
mknod("/dev/urandom", 0600 | S_IFCHR, makedev(1, 9));
|
||||
@@ -64,6 +64,7 @@ void gen_rand_str(char *buf, int len, bool varlen) {
|
||||
for (int i = 0; i < len - 1; ++i)
|
||||
buf[i] = ALPHANUM[dist(gen)];
|
||||
buf[len - 1] = '\0';
|
||||
return len - 1;
|
||||
}
|
||||
|
||||
int strend(const char *s1, const char *s2) {
|
||||
|
||||
Reference in New Issue
Block a user