diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-10-28 23:55:39 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-10-28 23:55:39 +0000 |
commit | c8ac19103dff5a625850c971aa276070a0be9575 (patch) | |
tree | 5947a6a443d48d3eb22484ae01c64a598aff2b2b /src/setup | |
parent | efc3843a9cfc57c9af3c1fc4a249cab8eaccc2e3 (diff) | |
download | gnunet-gtk-c8ac19103dff5a625850c971aa276070a0be9575.tar.gz gnunet-gtk-c8ac19103dff5a625850c971aa276070a0be9575.zip |
-use fork exec instead libgksu due to gtk2.0/gtk3.0 incompatibility
Diffstat (limited to 'src/setup')
-rw-r--r-- | src/setup/Makefile.am | 5 | ||||
-rw-r--r-- | src/setup/gnunet-setup.c | 53 |
2 files changed, 23 insertions, 35 deletions
diff --git a/src/setup/Makefile.am b/src/setup/Makefile.am index d904ef8b..e3391abd 100644 --- a/src/setup/Makefile.am +++ b/src/setup/Makefile.am | |||
@@ -31,7 +31,7 @@ gnunet_setup_SOURCES = \ | |||
31 | gnunet-setup-hostlist-server.c | 31 | gnunet-setup-hostlist-server.c |
32 | gnunet_setup_LDADD = \ | 32 | gnunet_setup_LDADD = \ |
33 | $(top_builddir)/src/lib/libgnunetgtk.la \ | 33 | $(top_builddir)/src/lib/libgnunetgtk.la \ |
34 | @GTK_LIBS@ @GNUNET_LIBS@ @GLADE_LIBS@ @QR_LIBS@ @GKSU_LIBS@ \ | 34 | @GTK_LIBS@ @GNUNET_LIBS@ @GLADE_LIBS@ @QR_LIBS@ \ |
35 | $(WINLIBS) \ | 35 | $(WINLIBS) \ |
36 | -lgnunetutil -lgnunetnat -lgnunetnamestore \ | 36 | -lgnunetutil -lgnunetnat -lgnunetnamestore \ |
37 | $(INTLLIBS) | 37 | $(INTLLIBS) |
@@ -39,8 +39,7 @@ gnunet_setup_CFLAGS = \ | |||
39 | @GTK_CFLAGS@ \ | 39 | @GTK_CFLAGS@ \ |
40 | @GNUNET_CFLAGS@ \ | 40 | @GNUNET_CFLAGS@ \ |
41 | @GLADE_CFLAGS@ \ | 41 | @GLADE_CFLAGS@ \ |
42 | @QR_CFLAGS@ \ | 42 | @QR_CFLAGS@ |
43 | @GKSU_CFLAGS@ | ||
44 | 43 | ||
45 | gnunet_setup_LDFLAGS = \ | 44 | gnunet_setup_LDFLAGS = \ |
46 | -export-dynamic | 45 | -export-dynamic |
diff --git a/src/setup/gnunet-setup.c b/src/setup/gnunet-setup.c index d41be339..88210d21 100644 --- a/src/setup/gnunet-setup.c +++ b/src/setup/gnunet-setup.c | |||
@@ -23,17 +23,15 @@ | |||
23 | * @brief Main function of gnunet-setup | 23 | * @brief Main function of gnunet-setup |
24 | * @author Christian Grothoff | 24 | * @author Christian Grothoff |
25 | */ | 25 | */ |
26 | #if ENABLE_NLS | ||
27 | #include <locale.h> | ||
28 | #endif | ||
29 | #if HAVE_LIBGKSU_LIBGKSU_H | ||
30 | #include <libgksu/gksu.h> | ||
31 | #endif | ||
32 | #include "gnunet-setup.h" | 26 | #include "gnunet-setup.h" |
33 | #include "gnunet-setup-options.h" | 27 | #include "gnunet-setup-options.h" |
34 | #include "gnunet-setup-gns.h" | 28 | #include "gnunet-setup-gns.h" |
35 | #include <gnunet/gnunet_constants.h> | 29 | #include <gnunet/gnunet_constants.h> |
36 | #include <regex.h> | 30 | #include <regex.h> |
31 | #if ENABLE_NLS | ||
32 | #include <locale.h> | ||
33 | #endif | ||
34 | |||
37 | 35 | ||
38 | /** | 36 | /** |
39 | * Main loop handle. | 37 | * Main loop handle. |
@@ -65,12 +63,11 @@ static struct GNUNET_OS_Process *resolver; | |||
65 | */ | 63 | */ |
66 | static struct GNUNET_OS_Process *namestore; | 64 | static struct GNUNET_OS_Process *namestore; |
67 | 65 | ||
68 | #if HAVE_LIBGKSU_LIBGKSU_H | ||
69 | /** | 66 | /** |
70 | * Flag to emable privilege escalation. | 67 | * Flag to enable privilege escalation. |
71 | */ | 68 | */ |
72 | static int do_gksu; | 69 | static int do_gksu; |
73 | #endif | 70 | |
74 | 71 | ||
75 | /** | 72 | /** |
76 | * Show all configuration options, even if we are run | 73 | * Show all configuration options, even if we are run |
@@ -441,7 +438,6 @@ start_namestore (void *cls, | |||
441 | } | 438 | } |
442 | 439 | ||
443 | 440 | ||
444 | #if HAVE_LIBGKSU_LIBGKSU_H | ||
445 | /** | 441 | /** |
446 | * Try elevating user priviledges to run as user 'gnunet' or 'root'. | 442 | * Try elevating user priviledges to run as user 'gnunet' or 'root'. |
447 | * | 443 | * |
@@ -451,23 +447,22 @@ start_namestore (void *cls, | |||
451 | static int | 447 | static int |
452 | try_gksu (const char *username) | 448 | try_gksu (const char *username) |
453 | { | 449 | { |
454 | GksuContext *gksu; | 450 | struct GNUNET_OS_Process *proc; |
455 | GError *err; | 451 | |
456 | 452 | proc = GNUNET_OS_start_process (GNUNET_NO, | |
457 | gksu = gksu_context_new (); | 453 | GNUNET_OS_INHERIT_STD_ALL, |
458 | gksu_context_set_user (gksu, username); | 454 | NULL, NULL, |
459 | gksu_context_set_command (gksu, "gnunet-setup"); | 455 | "gksu", |
460 | gksu_context_set_description (gksu, _("Elevate priviledges to setup GNUnet on the host")); | 456 | "-u", username, |
461 | gksu_context_set_message (gksu, _("Enter password to run gnunet-setup as user 'gnunet'")); | 457 | "-D", _("Elevate priviledges to setup GNUnet on the host"), |
462 | if (gksu_run_full (gksu, | 458 | "-m", _("Enter password to run gnunet-setup as user 'gnunet'"), |
463 | NULL, NULL, | 459 | NULL); |
464 | NULL, NULL, | 460 | if (NULL == proc) |
465 | &err)) | 461 | return GNUNET_SYSERR; |
466 | return GNUNET_OK; | 462 | GNUNET_OS_process_wait (proc); |
467 | g_object_unref (err); | 463 | GNUNET_OS_process_destroy (proc); |
468 | return GNUNET_SYSERR; | 464 | return GNUNET_OK; |
469 | } | 465 | } |
470 | #endif | ||
471 | 466 | ||
472 | 467 | ||
473 | /** | 468 | /** |
@@ -485,8 +480,6 @@ run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
485 | 480 | ||
486 | my_uid = getuid (); | 481 | my_uid = getuid (); |
487 | gnunet_pw = getpwnam ("gnunet"); | 482 | gnunet_pw = getpwnam ("gnunet"); |
488 | #if HAVE_LIBGKSU_LIBGKSU_H | ||
489 | |||
490 | if ( (0 != do_gksu) && | 483 | if ( (0 != do_gksu) && |
491 | (0 != my_uid) && | 484 | (0 != my_uid) && |
492 | (NULL != gnunet_pw) && | 485 | (NULL != gnunet_pw) && |
@@ -496,8 +489,6 @@ run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
496 | GNUNET_GTK_main_loop_quit (cls); | 489 | GNUNET_GTK_main_loop_quit (cls); |
497 | return; | 490 | return; |
498 | } | 491 | } |
499 | #endif | ||
500 | |||
501 | ml = cls; | 492 | ml = cls; |
502 | if (GNUNET_OK != GNUNET_GTK_main_loop_build_window (ml, NULL)) | 493 | if (GNUNET_OK != GNUNET_GTK_main_loop_build_window (ml, NULL)) |
503 | return; | 494 | return; |
@@ -564,11 +555,9 @@ int | |||
564 | main (int argc, char *const *argv) | 555 | main (int argc, char *const *argv) |
565 | { | 556 | { |
566 | struct GNUNET_GETOPT_CommandLineOption options[] = { | 557 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
567 | #if HAVE_LIBGKSU_LIBGKSU_H | ||
568 | { 'e', "elevate-priviledges", NULL, | 558 | { 'e', "elevate-priviledges", NULL, |
569 | gettext_noop ("run as user 'gnunet', if necessary by executing gksu to elevate rights"), | 559 | gettext_noop ("run as user 'gnunet', if necessary by executing gksu to elevate rights"), |
570 | 0, &GNUNET_GETOPT_set_one, &do_gksu }, | 560 | 0, &GNUNET_GETOPT_set_one, &do_gksu }, |
571 | #endif | ||
572 | { 'f', "force-full-setup", NULL, | 561 | { 'f', "force-full-setup", NULL, |
573 | gettext_noop ("force showing the full set of options, even if gnunet-setup is run as a normal user and as a user 'gnunet' exists on the system, most options should not apply to the normal user as GNUnet should be run by the 'gnunet' user"), | 562 | gettext_noop ("force showing the full set of options, even if gnunet-setup is run as a normal user and as a user 'gnunet' exists on the system, most options should not apply to the normal user as GNUnet should be run by the 'gnunet' user"), |
574 | 0, &GNUNET_GETOPT_set_one, &force_full_setup }, | 563 | 0, &GNUNET_GETOPT_set_one, &force_full_setup }, |