[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r28483 - msh/src
From: |
gnunet |
Subject: |
[GNUnet-SVN] r28483 - msh/src |
Date: |
Sat, 10 Aug 2013 08:22:34 +0200 |
Author: harsha
Date: 2013-08-10 08:22:33 +0200 (Sat, 10 Aug 2013)
New Revision: 28483
Modified:
msh/src/addressmap.c
msh/src/mshd-server.c
msh/src/mshd.c
Log:
- allow multiple addresses in reverse map
- make pathnames for unix domain sockets unique for each mshd instance
Modified: msh/src/addressmap.c
===================================================================
--- msh/src/addressmap.c 2013-08-09 17:19:21 UTC (rev 28482)
+++ msh/src/addressmap.c 2013-08-10 06:22:33 UTC (rev 28483)
@@ -613,7 +613,7 @@
{
if (GNUNET_SYSERR ==
GNUNET_CONTAINER_multihashmap32_put (rmap->map, (uint32_t) iaddr->ip,
iaddr,
-
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY))
+
GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE))
{
GNUNET_break (0);
return GNUNET_SYSERR;
Modified: msh/src/mshd-server.c
===================================================================
--- msh/src/mshd-server.c 2013-08-09 17:19:21 UTC (rev 28482)
+++ msh/src/mshd-server.c 2013-08-10 06:22:33 UTC (rev 28483)
@@ -505,6 +505,7 @@
our_uid = getuid ();
our_gid = getgid ();
+ (void) unlink (unixpath);
saddr.sun_family = AF_UNIX;
(void) strcpy (saddr.sun_path, unixpath);
local_serv = GNUNET_SERVER_create (&check_local_access, NULL,
@@ -728,6 +729,37 @@
/**
+ * Handler for messages with command's input stream data. The date will be
+ * written to the command's standard input stream.
+ *
+ * @param cls NULL
+ * @param client identification of the client
+ * @param message the actual message
+ */
+static void
+handle_command_input (void *cls,
+ struct GNUNET_SERVER_Client *client,
+ const struct GNUNET_MessageHeader* message)
+{
+ const struct MSH_MSG_CmdIO *msg;
+ struct ClientCtx *ctx;
+ struct ExecCtx *exec_ctx;
+ uint16_t size;
+
+ size = ntohs (message->size);
+ msg = (const struct MSH_MSG_CmdIO *) message;
+ ctx = GNUNET_SERVER_client_get_user_context (client, struct ClientCtx);
+ GNUNET_assert (NULL != ctx);
+ exec_ctx = ctx->exec_ctx;
+ GNUNET_assert (NULL != exec_ctx);
+ size -= sizeof (struct MSH_MSG_CmdIO);
+ GNUNET_break (size == GNUNET_DISK_file_write (exec_ctx->fin, msg->data,
+ size));
+ GNUNET_SERVER_receive_done (client, GNUNET_OK);
+}
+
+
+/**
* Initialises the server which spawns processes and forwards it stdin and
stdout
*
* @param h the network handle of the socket to listen for incoming connections
@@ -739,6 +771,7 @@
{&handle_runcmd, NULL, MSH_MTYPE_RUNCMD, 0},
{&handle_auth_challenge_response, NULL, MSH_MTYPE_CHALLENGE_RESPONSE,
sizeof (struct MSH_MSG_ChallengeResponse)},
+ {&handle_command_input, NULL, MSH_MTYPE_CMD_STREAM_STDIN, 0},
{NULL, NULL, 0, 0}
};
Modified: msh/src/mshd.c
===================================================================
--- msh/src/mshd.c 2013-08-09 17:19:21 UTC (rev 28482)
+++ msh/src/mshd.c 2013-08-10 06:22:33 UTC (rev 28483)
@@ -234,6 +234,11 @@
static struct GNUNET_OS_Process *process;
/**
+ * The path of the unix domain socket we use for communication with local MSH
clients
+ */
+static char *unixpath;
+
+/**
* Random hashcode for authentication
*/
struct GNUNET_HashCode shash;
@@ -405,6 +410,8 @@
static void
schedule_next_round ()
{
+ char *dtemp;
+ intmax_t pid;
int total_rounds;
GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == rtask);
@@ -421,21 +428,23 @@
addressmap_print (addrmap);
listen_mode = LISTEN_MODE_SERV;
rmap = addressmap_create_reverse_mapping (addrmap);
- init_local_server ();
+ pid = (intmax_t) getpid ();
+ dtemp - GNUNET_DISK_mkdtemp ("mshd");
+ GNUNET_assert (NULL != dtemp);
+ GNUNET_assert (0 < asprintf (&unixpath, "%s/%j.sock", dtemp, pid));
+ GNUNET_free (dtemp);
+ init_local_server (unixpath);
init_daemon_server (listen_socket);
listen_socket = NULL;
if (0 == rank)
{
- const char *unixpath = "/tmp/mshd.sock";
-
- (void) unlink (unixpath);
setenv (MSHD_SOCK_NAME, unixpath, 1);
proc = GNUNET_OS_start_process_vap (GNUNET_NO,
GNUNET_OS_INHERIT_STD_OUT_AND_ERR,
NULL,
NULL,
run_args[0],
- run_args);
+ run_args);
if (NULL == proc)
{
GNUNET_break (0);
@@ -1004,6 +1013,7 @@
ret = 1;
rwidth = 1;
+ GNUNET_log_setup ("mshd", NULL, NULL);
if (MPI_SUCCESS != MPI_Init(&argc, &argv))
{
LOG_ERROR ("Failed to initialise MPI\n");
@@ -1046,5 +1056,11 @@
GNUNET_free_non_null (s_addrs);
if (NULL != run_args)
free_argv (run_args);
+ if (NULL != unixpath)
+ {
+ (void) unlink (unixpath);
+ GNUNET_free (unixpath);
+ }
LOG_DEBUG ("Returning\n");
+ return ret;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r28483 - msh/src,
gnunet <=