e sudo gui support - add askpass util for sudo askpass support

this gives e by default sudo gui support with an askpass util that
sudo can use as well as setting the env var correctly so it will be
used by sudo.

@feature
devs/bu5hm4n/mixer_fix
Carsten Haitzler 6 years ago
parent 3b21839615
commit 8d780c7fb5
  1. 4
      configure.ac
  2. 3
      data/desktop/Makefile.mk
  3. 12
      data/desktop/enlightenment_askpass.desktop
  4. 6
      data/icons/Makefile.mk
  5. BIN
      data/icons/enlightenment-askpass.png
  6. 1
      src/bin/.gitignore
  7. 9
      src/bin/Makefile.mk
  8. 142
      src/bin/e_askpass_main.c
  9. 2
      src/bin/e_main.c

@ -476,6 +476,10 @@ PKG_CHECK_MODULES(E_IMC, [
eina >= ${efl_version}
])
PKG_CHECK_MODULES(E_ASKPASS, [
elementary >= ${efl_version}
])
PKG_CHECK_MODULES(E_THUMB, [
eina >= ${efl_version}
evas >= ${efl_version}

@ -1,5 +1,6 @@
desktopfilesdir = $(datadir)/applications
desktopfiles_DATA = \
data/desktop/enlightenment_filemanager.desktop
data/desktop/enlightenment_filemanager.desktop \
data/desktop/enlightenment_askpass.desktop
EXTRA_DIST += $(desktopfiles_DATA)

@ -0,0 +1,12 @@
[Desktop Entry]
Encoding=UTF-8
Type=Application
Name=Enlightenment Askpass
Comment=Enlightenment Password Request
Icon=enlightenment-askpass
OnlyShowIn=Enlightenment;
Exec=enlightenment_askpass
Terminal=false
Categories=System
StartupNotify=false
StartupWMClass=enlighenment_askpass

@ -10,3 +10,9 @@ data/icons/image_viewer.png \
data/icons/audio_player2.png
EXTRA_DIST += $(iconsfiles_DATA)
pixmapsdir = $(datadir)/pixmaps
pixmaps_DATA = \
data/icons/enlightenment-askpass.png
EXTRA_DIST += $(pixmaps_DATA)

Binary file not shown.

After

Width:  |  Height:  |  Size: 696 B

@ -14,5 +14,6 @@
/enlightenment_thumb
/enlightenment_open
/enlightenment_elm_cfgtool
/enlightenment_askpass
/e_fm/enlightenment_fm

@ -40,7 +40,8 @@ src/bin/enlightenment \
src/bin/enlightenment_imc \
src/bin/enlightenment_start \
src/bin/enlightenment_filemanager \
src/bin/enlightenment_open
src/bin/enlightenment_open \
src/bin/enlightenment_askpass
internal_bindir = $(libdir)/enlightenment/utils
internal_bin_PROGRAMS = \
@ -431,6 +432,12 @@ src/bin/e_start_main.c
src_bin_enlightenment_start_CPPFLAGS = $(E_CPPFLAGS) @E_START_CFLAGS@
src_bin_enlightenment_start_LDADD = @dlopen_libs@ @E_START_LIBS@
src_bin_enlightenment_askpass_SOURCES = \
src/bin/e_askpass_main.c
src_bin_enlightenment_askpass_LDADD = @E_ASKPASS_LIBS@
src_bin_enlightenment_askpass_CPPFLAGS = $(E_CPPFLAGS)
src_bin_enlightenment_thumb_SOURCES = \
src/bin/e_sha1.c \
src/bin/e_thumb_main.c \

@ -0,0 +1,142 @@
#include <Elementary.h>
#define TITLE "Enter Your Password"
#define TEXT "Please enter your user password"
#define GUIDE "Password"
#define OK "OK"
#define CANCEL "Cancel"
#define PAD "pad_medium"
int ret = -1;
static Evas_Object *entry = NULL;
static void
password_out(void)
{
const char *str = elm_object_text_get(entry);
if (str) printf("%s\n", str);
}
static void
cb_ok(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
password_out();
ret = 0;
elm_exit();
}
static void
cb_cancel(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
elm_exit();
}
EAPI int
elm_main(int argc, char **argv)
{
Evas_Object *win, *bx, *fr, *lab, *en, *sep, *bx2, *bt;
elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
elm_app_compile_bin_dir_set(PACKAGE_BIN_DIR);
elm_app_compile_lib_dir_set(PACKAGE_LIB_DIR);
elm_app_compile_data_dir_set(PACKAGE_DATA_DIR);
elm_app_info_set(elm_main, "enlightenment", "AUTHORS");
do {
win = elm_win_util_standard_add("main", TITLE);
elm_win_autodel_set(win, EINA_TRUE);
do {
bx = elm_box_add(win);
elm_box_horizontal_set(bx, EINA_FALSE);
evas_object_size_hint_align_set(bx, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_win_resize_object_add(win, bx);
do {
fr = elm_frame_add(win);
evas_object_size_hint_align_set(fr, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_object_style_set(fr, PAD);
elm_box_pack_end(bx, fr);
do {
lab = elm_label_add(win);
evas_object_size_hint_align_set(lab, EVAS_HINT_FILL, 0.5);
elm_object_text_set(lab, TEXT);
elm_object_content_set(fr, lab);
evas_object_show(lab);
} while (0);
evas_object_show(fr);
} while (0);
do {
fr = elm_frame_add(win);
evas_object_size_hint_align_set(fr, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_object_style_set(fr, PAD);
elm_box_pack_end(bx, fr);
do {
en = elm_entry_add(win);
entry = en;
elm_entry_scrollable_set(en, EINA_TRUE);
evas_object_size_hint_weight_set(en, EVAS_HINT_EXPAND, 0.0);
evas_object_size_hint_align_set(en, EVAS_HINT_FILL, 0.5);
elm_scroller_policy_set(en, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
elm_object_part_text_set(en, "guide", GUIDE);
elm_entry_single_line_set(en, EINA_TRUE);
elm_entry_password_set(en, EINA_TRUE);
evas_object_smart_callback_add(en, "activated", cb_ok, NULL);
evas_object_smart_callback_add(en, "aborted", cb_cancel, NULL);
elm_object_content_set(fr, en);
evas_object_show(en);
elm_object_focus_set(en, EINA_TRUE);
} while (0);
evas_object_show(fr);
} while (0);
do {
sep = elm_separator_add(win);
elm_separator_horizontal_set(sep, EINA_TRUE);
evas_object_size_hint_weight_set(sep, EVAS_HINT_EXPAND, 0.0);
evas_object_size_hint_align_set(sep, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_box_pack_end(bx, sep);
evas_object_show(sep);
} while (0);
do {
fr = elm_frame_add(win);
evas_object_size_hint_align_set(fr, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_object_style_set(fr, PAD);
elm_box_pack_end(bx, fr);
do {
bx2 = elm_box_add(win);
elm_box_horizontal_set(bx2, EINA_TRUE);
elm_box_homogeneous_set(bx2, EINA_TRUE);
evas_object_size_hint_align_set(bx2, 0.5, 0.5);
elm_object_content_set(fr, bx2);
do {
bt = elm_button_add(win);
elm_object_text_set(bt, OK);
evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_smart_callback_add(bt, "clicked", cb_ok, NULL);
elm_box_pack_end(bx2, bt);
evas_object_show(bt);
} while (0);
do {
bt = elm_button_add(win);
elm_object_text_set(bt, CANCEL);
evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_smart_callback_add(bt, "clicked", cb_cancel, NULL);
elm_box_pack_end(bx2, bt);
evas_object_show(bt);
} while (0);
evas_object_show(bx2);
} while (0);
evas_object_show(fr);
} while (0);
evas_object_show(bx);
} while (0);
elm_win_center(win, EINA_TRUE, EINA_TRUE);
evas_object_show(win);
} while (0);
elm_win_activate(win);
elm_run();
return ret;
}
ELM_MAIN()

@ -325,6 +325,8 @@ main(int argc, char **argv)
e_util_env_set("E_RESTART_OK", NULL);
e_util_env_set("PANTS", "ON");
e_util_env_set("DESKTOP", "Enlightenment");
snprintf(buff, sizeof(buff), "%s/enlightenment_askpass", e_prefix_bin_get());
e_util_env_set("SUDO_ASKPASS", buff);
TS("Environment Variables Done");
/* KDE5 applications don't understand anything other then gnome or kde */

Loading…
Cancel
Save