Merge remote branch 'origin/master' into gsoc

This commit is contained in:
Dan Williams
2010-08-26 09:18:37 -05:00
94 changed files with 15551 additions and 3684 deletions

View File

@@ -1,3 +1,4 @@
SUBDIRS=. tests
INCLUDES = \
-I$(top_srcdir)/src/system-settings \
@@ -5,15 +6,30 @@ INCLUDES = \
-I$(top_srcdir)/libnm-glib \
-I$(top_srcdir)/libnm-util
noinst_LTLIBRARIES = libifupdown-io.la
libifupdown_io_la_SOURCES = \
interface_parser.c \
interface_parser.h \
parser.c \
parser.h
libifupdown_io_la_CPPFLAGS = \
$(GLIB_CFLAGS) \
$(DBUS_CFLAGS) \
-DG_DISABLE_DEPRECATED \
-DSYSCONFDIR=\"$(sysconfdir)\"
libifupdown_io_la_LIBADD = \
$(top_builddir)/libnm-util/libnm-util.la \
$(GLIB_LIBS) \
$(GMODULE_LIBS)
pkglib_LTLIBRARIES = libnm-settings-plugin-ifupdown.la
libnm_settings_plugin_ifupdown_la_SOURCES = \
interface_parser.c \
interface_parser.h \
nm-ifupdown-connection.c \
nm-ifupdown-connection.h \
parser.c \
parser.h \
plugin.c \
plugin.h
@@ -28,6 +44,7 @@ libnm_settings_plugin_ifupdown_la_CPPFLAGS = \
libnm_settings_plugin_ifupdown_la_LDFLAGS = -module -avoid-version
libnm_settings_plugin_ifupdown_la_LIBADD = \
$(top_builddir)/libnm-util/libnm-util.la \
libifupdown-io.la \
$(GLIB_LIBS) \
$(GMODULE_LIBS) \
$(GUDEV_LIBS)

View File

@@ -73,85 +73,147 @@ void add_data(const char *key,const char *data)
//printf("added data '%s' with key '%s'\n",data,key);
}
#define SPACE_OR_TAB(string,ret) {ret = strchr(string,' ');ret=(ret == NULL?strchr(string,'\t'):ret);}
void ifparser_init(void)
// join values in src with spaces into dst; dst needs to be large enough
static char *join_values_with_spaces(char *dst, char **src)
{
FILE *inp = fopen(ENI_INTERFACES_FILE, "r");
int ret = 0;
char *line;
char *space;
char rline[255];
if (dst != NULL) {
*dst = '\0';
if (src != NULL && *src != NULL) {
strcat(dst, *src);
if (inp == NULL)
{
nm_warning ("Error: Can't open %s\n", ENI_INTERFACES_FILE);
for (src++; *src != NULL; src++) {
strcat(dst, " ");
strcat(dst, *src);
}
}
}
return(dst);
}
void ifparser_init (const char *eni_file, int quiet)
{
FILE *inp = fopen (eni_file, "r");
char line[255];
int skip_to_block = 1;
int skip_long_line = 0;
int offs = 0;
if (inp == NULL) {
if (!quiet)
g_warning ("Error: Can't open %s\n", eni_file);
return;
}
first = last = NULL;
while(1)
{
line = space = NULL;
ret = fscanf(inp,"%255[^\n]\n",rline);
if (ret == EOF)
break;
// If the line did not match, skip it
if (ret == 0) {
char *ignored;
ignored = fgets(rline, 255, inp);
first = last = NULL;
while (!feof(inp))
{
char *token[128]; // 255 chars can only be split into 127 tokens
char value[255]; // large enough to join previously split tokens
char *safeptr;
int toknum;
int len = 0;
char *ptr = fgets(line+offs, 255-offs, inp);
if (ptr == NULL)
break;
len = strlen(line);
// skip over-long lines
if (!feof(inp) && len > 0 && line[len-1] != '\n') {
if (!skip_long_line) {
if (!quiet)
g_message ("Error: Skipping over-long-line '%s...'\n", line);
}
skip_long_line = 1;
continue;
}
line = rline;
while(line[0] == ' ')
line++;
if (line[0]=='#' || line[0]=='\0')
// trailing '\n' found: remove it & reset offset to 0
if (len > 0 && line[len-1] == '\n') {
line[--len] = '\0';
offs = 0;
}
// if we're in long_line_skip mode, terminate it for real next line
if (skip_long_line) {
if (len == 0 || line[len-1] != '\\')
skip_long_line = 0;
continue;
}
// unwrap wrapped lines
if (len > 0 && line[len-1] == '\\') {
offs = len - 1;
continue;
}
//printf(">>%s<<\n", line);
#define SPACES " \t"
// tokenize input;
for (toknum = 0, token[toknum] = strtok_r(line, SPACES, &safeptr);
token[toknum] != NULL;
toknum++, token[toknum] = strtok_r(NULL, SPACES, &safeptr))
;
// ignore comments and empty lines
if (toknum == 0 || *token[0]=='#')
continue;
SPACE_OR_TAB(line,space)
if (space == NULL)
{
nm_warning ("Error: Can't parse interface line '%s'\n",line);
continue;
if (toknum < 2) {
if (!quiet) {
g_message ("Error: Can't parse interface line '%s'\n",
join_values_with_spaces(value, token));
}
space[0] = '\0';
skip_to_block = 1;
continue;
}
// There are four different stanzas:
// iface, mapping, auto and allow-*. Create a block for each of them.
if (strcmp(line,"iface")==0)
{
char *space2 = strchr(space+1,' ');
if (space2 == NULL)
{
nm_warning ("Error: Can't parse iface line '%s'\n",space+1);
// iface stanza takes at least 3 parameters
if (strcmp(token[0], "iface") == 0) {
if (toknum < 4) {
if (!quiet) {
g_message ("Error: Can't parse iface line '%s'\n",
join_values_with_spaces(value, token));
}
continue;
}
space2[0]='\0';
add_block(line,space+1);
if (space2[1]!='\0')
{
space = strchr(space2+1,' ');
if (space == NULL)
{
nm_warning ("Error: Can't parse data '%s'\n",space2+1);
continue;
}
space[0] = '\0';
add_data(space2+1,space+1);
}
add_block(token[0], token[1]);
skip_to_block = 0;
add_data(token[2], join_values_with_spaces(value, token + 3));
}
// auto and allow-auto stanzas are equivalent,
// both can take multiple interfaces as parameters: add one block for each
else if (strcmp(token[0], "auto") == 0 ||
strcmp(token[0], "allow-auto") == 0) {
int i;
for (i = 1; i < toknum; i++)
add_block("auto", token[i]);
skip_to_block = 0;
}
else if (strcmp(token[0], "mapping") == 0) {
add_block(token[0], join_values_with_spaces(value, token + 1));
skip_to_block = 0;
}
// allow-* can take multiple interfaces as parameters: add one block for each
else if (strncmp(token[0],"allow-",6) == 0) {
int i;
for (i = 1; i < toknum; i++)
add_block(token[0], token[i]);
skip_to_block = 0;
}
else {
if (skip_to_block) {
if (!quiet) {
g_message ("Error: ignoring out-of-block data '%s'\n",
join_values_with_spaces(value, token));
}
} else
add_data(token[0], join_values_with_spaces(value, token + 1));
}
else if (strcmp(line,"auto")==0)
add_block(line,space+1);
else if (strcmp(line,"mapping")==0)
add_block(line,space+1);
else if (strncmp(line,"allow-",6)==0)
add_block(line,space+1);
else
add_data(line,space+1);
//printf("line: '%s' ret=%d\n",rline,ret);
}
fclose(inp);
}
@@ -190,6 +252,18 @@ if_block *ifparser_getfirst(void)
return first;
}
int ifparser_get_num_blocks(void)
{
int i = 0;
if_block *iter = first;
while (iter) {
i++;
iter = iter->next;
}
return i;
}
if_block *ifparser_getif(const char* iface)
{
if_block *curr = first;
@@ -213,3 +287,15 @@ const char *ifparser_getkey(if_block* iface, const char *key)
}
return NULL;
}
int ifparser_get_num_info(if_block* iface)
{
int i = 0;
if_data *iter = iface->info;
while (iter) {
i++;
iter = iter->next;
}
return i;
}

View File

@@ -26,8 +26,6 @@
#include "config.h"
#define ENI_INTERFACES_FILE "/etc/network/interfaces"
typedef struct _if_data
{
char *key;
@@ -43,12 +41,14 @@ typedef struct _if_block
struct _if_block *next;
} if_block;
void ifparser_init(void);
void ifparser_init(const char *eni_file, int quiet);
void ifparser_destroy(void);
if_block *ifparser_getif(const char* iface);
if_block *ifparser_getfirst(void);
const char *ifparser_getkey(if_block* iface, const char *key);
int ifparser_get_num_blocks(void);
int ifparser_get_num_info(if_block* iface);
void add_block(const char *type, const char* name);
void add_data(const char *key,const char *data);

View File

@@ -55,6 +55,8 @@
#define G_UDEV_API_IS_SUBJECT_TO_CHANGE
#include <gudev/gudev.h>
#define ENI_INTERFACES_FILE "/etc/network/interfaces"
#define IFUPDOWN_PLUGIN_NAME "ifupdown"
#define IFUPDOWN_PLUGIN_INFO "(C) 2008 Canonical Ltd. To report bugs please use the NetworkManager mailing list."
#define IFUPDOWN_SYSTEM_HOSTNAME_FILE "/etc/hostname"
@@ -355,7 +357,7 @@ SCPluginIfupdown_init (NMSystemConfigInterface *config)
update_system_hostname (inotify_helper, NULL, NULL, config);
/* Read in all the interfaces */
ifparser_init ();
ifparser_init (ENI_INTERFACES_FILE, 0);
block = ifparser_getfirst ();
while (block) {
if(!strcmp ("auto", block->type) || !strcmp ("allow-hotplug", block->type))

View File

@@ -0,0 +1,32 @@
INCLUDES = \
-I$(top_srcdir)/include \
-I$(top_srcdir)/libnm-util \
-I$(top_srcdir)/libnm-glib \
-I$(top_srcdir)/system-settings/plugins/ifupdown
noinst_PROGRAMS = test-ifupdown
test_ifupdown_SOURCES = \
test-ifupdown.c
test_ifupdown_CPPFLAGS = \
$(GLIB_CFLAGS) \
$(DBUS_CFLAGS) \
-DTEST_ENI_DIR=\"$(abs_srcdir)\"
test_ifupdown_LDADD = \
$(top_builddir)/libnm-glib/libnm-glib.la \
$(top_builddir)/libnm-util/libnm-util.la \
$(top_builddir)/system-settings/plugins/ifupdown/libifupdown-io.la \
$(DBUS_LIBS)
if WITH_TESTS
check-local: test-ifupdown
$(abs_builddir)/test-ifupdown
endif
EXTRA_DIST = \
test1 test2 test3 test4 test5 test6 test7 test8 test9 test11 test12 \
test13 test14 test15 test16

View File

@@ -0,0 +1,496 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Copyright (C) 2010 Red Hat, Inc.
*
*/
#include <glib.h>
#include <string.h>
#include "interface_parser.h"
#include "parser.h"
typedef struct {
char *key;
char *data;
} ExpectedKey;
typedef struct {
char *type;
char *name;
GSList *keys;
} ExpectedBlock;
typedef struct {
GSList *blocks;
} Expected;
static ExpectedKey *
expected_key_new (const char *key, const char *data)
{
ExpectedKey *k;
k = g_malloc0 (sizeof (ExpectedKey));
g_assert (k);
k->key = g_strdup (key);
g_assert (k->key);
k->data = g_strdup (data);
g_assert (k->data);
return k;
}
static void
expected_key_free (ExpectedKey *k)
{
g_assert (k);
g_free (k->key);
g_free (k->data);
memset (k, 0, sizeof (ExpectedKey));
g_free (k);
}
static ExpectedBlock *
expected_block_new (const char *type, const char *name)
{
ExpectedBlock *b;
g_assert (type);
g_assert (name);
b = g_malloc0 (sizeof (ExpectedBlock));
g_assert (b);
b->type = g_strdup (type);
b->name = g_strdup (name);
return b;
}
static void
expected_block_free (ExpectedBlock *b)
{
g_assert (b);
g_slist_foreach (b->keys, (GFunc) expected_key_free, NULL);
g_slist_free (b->keys);
g_free (b->type);
g_free (b->name);
memset (b, 0, sizeof (ExpectedBlock));
g_free (b);
}
static void
expected_block_add_key (ExpectedBlock *b, ExpectedKey *k)
{
g_assert (b);
g_assert (k);
b->keys = g_slist_append (b->keys, k);
}
static Expected *
expected_new (void)
{
Expected *e;
e = g_malloc0 (sizeof (Expected));
g_assert (e);
return e;
}
static void
expected_add_block (Expected *e, ExpectedBlock *b)
{
g_assert (e);
g_assert (b);
e->blocks = g_slist_append (e->blocks, b);
}
static void
expected_free (Expected *e)
{
g_assert (e);
g_slist_foreach (e->blocks, (GFunc) expected_block_free, NULL);
g_slist_free (e->blocks);
memset (e, 0, sizeof (Expected));
g_free (e);
}
static void
compare_expected_to_ifparser (Expected *e)
{
if_block *n;
GSList *biter, *kiter;
g_assert_cmpint (g_slist_length (e->blocks), ==, ifparser_get_num_blocks ());
for (n = ifparser_getfirst (), biter = e->blocks;
n && biter;
n = n->next, biter = g_slist_next (biter)) {
if_data *m;
ExpectedBlock *b = biter->data;
g_assert (b->type && n->type);
g_assert_cmpstr (b->type, ==, n->type);
g_assert (b->name && n->name);
g_assert_cmpstr (b->name, ==, n->name);
g_assert_cmpint (g_slist_length (b->keys), ==, ifparser_get_num_info (n));
for (m = n->info, kiter = b->keys;
m && kiter;
m = m->next, kiter = g_slist_next (kiter)) {
ExpectedKey *k = kiter->data;
g_assert (k->key && m->key);
g_assert_cmpstr (k->key, ==, m->key);
g_assert (k->data && m->data);
g_assert_cmpstr (k->data, ==, m->data);
}
}
}
static void
dump_blocks (void)
{
if_block *n;
g_message ("\n***************************************************");
for (n = ifparser_getfirst (); n != NULL; n = n->next) {
if_data *m;
// each block start with its type & name
// (single quotes used to show typ & name baoundaries)
g_print("'%s' '%s'\n", n->type, n->name);
// each key-value pair within a block is indented & separated by a tab
// (single quotes used to show typ & name baoundaries)
for (m = n->info; m != NULL; m = m->next)
g_print("\t'%s'\t'%s'\n", m->key, m->data);
// blocks are separated by an empty line
g_print("\n");
}
g_message ("##################################################\n");
}
static void
init_ifparser_with_file (const char *path, const char *file)
{
char *tmp;
tmp = g_strdup_printf ("%s/%s", path, file);
ifparser_init (tmp, 1);
g_free (tmp);
}
static void
test1_ignore_line_before_first_block (const char *path)
{
Expected *e;
ExpectedBlock *b;
e = expected_new ();
b = expected_block_new ("auto", "eth0");
expected_add_block (e, b);
b = expected_block_new ("iface", "eth0");
expected_add_block (e, b);
expected_block_add_key (b, expected_key_new ("inet", "dhcp"));
init_ifparser_with_file (path, "test1");
compare_expected_to_ifparser (e);
ifparser_destroy ();
expected_free (e);
}
static void
test2_wrapped_line (const char *path)
{
Expected *e;
ExpectedBlock *b;
e = expected_new ();
b = expected_block_new ("auto", "lo");
expected_add_block (e, b);
init_ifparser_with_file (path, "test2");
compare_expected_to_ifparser (e);
ifparser_destroy ();
expected_free (e);
}
static void
test3_wrapped_multiline_multiarg (const char *path)
{
Expected *e;
ExpectedBlock *b;
e = expected_new ();
b = expected_block_new ("allow-hotplug", "eth0");
expected_add_block (e, b);
b = expected_block_new ("allow-hotplug", "wlan0");
expected_add_block (e, b);
b = expected_block_new ("allow-hotplug", "bnep0");
expected_add_block (e, b);
init_ifparser_with_file (path, "test3");
compare_expected_to_ifparser (e);
ifparser_destroy ();
expected_free (e);
}
static void
test4_allow_auto_is_auto (const char *path)
{
Expected *e;
ExpectedBlock *b;
e = expected_new ();
b = expected_block_new ("auto", "eth0");
expected_add_block (e, b);
init_ifparser_with_file (path, "test4");
compare_expected_to_ifparser (e);
ifparser_destroy ();
expected_free (e);
}
static void
test5_allow_auto_multiarg (const char *path)
{
Expected *e;
ExpectedBlock *b;
e = expected_new ();
b = expected_block_new ("allow-hotplug", "eth0");
expected_add_block (e, b);
b = expected_block_new ("allow-hotplug", "wlan0");
expected_add_block (e, b);
init_ifparser_with_file (path, "test5");
compare_expected_to_ifparser (e);
ifparser_destroy ();
expected_free (e);
}
static void
test6_mixed_whitespace (const char *path)
{
Expected *e;
ExpectedBlock *b;
e = expected_new ();
b = expected_block_new ("iface", "lo");
expected_block_add_key (b, expected_key_new ("inet", "loopback"));
expected_add_block (e, b);
init_ifparser_with_file (path, "test6");
compare_expected_to_ifparser (e);
ifparser_destroy ();
expected_free (e);
}
static void
test7_long_line (const char *path)
{
init_ifparser_with_file (path, "test7");
g_assert_cmpint (ifparser_get_num_blocks (), ==, 0);
ifparser_destroy ();
}
static void
test8_long_line_wrapped (const char *path)
{
init_ifparser_with_file (path, "test8");
g_assert_cmpint (ifparser_get_num_blocks (), ==, 0);
ifparser_destroy ();
}
static void
test9_wrapped_lines_in_block (const char *path)
{
Expected *e;
ExpectedBlock *b;
e = expected_new ();
b = expected_block_new ("iface", "eth0");
expected_add_block (e, b);
expected_block_add_key (b, expected_key_new ("inet", "static"));
expected_block_add_key (b, expected_key_new ("address", "10.250.2.3"));
expected_block_add_key (b, expected_key_new ("netmask", "255.255.255.192"));
expected_block_add_key (b, expected_key_new ("broadcast", "10.250.2.63"));
expected_block_add_key (b, expected_key_new ("gateway", "10.250.2.50"));
init_ifparser_with_file (path, "test9");
compare_expected_to_ifparser (e);
ifparser_destroy ();
expected_free (e);
}
static void
test11_complex_wrap (const char *path)
{
Expected *e;
ExpectedBlock *b;
e = expected_new ();
b = expected_block_new ("iface", "pppoe");
expected_add_block (e, b);
expected_block_add_key (b, expected_key_new ("inet", "manual"));
expected_block_add_key (b, expected_key_new ("pre-up", "/sbin/ifconfig eth0 up"));
init_ifparser_with_file (path, "test11");
compare_expected_to_ifparser (e);
ifparser_destroy ();
expected_free (e);
}
static void
test12_complex_wrap_split_word (const char *path)
{
Expected *e;
ExpectedBlock *b;
e = expected_new ();
b = expected_block_new ("iface", "pppoe");
expected_add_block (e, b);
expected_block_add_key (b, expected_key_new ("inet", "manual"));
expected_block_add_key (b, expected_key_new ("up", "ifup ppp0=dsl"));
init_ifparser_with_file (path, "test12");
compare_expected_to_ifparser (e);
ifparser_destroy ();
expected_free (e);
}
static void
test13_more_mixed_whitespace (const char *path)
{
Expected *e;
ExpectedBlock *b;
e = expected_new ();
b = expected_block_new ("iface", "dsl");
expected_block_add_key (b, expected_key_new ("inet", "ppp"));
expected_add_block (e, b);
init_ifparser_with_file (path, "test13");
compare_expected_to_ifparser (e);
ifparser_destroy ();
expected_free (e);
}
static void
test14_mixed_whitespace_block_start (const char *path)
{
Expected *e;
ExpectedBlock *b;
e = expected_new ();
b = expected_block_new ("iface", "wlan0");
expected_block_add_key (b, expected_key_new ("inet", "manual"));
expected_add_block (e, b);
b = expected_block_new ("iface", "wlan-adpm");
expected_block_add_key (b, expected_key_new ("inet", "dhcp"));
expected_add_block (e, b);
b = expected_block_new ("iface", "wlan-default");
expected_block_add_key (b, expected_key_new ("inet", "dhcp"));
expected_add_block (e, b);
init_ifparser_with_file (path, "test14");
compare_expected_to_ifparser (e);
ifparser_destroy ();
expected_free (e);
}
static void
test15_trailing_space (const char *path)
{
Expected *e;
ExpectedBlock *b;
e = expected_new ();
b = expected_block_new ("iface", "bnep0");
expected_block_add_key (b, expected_key_new ("inet", "static"));
expected_add_block (e, b);
init_ifparser_with_file (path, "test15");
compare_expected_to_ifparser (e);
ifparser_destroy ();
expected_free (e);
}
static void
test16_missing_newline (const char *path)
{
Expected *e;
e = expected_new ();
expected_add_block (e, expected_block_new ("mapping", "eth0"));
init_ifparser_with_file (path, "test16");
compare_expected_to_ifparser (e);
ifparser_destroy ();
expected_free (e);
}
#if GLIB_CHECK_VERSION(2,25,12)
typedef GTestFixtureFunc TCFunc;
#else
typedef void (*TCFunc)(void);
#endif
#define TESTCASE(t, d) g_test_create_case (#t, 0, d, NULL, (TCFunc) t, NULL)
int main (int argc, char **argv)
{
GTestSuite *suite;
g_test_init (&argc, &argv, NULL);
suite = g_test_get_root ();
if (0)
dump_blocks ();
g_test_suite_add (suite, TESTCASE (test1_ignore_line_before_first_block, TEST_ENI_DIR));
g_test_suite_add (suite, TESTCASE (test2_wrapped_line, TEST_ENI_DIR));
g_test_suite_add (suite, TESTCASE (test3_wrapped_multiline_multiarg, TEST_ENI_DIR));
g_test_suite_add (suite, TESTCASE (test4_allow_auto_is_auto, TEST_ENI_DIR));
g_test_suite_add (suite, TESTCASE (test5_allow_auto_multiarg, TEST_ENI_DIR));
g_test_suite_add (suite, TESTCASE (test6_mixed_whitespace, TEST_ENI_DIR));
g_test_suite_add (suite, TESTCASE (test7_long_line, TEST_ENI_DIR));
g_test_suite_add (suite, TESTCASE (test8_long_line_wrapped, TEST_ENI_DIR));
g_test_suite_add (suite, TESTCASE (test9_wrapped_lines_in_block, TEST_ENI_DIR));
g_test_suite_add (suite, TESTCASE (test11_complex_wrap, TEST_ENI_DIR));
g_test_suite_add (suite, TESTCASE (test12_complex_wrap_split_word, TEST_ENI_DIR));
g_test_suite_add (suite, TESTCASE (test13_more_mixed_whitespace, TEST_ENI_DIR));
g_test_suite_add (suite, TESTCASE (test14_mixed_whitespace_block_start, TEST_ENI_DIR));
g_test_suite_add (suite, TESTCASE (test15_trailing_space, TEST_ENI_DIR));
g_test_suite_add (suite, TESTCASE (test16_missing_newline, TEST_ENI_DIR));
return g_test_run ();
}

View File

@@ -0,0 +1,6 @@
# case 1: line before 1st block (must be ignored)
address 10.250.2.3
auto eth0
iface eth0 inet dhcp

View File

@@ -0,0 +1,5 @@
iface pppoe inet manual
# case 11: wrapped line (without leading space on the wrapped part, wrap within a multi-word value)
pre-up /sbin/ifconfig \
eth0 up

View File

@@ -0,0 +1,5 @@
iface pppoe inet manual
# case 12: wrapped line, splitting a word (must be joined again)
up ifup ppp0\
=dsl

View File

@@ -0,0 +1,3 @@
# case 13: variations of tabs & spaces
iface dsl inet ppp

View File

@@ -0,0 +1,5 @@
# case 14: variations of tabs and spaces (all must be recognized as lines starting an iface block)
iface wlan0 inet manual
iface wlan-adpm inet dhcp
iface wlan-default inet dhcp

View File

@@ -0,0 +1,3 @@
# case 15: trailing space (must be ignored)
iface bnep0 inet static

View File

@@ -0,0 +1,2 @@
# case 16: last line that is not followed by LF (added with 'echo -n "mapping eth0" >> /e/n/i')
mapping eth0

View File

@@ -0,0 +1,4 @@
# case 2: wrapped line
auto \
lo

View File

@@ -0,0 +1,5 @@
# case 3: line wrapped over multiple lines & multi-argument allow-*
allow-hotplug eth0 \
wlan0 \
bnep0

View File

@@ -0,0 +1,3 @@
# case 4: 'allow-auto' is synonymous to 'auto'
allow-auto eth0

View File

@@ -0,0 +1,3 @@
# case 5: multi-argument allow-* (even worse: trailing space)
allow-hotplug eth0 wlan0

View File

@@ -0,0 +1,3 @@
# case 6: mix between tabs and spaces
iface lo inet loopback

View File

@@ -0,0 +1,3 @@
# case 7: over-long line (must be ignored completely)
123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789

View File

@@ -0,0 +1,5 @@
# case 8: over-long line that wraps to consecutive lines (must be ignored completely)
123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 \
allow-test eth0 \
eth0

View File

@@ -0,0 +1,10 @@
iface eth0 inet static
# case 9: wrapped lines inside a block (to be on the safe side)
address \
10.250.2.3
netmask \
255.255.255.192
broadcast 10.250.2.63
gateway 10.250.2.50