ACF Libraries: Difference between revisions

From Alpine Linux
(added pidof)
m (Reverted edits by RuthHughes (talk) to last revision by Dubiousjim)
 
(44 intermediate revisions by 7 users not shown)
Line 1: Line 1:
= ACF Libraries <span style="color:red">(Using Lua Posix. Most will go away)</span>=
= ACF Libraries =
Because of using lua, a very small language, the need arises to build everything from scratch. This can lead to some confusion, apprehension, or just feeling overwhelmed. Here is documentation on what we have now in the form of libraries and common functions. We hope to build some more and use this information to get the juices flowing in regard to ACF.  
Because of using lua, a very small language, the need arises to build everything from scratch. This can lead to some confusion, apprehension, or just feeling overwhelmed. Here is documentation on what we have now in the form of libraries and common functions. We hope to build some more and use this information to get the juices flowing in regard to ACF.  


Some of these are lua libs or ones written for ACF.
Some of these are lua libs or ones written for ACF.
We are also using as a standard the lposix library which is documented here [[LPOSIX]]


== Generic Libraries (acf-lib) ==


===[[apk.lua]]===
Functions to load/unload apk packages
* delete - Deletes a package
* install - Installs a package
* version - Checks a package's installed version


== fs.lua ==
===[[date.lua]]===
Used for various filespecific functions
Date and time functions
=== is_dir ===
To be used with os.time() and os.date()
'''INPUT:'''<BR>
*date_to_seconds - Takes a date table and converts it to seconds from 1970
This library function required the following inputs/parameters.
*seconds_to_date - Takes table of seconds values and converts to a date sorted smallest to largest
* Path to directory
*string_to_table
** Example: /var/log/snort
*date_diff - Takes two values of seconds and gives back the difference
'''OUTPUT:'''<BR>
*num_month_name - Month number to name of month
This library function deliverers the following output/parameters.
*num_month_name_abr - Month number to abr of month
* '''''nil''''' or "directory"
*name_month_num - Month name to number
** If inputstring is a existing directory, the output is "directory" (not '''''nil''''')
*abr_month_num - Month abbreviation to number
'''CODING EXAMPLE:'''
*num_dow_name - Day of Week number to name
-- Include/Call for this library
*num_dow_name_abr - Day of week number to abbreviation
require("fs")
*name_dow_num - Day of Week full name to number
-- Check if url is a folder
*abr_dow_num - Day of week abbreviation to number
liboutput = fs.is_dir("/var/log/snort")
*what_tz - Checks to see what timezone the box is set to; /etc/TZ
If directory exist 'liboutput' would contain string:
*change_tz - Changes the timezone
directory
**Tables are included with this information
In directory is missing 'liboutput' would contain '''''nil''''' (nothing).
***Timezones
=== is_file ===
***Days of Week
'''INPUT:'''<BR>
***Months of the Year
This library function required the following inputs/parameters.
* Path to file
** Example: /var/log/messages
'''OUTPUT:'''<BR>
This library function deliverers the following output/parameters.
* '''''nil''''' or "file"
** If inputstring is a existing file, the output is "file" (not '''''nil''''')
'''CODING EXAMPLE:'''
-- Include/Call for this library
require("fs")
-- Check if url is a file
liboutput = fs.is_file("/var/log/messages")
If file exist 'liboutput' would contain string:
file
In file is missing 'liboutput' would contain '''''nil''''' (nothing).
=== read_file / read_file_as_array ===
'''INPUT:'''<BR>
This library function required the following inputs/parameters.
* Path to file
** Example: /var/log/messages
'''OUTPUT:'''<BR>
This library function deliverers the following output/parameters.
* Filecontent
** The filecontent is presented as a string (output comes as a table if 'read_file_as_array' is used)
'''CODING EXAMPLE:'''
-- Include/Call for this library
require("fs")
-- Get filecontent
liboutput = fs.read_file("/var/log/messages")
'liboutput' could contain something like:
Nov  6 13:17:01 inspiron /USR/SBIN/CRON[21751]: (root) CMD (  cd / && run-parts --report /etc/cron.hourly)
Nov  6 13:43:31 inspiron -- MARK --
'''CODING EXAMPLE (read_file_as_array):'''<BR>
If 'read_file_as_array' is used, you could do something like this see the output:
for a,b in ipairs(liboutput) do print(a,b) end
The output would look something like:
1 Nov  6 13:17:01 inspiron /USR/SBIN/CRON[21751]: (root) CMD (  cd / && run-parts --report /etc/cron.hourly)
2 Nov  6 13:43:31 inspiron -- MARK --
=== write_file ===
'''INPUT:'''<BR>
This library function required the following inputs/parameters.
* Path to file
** Example: /root/mynotes
* String
** Content that should be written to file
'''OUTPUT:'''<BR>
This library function deliverers the following output/parameters.
* Output is written to file
** The content of the inputstring is written to the file.
** <span style="color:red">Data is appended to file '''''(not sure)'''''</span>
'''CODING EXAMPLE:'''
-- Include/Call for this library
require("fs")
-- Write to file
fs.write_file("/var/log/messages", "Hello World!")
=== find ===
Lets you search for dir entries matching filespec.<BR>
<span style="color:red">Could be compared to 'find / -type d | grep tmp' '''''(not sure)'''''</span><BR>
'''INPUT:'''<BR>
This library function required the following inputs/parameters.
* SearchString
** This string is what we are searching for in the dirnames.
* Path
** This path is where we start searching
** <span style="color:red">Search is recursive '''''(not sure)'''''</span>
'''OUTPUT:'''<BR>
This library function deliverers the following output/parameters.
* SearchResult
** The SearchResult as a table (array)
'''CODING EXAMPLE:'''
-- Include/Call for this library
require("fs")
-- Search for dir
liboutput = fs.find("tmp", "/")
You could do something like this see the output:
for a,b in ipairs(liboutput) do print(a,b) end
The output would look something like:
1 /usr/tmp
2 /usr/tmp/apk_add


