Commit 8ec78254 authored by Roman Alifanov's avatar Roman Alifanov

added warning about the launch of extraneous files

parent 72bfce45
...@@ -29,6 +29,16 @@ VALID_FILE_EXTENSIONS=( ...@@ -29,6 +29,16 @@ VALID_FILE_EXTENSIONS=(
"*.appimage" "*.AppImage" "*.Appimage" "*.appimage" "*.AppImage" "*.Appimage"
) )
check_extension() {
local FILE="$1"
for EXT in "${VALID_FILE_EXTENSIONS[@]}"; do
if [[ "$FILE" == $EXT ]]; then
return 0
fi
done
return 1
}
# Notifications # Notifications
ntf() { ntf() {
notify-send --icon=epmgpi "$1" notify-send --icon=epmgpi "$1"
...@@ -39,6 +49,45 @@ ntf_error() { ...@@ -39,6 +49,45 @@ ntf_error() {
notify-send --icon=error "$1" notify-send --icon=error "$1"
} }
file_exec_warn() {
local NEED_RULES
if [ -x "$1" ]; then
NEED_RULES=False
else
NEED_RULES=True
fi
$YAD_DEFAULT --image="dialog-warning" \
\
--width=500 --height=200 \
--text="$(
gtxt \
"epmgpi has detected that you are running a file.
Launching extraneous files can lead to unforeseen consequences."
echo
echo
if [ "$NEED_RULES" = True ]; then
gtxt "Additionally, the file needs execute permissions.
Do you want to grant the file execute permissions and run it?"
else
gtxt "Do you really want to run the file?"
fi
)" \
--button="yad-yes:0" \
--button="yad-no:1"
local ANSWER=$?
if [[ $ANSWER -eq 0 ]]; then
if [ "$NEED_RULES" = True ]; then
chmod +x "$1"
fi
exec "$1"
fi
}
# Function to ask the user if the package should be repacked # Function to ask the user if the package should be repacked
repackq() { repackq() {
# Non-rpm files are repacked without --repack key # Non-rpm files are repacked without --repack key
...@@ -153,6 +202,11 @@ main() { ...@@ -153,6 +202,11 @@ main() {
exit 1 exit 1
fi fi
if ! check_extension "$FILE_PATH"; then
file_exec_warn "$FILE_PATH"
exit 0
fi
if echo "$FILE_PATH" | grep -q " "; then if echo "$FILE_PATH" | grep -q " "; then
gtxt "Package path contains spaces" gtxt "Package path contains spaces"
echo echo
......
...@@ -54,6 +54,15 @@ msgstr "" ...@@ -54,6 +54,15 @@ msgstr ""
msgid "Package path not specified. Calling package selection function..." msgid "Package path not specified. Calling package selection function..."
msgstr "" msgstr ""
msgid "epmgpi has detected that you are running a file.\nLaunching extraneous files can lead to unforeseen consequences."
msgstr ""
msgid "Do you really want to run the file?"
msgstr ""
msgid "Additionally, the file needs execute permissions.\n\nDo you want to grant the file execute permissions and run it?"
msgstr ""
msgid "Error: %s is not a file." msgid "Error: %s is not a file."
msgstr "" msgstr ""
......
...@@ -54,6 +54,15 @@ msgstr "Передайте путь к пакету, если не хотите ...@@ -54,6 +54,15 @@ msgstr "Передайте путь к пакету, если не хотите
msgid "Package path not specified. Calling package selection function..." msgid "Package path not specified. Calling package selection function..."
msgstr "Путь к пакету не указан. Вызов функции выбора пакета..." msgstr "Путь к пакету не указан. Вызов функции выбора пакета..."
msgid "epmgpi has detected that you are running a file.\nLaunching extraneous files can lead to unforeseen consequences."
msgstr "epmgpi обнаружил, что вы запускаете файл.\nЗапуск посторонних файлов может привести к непредвиденным последствиям."
msgid "Do you really want to run the file?"
msgstr "Вы действительно хотите запустить файл?"
msgid "Additionally, the file needs execute permissions.\n\nDo you want to grant the file execute permissions and run it?"
msgstr "Кроме того, файлу необходимы права на выполнение.\n\nВы хотите предоставить файлу права на выполнение и запустить его?"
msgid "Error: %s is not a file." msgid "Error: %s is not a file."
msgstr "Ошибка: %s - это не файл." msgstr "Ошибка: %s - это не файл."
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment