Skip to content

Commit

Permalink
fix: GPG bug fix when loading file (ytti#1109)
Browse files Browse the repository at this point in the history
* GPG bug fix

* Update Sources.md

* Update README.md
  • Loading branch information
elmobp authored and laf committed Nov 22, 2017
1 parent c81881d commit da89235
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -246,15 +246,12 @@ oxidized

Now tell Oxidized where it finds a list of network devices to backup configuration from. You can either use CSV or SQLite as source. To create a CSV source add the following snippet:

Note: If gpg is set to anything other than false it will attempt to decrypt the file contents
```
source:
default: csv
csv:
file: ~/.config/oxidized/router.db
delimiter: !ruby/regexp /:/
gpg: false
gpg_password: 'password'
map:
name: 0
model: 1
Expand Down
25 changes: 25 additions & 0 deletions docs/Sources.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,31 @@ Example csv `/var/lib/oxidized/router.db`:
rtr01.local:192.168.1.1:ios:oxidized:5uP3R53cR3T:T0p53cR3t
```

If you would like to use a GPG encrypted file as the source then you can use the following example:

```yaml
source:
default: csv
csv:
file: ~/.config/oxidized/router.db
delimiter: !ruby/regexp /:/
gpg: true
gpg_password: 'password'
map:
name: 0
model: 1
```
> Please note, if you are running GPG v2 then you will be prompted for your gpg password on start up, if you use GPG >= 2.1 then you can add the following config to stop that behaviour:
> Within `~/.gnupg/gpg-agent.conf`

> `allow-loopback-pinentry`

> and within: `~/.gnupg/gpg.conf`

> `pinentry-mode loopback`

### Source: SQL
Oxidized uses the `sequel` ruby gem. You can use a variety of databases that aren't explicitly listed. For more information visit https://github.com/jeremyevans/sequel Make sure you have the correct adapter!
### Source: MYSQL
Expand Down
4 changes: 2 additions & 2 deletions lib/oxidized/source/csv.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ def setup
def load
nodes = []
file = File.expand_path(@cfg.file)
file = if @cfg.gpg?
if @cfg.gpg?
crypto = GPGME::Crypto.new password: @cfg.gpg_password
crypto.decrypt(file).to_s
file = crypto.decrypt(File.open(file)).to_s
else
open(file)
end
Expand Down

0 comments on commit da89235

Please sign in to comment.