== html.lua ==
===[[format.lua]]===
Functions used by web_elements.lua. Written by nangel for ACF.
Used to format tables and strings
*dostounix - Converts DOS line endings to Unix
*escapemagiccharacters - Escape Lua magic characters
*escapespecialcharacters - Escape shell special characters
*parse_lines - Takes out the blank and commented lines
*parse_linesandwords - Removes blanks and comments, and parses each line for words
*parse_configfile - Parses a config file for name/value pairs
*search_replace - Goes through a table of lines to search and replace
*search_for_lines - Goes through a file or table of lines and returns a table of matching lines
*cap_begin_word - Capitalizes beginning of words
*string_to_table - Takes a delimited string and turns it into a table
*expand_bash_syntax_vars - Takes a string and expands any ${...} constructs with the Lua variable
*replace_line - Removes the indicated line from a string and replaces it
*insert_line - Inserts a new line at the indicated location in a string
*get_line - Returns the specified line by number
*opts_to_table - Searches an option string for separate options and puts them in a table
*table_to_opts - Goes through an options table and creates the option string
*update_ini_file - Set a value in a particular ini section
*parse_ini_file - Read a value / values from an ini file
*get_ini_section - Read an entire section from an ini file
*set_ini_section - Set an entire section in an ini file
*get_ini_entry - Get an entry value from an ini file, accounting for parent sections and variables


=== cookie.set ===
=== [[fs.lua]] ===
'''INPUT:'''<BR>
Used for various filesystem specific functions
This library required the following inputs/parameters.
*is_dir  - Test if the path is a directory
* name
*is_file - Test if the path is a file
* value
*is_link - Test if the path is a link
* path
*create_directory - Creates a directory if it doesn't exist, including the parent dirs
'''OUTPUT:'''<BR>
*remove_directory - Deletes a directory along with its contents
This library deliverers the following output/parameters.
*create_file - Creates a blank file (and the directory if necessary)
* String to set the cookie
*copy_properties - Copies the permissions and ownership of one file to another
'''CODING EXAMPLE:'''
*copy_file - Copies a file to a directory or new filename (creating the directory if necessary)
-- Set variable/Call for this library
*move_file - Moves a file to a directory or new filename (creating the directory if necessary)
*read_file / read_file_as_array - Reads a file as a string / array
*write_file - Replaces contents of a file
*write_line_file - Appends lines to a file
*find_files_as_array - Returns an array of files under "where" that match "what" (a Lua pattern)
*find - Give a path and a search string and iterate over matching files
*stat - Does almost the same as posix.stat, but instead it writes the output human readable


===html_escape ===
=== [[html.lua]] ===
'''INPUT:'''<BR>
Used to generate HTML code.
This library required the following inputs/parameters.
*cookie.set - Creates a cookie
*text-string
*cookie.unset - Clears a cookie
'''OUTPUT:'''<BR>
*html_escape - Escapes HTML encoded strings
This library deliverers the following output/parameters.
*entity - Outputs tags such as h1, h2, p, etc.
* String with &,>,< signs encoded
*link - Creates a link tag
'''CODING EXAMPLE:'''
*Form setup functions - Create form tags
-- Set variable/Call for this library
**form.text
bobo = require "html"
**form.longtext
format = bobo.html_escape("This is > a test < string &")
**form.password
print(format)
**form.hidden
This is &gt; a test &lt; string &amp;
**form.submit
**form.action
**form.file
**form.image
**form.select
**form.checkbox
**form.start
**form.stop


===nv_pair===
=== [[processinfo.lua]] ===
'''INPUT:'''<BR>
Manages processes
This library required the following inputs/parameters.
*package_version - Returns the version of an apk package
*name
*process_autostart - Returns a string describing run level of a process
*value
*read_initrunlevels - Returns all processes in all run levels
'''OUTPUT:'''<BR>
*add_runlevels - Add a process to a list of run levels
This library deliverers the following output/parameters.
*delete_runlevels - Remove a process from a list of run levels
* name="value"
*daemoncontrol - Start/Stop/Restart/... a process (calls /etc/init.d/service)
'''CODING EXAMPLE:'''
*pidof - Find the process ID of a running program
-- Set variable/Call for this library
bobo = require "html"
format = bobo.nv_pair("foo", "bar")
print(format)
foo="bar"


== join.lua <span style="color:red">(not working)</span>==
=== [[validator.lua]] ===
'''INPUT:'''<BR>
This contains multiple different functions that each will validate input in there own way.
This library required the following inputs/parameters.
*is_string - Tests if a variable is of type string
* Delimiter
*is_boolean - Tests if a variable is of type boolean
** Could be one or more chars.
*is_number - Tests if a variable is of type number
* Array
*is_ipv4 - Tests if this is a valid ipv4 address
** Data which is to be joined into a string.
*is_partial_ipv4 - Tests if this is part of a valid ipv4 address
'''OUTPUT:'''<BR>
*is_mac - Tests to see if this is a valid mac address
This library deliverers the following output/parameters.
*is_integer - Tests to see if a string contains an integer
* String
*is_integer_in_range - Tests to see if a string contains an integer in a given range
** Could be something like "Word, Word, Word, Word"
*is_port - Tests to see if a string contains an integer in the IP port range
'''CODING EXAMPLE:'''
*is_valid_filename - Tests to see if a string is a valid filename and (optionally) located in a specified path
-- Set variable/Call for this library
ourlib = require("join")
-- Create a array of data <span style="color:red">(Not sure if the next row is correct)</span>
arraytojoin = "Bird", "Fish", "Cow", "Hammer"
-- Process the data (note the delimiter)
liboutput = ourlib(";", arraytojoin)
'liboutput' would contain:
Bird;Fish;Cow;Hammer


== log_view.lua ==
== ACF-specific Libraries (acf-core) ==
===[[authenticator.lua]]===
Authentication module.  This module loads one sub-authenticator module and exposes its functionality via '''auth''' table.
* authenticate
* get_userinfo
* get_userinfo_roles
* list_users
* change_settings
* new_settings
* delete_user


== menubuilder.lua ==
===[[authenticator-plaintext.lua]]===
Written by nangel for ACF
Authentication sub-module for plaintext database
* list_fields
* read_field
* delete_field
* write_entry
* read_entry
* delete_entry


== pidof.lua ==
===[[controllerfunctions.lua]]===
=== pidof ===
Controller helper functions
find the process ID of a running program
* handle_clientdata
* handle_form
* handle_startstop


pidof.pidof(''program'')
=== menubuilder.lua ===
 
Written by nangel for ACF
'''INPUT'''
*get_menuitems
* program
 
'''OUTPUT'''
returns the PID's of running ''program'' or nil if there are none.
 
'''CODING EXAMPLE'''
require "pidof"
if pidof.pidof("mini_httpd") ~= nil then
  print("mini_httpd is running")
else
  print("mini_httpd is not running")
end
 
