22.3.1 Introduction to program execution

This module provides an API to execute a program under the privileges of the current user or under a more or less privileged user; sudo is used run a program as a different user: refer to its documentation for the required configuration; whoami is used to determine to which user the process belongs. Preselected program pathnames.

The functions described here must be used in the following way:

Every time we execute a program with sudo: we have to select the user under which to execute it; if we do not do it: the internally registered user defaults to :nosudo:, which tells the function not to use sudo. So the following script works as commented:

mbfl_program_enable_sudo

# This is executed with the privileges of the user that
# launched the script.
mbfl_program_exec ls /bin

mbfl_program_declare_sudo_user root
# This is executed with root privileges.
mbfl_program_exec ls /root

# This is executed with the privileges of the user that
# launched the script.
mbfl_program_exec ls /bin

This document describes version 3.0.0-devel.9 of Marcos Bash Functions Library.