mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-09 18:04:25 +09:00
changed config file name, take rsa,dsa and port into account
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@28 7dcaeef0-15fb-0310-b436-a5af3365683c
This commit is contained in:
@@ -45,6 +45,7 @@ SSH_OPTIONS *ssh_options_new(){
|
|||||||
|
|
||||||
void ssh_options_set_port(SSH_OPTIONS *opt, unsigned int port){
|
void ssh_options_set_port(SSH_OPTIONS *opt, unsigned int port){
|
||||||
opt->port=port&0xffff;
|
opt->port=port&0xffff;
|
||||||
|
opt->bindport=port&0xffff;
|
||||||
}
|
}
|
||||||
SSH_OPTIONS *ssh_options_copy(SSH_OPTIONS *opt){
|
SSH_OPTIONS *ssh_options_copy(SSH_OPTIONS *opt){
|
||||||
SSH_OPTIONS *ret=ssh_options_new();
|
SSH_OPTIONS *ret=ssh_options_new();
|
||||||
@@ -391,7 +392,7 @@ int ssh_options_getopt(SSH_OPTIONS *options, int *argcptr, char **argv){
|
|||||||
if(cont && localaddr)
|
if(cont && localaddr)
|
||||||
ssh_options_set_bind(options,localaddr,0);
|
ssh_options_set_bind(options,localaddr,0);
|
||||||
ssh_options_set_port(options,port);
|
ssh_options_set_port(options,port);
|
||||||
options->bindport=port;
|
//options->bindport=port;
|
||||||
ssh_options_allow_ssh1(options,ssh1);
|
ssh_options_allow_ssh1(options,ssh1);
|
||||||
ssh_options_allow_ssh2(options,ssh2);
|
ssh_options_allow_ssh2(options,ssh2);
|
||||||
|
|
||||||
|
|||||||
@@ -24,17 +24,21 @@ LIBSSH_LDFLAGS = -shared
|
|||||||
|
|
||||||
all: sftp_server
|
all: sftp_server
|
||||||
|
|
||||||
main.o: server.h
|
main.o: server.h libconfig/libconfig.h
|
||||||
list.o: server.h
|
list.o: server.h libconfig/libconfig.h
|
||||||
config.o: server.h
|
protocol.o: server.h libconfig/libconfig.h
|
||||||
libconfig/libconfig.a: libconfig/config.h
|
userauth.o: server.h libconfig/libconfig.h
|
||||||
|
config.o: server.h libconfig/libconfig.h
|
||||||
|
|
||||||
|
libconfig/libconfig.a: libconfig/libconfig.h
|
||||||
make -C libconfig/
|
make -C libconfig/
|
||||||
../libssh/libssh.a:
|
../libssh/libssh.a:
|
||||||
make -C ../libssh/ libssh.a
|
make -C ../libssh/ libssh.a
|
||||||
libconfig/config.h:
|
libconfig/libconfig.h:
|
||||||
cd libconfig ; ./configure ; cd ..
|
cd libconfig ; ./configure ; cd ..
|
||||||
|
make -C libconfig/
|
||||||
sftp_server: $(OBJECTS)
|
sftp_server: $(OBJECTS)
|
||||||
|
make -C ../libssh libssh.a
|
||||||
$(CC) -o sftp_server $(OBJECTS) $(LIBS) $(LDFLAGS)
|
$(CC) -o sftp_server $(OBJECTS) $(LIBS) $(LDFLAGS)
|
||||||
install: all
|
install: all
|
||||||
$(top_srcdir)/mkinstalldirs $(incldir)
|
$(top_srcdir)/mkinstalldirs $(incldir)
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ libconfig/libconfig.h:
|
|||||||
cd libconfig ; ./configure ; cd ..
|
cd libconfig ; ./configure ; cd ..
|
||||||
make -C libconfig/
|
make -C libconfig/
|
||||||
sftp_server: $(OBJECTS)
|
sftp_server: $(OBJECTS)
|
||||||
|
make -C ../libssh libssh.a
|
||||||
$(CC) -o sftp_server $(OBJECTS) $(LIBS) $(LDFLAGS)
|
$(CC) -o sftp_server $(OBJECTS) $(LIBS) $(LDFLAGS)
|
||||||
install: all
|
install: all
|
||||||
$(top_srcdir)/mkinstalldirs $(incldir)
|
$(top_srcdir)/mkinstalldirs $(incldir)
|
||||||
|
|||||||
@@ -292,7 +292,7 @@ int parse_config(char *file){
|
|||||||
printf("lc_process_file=%d,%s\n",r,lc_geterrstr());
|
printf("lc_process_file=%d,%s\n",r,lc_geterrstr());
|
||||||
lc_cleanup();
|
lc_cleanup();
|
||||||
//list_config();
|
//list_config();
|
||||||
return 0;
|
return r<0;
|
||||||
}
|
}
|
||||||
|
|
||||||
list *find_groups(char *user){
|
list *find_groups(char *user){
|
||||||
|
|||||||
@@ -76,10 +76,27 @@ int main(int argc, char **argv){
|
|||||||
SSH_BIND *ssh_bind;
|
SSH_BIND *ssh_bind;
|
||||||
CHANNEL *chan=NULL;
|
CHANNEL *chan=NULL;
|
||||||
SFTP_SESSION *sftp=NULL;
|
SFTP_SESSION *sftp=NULL;
|
||||||
|
int ret;
|
||||||
ssh_options_getopt(options,&argc,argv);
|
ssh_options_getopt(options,&argc,argv);
|
||||||
parse_config("sftp.conf");
|
if(argc>1)
|
||||||
ssh_options_set_dsa_server_key(options,"/etc/ssh/ssh_host_dsa_key");
|
ret=parse_config(argv[1]);
|
||||||
ssh_options_set_rsa_server_key(options,"/etc/ssh/ssh_host_rsa_key");
|
else
|
||||||
|
ret=parse_config("mercurius.conf");
|
||||||
|
if(ret != 0){
|
||||||
|
printf("Error parsing configuration file\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if(!rsa && !dsa){
|
||||||
|
printf("There must be at least one RSA or DSA host key\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if(dsa)
|
||||||
|
ssh_options_set_dsa_server_key(options,dsa);
|
||||||
|
if(rsa)
|
||||||
|
ssh_options_set_rsa_server_key(options,rsa);
|
||||||
|
printf("port : %d\n",port);
|
||||||
|
if(port!=0)
|
||||||
|
ssh_options_set_port(options,port);
|
||||||
ssh_bind=ssh_bind_new();
|
ssh_bind=ssh_bind_new();
|
||||||
ssh_bind_set_options(ssh_bind,options);
|
ssh_bind_set_options(ssh_bind,options);
|
||||||
if(ssh_bind_listen(ssh_bind)<0){
|
if(ssh_bind_listen(ssh_bind)<0){
|
||||||
|
|||||||
@@ -24,7 +24,10 @@ typedef struct list_struct {
|
|||||||
list *list_add(list *ptr, const char *key, void *data);
|
list *list_add(list *ptr, const char *key, void *data);
|
||||||
void *list_find(list *ptr, const char *key);
|
void *list_find(list *ptr, const char *key);
|
||||||
void list_set(list *ptr, const char *key, void *data);
|
void list_set(list *ptr, const char *key, void *data);
|
||||||
|
/* config.c */
|
||||||
|
extern int port;
|
||||||
|
extern char *dsa;
|
||||||
|
extern char *rsa;
|
||||||
struct group {
|
struct group {
|
||||||
list *users;
|
list *users;
|
||||||
char *chroot;
|
char *chroot;
|
||||||
|
|||||||
Reference in New Issue
Block a user