1
0
mirror of https://github.com/kellyjonbrazil/jc.git synced 2025-06-17 00:07:37 +02:00
Files
jc/docs/parsers/shadow.md
2022-01-25 17:07:47 -08:00

2.4 KiB

Home

jc.parsers.shadow

jc - JSON CLI output utility /etc/shadow file parser

Usage (cli):

$ sudo cat /etc/shadow | jc --shadow

Usage (module):

import jc result = jc.parse('shadow', shadow_file_output)

or

import jc.parsers.shadow result = jc.parsers.shadow.parse(shadow_file_output)

Schema:

[ { "username": string, "password": string, "last_changed": integer, "minimum": integer, "maximum": integer, "warn": integer, "inactive": integer, "expire": integer } ]

Examples:

$ sudo cat /etc/shadow | jc --shadow -p [ {

  • "username" - "root",

  • "password" - "*",

  • "last_changed" - 18113,

  • "minimum" - 0,

  • "maximum" - 99999,

  • "warn" - 7,

  • "inactive" - null,

  • "expire" - null }, {

  • "username" - "daemon",

  • "password" - "*",

  • "last_changed" - 18113,

  • "minimum" - 0,

  • "maximum" - 99999,

  • "warn" - 7,

  • "inactive" - null,

  • "expire" - null }, {

  • "username" - "bin",

  • "password" - "*",

  • "last_changed" - 18113,

  • "minimum" - 0,

  • "maximum" - 99999,

  • "warn" - 7,

  • "inactive" - null,

  • "expire" - null }, ... ]

    $ sudo cat /etc/shadow | jc --shadow -p -r [ {

  • "username" - "root",

  • "password" - "*",

  • "last_changed" - "18113",

  • "minimum" - "0",

  • "maximum" - "99999",

  • "warn" - "7",

  • "inactive" - "",

  • "expire" - "" }, {

  • "username" - "daemon",

  • "password" - "*",

  • "last_changed" - "18113",

  • "minimum" - "0",

  • "maximum" - "99999",

  • "warn" - "7",

  • "inactive" - "",

  • "expire" - "" }, {

  • "username" - "bin",

  • "password" - "*",

  • "last_changed" - "18113",

  • "minimum" - "0",

  • "maximum" - "99999",

  • "warn" - "7",

  • "inactive" - "",

  • "expire" - "" }, ... ]

info Objects

class info()

Provides parser metadata (version, author, etc.)

parse

def parse(data, raw=False, quiet=False)

Main text parsing function

Arguments:

  • data - (string) text data to parse
  • raw - (boolean) unprocessed output if True
  • quiet - (boolean) suppress warning messages if True

Returns:

List of Dictionaries. Raw or processed structured data.

Parser Information

Compatibility: linux, darwin, aix, freebsd

Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com)