Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
LSH
lsh
Commits
e74bdfa7
Commit
e74bdfa7
authored
Oct 17, 1998
by
Niels Möller
Browse files
Work in progress.
Rev: src/service.c:1.2 Rev: src/service.h:1.2 Rev: src/userauth.h:1.2
parent
5f90ae23
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/service.c
View file @
e74bdfa7
...
...
@@ -22,6 +22,7 @@
*/
#include
"service.h"
#include
"format.h"
struct
service_handler
{
...
...
@@ -29,6 +30,11 @@ struct service_handler
struct
alist
*
services
;
};
struct
lsh_string
*
format_service_accept
(
int
name
)
{
return
ssh_format
(
"%c%a"
,
SSH_MSG_SERVICE_ACCEPT
,
name
);
}
static
int
do_service
(
struct
packet_handler
*
c
,
struct
ssh_connection
*
connection
,
struct
lsh_string
*
packet
)
...
...
@@ -51,11 +57,18 @@ static int do_service(struct packet_handler *c,
struct
ssh_service
*
service
;
if
(
!
name
||
!
(
service
=
ALIST_GET
(
closure
->
services
,
name
)))
/* FIXME: Send a disconnect message */
return
LSH_FAIL
|
LSH_DIE
;
return
SERVICE_INIT
(
service
,
connection
);
||
!
(
service
=
ALIST_GET
(
closure
->
services
,
name
))
||
!
SERVICE_INIT
(
service
,
connection
))
{
int
res
=
A_WRITE
(
c
->
write
,
format_disconnect
(
SSH_DISCONNECT_SERVICE_NOT_AVAILABLE
,
"Service not available.
\n
"
));
return
(
LSH_PROBLEMP
(
res
)
?
LSH_FAIL
|
LSH_DIE
:
LSH_FAIL
|
LSH_CLOSE
);
}
return
A_WRITE
(
c
->
write
(
service_accept
(
name
)));
}
return
LSH_FAIL
|
LSH_DIE
;
}
...
...
src/service.h
View file @
e74bdfa7
...
...
@@ -27,6 +27,8 @@
#include
"connection.h"
/* Used on both client and server side */
/* The init function only returns 1 on success, 0 on failure. */
struct
ssh_service
{
int
(
init
*
)(
struct
ssh_service
*
self
,
struct
ssh_connection
*
c
);
...
...
@@ -37,6 +39,8 @@ struct ssh_service
/* services is an alist mapping names to service objects */
struct
packet_handler
*
make_service_handler
(
struct
alist
*
services
);
struct
lsh_string
*
format_service_request
(
int
name
);
int
request_service
(
int
name
,
struct
ssh_service
*
service
);
#endif
/* LSH_SERVICE_H_INCLUDED */
src/userauth.h
View file @
e74bdfa7
...
...
@@ -24,4 +24,25 @@
#ifndef LSH_USERAUTH_H_INCLUDED
#define LSH_USERAUTH_H_INCLUDED
#include
"lsh_types.h"
/* Returns 0 if the request is somehow invalid. Otheerwise, returns 1,
* and sets SERVICE non-NULL iff access is granted. */
/* FIXME: Something more general is needed for authentication methods
* which send additional messages. */
struct
userauth
{
struct
lsh_object
header
;
int
(
*
authenticate
)(
struct
userauth
*
self
,
lsh_string
*
user
,
int
requested_service
,
struct
simple_buffer
*
args
,
struct
ssh_service
**
service
);
};
#define AUTHENTICATE(s, u, r, a, g) \
((s)->authenticate((s), (u), (r), (a), (g)))
#endif
/* LSH_USERAUTH_H_INCLUDED */
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment