ifcfg-rh: remove iBFT handling (use the ibft plugin instead) (bgo #734009) (rh #990480)

Now that the ibft plugin handles iBFT data, no reason to do so from the
ifcfg-rh plugin.

https://bugzilla.gnome.org/show_bug.cgi?id=734009
This commit is contained in:
Dan Williams 2014-07-30 16:25:58 -05:00
parent 448254f761
commit 7b714524b9
15 changed files with 79 additions and 1033 deletions

View file

@ -117,7 +117,7 @@ nm_ifcfg_connection_new (NMConnection *source,
else {
char *keyfile = NULL, *routefile = NULL, *route6file = NULL;
tmp = connection_from_file (full_path, NULL, NULL, NULL,
tmp = connection_from_file (full_path, NULL, NULL,
&unhandled_spec,
&keyfile,
&routefile,
@ -269,7 +269,7 @@ commit_changes (NMSettingsConnection *connection,
* it if it's really changed.
*/
if (priv->path) {
reread = connection_from_file (priv->path, NULL, NULL, NULL,
reread = connection_from_file (priv->path, NULL, NULL,
NULL, NULL, NULL, NULL,
&error, NULL);
g_clear_error (&error);

View file

@ -274,251 +274,6 @@ read_mac_address (shvarFile *ifcfg, const char *key, gsize len,
return TRUE;
}
static void
iscsiadm_child_setup (gpointer user_data G_GNUC_UNUSED)
{
/* We are in the child process here; set a different process group to
* ensure signal isolation between child and parent.
*/
pid_t pid = getpid ();
setpgid (pid, pid);
/*
* We blocked signals in main(). We need to restore original signal
* mask for iscsiadm here so that it can receive signals.
*/
nm_unblock_posix_signals (NULL);
}
static char *
match_iscsiadm_tag (const char *line, const char *tag, gboolean *skip)
{
char *p;
if (g_ascii_strncasecmp (line, tag, strlen (tag)))
return NULL;
p = strchr (line, '=');
if (!p) {
PARSE_WARNING ("malformed iscsiadm record: no = in '%s'.", line);
*skip = TRUE;
return NULL;
}
p++; /* advance past = */
return g_strstrip (p);
}
#define ISCSI_HWADDR_TAG "iface.hwaddress"
#define ISCSI_BOOTPROTO_TAG "iface.bootproto"
#define ISCSI_IPADDR_TAG "iface.ipaddress"
#define ISCSI_SUBNET_TAG "iface.subnet_mask"
#define ISCSI_GATEWAY_TAG "iface.gateway"
#define ISCSI_DNS1_TAG "iface.primary_dns"
#define ISCSI_DNS2_TAG "iface.secondary_dns"
static gboolean
fill_ip4_setting_from_ibft (shvarFile *ifcfg,
NMSettingIP4Config *s_ip4,
const char *iscsiadm_path,
GError **error)
{
const char *argv[4] = { iscsiadm_path, "-m", "fw", NULL };
const char *envp[1] = { NULL };
gboolean success = FALSE, in_record = FALSE, hwaddr_matched = FALSE, skip = FALSE;
char *out = NULL, *err = NULL;
gint status = 0;
GByteArray *ifcfg_mac = NULL;
char **lines = NULL, **iter;
const char *method = NULL;
guint32 ipaddr;
guint32 gateway;
guint32 dns1;
guint32 dns2;
guint32 prefix = 0;
g_return_val_if_fail (s_ip4 != NULL, FALSE);
g_return_val_if_fail (iscsiadm_path != NULL, FALSE);
if (!g_spawn_sync ("/", (char **) argv, (char **) envp, 0,
iscsiadm_child_setup, NULL, &out, &err, &status, error))
return FALSE;
if (!WIFEXITED (status)) {
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"%s exited abnormally.", iscsiadm_path);
goto done;
}
if (WEXITSTATUS (status) != 0) {
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"%s exited with error %d. Message: '%s'",
iscsiadm_path, WEXITSTATUS (status), err ? err : "(none)");
goto done;
}
if (!read_mac_address (ifcfg, "HWADDR", ETH_ALEN, &ifcfg_mac, error))
goto done;
/* Ensure we got a MAC */
if (!ifcfg_mac) {
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"Missing device MAC address (no HWADDR tag present).");
goto done;
}
memset (&ipaddr, 0, sizeof (ipaddr));
memset (&gateway, 0, sizeof (gateway));
memset (&dns1, 0, sizeof (dns1));
memset (&dns2, 0, sizeof (dns2));
/* Success, lets parse the output */
lines = g_strsplit_set (out, "\n\r", -1);
for (iter = lines; iter && *iter; iter++) {
char *p;
if (!g_ascii_strcasecmp (*iter, "# BEGIN RECORD")) {
if (in_record) {
PARSE_WARNING ("malformed iscsiadm record: already parsing record.");
skip = TRUE;
}
} else if (!g_ascii_strcasecmp (*iter, "# END RECORD")) {
if (!skip && hwaddr_matched) {
/* Record is good; fill IP4 config with its info */
if (!method) {
PARSE_WARNING ("malformed iscsiadm record: missing BOOTPROTO.");
goto done;
}
g_object_set (s_ip4, NM_SETTING_IP4_CONFIG_METHOD, method, NULL);
if (!strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_MANUAL)) {
NMIP4Address *addr;
if (!ipaddr || !prefix) {
PARSE_WARNING ("malformed iscsiadm record: BOOTPROTO=static "
"but missing IP address or prefix.");
goto done;
}
addr = nm_ip4_address_new ();
nm_ip4_address_set_address (addr, ipaddr);
nm_ip4_address_set_prefix (addr, prefix);
nm_ip4_address_set_gateway (addr, gateway);
nm_setting_ip4_config_add_address (s_ip4, addr);
nm_ip4_address_unref (addr);
if (dns1)
nm_setting_ip4_config_add_dns (s_ip4, dns1);
if (dns2)
nm_setting_ip4_config_add_dns (s_ip4, dns2);
// FIXME: DNS search domains?
}
success = TRUE;
goto done;
}
skip = FALSE;
hwaddr_matched = FALSE;
memset (&ipaddr, 0, sizeof (ipaddr));
memset (&gateway, 0, sizeof (gateway));
memset (&dns1, 0, sizeof (dns1));
memset (&dns2, 0, sizeof (dns2));
prefix = 0;
method = NULL;
}
if (skip)
continue;
/* HWADDR */
if (!skip && (p = match_iscsiadm_tag (*iter, ISCSI_HWADDR_TAG, &skip))) {
guint8 *ibft_mac[ETH_ALEN];
if (!nm_utils_hwaddr_aton (p, ibft_mac, ETH_ALEN)) {
PARSE_WARNING ("malformed iscsiadm record: invalid hwaddress.");
skip = TRUE;
continue;
}
if (!nm_utils_hwaddr_matches (ibft_mac, ETH_ALEN, ifcfg_mac->data, ifcfg_mac->len)) {
/* This record isn't for the current device, ignore it */
skip = TRUE;
continue;
}
/* Success, this record is for this device */
hwaddr_matched = TRUE;
}
/* BOOTPROTO */
if (!skip && (p = match_iscsiadm_tag (*iter, ISCSI_BOOTPROTO_TAG, &skip))) {
if (!g_ascii_strcasecmp (p, "dhcp"))
method = NM_SETTING_IP4_CONFIG_METHOD_AUTO;
else if (!g_ascii_strcasecmp (p, "static"))
method = NM_SETTING_IP4_CONFIG_METHOD_MANUAL;
else {
PARSE_WARNING ("malformed iscsiadm record: unknown BOOTPROTO '%s'.", p);
skip = TRUE;
continue;
}
}
if (!skip && (p = match_iscsiadm_tag (*iter, ISCSI_IPADDR_TAG, &skip))) {
if (inet_pton (AF_INET, p, &ipaddr) < 1) {
PARSE_WARNING ("malformed iscsiadm record: invalid IP address '%s'.", p);
skip = TRUE;
continue;
}
}
if (!skip && (p = match_iscsiadm_tag (*iter, ISCSI_SUBNET_TAG, &skip))) {
guint32 mask;
if (inet_pton (AF_INET, p, &mask) < 1) {
PARSE_WARNING ("malformed iscsiadm record: invalid subnet mask '%s'.", p);
skip = TRUE;
continue;
}
prefix = nm_utils_ip4_netmask_to_prefix (mask);
}
if (!skip && (p = match_iscsiadm_tag (*iter, ISCSI_GATEWAY_TAG, &skip))) {
if (inet_pton (AF_INET, p, &gateway) < 1) {
PARSE_WARNING ("malformed iscsiadm record: invalid IP gateway '%s'.", p);
skip = TRUE;
continue;
}
}
if (!skip && (p = match_iscsiadm_tag (*iter, ISCSI_DNS1_TAG, &skip))) {
if (inet_pton (AF_INET, p, &dns1) < 1) {
PARSE_WARNING ("malformed iscsiadm record: invalid DNS1 address '%s'.", p);
skip = TRUE;
continue;
}
}
if (!skip && (p = match_iscsiadm_tag (*iter, ISCSI_DNS2_TAG, &skip))) {
if (inet_pton (AF_INET, p, &dns2) < 1) {
PARSE_WARNING ("malformed iscsiadm record: invalid DNS2 address '%s'.", p);
skip = TRUE;
continue;
}
}
}
success = TRUE;
done:
if (ifcfg_mac)
g_byte_array_free (ifcfg_mac, TRUE);
g_strfreev (lines);
g_free (out);
g_free (err);
return success;
}
/* Returns TRUE on missing address or valid address */
static gboolean
read_ip4_address (shvarFile *ifcfg,
@ -1242,7 +997,6 @@ error:
static NMSetting *
make_ip4_setting (shvarFile *ifcfg,
const char *network_file,
const char *iscsiadm_path,
GError **error)
{
NMSettingIP4Config *s_ip4 = NULL;
@ -1294,16 +1048,6 @@ make_ip4_setting (shvarFile *ifcfg,
method = NM_SETTING_IP4_CONFIG_METHOD_AUTO;
} else if (!g_ascii_strcasecmp (value, "static")) {
method = NM_SETTING_IP4_CONFIG_METHOD_MANUAL;
} else if (!g_ascii_strcasecmp (value, "ibft")) {
g_free (value);
g_object_set (s_ip4, NM_SETTING_IP4_CONFIG_NEVER_DEFAULT, never_default, NULL);
/* iSCSI Boot Firmware Table: need to read values from the iSCSI
* firmware for this device and create the IP4 setting using those.
*/
if (fill_ip4_setting_from_ibft (ifcfg, s_ip4, iscsiadm_path, error))
return NM_SETTING (s_ip4);
g_object_unref (s_ip4);
return NULL;
} else if (!g_ascii_strcasecmp (value, "autoip")) {
g_free (value);
g_object_set (s_ip4,
@ -1600,7 +1344,6 @@ read_aliases (NMSettingIP4Config *s_ip4, const char *filename, const char *netwo
static NMSetting *
make_ip6_setting (shvarFile *ifcfg,
const char *network_file,
const char *iscsiadm_path,
GError **error)
{
NMSettingIP6Config *s_ip6 = NULL;
@ -5005,7 +4748,6 @@ NMConnection *
connection_from_file (const char *filename,
const char *network_file, /* for unit tests only */
const char *test_type, /* for unit tests only */
const char *iscsiadm_path, /* for unit tests only */
char **out_unhandled,
char **out_keyfile,
char **out_routefile,
@ -5033,9 +4775,6 @@ connection_from_file (const char *filename,
if (!network_file)
network_file = SYSCONFDIR "/sysconfig/network";
if (!iscsiadm_path)
iscsiadm_path = "/sbin/iscsiadm";
ifcfg_name = utils_get_ifcfg_name (filename, TRUE);
if (!ifcfg_name) {
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
@ -5056,6 +4795,17 @@ connection_from_file (const char *filename,
goto done;
}
/* iBFT is handled by the iBFT settings plugin */
bootproto = svGetValue (parsed, "BOOTPROTO", FALSE);
if (bootproto && !g_ascii_strcasecmp (bootproto, "ibft")) {
if (out_ignore_error)
*out_ignore_error = TRUE;
g_set_error (error, IFCFG_PLUGIN_ERROR, 0,
"Ignoring iBFT configuration");
g_free (bootproto);
goto done;
}
type = NULL;
devtype = svGetValue (parsed, "DEVICETYPE", FALSE);
@ -5150,7 +4900,7 @@ connection_from_file (const char *filename,
if (!connection)
goto done;
s_ip6 = make_ip6_setting (parsed, network_file, iscsiadm_path, error);
s_ip6 = make_ip6_setting (parsed, network_file, error);
if (!s_ip6) {
g_object_unref (connection);
connection = NULL;
@ -5158,7 +4908,7 @@ connection_from_file (const char *filename,
} else
nm_connection_add_setting (connection, s_ip6);
s_ip4 = make_ip4_setting (parsed, network_file, iscsiadm_path, error);
s_ip4 = make_ip4_setting (parsed, network_file, error);
if (!s_ip4) {
g_object_unref (connection);
connection = NULL;
@ -5192,22 +4942,6 @@ connection_from_file (const char *filename,
if (s_dcb)
nm_connection_add_setting (connection, s_dcb);
/* iSCSI / ibft connections are read-only since their settings are
* stored in NVRAM and can only be changed in BIOS.
*/
bootproto = svGetValue (parsed, "BOOTPROTO", FALSE);
if ( bootproto
&& connection
&& !g_ascii_strcasecmp (bootproto, "ibft")) {
NMSettingConnection *s_con;
s_con = nm_connection_get_setting_connection (connection);
g_assert (s_con);
g_object_set (G_OBJECT (s_con), NM_SETTING_CONNECTION_READ_ONLY, TRUE, NULL);
}
g_free (bootproto);
if (!nm_connection_normalize (connection, NULL, NULL, error)) {
g_object_unref (connection);
connection = NULL;

View file

@ -29,7 +29,6 @@
NMConnection *connection_from_file (const char *filename,
const char *network_file, /* for unit tests only */
const char *test_type, /* for unit tests only */
const char *iscsiadm_path, /* for unit tests only */
char **out_unhandled,
char **out_keyfile,
char **out_routefile,

View file

@ -50,15 +50,5 @@ test_ifcfg_rh_utils_LDADD = \
TESTS = test-ifcfg-rh-utils test-ifcfg-rh
EXTRA_DIST = \
iscsiadm-test-dhcp \
iscsiadm-test-static \
iscsiadm-test-bad-ipaddr \
iscsiadm-test-bad-gateway \
iscsiadm-test-bad-dns1 \
iscsiadm-test-bad-dns2 \
iscsiadm-test-bad-entry \
iscsiadm-test-bad-record
endif

View file

@ -1,21 +0,0 @@
#!/bin/bash
cat << EOF
# BEGIN RECORD
iface.initiatorname = iqn.pjones6
iface.hwaddress = 00:33:21:98:b9:f0
iface.bootproto = STATIC
iface.ipaddress = 192.168.32.72
iface.subnet_mask = 255.255.252.0
iface.gateway = 192.168.35.254
iface.primary_dns = 10000.500.250.1
iface.secondary_dns = 10.16.255.3
iface.vlan = 0
iface.net_ifacename = eth0
node.name = iqn.0.2008-11.com.blahblah:iscsi0
node.conn[0].address = 10.16.52.16
node.conn[0].port = 3260
node.boot_lun = 00000000
# END RECORD
EOF

View file

@ -1,21 +0,0 @@
#!/bin/bash
cat << EOF
# BEGIN RECORD
iface.initiatorname = iqn.pjones6
iface.hwaddress = 00:33:21:98:b9:f0
iface.bootproto = STATIC
iface.ipaddress = 192.168.32.72
iface.subnet_mask = 255.255.252.0
iface.gateway = 192.168.35.254
iface.primary_dns = 10.16.255.2
iface.secondary_dns = blah.foo.bar.baz
iface.vlan = 0
iface.net_ifacename = eth0
node.name = iqn.0.2008-11.com.blahblah:iscsi0
node.conn[0].address = 10.16.52.16
node.conn[0].port = 3260
node.boot_lun = 00000000
# END RECORD
EOF

View file

@ -1,35 +0,0 @@
#!/bin/bash
cat << EOF
# BEGIN RECORD
iface.initiatorname = iqn.pjones6
iface.hwaddress = 00:33:21:98:b9:f0
iface.bootproto = STATIC
iface.ipaddress 192.168.32.72
iface.subnet_mask = 255.255.252.0
iface.gateway = 192.168.35.254
iface.primary_dns = 10.16.255.2
iface.secondary_dns = 10.16.255.3
iface.vlan = 0
iface.net_ifacename = eth0
node.name = iqn.0.2008-11.com.blahblah:iscsi0
node.conn[0].address = 10.16.52.16
node.conn[0].port = 3260
node.boot_lun = 00000000
# END RECORD
# BEGIN RECORD
iface.initiatorname = iqn.pjones6
iface.hwaddress = 00:33:21:98:b9:f1
iface.bootproto = DHCP
iface.gateway = 10.16.52.254
iface.primary_dns = 10.16.255.2
iface.secondary_dns = 10.16.255.3
iface.vlan = 0
iface.net_ifacename = eth1
node.name = iqn.1.2008-11.com.blahblah:iscsi1
node.conn[0].address = 10.16.52.16
node.conn[0].port = 3260
node.boot_lun = 00000000
# END RECORD
EOF

View file

@ -1,21 +0,0 @@
#!/bin/bash
cat << EOF
# BEGIN RECORD
iface.initiatorname = iqn.pjones6
iface.hwaddress = 00:33:21:98:b9:f0
iface.bootproto = STATIC
iface.ipaddress = aa.bb.cc.dd
iface.subnet_mask = 255.255.252.0
iface.gateway = 192.168.35.254
iface.primary_dns = 10.16.255.2
iface.secondary_dns = 10.16.255.3
iface.vlan = 0
iface.net_ifacename = eth0
node.name = iqn.0.2008-11.com.blahblah:iscsi0
node.conn[0].address = 10.16.52.16
node.conn[0].port = 3260
node.boot_lun = 00000000
# END RECORD
EOF

View file

@ -1,21 +0,0 @@
#!/bin/bash
cat << EOF
# BEGIN RECORD
iface.initiatorname = iqn.pjones6
iface.hwaddress = 00:33:21:98:b9:f0
iface.bootproto = STATIC
iface.ipaddress = 192.168.32.72
iface.subnet_mask = 255.255.252.0
iface.gateway = bb.cc.dd.ee
iface.primary_dns = 10.16.255.2
iface.secondary_dns = 10.16.255.3
iface.vlan = 0
iface.net_ifacename = eth0
node.name = iqn.0.2008-11.com.blahblah:iscsi0
node.conn[0].address = 10.16.52.16
node.conn[0].port = 3260
node.boot_lun = 00000000
# END RECORD
EOF

View file

@ -1,18 +0,0 @@
#!/bin/bash
cat << EOF
# BEGIN RECORD
iface.initiatorname = iqn.pjones6
iface.hwaddress = 00:33:21:98:b9:f0
iface.bootproto = DHCP
iface.gateway = 10.16.52.254
iface.primary_dns = 10.16.255.2
iface.secondary_dns = 10.16.255.3
iface.vlan = 0
iface.net_ifacename = eth0
node.name = iqn.0.2008-11.com.blahblah:iscsi0
node.conn[0].address = 10.16.52.16
node.conn[0].port = 3260
node.boot_lun = 00000000
EOF

View file

@ -1,33 +0,0 @@
#!/bin/bash
cat << EOF
# BEGIN RECORD
iface.initiatorname = iqn.pjones6
iface.hwaddress = 00:33:21:98:b9:f0
iface.bootproto = DHCP
iface.gateway = 10.16.52.254
iface.primary_dns = 10.16.255.2
iface.secondary_dns = 10.16.255.3
iface.vlan = 0
iface.net_ifacename = eth0
node.name = iqn.0.2008-11.com.blahblah:iscsi0
node.conn[0].address = 10.16.52.16
node.conn[0].port = 3260
node.boot_lun = 00000000
# END RECORD
# BEGIN RECORD
iface.initiatorname = iqn.pjones6
iface.hwaddress = 00:33:21:98:b9:f1
iface.bootproto = DHCP
iface.gateway = 10.16.52.254
iface.primary_dns = 10.16.255.2
iface.secondary_dns = 10.16.255.3
iface.vlan = 0
iface.net_ifacename = eth1
node.name = iqn.1.2008-11.com.blahblah:iscsi1
node.conn[0].address = 10.16.52.16
node.conn[0].port = 3260
node.boot_lun = 00000000
# END RECORD
EOF

View file

@ -1,35 +0,0 @@
#!/bin/bash
cat << EOF
# BEGIN RECORD
iface.initiatorname = iqn.pjones6
iface.hwaddress = 00:33:21:98:b9:f0
iface.bootproto = STATIC
iface.ipaddress = 192.168.32.72
iface.subnet_mask = 255.255.252.0
iface.gateway = 192.168.35.254
iface.primary_dns = 10.16.255.2
iface.secondary_dns = 10.16.255.3
iface.vlan = 0
iface.net_ifacename = eth0
node.name = iqn.0.2008-11.com.blahblah:iscsi0
node.conn[0].address = 10.16.52.16
node.conn[0].port = 3260
node.boot_lun = 00000000
# END RECORD
# BEGIN RECORD
iface.initiatorname = iqn.pjones6
iface.hwaddress = 00:33:21:98:b9:f1
iface.bootproto = DHCP
iface.gateway = 10.16.52.254
iface.primary_dns = 10.16.255.2
iface.secondary_dns = 10.16.255.3
iface.vlan = 0
iface.net_ifacename = eth1
node.name = iqn.1.2008-11.com.blahblah:iscsi1
node.conn[0].address = 10.16.52.16
node.conn[0].port = 3260
node.boot_lun = 00000000
# END RECORD
EOF

View file

@ -61,8 +61,7 @@ EXTRA_DIST = \
ifcfg-test-wifi-hidden \
test_ca_cert.pem \
test1_key_and_cert.pem \
ifcfg-test-ibft-dhcp \
ifcfg-test-ibft-static \
ifcfg-test-ibft \
ifcfg-test-static-routes-legacy \
route-test-static-routes-legacy \
ifcfg-test-wired-static-routes \

View file

@ -0,0 +1,10 @@
# Generated by dracut initrd
DEVICE="ibft0"
ONBOOT=yes
NETBOOT=yes
UUID="2aa8c19d-9744-4ca4-b74f-c37e73f2918e"
BOOTPROTO=ibft
HWADDR="00:33:21:98:b9:f0"
TYPE=Ethernet
NAME="ibft0"

File diff suppressed because it is too large Load diff