core: use nm_utils_modprobe()

https://bugzilla.gnome.org/show_bug.cgi?id=740651

(cherry picked from commit 32625f604b)
This commit is contained in:
Thomas Haller 2015-01-09 11:49:25 +01:00
parent 6d052c1350
commit 948cfd8f5c
3 changed files with 4 additions and 30 deletions

View file

@ -5060,20 +5060,9 @@ nm_device_activate_schedule_ip6_config_timeout (NMDevice *self)
_LOGD (LOGD_DEVICE | LOGD_IP6, "Activation: Stage 4 of 5 (IPv6 Configure Timeout) scheduled...");
}
static void
share_child_setup (gpointer user_data G_GNUC_UNUSED)
{
/* We are in the child process at this point */
pid_t pid = getpid ();
setpgid (pid, pid);
nm_unblock_posix_signals (NULL);
}
static gboolean
share_init (void)
{
int status;
char *modules[] = { "ip_tables", "iptable_nat", "nf_nat_ftp", "nf_nat_irc",
"nf_nat_sip", "nf_nat_tftp", "nf_nat_pptp", "nf_nat_h323",
NULL };
@ -5093,20 +5082,8 @@ share_init (void)
errsv, strerror (errsv));
}
for (iter = modules; *iter; iter++) {
char *argv[3] = { "/sbin/modprobe", *iter, NULL };
char *envp[1] = { NULL };
GError *error = NULL;
if (!g_spawn_sync ("/", argv, envp, G_SPAWN_STDOUT_TO_DEV_NULL | G_SPAWN_STDERR_TO_DEV_NULL,
share_child_setup, NULL, NULL, NULL, &status, &error)) {
nm_log_err (LOGD_SHARING, "share: error loading NAT module %s: (%d) %s",
*iter, error ? error->code : 0,
(error && error->message) ? error->message : "unknown");
if (error)
g_error_free (error);
}
}
for (iter = modules; *iter; iter++)
nm_utils_modprobe (NULL, *iter, NULL);
return TRUE;
}

View file

@ -2272,7 +2272,6 @@ build_rtnl_link (int ifindex, const char *name, NMLinkType type)
static gboolean
link_add (NMPlatform *platform, const char *name, NMLinkType type, const void *address, size_t address_len)
{
int r;
struct nl_object *l;
if (type == NM_LINK_TYPE_BOND) {
@ -2284,8 +2283,7 @@ link_add (NMPlatform *platform, const char *name, NMLinkType type, const void *a
* bond0 automatically.
*/
if (!g_file_test ("/sys/class/net/bonding_masters", G_FILE_TEST_EXISTS))
/* Ignore return value to shut up the compiler */
r = system ("modprobe bonding max_bonds=0");
nm_utils_modprobe (NULL, "bonding", "max_bonds=0", NULL);
}
debug ("link: add link '%s' of type '%s' (%d)",

View file

@ -1087,7 +1087,6 @@ nm_ppp_manager_start (NMPPPManager *manager,
NMCmdLine *ppp_cmd;
char *cmd_str;
struct stat st;
int ignored;
g_return_val_if_fail (NM_IS_PPP_MANAGER (manager), FALSE);
g_return_val_if_fail (NM_IS_ACT_REQUEST (req), FALSE);
@ -1107,7 +1106,7 @@ nm_ppp_manager_start (NMPPPManager *manager,
/* Make sure /dev/ppp exists (bgo #533064) */
if (stat ("/dev/ppp", &st) || !S_ISCHR (st.st_mode))
ignored = system ("/sbin/modprobe ppp_generic");
nm_utils_modprobe (NULL, "ppp_generic", NULL);
connection = nm_act_request_get_connection (req);
g_assert (connection);