=== modified file 'TODO' --- TODO 2009-01-12 22:02:33 +0000 +++ TODO 2009-01-17 12:12:26 +0000 @@ -1,9 +1,6 @@ -*- org -*- * mandos-client -** TODO [#B] Temporarily lower kernel log level - for less printouts during sucessfull boot. - klogctl(6, NULL, 0); klogctl(7, NULL, 0); ** TODO [#C] IPv4 support * plugin-runner @@ -41,9 +38,6 @@ * mandos-list *** Handle "no D-Bus server" and/or "no Mandos server found" better *** [#B] --dump option -** TODO Disable client -** TODO Enable client -** TODO Reset timer * Curses interface === modified file 'plugins.d/mandos-client.c' --- plugins.d/mandos-client.c 2009-01-14 14:20:17 +0000 +++ plugins.d/mandos-client.c 2009-01-17 12:12:26 +0000 @@ -60,7 +60,7 @@ #include /* PRIu16, intmax_t, SCNdMAX */ #include /* assert() */ #include /* perror(), errno */ -#include /* time() */ +#include /* time(), nanosleep() */ #include /* ioctl, ifreq, SIOCGIFFLAGS, IFF_UP, SIOCSIFFLAGS, if_indextoname(), if_nametoindex(), IF_NAMESIZE */ @@ -74,6 +74,7 @@ argp_state, struct argp, argp_parse(), ARGP_KEY_ARG, ARGP_KEY_END, ARGP_ERR_UNKNOWN */ +#include /* klogctl() */ /* Avahi */ /* All Avahi types, constants and functions @@ -840,6 +841,7 @@ ":!CTYPE-X.509:+CTYPE-OPENPGP" }; bool gnutls_initalized = false; bool gpgme_initalized = false; + double delay = 2.5; { struct argp_option options[] = { @@ -871,6 +873,10 @@ .arg = "STRING", .doc = "GnuTLS priority string for the TLS handshake", .group = 1 }, + { .name = "delay", .key = 131, + .arg = "SECONDS", + .doc = "Maximum delay to wait for interface startup", + .group = 2 }, { .name = NULL } }; @@ -904,6 +910,13 @@ case 130: /* --priority */ mc.priority = arg; break; + case 131: /* --delay */ + ret = sscanf(arg, "%lf%n", &delay, &numchars); + if(ret < 1 or arg[numchars] != '\0'){ + fprintf(stderr, "Bad delay\n"); + exit(EXIT_FAILURE); + } + break; case ARGP_KEY_ARG: argp_usage(state); case ARGP_KEY_END: @@ -928,16 +941,31 @@ /* If the interface is down, bring it up */ { + // Lower kernel loglevel to KERN_NOTICE to avoid + // KERN_INFO messages to mess up the prompt + ret = klogctl(8, NULL, 5); + if(ret == -1){ + perror("klogctl"); + } + sd = socket(PF_INET6, SOCK_DGRAM, IPPROTO_IP); if(sd < 0) { perror("socket"); exitcode = EXIT_FAILURE; + ret = klogctl(7, NULL, 0); + if(ret == -1){ + perror("klogctl"); + } goto end; } strcpy(network.ifr_name, interface); ret = ioctl(sd, SIOCGIFFLAGS, &network); if(ret == -1){ perror("ioctl SIOCGIFFLAGS"); + ret = klogctl(7, NULL, 0); + if(ret == -1){ + perror("klogctl"); + } exitcode = EXIT_FAILURE; goto end; } @@ -947,13 +975,33 @@ if(ret == -1){ perror("ioctl SIOCSIFFLAGS"); exitcode = EXIT_FAILURE; + ret = klogctl(7, NULL, 0); + if(ret == -1){ + perror("klogctl"); + } goto end; } } + // sleep checking until interface is running + for(int i=0; i < delay * 4; i++){ + ret = ioctl(sd, SIOCGIFFLAGS, &network); + if(ret == -1){ + perror("ioctl SIOCGIFFLAGS"); + } else if(network.ifr_flags & IFF_RUNNING){ + break; + } + struct timespec sleeptime = { .tv_nsec = 250000000 }; + nanosleep(&sleeptime, NULL); + } ret = (int)TEMP_FAILURE_RETRY(close(sd)); if(ret == -1){ perror("close"); } + // Restores kernel loglevel to default + ret = klogctl(7, NULL, 0); + if(ret == -1){ + perror("klogctl"); + } } uid = getuid(); @@ -1086,7 +1134,7 @@ if(debug){ fprintf(stderr, "Starting Avahi loop search\n"); } - + avahi_simple_poll_loop(mc.simple_poll); end: === modified file 'plugins.d/mandos-client.xml' --- plugins.d/mandos-client.xml 2009-01-04 21:54:55 +0000 +++ plugins.d/mandos-client.xml 2009-01-17 12:12:26 +0000 @@ -93,6 +93,10 @@ + + + + @@ -251,6 +255,22 @@ + + + + + + After bringing the network interface up, the program waits + for the interface to arrive in a running + state before proceeding. During this time, the kernel log + level will be lowered to reduce clutter on the system + console, alleviating any other plugins which might be + using the system console. This option sets the upper + limit of seconds to wait. The default is 2.5 seconds. + + + === modified file 'plugins.d/password-prompt.c' --- plugins.d/password-prompt.c 2009-01-13 04:35:19 +0000 +++ plugins.d/password-prompt.c 2009-01-17 12:12:26 +0000 @@ -194,7 +194,7 @@ const char *cryptsource = getenv("cryptsource"); const char *crypttarget = getenv("crypttarget"); const char *const prompt - = "Enter passphrase to unlock the disk"; + = "Enter passphrase to unlock the disk"; if(cryptsource == NULL){ if(crypttarget == NULL){ fprintf(stderr, "%s: ", prompt);