mirror of
git://github.com/lxc/lxc
synced 2025-08-31 15:09:28 +00:00
Use srand/rand instead of initstate/random
initstate/random doesn't work on bionic, srand/rand works on everything, so let's use that. Signed-off-by: Stéphane Graber <stgraber@ubuntu.com> Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
This commit is contained in:
@@ -301,7 +301,7 @@ AC_CHECK_DECLS([PR_CAPBSET_DROP], [], [], [#include <sys/prctl.h>])
|
||||
AC_CHECK_HEADERS([sys/signalfd.h pty.h ifaddrs.h sys/capability.h sys/personality.h utmpx.h sys/timerfd.h])
|
||||
|
||||
# Check for some syscalls functions
|
||||
AC_CHECK_FUNCS([setns pivot_root sethostname unshare])
|
||||
AC_CHECK_FUNCS([setns pivot_root sethostname unshare rand_r])
|
||||
|
||||
# Check for some functions
|
||||
AC_CHECK_LIB(util, openpty)
|
||||
|
@@ -288,7 +288,6 @@ static char *mkifname(char *template)
|
||||
int i = 0;
|
||||
FILE *urandom;
|
||||
unsigned int seed;
|
||||
char randstate[2048];
|
||||
struct ifaddrs *ifaddr, *ifa;
|
||||
int ifexists = 0;
|
||||
|
||||
@@ -304,7 +303,10 @@ static char *mkifname(char *template)
|
||||
}
|
||||
else
|
||||
seed = time(0);
|
||||
initstate(seed, randstate, 256);
|
||||
|
||||
#ifndef HAVE_RAND_R
|
||||
srand(seed);
|
||||
#endif
|
||||
|
||||
/* Generate random names until we find one that doesn't exist */
|
||||
while(1) {
|
||||
@@ -316,7 +318,11 @@ static char *mkifname(char *template)
|
||||
|
||||
for (i = 0; i < strlen(name); i++) {
|
||||
if (name[i] == 'X') {
|
||||
name[i] = padchar[random() % (strlen(padchar) - 1)];
|
||||
#ifdef HAVE_RAND_R
|
||||
name[i] = padchar[rand_r(&seed) % (strlen(padchar) - 1)];
|
||||
#else
|
||||
name[i] = padchar[rand() % (strlen(padchar) - 1)];
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user