lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20140320094257.14878.9997.stgit@localhost.localdomain>
Date:	Thu, 20 Mar 2014 15:12:57 +0530
From:	Janani Venkataraman <jananive@...ux.vnet.ibm.com>
To:	linux-kernel@...r.kernel.org
Cc:	amwang@...hat.com, procps@...elists.org, rdunlap@...otime.net,
	james.hogan@...tec.com, aravinda@...ux.vnet.ibm.com, hch@....de,
	mhiramat@...hat.com, jeremy.fitzhardinge@...rix.com,
	xemul@...allels.com, d.hatayama@...fujitsu.com, coreutils@....org,
	kosaki.motohiro@...fujitsu.com, adobriyan@...il.com,
	util-linux@...r.kernel.org, tarundsk@...ux.vnet.ibm.com,
	vapier@...too.org, roland@...k.frob.com, ananth@...ux.vnet.ibm.com,
	gorcunov@...nvz.org, avagin@...nvz.org, oleg@...hat.com,
	eparis@...hat.com, suzuki@...ux.vnet.ibm.com, andi@...stfloor.org,
	tj@...nel.org, akpm@...ux-foundation.org,
	torvalds@...ux-foundation.org
Subject: [PATCH 27/33] [libgencore] Request for dump

Request for a self dump and wait for an acknowledgement first and then a
response about the status of the dump.

  --------    gencore(file_name) --------
 |        |   ----------------> |        |
 |        |   ack(errno)        |        |
 | CLIENT |   <---------------- | SERVER |
 |        |   status(errno)     |(daemon)|
 |        |   <---------------- |        |
  --------                       --------

a) The client connects to the server(daemon)

b) Once the connection is accepted, request for dump is sent. This request
contains the file name where the dump is to be saved.

c) Once the request is sent, the client waits for an acknowledgment from the
server, that it has received the message.

d) Then the client waits for the status response from the server which either
is a sucess or a failure. If it is a failure, the correct errno is sent back.

Signed-off-by: Janani Venkataraman <jananive@...ux.vnet.ibm.com>
---
 src/Makefile.am |    1 +
 src/client.c    |   51 +++++++++++++++++++++++++++++++++++++++++++++++++++
 src/gencore.h   |    1 +
 3 files changed, 53 insertions(+)
 create mode 100644 src/gencore.h

diff --git a/src/Makefile.am b/src/Makefile.am
index a1d57ca..c8a52b7 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -3,6 +3,7 @@ HAVE_SYSTEMD_SOCKET_SUPPORT = 0
 SOCKET_PATH = /var/run/gencored.socket
 CFLAGS += -I. -DHAVE_SYSTEMD_SOCKET_SUPPORT='$(HAVE_SYSTEMD_SOCKET_SUPPORT)' -DSOCKET_PATH='"$(SOCKET_PATH)"'
 
+include_HEADERS = gencore.h
 lib_LTLIBRARIES = libgencore.la
 libgencore_la_LDFLAGS = -fPIC
 libgencore_la_SOURCES = client.c
diff --git a/src/client.c b/src/client.c
index cddaf94..8d078b7 100644
--- a/src/client.c
+++ b/src/client.c
@@ -27,6 +27,7 @@
 #include <unistd.h>
 #include <string.h>
 #include <errno.h>
+#include <gencore.h>
 
 int setup_connection(void)
 {
@@ -53,6 +54,51 @@ int setup_connection(void)
 	return socket_fd;
 }
 
+/* Sends message to client */
+int send_core_filename(int socket_fd, char *corefile)
+{
+	if (write(socket_fd, corefile , strlen(corefile) + 1) == -1)
+		return errno;
+
+	return 0;
+}
+
+/* Receive message from client */
+int receive_reply(int socket_fd)
+{
+	int reply;
+
+	if (read(socket_fd, &reply , sizeof(reply)) == -1)
+		return errno;
+
+	return reply;
+}
+
+int dump_request(int socket_fd, char *corefile)
+{
+	int ret;
+
+	/* Sends request */
+	ret = send_core_filename(socket_fd, corefile);
+	if (ret)
+		goto cleanup;
+
+	/* Receives acknowledgment */
+	ret = receive_reply(socket_fd);
+	if (ret)
+		goto cleanup;
+
+	/* Receives status */
+	ret = receive_reply(socket_fd);
+	if (ret)
+		goto cleanup;
+
+cleanup:
+	close(socket_fd);
+
+	return ret;
+}
+
 int gencore(char *corefile)
 {
 	int socket, ret;
@@ -64,6 +110,11 @@ int gencore(char *corefile)
 		goto cleanup;
 	}
 
+	/* Asks for a self dump */
+	ret = dump_request(socket, corefile);
+	if (ret)
+		goto cleanup;
+
 cleanup:
 
 	return ret;
diff --git a/src/gencore.h b/src/gencore.h
new file mode 100644
index 0000000..8ad0ca8
--- /dev/null
+++ b/src/gencore.h
@@ -0,0 +1 @@
+int gencore(char *corefile);

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