Add --autosysadmin flag

This commit is contained in:
Brice Waegeneire 2022-07-05 16:47:07 +02:00
parent 95b45bac8e
commit 21f7464d42
2 changed files with 12 additions and 6 deletions

View File

@ -5,6 +5,7 @@ and this project **does not adhere to [Semantic Versioning](http://semver.org/sp
### Added
* Add `--autosysadmin` flag
* Commit change in /etc of lxc containers
### Changed

View File

@ -47,6 +47,7 @@ Options
--no-evocheck disable evocheck execution
--auto use "auto" mode
--no-auto use "manual" mode (default)
--autosysadmin author change as autosysadmin
-v, --verbose increase verbosity
-n, --dry-run actions are not executed
--help print this message and exit
@ -97,9 +98,9 @@ get_who() {
}
get_begin_date() {
# XXX Begin end date isn't applicable when used in autosysadmin,
# so we use the same one as the end date.
if [ "${AUTOSYSADMIN}" -eq 1 ]; then
# XXX A begin date isn't applicable when used in autosysadmin, so we
# use the same date as the end date.
if is_autosysadmin; then
get_end_date
else
printf "%s %s" "$(date "+%Y")" "$(get_who | cut -d" " -f3,4,5)"
@ -108,7 +109,7 @@ get_begin_date() {
get_ip() {
ip=$(get_who | cut -d" " -f6 | sed -e "s/^(// ; s/)$//")
if [ "${AUTOSYSADMIN}" -eq 1 ] || [ "${ip}" = ":0" ]; then
if is_autosysadmin || [ "${ip}" = ":0" ]; then
ip="localhost"
elif [ -z "${ip}" ]; then
ip="unknown (no tty)"
@ -126,7 +127,7 @@ get_now() {
}
get_user() {
if [ "${AUTOSYSADMIN}" -eq 1 ]; then
if is_autosysadmin; then
echo autosysadmin
else
logname
@ -191,6 +192,10 @@ print_session_data() {
printf "Message : %s\n" "${MESSAGE}"
}
is_autosysadmin() {
test "${AUTOSYSADMIN}" -eq 1
}
is_repository_readonly() {
if [ "$(get_system)" = "OpenBSD" ]; then
partition=$(stat -f '%Sd' $1)
@ -515,7 +520,7 @@ HOSTNAME_TEXT=$(get_complete_hostname)
IP=$(get_ip)
BEGIN_DATE=$(get_begin_date)
END_DATE=$(get_end_date)
USER=$(logname)
USER=$(get_user)
PATH=${PATH}:/usr/sbin