时间:2022-05-22来源:www.pcxitongcheng.com作者:电脑系统城
如下图:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
<? xml version = "1.0" encoding = "UTF-8" ?> <!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> < server xmlns = "http://mina.apache.org/ftpserver/spring/v1" xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://mina.apache.org/ftpserver/spring/v1 https://mina.apache.org/ftpserver-project/ftpserver-1.0.xsd " id = "myServer" > < listeners > < nio-listener name = "default" port = "21" > < ssl > < keystore file = "./res/ftpserver.jks" password = "password" /> </ ssl > </ nio-listener > </ listeners > < file-user-manager file = "./res/conf/users.properties" /> </ server > |
目前数据库管理用户时采用的明文存储,salted和md5的方式没有测试成功,如有测试成功的朋友请指导一下。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
<? xml version = "1.0" encoding = "UTF-8" ?> <!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> < server xmlns = "http://mina.apache.org/ftpserver/spring/v1" xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance" xmlns:beans = "http://www.springframework.org/schema/beans" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://mina.apache.org/ftpserver/spring/v1 http://mina.apache.org/ftpserver/ftpserver-1.0.xsd " id = "myServer" > < listeners > < nio-listener name = "default" port = "21" > < ssl > < keystore file = "./res/ftpserver.jks" password = "password" /> </ ssl > </ nio-listener > </ listeners > < db-user-manager encrypt-passwords = "clear" > < data-source > < beans:bean class = "org.apache.commons.dbcp2.BasicDataSource" > < beans:property name = "driverClassName" value = "com.mysql.jdbc.Driver" /> < beans:property name = "url" value = "jdbc:mysql://localhost/ftpserver" /> < beans:property name = "username" value = "root" /> < beans:property name = "password" value = "123456" /> </ beans:bean > </ data-source > < insert-user >INSERT INTO FTP_USER (userid, userpassword, homedirectory, enableflag, writepermission, idletime, uploadrate, downloadrate) VALUES ('{userid}', '{userpassword}', '{homedirectory}', {enableflag}, {writepermission}, {idletime}, {uploadrate}, {downloadrate}) </ insert-user > < update-user >UPDATE FTP_USER SET userpassword='{userpassword}',homedirectory='{homedirectory}',enableflag={enableflag},writepermission={writepermission},idletime={idletime},uploadrate={uploadrate},downloadrate={downloadrate} WHERE userid='{userid}' </ update-user > < delete-user >DELETE FROM FTP_USER WHERE userid = '{userid}' </ delete-user > < select-user >SELECT userid, userpassword, homedirectory, enableflag, writepermission, idletime, uploadrate, downloadrate, maxloginnumber, maxloginperip FROM FTP_USER WHERE userid = '{userid}' </ select-user > < select-all-users > SELECT userid FROM FTP_USER ORDER BY userid </ select-all-users > < is-admin >SELECT userid FROM FTP_USER WHERE userid='{userid}' AND userid='admin' </ is-admin > < authenticate >SELECT userpassword from FTP_USER WHERE userid='{userid}' </ authenticate > </ db-user-manager > </ server > |
注意:org.apache.commons.dbcp2.BasicDataSource,看最新的commons.dbcp命名空间和1.x版本有区别
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
<? xml version = "1.0" encoding = "UTF-8" ?> <!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> < server xmlns = "http://mina.apache.org/ftpserver/spring/v1" xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance" xmlns:beans = "http://www.springframework.org/schema/beans" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://mina.apache.org/ftpserver/spring/v1 http://mina.apache.org/ftpserver/ftpserver-1.0.xsd " id = "myServer" > < listeners > < nio-listener name = "default" port = "21" > < ssl > < keystore file = "./res/ftpserver.jks" password = "password" /> </ ssl > </ nio-listener > </ listeners > < db-user-manager encrypt-passwords = "clear" > < data-source > < beans:bean class = "org.apache.commons.dbcp2.BasicDataSource" > < beans:property name = "driverClassName" value = "org.sqlite.JDBC" /> < beans:property name = "url" value = "jdbc:sqlite:ftp.db" /> </ beans:bean > </ data-source > < insert-user >INSERT INTO FTP_USER (userid, userpassword, homedirectory, enableflag, writepermission, idletime, uploadrate, downloadrate) VALUES ('{userid}', '{userpassword}', '{homedirectory}', {enableflag}, {writepermission}, {idletime}, {uploadrate}, {downloadrate}) </ insert-user > < update-user >UPDATE FTP_USER SET userpassword='{userpassword}',homedirectory='{homedirectory}',enableflag={enableflag},writepermission={writepermission},idletime={idletime},uploadrate={uploadrate},downloadrate={downloadrate} WHERE userid='{userid}' </ update-user > < delete-user >DELETE FROM FTP_USER WHERE userid = '{userid}' </ delete-user > < select-user >SELECT userid, userpassword, homedirectory, enableflag, writepermission, idletime, uploadrate, downloadrate, maxloginnumber, maxloginperip FROM FTP_USER WHERE userid = '{userid}' </ select-user > < select-all-users > SELECT userid FROM FTP_USER ORDER BY userid </ select-all-users > < is-admin >SELECT userid FROM FTP_USER WHERE userid='{userid}' AND userid='admin' </ is-admin > < authenticate >SELECT userpassword from FTP_USER WHERE userid='{userid}' </ authenticate > </ db-user-manager > </ server > |
注意:commons的jar包还保留着,多了个操作sqlitejdbc的jar包,下载地址:GitHub - xerial/sqlite-jdbc: SQLite JDBC Driver
需下载tomcat包,目前测试的这个版本可行tomcat-7 v7.0.109 (apache.org)
放入apache ftpserver bin目录里替换原有的ftpd.exe
这样安装为服务的时候就可以正常启动了
自己搞了个python脚本,采用了sqlalchemy来操作数据库
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
from sqlalchemy import create_engine from sqlalchemy import MetaData,Table,Column,Boolean,Integer,String import os engine = create_engine( 'sqlite:///ftp.db' ) conn = engine.connect() metadata = MetaData() ftpusers = Table( 'FTP_USER' ,metadata, Column( 'userid' ,String( 64 ),primary_key = True ), Column( 'userpassword' ,String( 64 ),nullable = False ), Column( 'homedirectory' ,String( 128 ),nullable = False ), Column( 'enableflag' ,Boolean(),default = True ), Column( 'writepermission' ,Boolean(),default = True ), Column( 'idletime' ,Integer(),default = 0 ), Column( 'uploadrate' ,Integer(),default = 0 ), Column( 'downloadrate' ,Integer(),default = 0 ), Column( 'maxloginnumber' ,Integer(),default = 0 ), Column( 'maxloginperip' ,Integer(),default = 0 ) ) metadata.create_all(engine) def addgeneraluser(): deluser = ftpusers.delete().where(ftpusers.c.userid = = "nic" ) rs = conn.execute(deluser) dirname = "./files/alluser" if not os.path.exists(dirname): os.mkdir(dirname) ins = ftpusers.insert().values( userid = "nic" , userpassword = "123321" , homedirectory = dirname, writepermission = 0 , maxloginnumber = 1 ) result = conn.execute(ins) def addadmin(): deladmin = ftpusers.delete().where(ftpusers.c.userid = = "admin" ) rs = conn.execute(deladmin) ins = ftpusers.insert().values( userid = "admin" , userpassword = "123456" , homedirectory = "./files" , writepermission = 1 ) result = conn.execute(ins) def getusers(): sel = ftpusers.select() rs = conn.execute(sel) print (rs.fetchall()) addgeneraluser() getusers() |
可以方便的增加用户了,generaluser只读权限只能同时登录一个,admin权限可读写,不限制。
2023-03-17
Nginx主机域名配置实现2023-03-17
Nginx配置-日志格式配置方式2023-03-17
Apache APISIX Dashboard 未授权访问漏洞分析(CVE-2021-45232)正常项目无法访问(Linux 服务器),启动tomcat时卡在下图位置,项目无法启动。1、先检查tomcat日志、项目日志没有报错信息,且没再产生新的日志信息。2、jdk、tomcat 、 jvm 配置,服...
2023-03-15
这篇文章主要介绍了Kubernetes中Nginx服务启动失败排查流程(Error: ImagePullBackOff),本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以...
2023-03-15