From: hallyn Date: Fri, 13 Dec 2013 21:13:19 +0000 (-0800) Subject: Merge pull request #101 from ahippo/master X-Git-Tag: lxc-1.0.0.beta1~12 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a611bce104ddb9f76a140eab7ffc9d714a79bb9c;p=thirdparty%2Flxc.git Merge pull request #101 from ahippo/master run_buffer(): unblock all signals for spawned scripts. --- a611bce104ddb9f76a140eab7ffc9d714a79bb9c diff --cc src/lxc/conf.c index c8f0f7d1c,fa776188a..8e40e591a --- a/src/lxc/conf.c +++ b/src/lxc/conf.c @@@ -278,9 -280,77 +278,9 @@@ static struct caps_opt caps_opt[] = static struct caps_opt caps_opt[] = {}; #endif -static char padchar[] = -"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - -static char *mkifname(char *template) -{ - char *name = NULL; - int i = 0; - FILE *urandom; - unsigned int seed; - struct ifaddrs *ifaddr, *ifa; - int ifexists = 0; - - /* Get all the network interfaces */ - getifaddrs(&ifaddr); - - /* Initialize the random number generator */ - process_lock(); - urandom = fopen ("/dev/urandom", "r"); - process_unlock(); - if (urandom != NULL) { - if (fread (&seed, sizeof(seed), 1, urandom) <= 0) - seed = time(0); - process_lock(); - fclose(urandom); - process_unlock(); - } - else - seed = time(0); - -#ifndef HAVE_RAND_R - srand(seed); -#endif - - /* Generate random names until we find one that doesn't exist */ - while(1) { - ifexists = 0; - name = strdup(template); - - if (name == NULL) - return NULL; - - for (i = 0; i < strlen(name); i++) { - if (name[i] == 'X') { -#ifdef HAVE_RAND_R - name[i] = padchar[rand_r(&seed) % (strlen(padchar) - 1)]; -#else - name[i] = padchar[rand() % (strlen(padchar) - 1)]; -#endif - } - } - - for (ifa = ifaddr; ifa != NULL; ifa = ifa->ifa_next) { - if (strcmp(ifa->ifa_name, name) == 0) { - ifexists = 1; - break; - } - } - - if (ifexists == 0) - break; - - free(name); - } - - freeifaddrs(ifaddr); - return name; -} - static int run_buffer(char *buffer) { - FILE *f; + struct lxc_popen_FILE *f; char *output; int ret;