PadicoTM

Documentation

« back to PM2 home.
control-ssh2.c
Go to the documentation of this file.
1/*
2 * Padico -- a High Performance Parallel and Distributed Computing Environment
3 * Copyright (c) 2002-2024 INRIA and the University of Rennes 1
4 * Alexandre DENIS <Alexandre.Denis@inria.fr>
5 * Christian PEREZ <Christian.Perez@inria.fr>
6 *
7 * The software has been registered at the Agency for the Protection of
8 * Programs (APP) under the number IDDN.FR.001.260013.000.S.P.2002.000.10000.
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 */
24
29#include <Padico/Puk.h>
30#include <Padico/Module.h>
31#include <Padico/PadicoTM.h>
32#include <Padico/SysIO.h>
33#include <Padico/PadicoControl.h>
34#include <Padico/SocketFactory.h>
35
36#include <arpa/inet.h>
37#include <sys/types.h>
38#include <sys/socket.h>
39#include <netdb.h>
40#include <poll.h>
41#include <unistd.h>
42
43#ifdef HAVE_LIBSSH2_H
44#include <libssh2.h>
45#endif
46
47static int control_ssh2_init(void);
48static void control_ssh2_finalize(void);
49
51
61#define OPENSSH_MIN_VERSION 5.4
62
63/* *** PadicoControl driver ******************************** */
64
66
71
72
73/* *** PadicoBootstrap driver ******************************** */
74
75static int ssh2_control_bootstrap_connect(void*_status, const char*hostname, padico_topo_uuid_t uuid);
76
78 {
80 .bootstrap_connect = &ssh2_control_bootstrap_connect
81 };
82
83/* *** PadicoComponent driver ******************************** */
84
86static void ssh2_control_destroy(void*);
87
89 {
90 .instantiate = &ssh2_control_instantiate,
91 .destroy = &ssh2_control_destroy
92 };
93
94/* ********************************************************* */
101
103{
105 float version;
106};
107
130
133/* ********************************************************* */
134/* *** OpenSSH specific functions */
135
136static float ssh2_openssh_version(const char*ssh_path)
137{
138 float version = 0;
139 int fd[2];
140 PUK_ABI_FSYS_REAL(pipe)(fd);
141 pid_t child = fork();
142 if(!child)
143 {
144 PUK_ABI_FSYS_REAL(close)(fd[0]);
146 unsetenv("LD_PRELOAD");
148 const char *argv[] =
149 {
150 "ssh",
151 "-V",
152 NULL
153 };
155 PUK_ABI_PROC_REAL(execv)(ssh_path, (char**)argv);
157 PUK_ABI_FSYS_REAL(close)(fd[1]);
158 exit(1);
159 }
160 else if(child > 0)
161 {
162 PUK_ABI_FSYS_REAL(close)(fd[1]);
163 char buf[512];
164 memset(buf, 0, 512);
165 PUK_ABI_FSYS_REAL(read)(fd[0], buf, 512);
166 sscanf(buf, "OpenSSH_%f*s", &version);
167 padico_out(40, "OpenSSH version on localhost: %g\n", version);
168 PUK_ABI_FSYS_REAL(close)(fd[0]);
169 }
170 else
171 {
172 version = 0;
173 }
174 return version;
175}
176
177static void ssh2_openssh_config(struct ssh2_control_status_s*status, const char*filename,
178 char**nodes, char**users, int n)
179{
180 FILE*config_file = fopen(filename, "w");
182 "Host *\n"
183 "StrictHostKeyChecking no\n"
184 "ForwardAgent yes\n"
185 "Ciphers %s\n\n", status->ssh_cipher);
186 int i=0;
188 "Host %s\n"
189 "User %s\n\n",
190 nodes[i], users[i]);
191 for(i=1; i < n; i++)
192 {
194 "Host %s\n"
195 "User %s\n"
196 "ProxyCommand ssh -x -e none -F %s -W %%h:%%p %s\n\n",
197 nodes[i], users[i], filename, nodes[i-1]);
198 }
200}
201
203 char**nodes, char**users, int n, char*destination)
204{
205 int sv[2] = { -1, -1};
206 int keepalive = 1;
208 int rc = 0;
209 int err = 0;
214 if(rc)
215 return -err;
216 rc = PUK_ABI_FSYS_REAL(setsockopt)(sv[0], SOL_SOCKET, SO_KEEPALIVE, &keepalive, sizeof(keepalive));
218 if(rc)
219 return -err;
220 rc = PUK_ABI_FSYS_REAL(setsockopt)(sv[1], SOL_SOCKET, SO_KEEPALIVE, &keepalive, sizeof(keepalive));
222 if(rc)
223 return -err;
225 status->openssh.pid = fork();
227 if(status->openssh.pid > 0)
228 {
229 rc = PUK_ABI_FSYS_REAL(close)(sv[1]);
230 status->ssh_server_fd = sv[0];
231 }
232 else if(status->openssh.pid == 0)
233 {
234 rc = PUK_ABI_FSYS_REAL(close)(sv[0]);
235 if(rc)
236 goto ossh_error;
237 rc = PUK_ABI_FSYS_REAL(dup2)(sv[1], 0);
238 if(rc == -1)
239 goto ossh_error;
240 rc = PUK_ABI_FSYS_REAL(dup2)(sv[1], 1);
241 if(rc == -1)
242 goto ossh_error;
243 rc = PUK_ABI_FSYS_REAL(close)(sv[1]);
244 if(rc)
245 goto ossh_error;
246 unsetenv("LD_PRELOAD");
248 const char *argv[] =
249 {
250 "ssh",
251 "-W",
253 "-F",
255 "-x",
256 "-e",
257 "none",
258 nodes[n-1],
259 NULL
260 };
261 padico_print("ssh tunnel to %s through %s\n", destination, nodes[n-1]);
263 rc = PUK_ABI_PROC_REAL(execv)(status->ssh_path, (char**)argv);
267 return rc;
268 }
269 else
270 {
272 return err;
273 }
275 return 0;
276}
277
278/* ********************************************************* */
279/* *** LibSSH2 specific functions */
280
281#ifdef HAVE_LIBSSH2_H
282
284{
285 struct addrinfo *res;
286 if(getaddrinfo(status->ssh_host, "ssh", NULL, &res))
287 {
288 padico_warning("Cannot resolve ssh server: %s\n", status->ssh_host);
289 return -ENETUNREACH;
290 }
292 return fd;
293}
294
296{
299 int rc = -1;
300 const char *userauthlist = libssh2_userauth_list(status->session, status->ssh_user, strlen(status->ssh_user));
301 if (strstr(userauthlist, "publickey") == NULL)
302 {
303 padico_warning("ssh server %s don't support \"publickey\" authentication\n", status->ssh_host);
304 return -1;
305 }
307 if (!agent)
308 {
309 padico_warning("Failure initializing ssh-agent support\n");
310 goto noagent;
311 }
313 {
314 padico_warning("Failure connecting to ssh-agent\n");
315 goto noagent;
316 }
318 {
319 padico_warning("Failure requesting identities to ssh-agent\n");
320 goto noagent;
321 }
322 while (1)
323 {
325 if (rc == 1)
326 break;
327 if (rc < 0)
328 {
329 padico_warning("Failure obtaining identity from ssh-agent support\n");
330 return -1;
331 }
332 if ((rc = libssh2_agent_userauth(agent, status->ssh_user, identity)) == 0)
333 {
334 break;
335 }
337 }
338 noagent:
339 if (rc)
340 {
341 padico_warning("Couldn't find a good key in the ssh-agent identity collection\n");
342 const char*home = padico_getenv("HOME");
344 padico_string_catf(priv, "%s/.ssh/id_rsa", home);
346 padico_string_catf(pub, "%s/.ssh/id_rsa.pub", home);
347 if(access(padico_string_get(pub), F_OK) == 0)
348 {
349 padico_out(40,"Try %s without passphrase\n", padico_string_get(priv));
353 }
354 }
355 if(agent)
356 {
359 }
360 return rc;
361}
362
364{
365 struct ssh2_control_status_s*status = _status;
366 if(!status->session)
367 {
369 if(status->ssh_server_fd < 0)
370 {
371 return -ENETUNREACH;
372 }
373 status->session = libssh2_session_init();
374 if(status->session)
375 {
378 {
379 padico_warning("Start or init libssh failed\n");
381 status->ssh_server_fd = -1;
383 status->session = NULL;
384 return -ECONNREFUSED;
385 }
386 if(ssh2_libssh2_authenticate(status))
387 {
389 status->ssh_server_fd = -1;
390 libssh2_session_disconnect(status->session, "Authentication fail\n");
392 status->session = NULL;
393 return -ECONNREFUSED;
394 }
395 }
396 else
397 return -ENETUNREACH;
398 }
399 return 0;
400}
401
402#endif /* HAVE_LIBSSH2_H */
403
404/* ********************************************************* */
405/* *** SSH2 helper function */
406
407static ssize_t ssh2_control_in(struct ssh2_control_status_s*status, void* buf, size_t count)
408{
409 ssize_t done = 0;
410#ifdef HAVE_LIBSSH2_H
411 if(status->openssh.pid == 0 && status->session)
412 {
413 if(count > 0)
414 {
415 while(done < count)
416 {
417 int rc = libssh2_channel_read(status->channel, buf + done, count - done);
418 if(rc > 0)
419 done += rc;
420 else if(rc == 0)
421 return done;
422 else if(rc == LIBSSH2_ERROR_EAGAIN)
423 continue;
424 else
425 return rc;
426 }
427 }
428 }
429 else
430 {
431#endif /* HAVE_LIBSSH2_H */
432 done = padico_sysio_in(status->ssh_server_fd, buf, count);
433#ifdef HAVE_LIBSSH2_H
434 }
435#endif /* HAVE_LIBSSH2_H */
436 return done;
437}
438
439static ssize_t ssh2_control_out(struct ssh2_control_status_s*status, const void* buf, size_t count)
440{
441 ssize_t done = 0;
442#ifdef HAVE_LIBSSH2_H
443 if(status->openssh.pid == 0 && status->session)
444 {
445 padico_out(40,"%s\n",(char*)buf);
446 if(count > 0)
447 {
448 while(done < count)
449 {
450 int rc = libssh2_channel_write(status->channel, buf + done, count - done);
451 if(rc > 0)
452 done += rc;
453 else if(rc == 0)
454 {
455 return done;
456 }
457 else if(rc == LIBSSH2_ERROR_EAGAIN)
458 continue;
459 else
460 return rc;
461 }
462 }
463 }
464 else
465 {
466#endif /* HAVE_LIBSSH2_H */
467 done = padico_sysio_out(status->ssh_server_fd, buf, count);
468#ifdef HAVE_LIBSSH2_H
469 }
470#endif /* HAVE_LIBSSH2_H */
471 return done;
472}
473
474static ssize_t ssh2_control_outv(struct ssh2_control_status_s*status, const struct iovec *iov, int iovcnt)
475{
476 ssize_t done = 0;
477#ifdef HAVE_LIBSSH2_H
478 if(status->openssh.pid == 0 && status->session)
479 {
480 int i = 0;
481 for(i = 0; i < iovcnt; i++)
482 {
483 int rc = ssh2_control_out(status, iov[i].iov_base, iov[i].iov_len);
484 if(rc > 0)
485 {
486 assert(rc == iov[i].iov_len);
487 done += rc;
488 }
489 else if(rc == 0)
490 return done;
491 else
492 return rc;
493 }
494 }
495 else
496 {
497#endif /* HAVE_LIBSSH2_H */
499#ifdef HAVE_LIBSSH2_H
500 }
501#endif /* HAVE_LIBSSH2_H */
502 return done;
503}
504
505/* ********************************************************* */
506/* *** PadicoControl */
508
510{
512 padico_control_delete_node(status->instance, status->peer);
513 ssh2_control_connector_notify(status, padico_rc_error("Control_SSH2: connection lost"));
514}
515
517{
518 struct ssh2_control_status_s*status = _status;
519 const struct iovec*v = padico_control_msg_get_iovec(msg);
521 const size_t size = padico_control_msg_get_size(msg);
522 struct iovec*v2 = padico_malloc(sizeof(struct iovec) * (iovcnt + 1));
523 int i;
524 for(i=0; i<iovcnt; i++)
525 {
526 v2[i+1].iov_base = v[i].iov_base;
527 v2[i+1].iov_len = v[i].iov_len;
528 }
529 marcel_mutex_lock(&status->lock);
530 while(status->state == SSH2_CONTROL_STATE_INIT)
531 {
532 padico_out(80, "wait for the establishment of the control channel.\n");
533 marcel_cond_wait(&status->connection_event, &status->lock);
534 }
535 assert(status->ssh_server_fd > 0);
536 assert(node == status->peer);
538 v2[0].iov_base = &n_size;
539 v2[0].iov_len = sizeof(n_size);
540 int sysrc = ssh2_control_outv(status, v2, iovcnt + 1);
541 marcel_mutex_unlock(&status->lock);
542 if(sysrc < 0)
543 {
545 }
547 assert(sysrc == size + sizeof(n_size));
548 padico_out(30, "send ok.\n");
549}
550
551
552static int ssh2_control_read_callback(int fd, void*key)
553{
554 int again = 1;
555 struct ssh2_control_status_s*status = (struct ssh2_control_status_s*)key;
556 size_t size;
557 char*bytes;
558 marcel_mutex_lock(&status->lock);
559#ifdef HAVE_LIBSSH2_H
560 if(status->openssh.pid == 0 && status->session)
561 {
562 libssh2_channel_read(status->channel, NULL, 0);
563 while(libssh2_poll_channel_read(status->channel, 0))
564 {
565 uint32_t n_size = 0;
566 assert(status->ssh_server_fd == fd);
567 padico_out(40, "entering...\n");
568 int sysrc = ssh2_control_in(status, &n_size, sizeof(uint32_t));
569 if(sysrc <= 0)
570 {
571 again = 0;
573 goto exit;
574 }
575 size = ntohl(n_size);
576 bytes = NULL;
577 if(size > 0)
578 {
579 bytes = padico_malloc(size);
580 sysrc = ssh2_control_in(status, bytes, size);
581 if(sysrc < size)
582 {
583 again = 0;
585 goto exit;
586 }
587 }
588 padico_out(40, "received message- len=%ld; msg=*%s*\n", puk_ulong(size), bytes);
589 padico_control_deliver_message(status->instance, status->peer, bytes, size);
590 }
591 exit:
592 if(libssh2_channel_eof(status->channel))
593 {
594 again = 0;
596 }
597 }
598 else
599 {
600#endif /* HAVE_LIBSSH2_H */
601 assert(status->ssh_server_fd == fd);
602 padico_out(40, "entering...\n");
603 uint32_t n_size = 0;
604 int sysrc = padico_sysio_in(fd, &n_size, sizeof(uint32_t));
605 if(sysrc <= 0)
606 {
607 again = 0;
609 return again;
610 }
611 size = ntohl(n_size);
612 bytes = NULL;
613 if(size > 0)
614 {
615 bytes = padico_malloc(size);
616 sysrc = padico_sysio_in(fd, bytes, size);
617 if(sysrc < size)
618 {
619 again = 0;
621 return again;
622 }
623 }
624 padico_out(40, "received message- len=%ld; msg=*%s*\n", puk_ulong(size), bytes);
625 padico_control_deliver_message(status->instance, status->peer, bytes, size);
626#ifdef HAVE_LIBSSH2_H
627 }
628#endif /* HAVE_LIBSSH2_H */
629 marcel_mutex_unlock(&status->lock);
630 return again;
631}
632
633/* ********************************************************* */
634/* *** PadicoConnector */
636{
637 if(status->req)
638 {
639 padico_tm_req_notify(status->req->id, rc);
640 status->req = NULL;
641 }
642 else padico_rc_delete(rc);
643}
644
645static void*ssh2_control_start(void*_status)
646{
647 struct ssh2_control_status_s*status = _status;
648 /* announce local node to peer node */
650 const char*msg = padico_string_get(self_node);
651 marcel_mutex_lock(&status->lock);
652 assert(status->ssh_server_fd > 0);
654 uint32_t size = strlen(msg) + 1;
655 int sysrc = ssh2_control_out(status, &size, sizeof(size));
656 if(sysrc > 0)
657 {
658 sysrc = ssh2_control_out(status, msg, size);
659 }
660 if(sysrc < 0)
661 {
663 }
664 marcel_mutex_unlock(&status->lock);
665 msg = NULL;
667 /* receive peer announce */
668 sysrc = ssh2_control_in(status, &size, sizeof(size));
669 assert(sysrc == sizeof(size));
670 if(sysrc <= 0)
671 {
673 return NULL;
674 }
677 if(sysrc < size)
678 {
680 return NULL;
681 }
682 /* parse peer announce */
687 {
689 padico_fatal("parse error on initial handshake message.");
690 }
691 if(!puk_parse_is(&e, "Topology:node"))
692 {
693 padico_fatal("root entity is not \"Topology:node\" while initializing control channel.\n");
694 }
696 assert(peer != NULL);
697 assert(status->peer == NULL);
698 status->peer = peer;
701
702 /* authorize to send */
703 marcel_mutex_lock(&status->lock);
708 marcel_mutex_unlock(&status->lock);
709 /* activate polling */
710 padico_io_activate(status->in_io);
711
712 /* notify connection establishment */
713 padico_out(20, "the connection to node %s is up\n", padico_topo_node_getname(peer));
716
720
721 return NULL;
722}
723
724
725/* ********************************************************* */
726/* *** PadicoBootstrap */
727
730{
731 const unsigned int port_base = 20000;
732 const unsigned int port_end = 32000;
733 const unsigned int port_range = port_end - port_base;
735 const unsigned int port_offset = puk_hash_default((void*)session_id, strlen(session_id));
737 return port;
738}
739
740static int ssh2_control_bootstrap_connect(void*_status, const char*hostname, padico_topo_uuid_t uuid)
741{
742 struct ssh2_control_status_s*status = (struct ssh2_control_status_s*) _status;
743
746 const struct in_addr*ip = padico_topo_host_getaddr(host);
747 if(!ip)
748 {
749 padico_fatal("cannot find host '%s': host has no IP address.\n", hostname);
750 }
751 int n = 0, i = 0;
752 int rc = -1;
753 char*ssh_host = padico_strdup(status->ssh_host);
754 char*ssh_user = padico_strdup(status->ssh_user);
755 char**nodes = padico_malloc(sizeof(char*));
756 char**users = padico_malloc(sizeof(char*));
757 char*save_node = NULL, *save_user = NULL;
758 char*node_token = strtok_r((char*)ssh_host, ",", &save_node);
759 char*user_token = strtok_r((char*)ssh_user, ",", &save_user);
760 while(node_token != NULL)
761 {
762 nodes[n] = node_token;
763 users[n] = user_token;
764 n++;
765 nodes = padico_realloc(nodes, (n+1)*sizeof(char*));
766 users = padico_realloc(users, (n+1)*sizeof(char*));
769 }
770
771 const char * remote_desthost;
772 if(status->ssh_dest)
773 remote_desthost = status->ssh_dest;
774 else
776 unsigned int remote_destport = ntohs(port);
777#ifdef HAVE_LIBSSH2_H
778 if(n == 1)
779 {
781 if(rc == 0)
782 {
783 padico_out(10,"connecting to %s:%d with ssh server %s@%s\n", remote_desthost, remote_destport, status->ssh_user, status->ssh_host);
786 if (!status->channel)
787 {
788 padico_out(30, "Could not open the direct-tcpip channel\n");
789 return -ENETUNREACH;
790 }
792 }
793 }
794 else
795 {
796#endif /* HAVE_LIBSSH2_H */
797 if(status->openssh.version >= OPENSSH_MIN_VERSION)
798 {
803 }
804 else
805 {
806 return -ENETUNREACH;
807 }
808#ifdef HAVE_LIBSSH2_H
809 }
810#endif /* HAVE_LIBSSH2_H */
811
813 ssh2_control_start(status);
814 marcel_mutex_lock(&status->lock);
815 while(status->state == SSH2_CONTROL_STATE_INIT)
816 {
817 padico_out(80, "wait for the establishment of the control channel.\n");
818 marcel_cond_wait(&status->connection_event, &status->lock);
819 }
821 {
822 rc = -ENETUNREACH;
823 }
824 marcel_mutex_unlock(&status->lock);
825 if(!rc)
826 {
827#ifdef HAVE_LIBSSH2_H
828 if(status->session)
829 padico_print("(LibSSH2) ssh server=%s; cipher=%s, addr=%s:%d\n",
832#endif /* HAVE_LIBSSH2_H */
833 if(status->openssh.pid > 0)
834 {
836 padico_string_catf(msg_ossh, "(OpenSSH_%g) addr=%s:%d [ ",
838 for(i = 0; i < n-1; i++)
839 {
840 padico_string_catf(msg_ossh, "%s@%s <-> ", users[i], nodes[i]);
841 }
842 padico_string_catf(msg_ossh, "%s@%s ]\n", users[n-1], nodes[n-1]);
845 }
846 }
849
850 return rc;
851}
852
853/* ********************************************************* */
854/* *** PadicoComponent */
855
857{
858 struct ssh2_control_status_s*status = padico_malloc(sizeof(struct ssh2_control_status_s));
859 *status = (struct ssh2_control_status_s)
860 {
861 .peer = NULL,
862 .ssh_server_fd = -1,
863 .in_io = NULL,
865 .instance = instance,
866 .context = context,
867 .req = NULL,
868#ifdef HAVE_LIBSSH2_H
869 .session = NULL,
870 .channel = NULL,
871#endif
872 };
873 marcel_mutex_init(&status->lock, 0);
875 status->ssh_host = puk_context_getattr(context, "ssh_host");
876 status->ssh_user = puk_context_getattr(context, "ssh_user");
877 status->ssh_cipher = puk_context_getattr(context, "ssh_cipher");
878 status->ssh_dest = puk_context_getattr(context, "ssh_dest");
879 status->ssh_path = puk_context_getattr(context, "ssh_path");
880 status->openssh.pid = 0;
881 status->openssh.version = ssh2_openssh_version(status->ssh_path);
882 return (void*)status;
883}
884
885static void ssh2_control_destroy(void*_status)
886{
887 if(_status)
888 {
889 struct ssh2_control_status_s*status = _status;
890 if(status->ssh_server_fd != -1)
892#ifdef HAVE_LIBSSH2_H
893 if(status->channel)
895 if(status->session)
896 {
897 libssh2_session_disconnect(status->session, "Normal Shutdown, Control_SSH2 destroy");
899 }
900#endif
901 padico_free(_status);
902 }
903}
904
905/* ********************************************************* */
906
908
909static int control_ssh2_init(void)
910{
911 char *username = getenv("USER");
912 const char*default_cipher = "arcfour,aes128-cbc,blowfish-cbc,aes192-cbc,cast128-cbc,3des-cbc";
914 puk_component_declare("Control_SSH2",
915 puk_component_provides("PadicoComponent", "component", &ssh2_control_component_driver),
916 puk_component_provides("PadicoControl", "control", &ssh2_control_driver),
917 puk_component_provides("PadicoBootstrap", "bootstrap", &ssh2_bootstrap_driver),
918 puk_component_attr("ssh_host", "localhost"),
919 puk_component_attr("ssh_user", username),
920 puk_component_attr("ssh_dest", NULL),
921 puk_component_attr("ssh_cipher", default_cipher),
922 puk_component_attr("ssh_path", "/usr/bin/ssh"));
924 return 0;
925}
926
assert(slab_size > 0)
struct ns_rulebucket_hash_entry_s * e
const const struct ns_rule_bucket_s * key
ssize_t n
return NULL
Definition Shm.h:88
padico_topo_host_t host
padico_topo_host_t const char * uuid
static padico_topo_node_t peer
void *static bench_vect_buffer_queue_t v
Definition bench_vect.c:22
static int done
Definition console-mod.c:49
padico_topo_node_vect_t nodes
puk_instance_t instance
the listening bootstrap instance
static float ssh2_openssh_version(const char *ssh_path)
static int ssh2_libssh2_connect_server(struct ssh2_control_status_s *status)
static int ssh2_libssh2_init_ssh_connection(struct ssh2_control_status_s *_status)
static ssize_t ssh2_control_outv(struct ssh2_control_status_s *status, const struct iovec *iov, int iovcnt)
static void * ssh2_control_start(void *_status)
static int ssh2_control_read_callback(int fd, void *key)
static ssize_t ssh2_control_out(struct ssh2_control_status_s *status, const void *buf, size_t count)
static void ssh2_control_connector_notify(struct ssh2_control_status_s *status, padico_rc_t rc)
static int ssh2_openssh_init_ssh_connection(struct ssh2_control_status_s *status, char **nodes, char **users, int n, char *destination)
static int control_ssh2_init(void)
static uint16_t ssh2_control_bootstrap_auto_port(padico_topo_node_t node)
get a bootstrap port from an UUID
static int ssh2_libssh2_authenticate(struct ssh2_control_status_s *status)
static void ssh2_openssh_config(struct ssh2_control_status_s *status, const char *filename, char **nodes, char **users, int n)
static ssize_t ssh2_control_in(struct ssh2_control_status_s *status, void *buf, size_t count)
static void ssh2_control_connection_lost(struct ssh2_control_status_s *status)
static void control_ssh2_finalize(void)
static puk_component_t control_ssh2_component
static int size
Definition datacheck.c:34
static int fd
Definition datacheck.c:32
static const struct puk_component_driver_s ssh2_control_component_driver
ssh2_control_state_e
static void ssh2_control_destroy(void *)
static void ssh2_control_send_common(void *_status, padico_topo_node_t node, padico_control_msg_t msg)
static const struct padico_bootstrap_driver_s ssh2_bootstrap_driver
static int ssh2_control_bootstrap_connect(void *_status, const char *hostname, padico_topo_uuid_t uuid)
static void * ssh2_control_instantiate(puk_instance_t, puk_context_t)
#define OPENSSH_MIN_VERSION
static const struct padico_control_driver_s ssh2_control_driver
@ SSH2_CONTROL_STATE_INIT
connection is initializing
@ SSH2_CONTROL_STATE_CONNECTED
connection is established
@ SSH2_CONTROL_STATE_DISCONNECTED
connection has been disconnected
static void padico_control_new_node(puk_instance_t controler, padico_topo_node_t node)
static void padico_control_plug_controler(puk_instance_t controler, puk_instance_t server)
static void padico_control_event_enable(void)
size_t padico_control_msg_get_size(padico_control_msg_t msg)
get the total number of bytes in the control message
Definition na-control.c:223
static void padico_control_event_disable(void)
static void padico_control_event_flush(void)
const struct iovec * padico_control_msg_get_iovec(padico_control_msg_t msg)
get an iovec from the control message content; caller takes ownership of iovec and must free it
Definition na-control.c:205
static void padico_control_delete_node(puk_instance_t controler, padico_topo_node_t node)
void padico_control_deliver_message(puk_instance_t controler, padico_topo_node_t from, char *cmd, size_t size)
Deliver an incoming control message from an component to PadicoControl.
Definition na-control.c:388
static void padico_control_event_sync(void)
int padico_control_msg_get_iovec_size(padico_control_msg_t msg)
get the number of iovec entries in the control message
Definition na-control.c:199
void padico_tm_req_notify(padico_req_id_t req_id, padico_rc_t rc)
static void puk_spinlock_release(void)
Definition PadicoTM.h:83
#define PUK_ABI_PROC_REAL(SYM)
Definition PadicoTM.h:91
#define PUK_ABI_FSYS_REAL(SYM)
Definition PadicoTM.h:89
static void puk_spinlock_acquire(void)
Definition PadicoTM.h:81
padico_rc_t rc
Definition PadicoTM.h:146
#define __puk_abi_wrap__errno
Definition PadicoTM.h:101
int padico_sysio_connected_inet_socket_sockaddr(const struct sockaddr *addr)
Definition sysio.c:867
#define PADICO_IO_EVENT_READ
the fildes is readable
Definition SysIO.h:62
ssize_t padico_sysio_in(int fildes, void *buf, size_t nbyte)
Definition sysio.c:792
void padico_io_activate(padico_sysio_t io)
Activates the I/O handle - when not activated, the callback is not triggered.
Definition sysio.c:278
ssize_t padico_sysio_outv(int fildes, const struct iovec *buf, int iovcnt)
Definition sysio.c:828
padico_sysio_t padico_io_register(int fd, unsigned int what, padico_sysio_callback_t callback, void *key)
Registers a file descriptor for polling.
Definition sysio.c:205
#define padico_io_t
for backwards compatibility with legacy codes
Definition SysIO.h:53
ssize_t padico_sysio_out(int fildes, const void *buf, size_t nbyte)
Definition sysio.c:808
int padico_sysio_close(int fd)
Definition sysio.c:776
padico_string_t padico_topo_node_serialize(padico_topo_node_t node)
Definition topo-xml.c:168
padico_topo_node_t padico_topo_getlocalnode(void)
Definition topology.c:1891
const char * padico_topo_node_getname(padico_topo_node_t node)
Get the canonical name of a node.
Definition topology.c:1917
const struct in_addr * padico_topo_host_getaddr(padico_topo_host_t host)
Get the canonical IP address of a host.
Definition topology.c:1977
padico_topo_uuid_t padico_topo_node_getuuid(padico_topo_node_t node)
Get the UUID of a node.
Definition topology.c:1912
padico_topo_host_t padico_topo_host_resolvebyname(const char *hostname)
resolve a host from name
Definition topology.c:2681
const char * padico_topo_node_getsession(padico_topo_node_t node)
Get the boot session ID.
Definition topology.c:1922
void recv_msg(int fd, unsigned char *buffer, int size)
Definition io-helpers.c:96
padico_topo_node_t node
Definition na-control.c:65
int port_offset
Definition sf-srtun.c:102
Interface: "PadicoBootstrap" Connection for PadicoControl with implicit address
int(* bootstrap_new)(void *_status)
create a new listening bootstrap endpoint.
Interface: "PadicoControl".
void(* send_common)(void *_status, padico_topo_node_t node, padico_control_msg_t msg)
A control message.
Definition na-control.c:57
puk_instance_t instance
self as an instance (used for interactions with padico_control_*)
LIBSSH2_CHANNEL * channel
const char * ssh_cipher
struct ssh2_openssh_s openssh
padico_topo_node_t peer
peer node
padico_sysio_t in_io
IO handler (used for receipt only)
padico_req_t req
request object used for asynchronous connection
LIBSSH2_SESSION * session
puk_context_t context
pthread_cond_t connection_event
condition signaled upon connection event
enum ssh2_control_state_e state
whether the channel is connected
pthread_mutex_t lock
Node UUID, in plain text (hex encoding)
static int port
Definition vrp-test.c:15