== privsep.lua ==
===drop_privs===
Drop privileges while allowing a few functions still have root permissions.
privsep.drop_privs(user, group, functable)
 
Depends on ''posix'' and ''json''.
 
'''INPUT:'''<br>
* user
* group
* functable
** a table of functions that will run as root
 
'''OUTPUT:'''
returns a table identical to ''functable'', except the funcs are wrapped and runs in a separate process with root permissions.
 
'''CODING EXAMPLE:'''
<pre>
#!/usr/bin/env lua
 
require "posix"
require "privsep"
 
-- register those as privileged funcs
a = {}
function a.getuid()
        return posix.getpid().euid
end
 
-- main ---------------------------------------------------------
priv = privsep.drop_privs("nobody", "nogroup", a)
if priv == nil then
        error("failed to drop privileges")
end
 
print("current uid:", posix.getpid().euid)
print("privileged uid:", priv.getuid())
</pre>
 
 
== service_controller.lua ==
This is comprised of many local functions. Will just go through the exported ones.
 
===create_services_controller===


== service_model.lua ==
=== [[modelfunctions.lua]] ===
Has many functions inside the one below.
*getenabled
*startstop_service
*getstatus
*getfiledetails
*setfiledetails
*validateselect
*validatemulti
*write_file_with_audit


===create_service_model===
=== [[roles.lua]] ===
'''INPUT'''
*list_controllers
*cfglist
*get_controllers
*loglist
*get_controllers_func
*servlist
*get_controllers_view
*notepath
*list_default_roles
'''OUPUT'''
*list_roles
*Returns a me table:
*list_all_roles
**Looks like it contains information about the service.
*get_roles_perm
***Processes running
*get_role_perm
***If there is an /etc/init.d/ script
*delete_role
***Where is the programs config file
*set_role_perm
***Where does it log to


== session.lua ==
=== [[session.lua]] ===
Written by nangel for ACF.
Written by nangel for ACF.
=== random_hash ===
*random_hash - will create a bash64-like hash from /dev/urandom
Returns a base64 encoded hash, using _- as the extra characters, as these are safe for using in a URL.
*hash_ip_addr - create a hash encoded ip address  
 
*ip_addr_from_hash - take the hash encoded ip and give me the ip
'''INPUT:'''<BR>
*serialize - go through a table or set of tables and serialize
hash size, in bits
*save_session - save the session table
'''OUTPUT:'''<BR>
*load_session - load a saved session table
A base64 encoded hash of at least ''bits'' length.
*unlink_session - delete a saved session table
* HASH
*record_event - record an invalid login attempt
** Comes from reading /dev/urandom
*count_events - check if there are too many invalid attempts
'''CODING EXAMPLE:'''
*expired_events - delete the expired invalid attempts and saved sessions
-- Set variable/Call for this library
bobo = require "session"
print(bobo.random_hash(100))
will output a hash from /dev/urandom that is 17 char long
 
