fipolate

2014-10-12 23:16 UTC
  • Xyne

Metadata

Description:

Interpolate text files with variables through a fifo via user prompts.

Latest Version:

2013.3

Architecture:

  • any

Dependencies:

  • python3
  • python-pyinotify

Arch Repositories:

  • [xyne-any]
  • [xyne-i686]
  • [xyne-x86_64]

AUR ID:

66424

Arch Forum ID:

156444

Tags:

About

Fipolate was written to deal with wpa_supplicant files containing passwords. Instead of writing a file with passwords to disk, a template file can be created with placeholder variables. Fipolate will read this file and prompt the user when it encounters variables in the file. It will then send the interpolated file to a named pipe (FIFO) through which it can be read by other applications as necessary.

Example

Fipolate uses a regular rexpression to determine variables in the input file. The default regular rexpression is

<%(\*)?(.+?)%>

The regular expression contains two capturing groups. The first is an indicator for password fields ("*"). The second is the variable name. The rest of the pattern is just a delimiter that should only appear around variables in the input file.

To make this clear, here is an example input file (input.txt):

network={
  ssid="cryptonet"
  key_mgmt=WPA-EAP
  eap=PEAP
  identity="<%identity%>"
  password="<%*password%>"
}

The two variables are identity and password. Both are delimited with <% and %>. The password is marked as a password prompt by the *, which is the first capturing group in the default regular expression.

$ fipolate tmp.fifo input.txt
identity: foo
password:

$ cat tmp.fifo
network={
  ssid="cryptonet"
  key_mgmt=WPA-EAP
  eap=PEAP
  identity="foo"
  password="supersecretpassword"
}

To use %%% as the delimiter on both sides and pass: as the password indicator, the regular expression would be:

%%%(pass:)?(.+?)%%%

The input file would then be

network={
  ssid="cryptonet"
  key_mgmt=WPA-EAP
  eap=PEAP
  identity="%%%identity%%%"
  password="%%%pass:password%%%"
}

The regular expression can always be chosen in a way to ensure that only the user-defined variables are interpolated in the input file.

TODO

  • Determine if it is possible to detect a waiting application on the other end of the pipe. This could be used to control writing instead of the interval option.

Help Message

$ fipolate --help

usage: fipolate [-h] [--to-file] [-m <octal mode>] [-r <regex>]
                <fifo path> <input file path>

Interpolate an input file with user-defined variables.

positional arguments:
  <fifo path>           The output FIFO or file path.
  <input file path>     The input file to interpolate.

optional arguments:
  -h, --help            show this help message and exit
  --to-file             Write to a regular file instead of a FIFO.
  -m <octal mode>, --mode <octal mode>
                        The mode of the output fifo/file. It must be user-
                        readable. (default: 600)
  -r <regex>, --regex <regex>
                        The regular expression for interpolation. It must
                        contain two capturing groups. The first determines if
                        getpass is used to prompt for the replacement. The
                        second determines the prompt itself. (default:
                        <%(\*)?(.+?)%>)

CHANGELOG

2013-02-12

  • added inotify event watching via pyinotify to track when other end of pipe is closes
  • removed unnecessary block and interval options
  • fixed bug in mode option
  • added FIFO checks to avoid problems in unexpected events such FIFO deletion while running
Contact
echo xyne.archlinux.ca | sed 's/\./@/'
Feeds
Blog News
Validation
XHTML 1.0 Strict CSS level 3 Atom 1.0