Browse Source

ktpd_session contains ksession_t

Serj Kalichev 3 years ago
parent
commit
c3449345e3
5 changed files with 17 additions and 8 deletions
  1. 3 3
      bin/klishd/klishd.c
  2. 1 2
      klish/ktp/Makefile.am
  3. 6 1
      klish/ktp/ktpd_session.c
  4. 4 1
      klish/ktp/private.h
  5. 3 1
      klish/ktp_session.h

+ 3 - 3
bin/klishd/klishd.c

@@ -256,17 +256,17 @@ err:
 	// ATTENTION: It's a forked service process
 	retval = -1; // Pessimism for service process
 
-	ktpd_session = ktpd_session_new(client_fd);
+	ktpd_session = ktpd_session_new(client_fd, scheme, NULL);
 	assert(ktpd_session);
 	if (!ktpd_session) {
-		syslog(LOG_ERR, "Can't create KTPd session");
+		syslog(LOG_ERR, "Can't create KTPd session\n");
 		close(client_fd);
 		goto err_client;
 	}
 
 //	ktpd_session_set_stall_cb(ktpd_session, fd_stall_cb, eloop);
 //	faux_eloop_add_fd(eloop, new_conn, POLLIN, client_ev, clients);
-	syslog(LOG_DEBUG, "New connection %d", client_fd);
+	syslog(LOG_DEBUG, "New connection %d\n", client_fd);
 
 	retval = 0;
 err_client:

+ 1 - 2
klish/ktp/Makefile.am

@@ -1,5 +1,4 @@
 libklish_la_SOURCES += \
 	klish/ktp/ktp.c \
 	klish/ktp/ktp_session.c \
-	klish/ktp/ktpd_session.c \
-	klish/ktp/ktpd_clients.c
+	klish/ktp/ktpd_session.c

+ 6 - 1
klish/ktp/ktpd_session.c

@@ -13,6 +13,7 @@
 #include <faux/str.h>
 #include <faux/async.h>
 #include <faux/msg.h>
+#include <klish/ksession.h>
 #include <klish/ktp.h>
 #include <klish/ktp_session.h>
 
@@ -134,7 +135,8 @@ static bool_t ktpd_session_stall_cb(faux_async_t *async,
 }
 
 
-ktpd_session_t *ktpd_session_new(int sock)
+ktpd_session_t *ktpd_session_new(int sock, const kscheme_t *scheme,
+	const char *start_entry)
 {
 	ktpd_session_t *session = NULL;
 
@@ -148,6 +150,8 @@ ktpd_session_t *ktpd_session_new(int sock)
 
 	// Init
 	session->state = KTPD_SESSION_STATE_NOT_AUTHORIZED;
+	session->ksession = ksession_new(scheme, start_entry);
+	assert(session->ksession);
 	session->async = faux_async_new(sock);
 	assert(session->async);
 	// Receive message header first
@@ -165,6 +169,7 @@ void ktpd_session_free(ktpd_session_t *session)
 	if (!session)
 		return;
 
+	ksession_free(session->ksession);
 	faux_free(session->hdr);
 	close(ktpd_session_fd(session));
 	faux_async_free(session->async);

+ 4 - 1
klish/ktp/private.h

@@ -14,7 +14,9 @@ typedef enum {
 	KTPD_SESSION_STATE_WAIT_FOR_PROCESS = 'p',
 } ktpd_session_state_e;
 
+
 struct ktpd_session_s {
+	ksession_t *ksession;
 	ktpd_session_state_e state;
 	uid_t uid;
 	gid_t gid;
@@ -40,9 +42,10 @@ struct ktp_session_s {
 	faux_net_t *net;
 };
 
-
+/*
 struct ktpd_clients_s {
 	faux_list_t *list;
 };
+*/
 
 #endif // _klish_ktp_private_h

+ 3 - 1
klish/ktp_session.h

@@ -3,6 +3,7 @@
 
 #include <faux/faux.h>
 #include <faux/list.h>
+#include <klish/ksession.h>
 
 #define USOCK_PATH_MAX sizeof(((struct sockaddr_un *)0)->sun_path)
 
@@ -24,7 +25,8 @@ bool_t ktp_session_connected(ktp_session_t *session);
 int ktp_session_fd(const ktp_session_t *session);
 
 // Server KTP session
-ktpd_session_t *ktpd_session_new(int sock);
+ktpd_session_t *ktpd_session_new(int sock, const kscheme_t *scheme,
+	const char *start_entry);
 void ktpd_session_free(ktpd_session_t *session);
 bool_t ktpd_session_connected(ktpd_session_t *session);
 int ktpd_session_fd(const ktpd_session_t *session);