Date: Sun, 20 Mar 2005 13:07:45 +0300 (MSK) From: Stanislav Sedov <stas@core.310.ru> To: FreeBSD-gnats-submit@FreeBSD.org Subject: ports/79049: New port net-mgmt/netdump-server:RedHat server part\ Message-ID: <200503201007.j2KA7jPF038822@core.310.ru> Resent-Message-ID: <200503201040.j2KAe5LW004730@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 79049 >Category: ports >Synopsis: New port net-mgmt/netdump-server:RedHat server part\ >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Sun Mar 20 10:40:05 GMT 2005 >Closed-Date: >Last-Modified: >Originator: Stanislav Sedov <stas@core.310.ru> >Release: FreeBSD 4.11-STABLE i386 >Organization: Moscow Engineering Physics Institute (MEPhI) >Environment: System: FreeBSD core.310.ru 4.11-STABLE FreeBSD 4.11-STABLE #0: Sat Mar 5 06:31:52 MSK 2005 stas@core.310.ru:/work/src/fbsd/src/sys/compile/DESKTOP i386 >Description: Netdump-server listens on the network for connections from linux kernels using the netconsole/netdump module. When such a machine crashes it contacts the netdump-server on the specified ip/port. The server then proceeds to log console messages, including the oops message, and a kernel memory dump in a specified directory, and then reboots the machine. >How-To-Repeat: >Fix: --- netdump-server.shar begins here --- # This is a shell archive. Save it in a file, remove anything before # this line, and then unpack it by entering "sh file". Note, it may # create directories; files and directories will be owned by you and # have default permissions. # # This archive contains: # # netdump-server # netdump-server/files # netdump-server/files/patch-ae # netdump-server/files/netdump.conf # netdump-server/files/patch-aa # netdump-server/files/patch-ab # netdump-server/files/patch-ac # netdump-server/files/patch-ad # netdump-server/files/patch-af # netdump-server/files/patch-ag # netdump-server/files/patch-ah # netdump-server/files/netdump-server.sh # netdump-server/Makefile # netdump-server/distinfo # netdump-server/pkg-descr # netdump-server/pkg-plist # netdump-server/pkg-message # echo c - netdump-server mkdir -p netdump-server > /dev/null 2>&1 echo c - netdump-server/files mkdir -p netdump-server/files > /dev/null 2>&1 echo x - netdump-server/files/patch-ae sed 's/^X//' >netdump-server/files/patch-ae << 'END-of-netdump-server/files/patch-ae' X--- Makefile.orig Tue Mar 1 20:33:03 2005 X+++ Makefile Sat Mar 19 16:53:49 2005 X@@ -1,7 +1,7 @@ X DEBUG_FLAGS=-Wall -g X X-CFLAGS=`glib-config --cflags` $(DEBUG_FLAGS) -D_FILE_OFFSET_BITS=64 X-LDFLAGS=`glib-config --libs` -lpopt X+CFLAGS += `pkg-config --cflags glib-2.0` $(DEBUG_FLAGS) -D_FILE_OFFSET_BITS=64 -I /usr/local/include X+LDFLAGS += `pkg-config --libs glib-2.0` -L/usr/local/lib -lpopt X X VERSION=$(shell awk '/Version:/ { print $$2 }' netdump.spec) X # Used to append this to CVSTAG: _$(subst .,-,$(RELEASE)), but now that END-of-netdump-server/files/patch-ae echo x - netdump-server/files/netdump.conf sed 's/^X//' >netdump-server/files/netdump.conf << 'END-of-netdump-server/files/netdump.conf' Xdaemon=true Xsecure=0 Xdumpdirprefix="/var/spool/netdump" END-of-netdump-server/files/netdump.conf echo x - netdump-server/files/patch-aa sed 's/^X//' >netdump-server/files/patch-aa << 'END-of-netdump-server/files/patch-aa' X--- configuration.c.orig Sun Mar 20 11:17:08 2005 X+++ configuration.c Sun Mar 20 10:06:04 2005 X@@ -2,6 +2,7 @@ X #include <string.h> X #include <unistd.h> X #include <stdio.h> X+#include <stdlib.h> X #include <syslog.h> X #include <sys/types.h> X #include <sys/stat.h> X@@ -15,6 +16,8 @@ X X NetdumpConfiguration config; X X+char *netdump_dir_prefix = NETDUMP_DIR_PREFIX; X+ X enum ConfigType { X CONFIG_NONE, X CONFIG_BOOLEAN, X@@ -46,6 +49,7 @@ X { "max_concurrent_dumps", CONFIG_INT, CONFIG_OFFSET(max_concurrent_dumps), GINT_TO_POINTER (4) }, X { "daemon", CONFIG_BOOLEAN, CONFIG_OFFSET(daemon), GINT_TO_POINTER (0) }, X { "pidfile", CONFIG_STRING, CONFIG_OFFSET(pidfile), NULL }, X+ { "dumpdirprefix", CONFIG_STRING, CONFIG_OFFSET(dumpdirprefix), NETDUMP_DIR_PREFIX }, X { "secure", CONFIG_INT, CONFIG_OFFSET(secure), GINT_TO_POINTER (1) }, X { "space_check", CONFIG_INT, CONFIG_OFFSET(space_check), GINT_TO_POINTER (1) }, X }; X@@ -118,7 +122,20 @@ X *(guint16 *)ptr = GPOINTER_TO_INT (config_data[i].default_value); X break; X case CONFIG_STRING: X- *(gchar **)ptr = (gchar *)config_data[i].default_value; X+ if (config_data[i].default_value != NULL) { X+ *(char **)ptr = (char *)malloc(strlen(config_data[i].default_value) + 1); X+ if (*(char **)ptr != NULL) { X+ strncpy(*(char **)ptr, config_data[i].default_value, strlen(config_data[i].default_value)); X+ (*(char **)ptr)[strlen(config_data[i].default_value)] = '\0'; X+ } X+ else { X+ syslog(LOG_ERR, "Cannot malloc\n"); X+ exit(1); X+ } X+ } X+ else X+ ptr = (char *)NULL; X+ X break; X case CONFIG_NONE: X break; X@@ -181,7 +198,18 @@ X if (token != G_TOKEN_STRING) X return G_TOKEN_STRING; X X- *(char **)ptr = scanner->value.v_string; X+ if (*(char **)ptr != NULL) X+ free(*(char **)ptr); X+ *(char **)ptr = (char *)malloc(strlen(scanner->value.v_string) + 1); X+ if (*(char **)ptr != NULL) { X+ strncpy(*(char **)ptr, scanner->value.v_string, strlen(scanner->value.v_string)); X+ (*(char **)ptr)[strlen(scanner->value.v_string)] = '\0'; X+ } X+ else { X+ syslog(LOG_ERR, "Cannot malloc\n"); X+ exit(1); X+ } X+ X break; X case CONFIG_NONE: X break; X@@ -277,6 +305,8 @@ X "run in background as a daemon", NULL }, X { "pidfile", 'P', POPT_ARG_STRING, &config.pidfile, 0, X "file in which to store the pid", "path" }, X+ { "dumpdirprefix", 'D', POPT_ARG_STRING, &config.dumpdirprefix, 0, X+ "dir in which to store dumps", "/var/spool/netdump" }, X { "secure", 's', POPT_ARG_INT, &config.secure, 0, X "use ssh to send client identification", "1" }, X { "space_check", 'S', POPT_ARG_INT, &config.space_check, 0, X@@ -305,7 +335,7 @@ X /* Set the default values */ X config_set_defaults(); X X- config_load ("/etc/netdump.conf"); X+ config_load ("/usr/local/etc/netdump.conf"); X X optCon = poptGetContext("netdump-server", argc, (const char **)argv, X optionsTable, 0); END-of-netdump-server/files/patch-aa echo x - netdump-server/files/patch-ab sed 's/^X//' >netdump-server/files/patch-ab << 'END-of-netdump-server/files/patch-ab' X--- configuration.h.orig Sun Mar 20 11:17:12 2005 X+++ configuration.h Sun Mar 20 08:57:43 2005 X@@ -6,6 +6,7 @@ X int max_concurrent_dumps; X gboolean daemon; X char *pidfile; X+ char *dumpdirprefix; X int secure; X int space_check; X } NetdumpConfiguration; END-of-netdump-server/files/patch-ab echo x - netdump-server/files/patch-ac sed 's/^X//' >netdump-server/files/patch-ac << 'END-of-netdump-server/files/patch-ac' X--- netdump-server.8.orig Sat Mar 19 16:56:34 2005 X+++ netdump-server.8 Sat Mar 19 16:58:00 2005 X@@ -50,6 +50,9 @@ X Store a pidfile. The default service uses /var/run/netdump-server.pid. X The default is not to write a pidfile. X .TP X+--dumpdirprefix \fIpath\fP X+The directory in which to save dumps. The default - /var/spool/netdump. X+.TP X --daemon X netdump-server should background itself and run as a daemon. X .TP X@@ -76,7 +79,7 @@ X /etc/netdump.conf X A configuration file read by netdump-server on startup. It is a X "key=value" style file. Currently it supports the options: X-port, max_concurrent_dumps, daemon and pidfile. X+port, max_concurrent_dumps, daemon, pidfile and dumpdirprefix. X .TP X /etc/init.d/netdump-server X An init script to start a default system installation of netdump-server. END-of-netdump-server/files/patch-ac echo x - netdump-server/files/patch-ad sed 's/^X//' >netdump-server/files/patch-ad << 'END-of-netdump-server/files/patch-ad' X--- netdumpclient.c.orig Fri Sep 3 23:53:20 2004 X+++ netdumpclient.c Sat Mar 19 16:53:49 2005 X@@ -5,7 +5,8 @@ X #include <syslog.h> X #include <sys/types.h> X #include <sys/stat.h> X-#include <sys/vfs.h> X+#include <sys/param.h> X+#include <sys/mount.h> X #include <fcntl.h> X #include <unistd.h> X #include <stdlib.h> X@@ -898,7 +899,7 @@ X if (tried_once) X syslog (LOG_ERR, "No space for dump image, even after calling netdump-nospace"); X else X- syslog (LOG_ERR, "No space for dump image"); X+ syslog (LOG_ERR, "No space for dump image, avail = %lld, need = %lld\n", buf.f_bavail, memdump_size); X X status_request (client, TRUE); X g_free (file); END-of-netdump-server/files/patch-ad echo x - netdump-server/files/patch-af sed 's/^X//' >netdump-server/files/patch-af << 'END-of-netdump-server/files/patch-af' X--- netdumpelf.h.orig Fri Sep 3 23:53:20 2004 X+++ netdumpelf.h Sun Mar 20 12:49:10 2005 X@@ -1,7 +1,21 @@ X #include <sys/time.h> X-#include <linux/types.h> X+#include <sys/types.h> X #include <elf.h> X X+typedef __uint32_t __u32; X+typedef __uint64_t __u64; X+typedef __uint16_t __u16; X+typedef __uint8_t __u8; X+typedef uid_t __kernel_uid_t; X+typedef gid_t __kernel_gid_t; X+typedef Elf_Note Elf32_Nhdr; X+typedef Elf_Note Elf64_Nhdr; X+ X+#if __FreeBSD_version < 500000 X+#define ELFMAG "\177ELF" X+#define SELFMAG 4 X+#endif X+ X #ifndef NT_TASKSTRUCT X #define NT_TASKSTRUCT 4 X #endif X@@ -87,9 +101,9 @@ X #define CLIENT_BYTE_ORDER(client) \ X ((client->machine_type == EM_386 || \ X client->machine_type == EM_X86_64 || \ X- client->machine_type == EM_IA_64) ? __LITTLE_ENDIAN : __BIG_ENDIAN) X+ client->machine_type == EM_IA_64) ? LITTLE_ENDIAN : BIG_ENDIAN) X X-#define BYTE_SWAP_REQUIRED(client) (__BYTE_ORDER != CLIENT_BYTE_ORDER(client)) X+#define BYTE_SWAP_REQUIRED(client) (BYTE_ORDER != CLIENT_BYTE_ORDER(client)) X X typedef unsigned short u16; X END-of-netdump-server/files/patch-af echo x - netdump-server/files/patch-ag sed 's/^X//' >netdump-server/files/patch-ag << 'END-of-netdump-server/files/patch-ag' X--- server.c.orig Sun Mar 20 11:17:45 2005 X+++ server.c Sun Mar 20 10:09:04 2005 X@@ -66,7 +66,7 @@ X dir = g_new (CrashDir, 1); X dir->time = now; X dir->path = g_strdup_printf ("%s/%d.%d.%d.%d-%s", X- NETDUMP_DIR_PREFIX, X+ config.dumpdirprefix, X (ip >> 24) & 0xff, X (ip >> 16) & 0xff, X (ip >> 8) & 0xff, X@@ -100,7 +100,7 @@ X char *cmdline; X int res = -1; X X- filename = g_strconcat (NETDUMP_DIR_PREFIX "/scripts/", X+ filename = g_strconcat (config.dumpdirprefix, "/scripts/", X script, X NULL); X X@@ -147,7 +147,7 @@ X } X X path = g_strdup_printf ("%s/magic/%d.%d.%d.%d", X- NETDUMP_DIR_PREFIX, X+ config.dumpdirprefix, X (ip >> 24) & 0xff, X (ip >> 16) & 0xff, X (ip >> 8) & 0xff, X@@ -373,10 +373,10 @@ X X openlog("netdump", LOG_PID, LOG_DAEMON); X X- if (chdir (NETDUMP_DIR_PREFIX) == -1) X+ if (chdir (config.dumpdirprefix) == -1) X { X- syslog (LOG_ERR, "can't cd to %s", NETDUMP_DIR_PREFIX); X- fprintf (stderr, "can't cd to %s", NETDUMP_DIR_PREFIX); X+ syslog (LOG_ERR, "can't cd to %s", config.dumpdirprefix); X+ fprintf (stderr, "can't cd to %s\n", config.dumpdirprefix); X exit (1); X } X X@@ -429,6 +429,11 @@ X X loop = g_main_new (TRUE); X g_main_run (loop); X+ X+ if (config.pidfile != NULL) X+ free(config.pidfile); X+ if (config.dumpdirprefix != NULL) X+ free(config.dumpdirprefix); X X return 0; X } END-of-netdump-server/files/patch-ag echo x - netdump-server/files/patch-ah sed 's/^X//' >netdump-server/files/patch-ah << 'END-of-netdump-server/files/patch-ah' X--- server.h.orig Fri Sep 3 23:53:20 2004 X+++ server.h Sat Mar 19 16:53:49 2005 X@@ -7,7 +7,7 @@ X X #define NETDUMP_PORT 6666 X X-#define NETDUMP_DIR_PREFIX "/var/crash" X+#define NETDUMP_DIR_PREFIX "/var/spool/netdump" X X extern int master_socket; X END-of-netdump-server/files/patch-ah echo x - netdump-server/files/netdump-server.sh sed 's/^X//' >netdump-server/files/netdump-server.sh << 'END-of-netdump-server/files/netdump-server.sh' X#!/bin/sh X# X X# PROVIDE: netdump_server X# REQUIRE: X# BEFORE: X# KEYWORD: FreeBSD shutdown X X# Add the following line to /etc/rc.conf to enable mpd: X# X#netdump_server_enable="YES" X X. %%RC_SUBR%% X Xload_rc_config netdump_server X Xnetdump_server_enable=${netdump_server_enable-"NO"} Xnetdump_server_flags=${netdump_server_flags-"--daemon --secure 0"} X Xname=netdump_server Xrcvar=`set_rcvar` Xcommand=%%PREFIX%%/bin/netdump-server Xpidfile=/var/run/netdump-server.pid Xstart_cmd=start_cmd Xstop_cmd=stop_cmd X Xstart_cmd() X{ X if [ -r ${pidfile} ]; then X echo "netdump_server already runned" X exit 1 X fi X X touch $pidfile X chown netdump $pidfile X X su -m netdump -c "${command} --pidfile ${pidfile} ${netdump_server_flags}" X} X Xstop_cmd() X{ X if [ -r ${pidfile} ]; then X pid=`cat ${pidfile}` X kill -TERM ${pid} X wait_for_pids ${pid} X X rm -rf ${pidfile} X else X echo "netdump-server not runned" X fi X} X Xload_rc_config $name Xrun_rc_command "$1" END-of-netdump-server/files/netdump-server.sh echo x - netdump-server/Makefile sed 's/^X//' >netdump-server/Makefile << 'END-of-netdump-server/Makefile' X# New ports collection makefile for: netdump-server X# Date created: 20 Mar 2005 X# Whom: Stanislav Sedov X# X XPORTNAME= netdump-server XPORTVERSION= 0.7.7 XCATEGORIES= net-mgmt XMASTER_SITES= http://mbsd.msk.ru/dist/ XDISTNAME= netdump-${PORTVERSION} X XMAINTAINER= stas@core.310.ru XCOMMENT= RedHat server part of netdump/netconsole package for linux X XLIB_DEPENDS= popt:${PORTSDIR}/devel/popt \ X glib:${PORTSDIR}/devel/glib20 XBUILD_DEPENDS= pkg-config:${PORTSDIR}/devel/pkgconfig X XPKGMESSAGE= ${WRKDIR}/pkg-message X XDOCSFILES= README README.client XCONFIGFILE= netdump.conf XMAN8= netdump.8 netdump-server.8 X XUSE_RC_SUBR= yes XRC_SCRIPT= netdump-server.sh X XSED_SCRIPT+= -e 's,%%PREFIX%%,${PREFIX},g' \ X -e 's,%%RC_SUBR%%,${RC_SUBR},g' \ X -e 's,%%CONFIGFILE%%,${CONFIGFILE},g' X Xpost-patch: X ${SED} ${SED_SCRIPT} < ${FILESDIR}/${RC_SCRIPT} > \ X ${WRKDIR}/${RC_SCRIPT} X ${SED} ${SED_SCRIPT} < ${FILESDIR}/${CONFIGFILE} > \ X ${WRKDIR}/${CONFIGFILE}.sample X ${SED} ${SED_SCRIPT} < ${PKGDIR}/pkg-message > \ X ${PKGMESSAGE} X Xdo-install: X ${INSTALL_MAN} ${WRKSRC}/netdump-server.8 ${MANPREFIX}/man/man8 X ${INSTALL_MAN} ${WRKSRC}/netdump.8 ${MANPREFIX}/man/man8 X ${INSTALL_PROGRAM} ${WRKSRC}/netdump-server ${PREFIX}/bin X X.if exists(${PREFIX}/etc/netdump.conf) X @echo "====> Preserving your previous configuration." X.else X ${INSTALL_DATA} ${WRKDIR}/${CONFIGFILE}.sample ${PREFIX}/etc X.endif X X ${INSTALL_SCRIPT} ${WRKDIR}/netdump-server.sh ${PREFIX}/etc/rc.d X X ${MKDIR} ${EXAMPLESDIR} X X for filename in ${WRKSRC}/example_scripts/*; do \ X ${INSTALL_SCRIPT} $${filename} ${EXAMPLESDIR}; \ X done X Xpost-install: X X.if !defined(NOPORTDOCS) X @${MKDIR} ${DOCSDIR} X.for FILE in ${DOCSFILES} X @${INSTALL_DATA} ${WRKSRC}/${FILE} ${DOCSDIR} X.endfor X.endif X X if ! pw usershow "netdump" 2>/dev/null 1>&2; then \ X if pw useradd -n netdump -g operator -h - \ X -s "/sbin/nologin" -d "/nonexistent" \ X -c "Netdump-server pseudo user"; \ X then \ X echo "Added user \"netdump\""; \ X else \ X echo "Adding user \"netdump\" failed!"; \ X exit 1; \ X fi \ X fi X X if [ ! -d /var/spool/netdump ]; then \ X ${MKDIR} /var/spool/netdump; \ X ${CHOWN} netdump:operator /var/spool/netdump; \ X ${CHMOD} 700 /var/spool/netdump; \ X fi X X @${CAT} ${PKGMESSAGE} X X.include <bsd.port.mk> END-of-netdump-server/Makefile echo x - netdump-server/distinfo sed 's/^X//' >netdump-server/distinfo << 'END-of-netdump-server/distinfo' XMD5 (netdump-0.7.7.tar.gz) = 0b2b15cd95d2e64bac4ae5e05f49e82f END-of-netdump-server/distinfo echo x - netdump-server/pkg-descr sed 's/^X//' >netdump-server/pkg-descr << 'END-of-netdump-server/pkg-descr' X Netdump-server listens on the network for connections from linux Xkernels using the netconsole/netdump module. When such a machine crashes Xit contacts the netdump-server on the specified ip/port. The server then Xproceeds to log console messages, including the oops message, and a kernel Xmemory dump in a specified directory, and then reboots the machine. X XWWW: http://www.redhat.com END-of-netdump-server/pkg-descr echo x - netdump-server/pkg-plist sed 's/^X//' >netdump-server/pkg-plist << 'END-of-netdump-server/pkg-plist' Xbin/netdump-server Xetc/rc.d/netdump-server.sh X%%EXAMPLESDIR%%/netdump-crash X%%EXAMPLESDIR%%/netdump-nospace X%%EXAMPLESDIR%%/netdump-reboot X%%EXAMPLESDIR%%/netdump-start X%%PORTDOCS%%%%DOCSDIR%%/README X%%PORTDOCS%%%%DOCSDIR%%/README.client X%%PORTDOCS%%@dirrm %%DOCSDIR%% X@dirrm %%EXAMPLESDIR%% END-of-netdump-server/pkg-plist echo x - netdump-server/pkg-message sed 's/^X//' >netdump-server/pkg-message << 'END-of-netdump-server/pkg-message' X============================================================================= X XThis port installed sample config script '%%PREFIX%%/etc/%%CONFIGFILE%%.sample'. XRename it to '%%PREFIX%%/etc/%%CONFIGFILE%%' and edit to suit your needs. X XDumps will be stored in /var/spool/netdump. You can change it in config or Xusing runtime options. X XIn order to enable logging add '!netdump' part to syslog.conf. X XIf you want to use netdump-server in secure way set password for netdump Xaccount and change 'secure' config option to 1. X XTo run netdump-server from startup, add netdump_server_enable="YES" Xin your /etc/rc.conf. X X============================================================================= END-of-netdump-server/pkg-message exit --- netdump-server.shar ends here --- >Release-Note: >Audit-Trail: >Unformatted: of netdump/netconsole package for linux
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200503201007.j2KA7jPF038822>