summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2016-08-13 17:39:17 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2016-08-13 17:39:17 +0900
commit8d780c7fb5ccb04c49c98370c9e4ec7a2440bbb1 (patch)
treebacc471e5ae2c44cb8c5dfec50036a9895e4636b
parent3b21839615037b5d0560df065abfd473517684e9 (diff)
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
-rw-r--r--configure.ac4
-rw-r--r--data/desktop/Makefile.mk3
-rw-r--r--data/desktop/enlightenment_askpass.desktop12
-rw-r--r--data/icons/Makefile.mk6
-rw-r--r--data/icons/enlightenment-askpass.pngbin0 -> 696 bytes
-rw-r--r--src/bin/.gitignore1
-rw-r--r--src/bin/Makefile.mk9
-rw-r--r--src/bin/e_askpass_main.c142
-rw-r--r--src/bin/e_main.c2
9 files changed, 177 insertions, 2 deletions
diff --git a/configure.ac b/configure.ac
index aa18bbe45..498090a63 100644
--- a/configure.ac
+++ b/configure.ac
@@ -476,6 +476,10 @@ PKG_CHECK_MODULES(E_IMC, [
476 eina >= ${efl_version} 476 eina >= ${efl_version}
477]) 477])
478 478
479PKG_CHECK_MODULES(E_ASKPASS, [
480 elementary >= ${efl_version}
481])
482
479PKG_CHECK_MODULES(E_THUMB, [ 483PKG_CHECK_MODULES(E_THUMB, [
480 eina >= ${efl_version} 484 eina >= ${efl_version}
481 evas >= ${efl_version} 485 evas >= ${efl_version}
diff --git a/data/desktop/Makefile.mk b/data/desktop/Makefile.mk
index 07730a208..7e38ebf4a 100644
--- a/data/desktop/Makefile.mk
+++ b/data/desktop/Makefile.mk
@@ -1,5 +1,6 @@
1desktopfilesdir = $(datadir)/applications 1desktopfilesdir = $(datadir)/applications
2desktopfiles_DATA = \ 2desktopfiles_DATA = \
3data/desktop/enlightenment_filemanager.desktop 3data/desktop/enlightenment_filemanager.desktop \
4data/desktop/enlightenment_askpass.desktop
4 5
5EXTRA_DIST += $(desktopfiles_DATA) 6EXTRA_DIST += $(desktopfiles_DATA)
diff --git a/data/desktop/enlightenment_askpass.desktop b/data/desktop/enlightenment_askpass.desktop
new file mode 100644
index 000000000..5efb99223
--- /dev/null
+++ b/data/desktop/enlightenment_askpass.desktop
@@ -0,0 +1,12 @@
1[Desktop Entry]
2Encoding=UTF-8
3Type=Application
4Name=Enlightenment Askpass
5Comment=Enlightenment Password Request
6Icon=enlightenment-askpass
7OnlyShowIn=Enlightenment;
8Exec=enlightenment_askpass
9Terminal=false
10Categories=System
11StartupNotify=false
12StartupWMClass=enlighenment_askpass
diff --git a/data/icons/Makefile.mk b/data/icons/Makefile.mk
index 84951de10..bde02dba7 100644
--- a/data/icons/Makefile.mk
+++ b/data/icons/Makefile.mk
@@ -10,3 +10,9 @@ data/icons/image_viewer.png \
10data/icons/audio_player2.png 10data/icons/audio_player2.png
11 11
12EXTRA_DIST += $(iconsfiles_DATA) 12EXTRA_DIST += $(iconsfiles_DATA)
13
14pixmapsdir = $(datadir)/pixmaps
15pixmaps_DATA = \
16data/icons/enlightenment-askpass.png
17
18EXTRA_DIST += $(pixmaps_DATA)
diff --git a/data/icons/enlightenment-askpass.png b/data/icons/enlightenment-askpass.png
new file mode 100644
index 000000000..09886d5fe
--- /dev/null
+++ b/data/icons/enlightenment-askpass.png
Binary files differ
diff --git a/src/bin/.gitignore b/src/bin/.gitignore
index b7fce7db5..fe388f12d 100644
--- a/src/bin/.gitignore
+++ b/src/bin/.gitignore
@@ -14,5 +14,6 @@
14/enlightenment_thumb 14/enlightenment_thumb
15/enlightenment_open 15/enlightenment_open
16/enlightenment_elm_cfgtool 16/enlightenment_elm_cfgtool
17/enlightenment_askpass
17 18
18/e_fm/enlightenment_fm 19/e_fm/enlightenment_fm
diff --git a/src/bin/Makefile.mk b/src/bin/Makefile.mk
index 5fdcb2760..d39ef158b 100644
--- a/src/bin/Makefile.mk
+++ b/src/bin/Makefile.mk
@@ -40,7 +40,8 @@ src/bin/enlightenment \
40src/bin/enlightenment_imc \ 40src/bin/enlightenment_imc \
41src/bin/enlightenment_start \ 41src/bin/enlightenment_start \
42src/bin/enlightenment_filemanager \ 42src/bin/enlightenment_filemanager \
43src/bin/enlightenment_open 43src/bin/enlightenment_open \
44src/bin/enlightenment_askpass
44 45
45internal_bindir = $(libdir)/enlightenment/utils 46internal_bindir = $(libdir)/enlightenment/utils
46internal_bin_PROGRAMS = \ 47internal_bin_PROGRAMS = \
@@ -431,6 +432,12 @@ src/bin/e_start_main.c
431src_bin_enlightenment_start_CPPFLAGS = $(E_CPPFLAGS) @E_START_CFLAGS@ 432src_bin_enlightenment_start_CPPFLAGS = $(E_CPPFLAGS) @E_START_CFLAGS@
432src_bin_enlightenment_start_LDADD = @dlopen_libs@ @E_START_LIBS@ 433src_bin_enlightenment_start_LDADD = @dlopen_libs@ @E_START_LIBS@
433 434
435src_bin_enlightenment_askpass_SOURCES = \
436src/bin/e_askpass_main.c
437
438src_bin_enlightenment_askpass_LDADD = @E_ASKPASS_LIBS@
439src_bin_enlightenment_askpass_CPPFLAGS = $(E_CPPFLAGS)
440
434src_bin_enlightenment_thumb_SOURCES = \ 441src_bin_enlightenment_thumb_SOURCES = \
435src/bin/e_sha1.c \ 442src/bin/e_sha1.c \
436src/bin/e_thumb_main.c \ 443src/bin/e_thumb_main.c \
diff --git a/src/bin/e_askpass_main.c b/src/bin/e_askpass_main.c
new file mode 100644
index 000000000..8cf169e49
--- /dev/null
+++ b/src/bin/e_askpass_main.c
@@ -0,0 +1,142 @@
1#include <Elementary.h>
2
3#define TITLE "Enter Your Password"
4#define TEXT "Please enter your user password"
5#define GUIDE "Password"
6#define OK "OK"
7#define CANCEL "Cancel"
8#define PAD "pad_medium"
9
10int ret = -1;
11
12static Evas_Object *entry = NULL;
13
14static void
15password_out(void)
16{
17 const char *str = elm_object_text_get(entry);
18 if (str) printf("%s\n", str);
19}
20
21static void
22cb_ok(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
23{
24 password_out();
25 ret = 0;
26 elm_exit();
27}
28
29static void
30cb_cancel(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
31{
32 elm_exit();
33}
34
35EAPI int
36elm_main(int argc, char **argv)
37{
38 Evas_Object *win, *bx, *fr, *lab, *en, *sep, *bx2, *bt;
39
40 elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
41
42 elm_app_compile_bin_dir_set(PACKAGE_BIN_DIR);
43 elm_app_compile_lib_dir_set(PACKAGE_LIB_DIR);
44 elm_app_compile_data_dir_set(PACKAGE_DATA_DIR);
45 elm_app_info_set(elm_main, "enlightenment", "AUTHORS");
46
47 do {
48 win = elm_win_util_standard_add("main", TITLE);
49 elm_win_autodel_set(win, EINA_TRUE);
50 do {
51 bx = elm_box_add(win);
52 elm_box_horizontal_set(bx, EINA_FALSE);
53 evas_object_size_hint_align_set(bx, EVAS_HINT_FILL, EVAS_HINT_FILL);
54 elm_win_resize_object_add(win, bx);
55 do {
56 fr = elm_frame_add(win);
57 evas_object_size_hint_align_set(fr, EVAS_HINT_FILL, EVAS_HINT_FILL);
58 elm_object_style_set(fr, PAD);
59 elm_box_pack_end(bx, fr);
60 do {
61 lab = elm_label_add(win);
62 evas_object_size_hint_align_set(lab, EVAS_HINT_FILL, 0.5);
63 elm_object_text_set(lab, TEXT);
64 elm_object_content_set(fr, lab);
65 evas_object_show(lab);
66 } while (0);
67 evas_object_show(fr);
68 } while (0);
69 do {
70 fr = elm_frame_add(win);
71 evas_object_size_hint_align_set(fr, EVAS_HINT_FILL, EVAS_HINT_FILL);
72 elm_object_style_set(fr, PAD);
73 elm_box_pack_end(bx, fr);
74 do {
75 en = elm_entry_add(win);
76 entry = en;
77 elm_entry_scrollable_set(en, EINA_TRUE);
78 evas_object_size_hint_weight_set(en, EVAS_HINT_EXPAND, 0.0);
79 evas_object_size_hint_align_set(en, EVAS_HINT_FILL, 0.5);
80 elm_scroller_policy_set(en, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
81 elm_object_part_text_set(en, "guide", GUIDE);
82 elm_entry_single_line_set(en, EINA_TRUE);
83 elm_entry_password_set(en, EINA_TRUE);
84 evas_object_smart_callback_add(en, "activated", cb_ok, NULL);
85 evas_object_smart_callback_add(en, "aborted", cb_cancel, NULL);
86 elm_object_content_set(fr, en);
87 evas_object_show(en);
88 elm_object_focus_set(en, EINA_TRUE);
89 } while (0);
90 evas_object_show(fr);
91 } while (0);
92 do {
93 sep = elm_separator_add(win);
94 elm_separator_horizontal_set(sep, EINA_TRUE);
95 evas_object_size_hint_weight_set(sep, EVAS_HINT_EXPAND, 0.0);
96 evas_object_size_hint_align_set(sep, EVAS_HINT_FILL, EVAS_HINT_FILL);
97 elm_box_pack_end(bx, sep);
98 evas_object_show(sep);
99 } while (0);
100 do {
101 fr = elm_frame_add(win);
102 evas_object_size_hint_align_set(fr, EVAS_HINT_FILL, EVAS_HINT_FILL);
103 elm_object_style_set(fr, PAD);
104 elm_box_pack_end(bx, fr);
105 do {
106 bx2 = elm_box_add(win);
107 elm_box_horizontal_set(bx2, EINA_TRUE);
108 elm_box_homogeneous_set(bx2, EINA_TRUE);
109 evas_object_size_hint_align_set(bx2, 0.5, 0.5);
110 elm_object_content_set(fr, bx2);
111 do {
112 bt = elm_button_add(win);
113 elm_object_text_set(bt, OK);
114 evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
115 evas_object_smart_callback_add(bt, "clicked", cb_ok, NULL);
116 elm_box_pack_end(bx2, bt);
117 evas_object_show(bt);
118 } while (0);
119 do {
120 bt = elm_button_add(win);
121 elm_object_text_set(bt, CANCEL);
122 evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
123 evas_object_smart_callback_add(bt, "clicked", cb_cancel, NULL);
124 elm_box_pack_end(bx2, bt);
125 evas_object_show(bt);
126 } while (0);
127 evas_object_show(bx2);
128 } while (0);
129 evas_object_show(fr);
130 } while (0);
131 evas_object_show(bx);
132 } while (0);
133 elm_win_center(win, EINA_TRUE, EINA_TRUE);
134 evas_object_show(win);
135 } while (0);
136
137 elm_win_activate(win);
138
139 elm_run();
140 return ret;
141}
142ELM_MAIN()
diff --git a/src/bin/e_main.c b/src/bin/e_main.c
index 28ed4bc69..4c705fcdc 100644
--- a/src/bin/e_main.c
+++ b/src/bin/e_main.c
@@ -325,6 +325,8 @@ main(int argc, char **argv)
325 e_util_env_set("E_RESTART_OK", NULL); 325 e_util_env_set("E_RESTART_OK", NULL);
326 e_util_env_set("PANTS", "ON"); 326 e_util_env_set("PANTS", "ON");
327 e_util_env_set("DESKTOP", "Enlightenment"); 327 e_util_env_set("DESKTOP", "Enlightenment");
328 snprintf(buff, sizeof(buff), "%s/enlightenment_askpass", e_prefix_bin_get());
329 e_util_env_set("SUDO_ASKPASS", buff);
328 TS("Environment Variables Done"); 330 TS("Environment Variables Done");
329 331
330 /* KDE5 applications don't understand anything other then gnome or kde */ 332 /* KDE5 applications don't understand anything other then gnome or kde */