=== hash_ip_address ===
'''INPUT:'''<BR>
This library required the following inputs/parameters.
* ip address
'''OUTPUT:'''<BR>
This library deliverers the following output/parameters.
* HEX incoded ip address
'''CODING EXAMPLE:'''
-- Set variable/Call for this library
bobo = require "session"
print(bobo.has_ip_address("192.168.10.1))
Output could be:
c0a80a01
 
=== ip_addr_from_hash ===
'''INPUT:'''<BR>
This library required the following inputs/parameters.
* HEX encoded ip address
'''OUTPUT:'''<BR>
This library deliverers the following output/parameters.
* ip address
'''CODING EXAMPLE:'''
-- Set variable/Call for this library
bobo = require "session"
print(bobo.ip_addr_from_hash("c0a80a01")
Output could be:
192.168.10.1
 
=== serialize ===
'''INPUT:'''<BR>
This library required the following inputs/parameters.
* name
** What to use for the new elements
* value
**value: table to serialize
* saved
** not sure what its used of
'''OUTPUT:'''<BR>
This library deliverers the following output/parameters.
* string with the table serialized
'''CODING EXAMPLE:'''
-- Set variable/Call for this library
bobo = require "session"
t = {foo={1,2,3,4}, "one", "two", "bar", "baz"}
stuff = bobo.serialize(1,t)
print(stuff)
1 = {}
1[1] = "one"
1[2] = "two"
1[3] = "bar"
1[4] = "baz"
1["foo"] = {}
1["foo"][1] = 1
1["foo"][2] = 2
1["foo"][3] = 3
1["foo"][4] = 4
 
=== save_session ===
'''INPUT:'''<BR>
This library required the following inputs/parameters.
* sessionpath,session,sessiontable
'''OUTPUT:'''<BR>
This library deliverers the following output/parameters.
* true is success, false if error
'''CODING EXAMPLE:'''
-- Set variable/Call for this library
bobo = require "session"
print(bobo.save_session("tmp", session, sessiontable)
-- will print true is success
-- false if failed
 
== split.lua ==
'''INPUT:'''<BR>
This library required the following inputs/parameters.
* Delimiter
** Could be one or more chars.
* String or line from a file: bobo~foo~bar~baz~1
** Data is to be split into a table
'''OUTPUT:'''<BR>
This library deliverers the following output/parameters.
* Table
** { 1 = "bobo", 2 = "foo", 3 = "bar", 4 = "baz", 5 = 1}
'''CODING EXAMPLE:'''
-- Set variable/Call for this library
strsplit = require("split")
-- Grab the line from a file or input it into the funtcion
line = "bobo~foo~bar~baz~1"
-- Process the data (note the delimiter)
t = ourlib("~", line)
't' would contain:
{ 1 = "bobo", 2 = "foo", 3 = "bar", 4 = "baz", 5 = 1}
for a,b in ipairs(t) do print(a,b) end
1 bobo
2 foo
3 bar
4 baz
5 1
 
== validator.lua ==
This contains multiple different functions that each will validate input in there own way.
=== is_ipv4 (function) ===
'''INPUT:'''<BR>
This library function required the following inputs/parameters.
* String in form of ip address
** Example: 192.168.24.10
'''OUTPUT:'''<BR>
This library function deliverers the following output/parameters.
* '''''false''''' or "true"
'''CODING EXAMPLE:'''
-- Include/Call for this library
require("validator")
-- Check if url is a folder
liboutput = validator.is_ip("192.168.24.10")
If the string is a valid ip 'liboutput' would contain string:
true
If the string is missing or an invalid ip 'liboutput' would contain '''''false'''''.


===is_mac (function) ===
=== [[viewfunctions.lua]] ===
'''INPUT:'''<BR>
displayinfo - obsolete
This library function required the following inputs/parameters.
displaymanagement - obsolete
* String in form of mac address
*displayitem
** Example: 00:ca:ba:de:00:12
*displayformitem
'''OUTPUT:'''<BR>
*displayform
This library function deliverers the following output/parameters.
*displaycommandresults
* '''''false''''' or "true"
'''CODING EXAMPLE:'''
-- Include/Call for this library
require("validator")
-- Check if url is a folder
liboutput = validator.is_mac("00:ca:ba:de:00:12")
If the string is a valid mac address 'liboutput' would contain string:
true
If the string is missing or an invalid ip 'liboutput' would contain '''''false'''''.


===is_integer(function)===
[[Category:ACF]] [[Category:Lua]]
'''INPUT:'''<BR>
This library function required the following inputs/parameters.
* Number
** Example: 100
'''OUTPUT:'''<BR>
This library function deliverers the following output/parameters.
* '''''false''''' or "true"
'''CODING EXAMPLE:'''
-- Include/Call for this library
require("validator")
-- Check if url is a folder
liboutput = validator.is_integer("100")
If the string is a valid ip 'liboutput' would contain string:
true
If the string is missing or an invalid ip 'liboutput' would contain '''''false'''''.
 
===is_integer_in_range (function)===
'''INPUT:'''<BR>
This library function required the following inputs/parameters.
* 3 numbers --- number to test, min, max
** Example: (10,5,12)
'''OUTPUT:'''<BR>
This library function deliverers the following output/parameters.
* '''''false''''' or "true"
'''CODING EXAMPLE:'''
-- Include/Call for this library
require("validator")
-- Check if url is a folder
liboutput = validator.is_integer_in_range(10,5,15)
If the string is a valid ip 'liboutput' would contain string:
true
If the string is missing or an invalid ip 'liboutput' would contain '''''false'''''.
 
===is_port (function)===
'''INPUT:'''<BR>
This library function required the following inputs/parameters.
* Number - is it between 1 and 65535
** Example: 45
'''OUTPUT:'''<BR>
This library function deliverers the following output/parameters.
* '''''false''''' or "true"
'''CODING EXAMPLE:'''
-- Include/Call for this library
require("validator")
-- Check if url is a folder
liboutput = validator.is_port("45")
If the string is a valid ip 'liboutput' would contain string:
true
If the string is missing or an invalid ip 'liboutput' would contain '''''false'''''.
 
== web_elements.lua ==
Written by nangel for ACF.
=== render_table ===
'''INPUT:'''<BR>
This library function required the following inputs/parameters.
* Element
** The element should be type 'table'
** Element could be: group, label, html, log, link, form
* Level
** Level should be a 'number'
'''OUTPUT:'''<BR>
This library function deliverers the following output/parameters.
* HTML
** HTML formated output/elements
** <span style="color:red;">The output is partially generated by html.lua</span>
=== render_mainmenu ===
'''INPUT:'''<BR>
This library function required the following inputs/parameters.
* menu
* prefix
* controller
* action
'''OUTPUT:'''<BR>
This library function deliverers the following output/parameters.
* MainMenu (HTML)
** HTML formated output/elements
** <span style="color:red;">The output is partially generated by html.lua</span>
=== render_submenu ===
'''INPUT:'''<BR>
This library function required the following inputs/parameters.
* menu
* group
* cat
* subcat
'''OUTPUT:'''<BR>
This library function deliverers the following output/parameters.
* SubMenu (HTML)
** HTML formated output/elements
** <span style="color:red;">The output is partially generated by html.lua</span>

Latest revision as of 12:30, 7 March 2016

ACF Libraries

Because of using lua, a very small language, the need arises to build everything from scratch. This can lead to some confusion, apprehension, or just feeling overwhelmed. Here is documentation on what we have now in the form of libraries and common functions. We hope to build some more and use this information to get the juices flowing in regard to ACF.

Some of these are lua libs or ones written for ACF. We are also using as a standard the lposix library which is documented here LPOSIX

Generic Libraries (acf-lib)

apk.lua

Functions to load/unload apk packages

  • delete - Deletes a package
  • install - Installs a package
  • version - Checks a package's installed version

date.lua

Date and time functions To be used with os.time() and os.date()

  • date_to_seconds - Takes a date table and converts it to seconds from 1970
  • seconds_to_date - Takes table of seconds values and converts to a date sorted smallest to largest
  • string_to_table
  • date_diff - Takes two values of seconds and gives back the difference
  • num_month_name - Month number to name of month
  • num_month_name_abr - Month number to abr of month
  • name_month_num - Month name to number
  • abr_month_num - Month abbreviation to number
  • num_dow_name - Day of Week number to name
  • num_dow_name_abr - Day of week number to abbreviation
  • name_dow_num - Day of Week full name to number
  • abr_dow_num - Day of week abbreviation to number
  • what_tz - Checks to see what timezone the box is set to; /etc/TZ
  • change_tz - Changes the timezone
    • Tables are included with this information
      • Timezones
      • Days of Week
      • Months of the Year

format.lua

Used to format tables and strings

  • dostounix - Converts DOS line endings to Unix
  • escapemagiccharacters - Escape Lua magic characters
  • escapespecialcharacters - Escape shell special characters
  • parse_lines - Takes out the blank and commented lines
  • parse_linesandwords - Removes blanks and comments, and parses each line for words
  • parse_configfile - Parses a config file for name/value pairs
  • search_replace - Goes through a table of lines to search and replace
  • search_for_lines - Goes through a file or table of lines and returns a table of matching lines
  • cap_begin_word - Capitalizes beginning of words
  • string_to_table - Takes a delimited string and turns it into a table
  • expand_bash_syntax_vars - Takes a string and expands any ${...} constructs with the Lua variable
  • replace_line - Removes the indicated line from a string and replaces it
  • insert_line - Inserts a new line at the indicated location in a string
  • get_line - Returns the specified line by number
  • opts_to_table - Searches an option string for separate options and puts them in a table
  • table_to_opts - Goes through an options table and creates the option string
  • update_ini_file - Set a value in a particular ini section
  • parse_ini_file - Read a value / values from an ini file
  • get_ini_section - Read an entire section from an ini file
  • set_ini_section - Set an entire section in an ini file
  • get_ini_entry - Get an entry value from an ini file, accounting for parent sections and variables

fs.lua

Used for various filesystem specific functions

  • is_dir - Test if the path is a directory
  • is_file - Test if the path is a file
  • is_link - Test if the path is a link
  • create_directory - Creates a directory if it doesn't exist, including the parent dirs
  • remove_directory - Deletes a directory along with its contents
  • create_file - Creates a blank file (and the directory if necessary)
  • copy_properties - Copies the permissions and ownership of one file to another
  • copy_file - Copies a file to a directory or new filename (creating the directory if necessary)
  • move_file - Moves a file to a directory or new filename (creating the directory if necessary)
  • read_file / read_file_as_array - Reads a file as a string / array
  • write_file - Replaces contents of a file
  • write_line_file - Appends lines to a file
  • find_files_as_array - Returns an array of files under "where" that match "what" (a Lua pattern)
  • find - Give a path and a search string and iterate over matching files
  • stat - Does almost the same as posix.stat, but instead it writes the output human readable

html.lua

Used to generate HTML code.

  • cookie.set - Creates a cookie
  • cookie.unset - Clears a cookie
  • html_escape - Escapes HTML encoded strings
  • entity - Outputs tags such as h1, h2, p, etc.
  • link - Creates a link tag
  • Form setup functions - Create form tags
    • form.text
    • form.longtext
    • form.password
    • form.hidden
    • form.submit
    • form.action
    • form.file
    • form.image
    • form.select
    • form.checkbox
    • form.start
    • form.stop

processinfo.lua

Manages processes

  • package_version - Returns the version of an apk package
  • process_autostart - Returns a string describing run level of a process
  • read_initrunlevels - Returns all processes in all run levels
  • add_runlevels - Add a process to a list of run levels
  • delete_runlevels - Remove a process from a list of run levels
  • daemoncontrol - Start/Stop/Restart/... a process (calls /etc/init.d/service)
  • pidof - Find the process ID of a running program

validator.lua

This contains multiple different functions that each will validate input in there own way.

  • is_string - Tests if a variable is of type string
  • is_boolean - Tests if a variable is of type boolean
  • is_number - Tests if a variable is of type number
  • is_ipv4 - Tests if this is a valid ipv4 address
  • is_partial_ipv4 - Tests if this is part of a valid ipv4 address
  • is_mac - Tests to see if this is a valid mac address
  • is_integer - Tests to see if a string contains an integer
  • is_integer_in_range - Tests to see if a string contains an integer in a given range
  • is_port - Tests to see if a string contains an integer in the IP port range
  • is_valid_filename - Tests to see if a string is a valid filename and (optionally) located in a specified path

ACF-specific Libraries (acf-core)

authenticator.lua

Authentication module. This module loads one sub-authenticator module and exposes its functionality via auth table.

  • authenticate
  • get_userinfo
  • get_userinfo_roles
  • list_users
  • change_settings
  • new_settings
  • delete_user

authenticator-plaintext.lua

Authentication sub-module for plaintext database

  • list_fields
  • read_field
  • delete_field
  • write_entry
  • read_entry
  • delete_entry

controllerfunctions.lua

Controller helper functions

  • handle_clientdata
  • handle_form
  • handle_startstop

menubuilder.lua

Written by nangel for ACF

  • get_menuitems

modelfunctions.lua

  • getenabled
  • startstop_service
  • getstatus
  • getfiledetails
  • setfiledetails
  • validateselect
  • validatemulti
  • write_file_with_audit

roles.lua

  • list_controllers
  • get_controllers
  • get_controllers_func
  • get_controllers_view
  • list_default_roles
  • list_roles
  • list_all_roles
  • get_roles_perm
  • get_role_perm
  • delete_role
  • set_role_perm

session.lua

Written by nangel for ACF.

  • random_hash - will create a bash64-like hash from /dev/urandom
  • hash_ip_addr - create a hash encoded ip address
  • ip_addr_from_hash - take the hash encoded ip and give me the ip
  • serialize - go through a table or set of tables and serialize
  • save_session - save the session table
  • load_session - load a saved session table
  • unlink_session - delete a saved session table
  • record_event - record an invalid login attempt
  • count_events - check if there are too many invalid attempts
  • expired_events - delete the expired invalid attempts and saved sessions

viewfunctions.lua

displayinfo - obsolete displaymanagement - obsolete

  • displayitem
  • displayformitem
  • displayform
  • displaycommandresults