2004-09-07 Dan Williams <dcbw@redhat.com>
Patch from: Narayan Newton <narayan_newton@yahoo.com> * configure.in initscript/Makefile.am initscript/Slackware/Makfile.am initscript/Slackware/rc.networkmanager src/Makefile.am src/backends/NetworkManagerSlackware.c - Add Slackware support git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@127 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:

committed by
Dan Williams

parent
bdfc6a8258
commit
2664cc656f
12
ChangeLog
12
ChangeLog
@@ -1,3 +1,15 @@
|
|||||||
|
2004-09-07 Dan Williams <dcbw@redhat.com>
|
||||||
|
|
||||||
|
Patch from: Narayan Newton <narayan_newton@yahoo.com>
|
||||||
|
|
||||||
|
* configure.in
|
||||||
|
initscript/Makefile.am
|
||||||
|
initscript/Slackware/Makfile.am
|
||||||
|
initscript/Slackware/rc.networkmanager
|
||||||
|
src/Makefile.am
|
||||||
|
src/backends/NetworkManagerSlackware.c
|
||||||
|
- Add Slackware support
|
||||||
|
|
||||||
2004-09-07 Dan Williams <dcbw@redhat.com>
|
2004-09-07 Dan Williams <dcbw@redhat.com>
|
||||||
|
|
||||||
Patches below from:
|
Patches below from:
|
||||||
|
@@ -22,6 +22,7 @@ AC_ARG_WITH(distro,
|
|||||||
--with-distro=gentoo
|
--with-distro=gentoo
|
||||||
--with-distro=debian
|
--with-distro=debian
|
||||||
--with-distro=mandrake
|
--with-distro=mandrake
|
||||||
|
--with-distro=slackware
|
||||||
],,)
|
],,)
|
||||||
|
|
||||||
TARGET_DISTRO=
|
TARGET_DISTRO=
|
||||||
@@ -32,6 +33,7 @@ if test "z$with_distro" = "z"; then
|
|||||||
AC_CHECK_FILE(/etc/fedora-release,with_distro="redhat")
|
AC_CHECK_FILE(/etc/fedora-release,with_distro="redhat")
|
||||||
AC_CHECK_FILE(/etc/gentoo-release,with_distro="gentoo")
|
AC_CHECK_FILE(/etc/gentoo-release,with_distro="gentoo")
|
||||||
AC_CHECK_FILE(/etc/debian_version,with_distro="debian")
|
AC_CHECK_FILE(/etc/debian_version,with_distro="debian")
|
||||||
|
AC_CHECK_FILE(/etc/slackware-version,with_distro="slackware")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if test "z$with_distro" = "z"; then
|
if test "z$with_distro" = "z"; then
|
||||||
@@ -52,6 +54,10 @@ else
|
|||||||
TARGET_DISTRO=Debian
|
TARGET_DISTRO=Debian
|
||||||
SYSTEM_BACKEND_FILE=NetworkManagerDebian.o
|
SYSTEM_BACKEND_FILE=NetworkManagerDebian.o
|
||||||
;;
|
;;
|
||||||
|
slackware)
|
||||||
|
TARGET_DISTRO=Slackware
|
||||||
|
SYSTEM_BACKEND_FILE=NetworkManagerSlackware.o
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Your distribution(${with_distro}) is not yet supported! (patches welcome)"
|
echo "Your distribution(${with_distro}) is not yet supported! (patches welcome)"
|
||||||
exit 1
|
exit 1
|
||||||
@@ -140,6 +146,7 @@ initscript/Makefile
|
|||||||
initscript/RedHat/Makefile
|
initscript/RedHat/Makefile
|
||||||
initscript/Gentoo/Makefile
|
initscript/Gentoo/Makefile
|
||||||
initscript/Debian/Makefile
|
initscript/Debian/Makefile
|
||||||
|
initscript/Slackware/Makefile
|
||||||
po/Makefile.in
|
po/Makefile.in
|
||||||
NetworkManager.pc
|
NetworkManager.pc
|
||||||
])
|
])
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
SUBDIRS = $(TARGET_DISTRO)
|
SUBDIRS = $(TARGET_DISTRO)
|
||||||
DIST_SUBDIRS=RedHat Gentoo Debian
|
DIST_SUBDIRS=RedHat Gentoo Debian Slackware
|
||||||
|
|
||||||
INCLUDES = \
|
INCLUDES = \
|
||||||
$(NM_CFLAGS) \
|
$(NM_CFLAGS) \
|
||||||
-Wall \
|
-Wall \
|
||||||
|
5
initscript/Slackware/Makefile.am
Normal file
5
initscript/Slackware/Makefile.am
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
EXTRA_DIST = rc.networkmanager
|
||||||
|
|
||||||
|
initddir = $(sysconfdir)/rc.d
|
||||||
|
initd_SCRIPTS = rc.networkmanager
|
||||||
|
|
66
initscript/Slackware/rc.networkmanager
Executable file
66
initscript/Slackware/rc.networkmanager
Executable file
@@ -0,0 +1,66 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# NetworkManager: NetworkManager daemon
|
||||||
|
#
|
||||||
|
# description: This is a daemon for automatically switching network \
|
||||||
|
# connections to the best available connection. \
|
||||||
|
#
|
||||||
|
# processname: NetworkManager
|
||||||
|
# pidfile: /var/run/NetworkManager.pid
|
||||||
|
#
|
||||||
|
# We need /sbin/ip
|
||||||
|
[ -x /sbin/ip ] || exit 1
|
||||||
|
|
||||||
|
processname=NetworkManager
|
||||||
|
servicename=NetworkManager
|
||||||
|
pidfile=/var/run/NetworkManager.pid
|
||||||
|
|
||||||
|
RETVAL=0
|
||||||
|
|
||||||
|
start()
|
||||||
|
{
|
||||||
|
if [ "`pgrep dbus-daemon-1`" = "" ]; then
|
||||||
|
echo -n "D-BUS must be running to start NetworkManager"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [ "`pgrep hald`" = "" ]; then
|
||||||
|
echo -n "HAL must be running to start NetworkManager"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo -n $"Starting NetworkManager daemon: "
|
||||||
|
$servicename
|
||||||
|
RETVAL=$?
|
||||||
|
echo
|
||||||
|
[ $RETVAL -eq 0 ] && echo `/sbin/pidof $processname` > $pidfile
|
||||||
|
}
|
||||||
|
|
||||||
|
stop()
|
||||||
|
{
|
||||||
|
echo -n $"Stopping NetworkManager daemon: "
|
||||||
|
|
||||||
|
killall -s TERM $servicename
|
||||||
|
RETVAL=$?
|
||||||
|
echo
|
||||||
|
if [ $RETVAL -eq 0 ]; then
|
||||||
|
rm -f $pidfile
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# See how we were called.
|
||||||
|
case "$1" in
|
||||||
|
start)
|
||||||
|
start
|
||||||
|
;;
|
||||||
|
stop)
|
||||||
|
stop
|
||||||
|
;;
|
||||||
|
restart)
|
||||||
|
stop
|
||||||
|
start
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo $"Usage: $0 {start|stop|restart}"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
exit $RETVAL
|
@@ -34,9 +34,10 @@ NetworkManager_SOURCES += gnome-keyring-md5.c gnome-keyring-md5.h
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
EXTRA_NetworkManager_SOURCES = \
|
EXTRA_NetworkManager_SOURCES = \
|
||||||
backends/NetworkManagerDebian.c \
|
backends/NetworkManagerDebian.c \
|
||||||
backends/NetworkManagerGentoo.c \
|
backends/NetworkManagerGentoo.c \
|
||||||
backends/NetworkManagerRedHat.c
|
backends/NetworkManagerRedHat.c \
|
||||||
|
backends/NetworkManagerSlackware.c
|
||||||
|
|
||||||
|
|
||||||
NetworkManager_LDADD = $(NM_LIBS) $(IWLIB) backends/$(SYSTEM_BACKEND_FILE)
|
NetworkManager_LDADD = $(NM_LIBS) $(IWLIB) backends/$(SYSTEM_BACKEND_FILE)
|
||||||
|
218
src/backends/NetworkManagerSlackware.c
Normal file
218
src/backends/NetworkManagerSlackware.c
Normal file
@@ -0,0 +1,218 @@
|
|||||||
|
/* NetworkManager -- Network link manager
|
||||||
|
*
|
||||||
|
* Narayan Newton <narayan_newton@yahoo.com>
|
||||||
|
*
|
||||||
|
* 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 of the License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*
|
||||||
|
* (C) Copyright 2004 RedHat, Inc.
|
||||||
|
* (C) Copyright 2004 Narayan Newton
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <signal.h>
|
||||||
|
#include "NetworkManagerSystem.h"
|
||||||
|
#include "NetworkManagerUtils.h"
|
||||||
|
#include "NetworkManagerDevice.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Mostly a mix of the Gentoo and RedHat Backends
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* nm_system_init
|
||||||
|
*
|
||||||
|
* Initializes the distribution-specific system backend
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void nm_system_init (void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* nm_system_device_run_dhcp
|
||||||
|
*
|
||||||
|
* Run the dhcp daemon for a particular interface.
|
||||||
|
*
|
||||||
|
* Returns: TRUE on success
|
||||||
|
* FALSE on dhcp error
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
gboolean nm_system_device_run_dhcp (NMDevice *dev)
|
||||||
|
{
|
||||||
|
char buf [500];
|
||||||
|
int err;
|
||||||
|
|
||||||
|
g_return_val_if_fail (dev != NULL, FALSE);
|
||||||
|
|
||||||
|
/* Fake it for a test device */
|
||||||
|
if (nm_device_is_test_device (dev))
|
||||||
|
{
|
||||||
|
g_usleep (2000);
|
||||||
|
return (TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
snprintf (buf, 500, "/sbin/dhcpcd %s", nm_device_get_iface(dev));
|
||||||
|
err = nm_spawn_process (buf);
|
||||||
|
return (err == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* nm_system_device_stop_dhcp
|
||||||
|
*
|
||||||
|
* Kill any dhcp daemon that happens to be around. We may be changing
|
||||||
|
* interfaces and we're going to bring the previous one down, so there's
|
||||||
|
* no sense in keeping the dhcp daemon running on the old interface.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void nm_system_device_stop_dhcp (NMDevice *dev)
|
||||||
|
{
|
||||||
|
FILE *pidfile;
|
||||||
|
char buf [500];
|
||||||
|
|
||||||
|
g_return_if_fail (dev != NULL);
|
||||||
|
|
||||||
|
/* Not really applicable for test devices */
|
||||||
|
if (nm_device_is_test_device (dev))
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* Find and kill the previous dhclient process for this device */
|
||||||
|
snprintf (buf, 500, "/etc/dhcpc/dhcpcd-%s.pid", nm_device_get_iface (dev));
|
||||||
|
pidfile = fopen (buf, "r");
|
||||||
|
if (pidfile)
|
||||||
|
{
|
||||||
|
int len;
|
||||||
|
unsigned char s_pid[20];
|
||||||
|
pid_t n_pid = -1;
|
||||||
|
|
||||||
|
memset (s_pid, 0, 20);
|
||||||
|
fgets (s_pid, 20, pidfile);
|
||||||
|
len = strlen (s_pid);
|
||||||
|
fclose (pidfile);
|
||||||
|
|
||||||
|
n_pid = atoi (s_pid);
|
||||||
|
if (n_pid > 0)
|
||||||
|
kill (n_pid, SIGTERM);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* nm_system_device_flush_routes
|
||||||
|
*
|
||||||
|
* Flush all routes associated with a network device
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void nm_system_device_flush_routes (NMDevice *dev)
|
||||||
|
{
|
||||||
|
char buf [100];
|
||||||
|
|
||||||
|
g_return_if_fail (dev != NULL);
|
||||||
|
|
||||||
|
/* Not really applicable for test devices */
|
||||||
|
if (nm_device_is_test_device (dev))
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* Remove routing table entries */
|
||||||
|
snprintf (buf, 100, "/sbin/ip route flush dev %s", nm_device_get_iface (dev));
|
||||||
|
nm_spawn_process (buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* nm_system_device_flush_addresses
|
||||||
|
*
|
||||||
|
* Flush all network addresses associated with a network device
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void nm_system_device_flush_addresses (NMDevice *dev)
|
||||||
|
{
|
||||||
|
char buf [100];
|
||||||
|
|
||||||
|
g_return_if_fail (dev != NULL);
|
||||||
|
|
||||||
|
/* Not really applicable for test devices */
|
||||||
|
if (nm_device_is_test_device (dev))
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* Remove all IP addresses for a device */
|
||||||
|
snprintf (buf, 100, "/sbin/ip address flush dev %s", nm_device_get_iface (dev));
|
||||||
|
nm_spawn_process (buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* nm_system_enable_loopback
|
||||||
|
*
|
||||||
|
* Bring up the loopback interface
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void nm_system_enable_loopback (void)
|
||||||
|
{
|
||||||
|
nm_spawn_process ("/sbin/ip link set dev lo up");
|
||||||
|
nm_spawn_process ("ip addr add 127.0.0.1/8 brd 127.255.255.255 dev lo label loopback");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* nm_system_delete_default_route
|
||||||
|
*
|
||||||
|
* Remove the old default route in preparation for a new one
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void nm_system_delete_default_route (void)
|
||||||
|
{
|
||||||
|
nm_spawn_process ("/sbin/ip route del default");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* nm_system_kill_all_dhcp_daemons
|
||||||
|
*
|
||||||
|
* Kill all DHCP daemons currently running, done at startup.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void nm_system_kill_all_dhcp_daemons (void)
|
||||||
|
{
|
||||||
|
nm_spawn_process ("/usr/bin/killall -q dhcpcd");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* nm_system_update_dns
|
||||||
|
*
|
||||||
|
* Make glibc/nscd aware of any changes to the resolv.conf file by
|
||||||
|
* restarting nscd.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void nm_system_update_dns (void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* nm_system_load_device_modules
|
||||||
|
*
|
||||||
|
* These should already be loaded
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void nm_system_load_device_modules (void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Reference in New Issue
Block a user