aboutsummaryrefslogtreecommitdiff
path: root/src/setup/gnunet-setup.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-10-28 23:55:39 +0000
committerChristian Grothoff <christian@grothoff.org>2012-10-28 23:55:39 +0000
commitc8ac19103dff5a625850c971aa276070a0be9575 (patch)
tree5947a6a443d48d3eb22484ae01c64a598aff2b2b /src/setup/gnunet-setup.c
parentefc3843a9cfc57c9af3c1fc4a249cab8eaccc2e3 (diff)
downloadgnunet-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/gnunet-setup.c')
-rw-r--r--src/setup/gnunet-setup.c53
1 files changed, 21 insertions, 32 deletions
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 */
66static struct GNUNET_OS_Process *namestore; 64static 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 */
72static int do_gksu; 69static 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,
451static int 447static int
452try_gksu (const char *username) 448try_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
564main (int argc, char *const *argv) 555main (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 },