mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-10-16 02:59:59 +00: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) {
|
||||
|
@@ -105,4 +105,4 @@ void init_argv0(int argc, char **argv);
|
||||
void set_nice_name(const char *name);
|
||||
uint32_t binary_gcd(uint32_t u, uint32_t v);
|
||||
int switch_mnt_ns(int pid);
|
||||
void gen_rand_str(char *buf, int len, bool varlen = true);
|
||||
int gen_rand_str(char *buf, int len, bool varlen = true);
|
||||
|
Reference in New Issue
Block a user