mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-04 12:20:42 +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){
|
||||
opt->port=port&0xffff;
|
||||
opt->bindport=port&0xffff;
|
||||
}
|
||||
SSH_OPTIONS *ssh_options_copy(SSH_OPTIONS *opt){
|
||||
SSH_OPTIONS *ret=ssh_options_new();
|
||||
@@ -391,7 +392,7 @@ int ssh_options_getopt(SSH_OPTIONS *options, int *argcptr, char **argv){
|
||||
if(cont && localaddr)
|
||||
ssh_options_set_bind(options,localaddr,0);
|
||||
ssh_options_set_port(options,port);
|
||||
options->bindport=port;
|
||||
//options->bindport=port;
|
||||
ssh_options_allow_ssh1(options,ssh1);
|
||||
ssh_options_allow_ssh2(options,ssh2);
|
||||
|
||||
|
||||
@@ -24,17 +24,21 @@ LIBSSH_LDFLAGS = -shared
|
||||
|
||||
all: sftp_server
|
||||
|
||||
main.o: server.h
|
||||
list.o: server.h
|
||||
config.o: server.h
|
||||
libconfig/libconfig.a: libconfig/config.h
|
||||
main.o: server.h libconfig/libconfig.h
|
||||
list.o: server.h libconfig/libconfig.h
|
||||
protocol.o: server.h libconfig/libconfig.h
|
||||
userauth.o: server.h libconfig/libconfig.h
|
||||
config.o: server.h libconfig/libconfig.h
|
||||
|
||||
libconfig/libconfig.a: libconfig/libconfig.h
|
||||
make -C libconfig/
|
||||
../libssh/libssh.a:
|
||||
make -C ../libssh/ libssh.a
|
||||
libconfig/config.h:
|
||||
libconfig/libconfig.h:
|
||||
cd libconfig ; ./configure ; cd ..
|
||||
make -C libconfig/
|
||||
sftp_server: $(OBJECTS)
|
||||
|
||||
make -C ../libssh libssh.a
|
||||
$(CC) -o sftp_server $(OBJECTS) $(LIBS) $(LDFLAGS)
|
||||
install: all
|
||||
$(top_srcdir)/mkinstalldirs $(incldir)
|
||||
|
||||
@@ -38,7 +38,7 @@ libconfig/libconfig.h:
|
||||
cd libconfig ; ./configure ; cd ..
|
||||
make -C libconfig/
|
||||
sftp_server: $(OBJECTS)
|
||||
|
||||
make -C ../libssh libssh.a
|
||||
$(CC) -o sftp_server $(OBJECTS) $(LIBS) $(LDFLAGS)
|
||||
install: all
|
||||
$(top_srcdir)/mkinstalldirs $(incldir)
|
||||
|
||||
@@ -292,7 +292,7 @@ int parse_config(char *file){
|
||||
printf("lc_process_file=%d,%s\n",r,lc_geterrstr());
|
||||
lc_cleanup();
|
||||
//list_config();
|
||||
return 0;
|
||||
return r<0;
|
||||
}
|
||||
|
||||
list *find_groups(char *user){
|
||||
|
||||
@@ -69,17 +69,34 @@ CHANNEL *recv_channel(SSH_SESSION *session){
|
||||
return NULL;
|
||||
return chan;
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv){
|
||||
SSH_OPTIONS *options=ssh_options_new();
|
||||
SSH_SESSION *session;
|
||||
SSH_BIND *ssh_bind;
|
||||
CHANNEL *chan=NULL;
|
||||
SFTP_SESSION *sftp=NULL;
|
||||
int ret;
|
||||
ssh_options_getopt(options,&argc,argv);
|
||||
parse_config("sftp.conf");
|
||||
ssh_options_set_dsa_server_key(options,"/etc/ssh/ssh_host_dsa_key");
|
||||
ssh_options_set_rsa_server_key(options,"/etc/ssh/ssh_host_rsa_key");
|
||||
if(argc>1)
|
||||
ret=parse_config(argv[1]);
|
||||
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_set_options(ssh_bind,options);
|
||||
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);
|
||||
void *list_find(list *ptr, const char *key);
|
||||
void list_set(list *ptr, const char *key, void *data);
|
||||
|
||||
/* config.c */
|
||||
extern int port;
|
||||
extern char *dsa;
|
||||
extern char *rsa;
|
||||
struct group {
|
||||
list *users;
|
||||
char *chroot;
|
||||
|
||||
Reference in New Issue
Block a user