This commit is contained in:
2025-04-15 10:34:07 +03:00
parent 35982a0ae7
commit 6df5baa457
10 changed files with 63 additions and 55 deletions

View File

@ -154,35 +154,31 @@ msgstr ""
msgid "Install a new package"
msgstr ""
#: install.go:58
#: install.go:62
msgid "Command install expected at least 1 argument, got %d"
msgstr ""
#: install.go:86
msgid "Error pulling repositories"
msgstr ""
#: install.go:103
#: install.go:101
msgid "Error parsing os release"
msgstr ""
#: install.go:148
#: install.go:146
msgid "Remove an installed package"
msgstr ""
#: install.go:166 install.go:216
#: install.go:164 install.go:214
msgid "Unable to detect a supported package manager on the system"
msgstr ""
#: install.go:170
#: install.go:168
msgid "Error listing installed packages"
msgstr ""
#: install.go:211
#: install.go:209
msgid "Command remove expected at least 1 argument, got %d"
msgstr ""
#: install.go:224
#: install.go:222
msgid "Error removing packages"
msgstr ""
@ -194,6 +190,10 @@ msgstr ""
msgid "Error initialization database"
msgstr ""
#: internal/cliutils/app_builder/builder.go:135
msgid "Error pulling repositories"
msgstr ""
#: internal/cliutils/prompt.go:60
msgid "Would you like to view the build script for %s"
msgstr ""
@ -311,15 +311,15 @@ msgstr ""
msgid "ERROR"
msgstr ""
#: internal/utils/cmd.go:79
#: internal/utils/cmd.go:83
msgid "Error dropping capabilities"
msgstr ""
#: internal/utils/cmd.go:86
#: internal/utils/cmd.go:103
msgid "You need to be root to perform this action"
msgstr ""
#: internal/utils/cmd.go:128
#: internal/utils/cmd.go:145
msgid "You need to be a %s member to perform this action"
msgstr ""

View File

@ -167,35 +167,31 @@ msgstr "Ошибка кодирования переменных скрита"
msgid "Install a new package"
msgstr "Установить новый пакет"
#: install.go:58
#: install.go:62
msgid "Command install expected at least 1 argument, got %d"
msgstr "Для команды install ожидался хотя бы 1 аргумент, получено %d"
#: install.go:86
msgid "Error pulling repositories"
msgstr "Ошибка при извлечении репозиториев"
#: install.go:103
#: install.go:101
msgid "Error parsing os release"
msgstr "Ошибка при разборе файла выпуска операционной системы"
#: install.go:148
#: install.go:146
msgid "Remove an installed package"
msgstr "Удалить установленный пакет"
#: install.go:166 install.go:216
#: install.go:164 install.go:214
msgid "Unable to detect a supported package manager on the system"
msgstr "Не удалось обнаружить поддерживаемый менеджер пакетов в системе"
#: install.go:170
#: install.go:168
msgid "Error listing installed packages"
msgstr "Ошибка при составлении списка установленных пакетов"
#: install.go:211
#: install.go:209
msgid "Command remove expected at least 1 argument, got %d"
msgstr "Для команды remove ожидался хотя бы 1 аргумент, получено %d"
#: install.go:224
#: install.go:222
msgid "Error removing packages"
msgstr "Ошибка при удалении пакетов"
@ -208,6 +204,10 @@ msgstr "Ошибка при кодировании конфигурации"
msgid "Error initialization database"
msgstr "Ошибка инициализации базы данных"
#: internal/cliutils/app_builder/builder.go:135
msgid "Error pulling repositories"
msgstr "Ошибка при извлечении репозиториев"
#: internal/cliutils/prompt.go:60
msgid "Would you like to view the build script for %s"
msgstr "Показать скрипт для пакета %s"
@ -326,16 +326,16 @@ msgstr "%s %s загружается — %s/с\n"
msgid "ERROR"
msgstr "ОШИБКА"
#: internal/utils/cmd.go:79
#: internal/utils/cmd.go:83
#, fuzzy
msgid "Error dropping capabilities"
msgstr "Ошибка при открытии базы данных"
#: internal/utils/cmd.go:86
#: internal/utils/cmd.go:103
msgid "You need to be root to perform this action"
msgstr ""
#: internal/utils/cmd.go:128
#: internal/utils/cmd.go:145
msgid "You need to be a %s member to perform this action"
msgstr ""

View File

@ -70,9 +70,13 @@ func DropCapsToAlrUser() error {
if err != nil {
return err
}
return EnuseIsAlrUser()
return EnsureIsAlrUser()
}
// ExitIfCantDropCapsToAlrUser attempts to drop capabilities to the already
// running user. Returns a cli.ExitCoder with an error if the operation fails.
// See also [ExitIfCantDropCapsToAlrUserNoPrivs] for a version that also applies
// no-new-privs.
func ExitIfCantDropCapsToAlrUser() cli.ExitCoder {
err := DropCapsToAlrUser()
if err != nil {
@ -81,6 +85,19 @@ func ExitIfCantDropCapsToAlrUser() cli.ExitCoder {
return nil
}
// ExitIfCantDropCapsToAlrUserNoPrivs combines [ExitIfCantDropCapsToAlrUser] with [NoNewPrivs]
func ExitIfCantDropCapsToAlrUserNoPrivs() cli.ExitCoder {
if err := ExitIfCantDropCapsToAlrUser(); err != nil {
return err
}
if err := NoNewPrivs(); err != nil {
return cliutils.FormatCliExit("error no new privs", err)
}
return nil
}
func ExitIfNotRoot() error {
if os.Getuid() != 0 {
return cli.Exit(gotext.Get("You need to be root to perform this action"), 1)
@ -88,7 +105,7 @@ func ExitIfNotRoot() error {
return nil
}
func EnuseIsAlrUser() error {
func EnsureIsAlrUser() error {
uid, gid, err := GetUidGidAlrUser()
if err != nil {
return err