Services

Parses /etc/services

Author: Raphael Pinson rap.nosp@m.hink@gmai.nosp@m.l.com

Summary
ServicesParses /etc/services
ReferenceThis lens tries to keep as close as possible to ‘man services’ where possible.
LicenseThis file is licensed under the GPL.
Lens UsageSample usage of this lens in augtool
Configuration filesThis lens applies to /etc/services.
USEFUL PRIMITIVES
Generic primitives
eol
Separators
LENSES
port
protocol
alias
recordA standard /etc/services record TODO: make sure a space is added before a comment on new nodes
lns

Reference

This lens tries to keep as close as possible to ‘man services’ where possible.

The definitions from ‘man services’ are put as commentaries for reference throughout the file.  More information can be found in the manual.

License

This file is licensed under the GPL.

Lens Usage

Sample usage of this lens in augtool

  • Get the name of the service running on port 22 with protocol tcp
match "/files/etc/services/service-name[port = '22'][protocol = 'tcp']"
  • Remove the tcp entry for “domain” service
rm "/files/etc/services/service-name[. = 'domain'][protocol = 'tcp']"
  • Add a tcp service named “myservice” on port 55234
ins service-name after /files/etc/services/service-name[last()]
set /files/etc/services/service-name[last()] "myservice"
set "/files/etc/services/service-name[. = 'myservice']/port" "55234"
set "/files/etc/services/service-name[. = 'myservice']/protocol" "tcp"

Configuration files

This lens applies to /etc/services.  See <filter>.

USEFUL PRIMITIVES

Generic primitives

eol

let eol = del /[ \t]*(#)?[ \t]*\n/ "\n"

Separators

LENSES

port

let port = [ label "port" . store num_re ]

protocol

let protocol = [ label "protocol" . store protocol_re ]

alias

let alias = [ label "alias" . store word_re ]

record

let record = [ label "service-name" . store word_re . sep_spc . port . del "/" "/" . protocol . ( sep_spc . alias )* . (comment|eol) ]

A standard /etc/services record TODO: make sure a space is added before a comment on new nodes

lns

let lns = (empty | comment record)*
let eol = del /[ \t]*(#)?[ \t]*\n/ "\n"
let port = [ label "port" . store num_re ]
let protocol = [ label "protocol" . store protocol_re ]
let alias = [ label "alias" . store word_re ]
let record = [ label "service-name" . store word_re . sep_spc . port . del "/" "/" . protocol . ( sep_spc . alias )* . (comment|eol) ]
A standard /etc/services record TODO: make sure a space is added before a comment on new nodes
let lns = (empty | comment record)*
Close