comparison src/goodjava/lucene/backup/BackupServer.java @ 1698:2dbcc8360a3e

backup security
author Franklin Schmidt <fschmidt@gmail.com>
date Mon, 27 Jun 2022 20:51:49 -0600
parents aff2309ae510
children
comparison
equal deleted inserted replaced
1697:aff2309ae510 1698:2dbcc8360a3e
120 backup = getBackup(name); 120 backup = getBackup(name);
121 rpc.write(Rpc.OK); 121 rpc.write(Rpc.OK);
122 } else if( backup != null ) { 122 } else if( backup != null ) {
123 backup.handle(rpc,call); 123 backup.handle(rpc,call);
124 } else if( call.cmd.equals("copy") ) { 124 } else if( call.cmd.equals("copy") ) {
125 try {
126 if( !IoUtils.getInetAddresses().contains(rpc.socket.getInetAddress()) ) {
127 rpc.write( new RpcException("only localhost allowed") );
128 rpc.close();
129 return;
130 }
131 } catch(IOException e) {
132 throw new RuntimeException(e);
133 }
125 String dirName = (String)call.args[0]; 134 String dirName = (String)call.args[0];
126 copy(new File(dirName)); 135 copy(new File(dirName));
127 rpc.write(Rpc.OK); 136 rpc.write(Rpc.OK);
128 } else { 137 } else {
129 rpc.write( new RpcException("login expected") ); 138 rpc.write( new RpcException("login expected") );