aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/daemon/daemon.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/daemon/daemon.c')
-rw-r--r--src/plugins/daemon/daemon.c119
1 files changed, 60 insertions, 59 deletions
diff --git a/src/plugins/daemon/daemon.c b/src/plugins/daemon/daemon.c
index 304a6cbb..1c3b4538 100644
--- a/src/plugins/daemon/daemon.c
+++ b/src/plugins/daemon/daemon.c
@@ -37,9 +37,7 @@
37/* Not used because libgksu2 headers have broken depends in Debian 37/* Not used because libgksu2 headers have broken depends in Debian
38And this is not really needed 38And this is not really needed
39#include <libgksu/libgksu.h> */ 39#include <libgksu/libgksu.h> */
40gboolean 40gboolean gksu_run (gchar * command_line, GError ** error);
41gksu_run (gchar *command_line,
42 GError **error);
43#endif 41#endif
44 42
45static struct GNUNET_CronManager *cron; 43static struct GNUNET_CronManager *cron;
@@ -172,12 +170,12 @@ doUpdateMenus (void *arg)
172 if (ret == 0) 170 if (ret == 0)
173 { 171 {
174 canStart = 0; 172 canStart = 0;
175 fn = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (chooser)); 173 fn = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (chooser));
176 if (NULL == fn) 174 if (NULL == fn)
177 GNUNET_GC_get_configuration_value_filename (cfg, "DAEMON", 175 GNUNET_GC_get_configuration_value_filename (cfg, "DAEMON",
178 "CONFIGFILE", 176 "CONFIGFILE",
179 GNUNET_DEFAULT_DAEMON_CONFIG_FILE, 177 GNUNET_DEFAULT_DAEMON_CONFIG_FILE,
180 &fn); 178 &fn);
181 if (isLocal && fn) 179 if (isLocal && fn)
182 { 180 {
183 if (GNUNET_disk_file_test (ectx, fn) == GNUNET_YES) 181 if (GNUNET_disk_file_test (ectx, fn) == GNUNET_YES)
@@ -195,7 +193,7 @@ doUpdateMenus (void *arg)
195#if defined(WINDOWS) || defined(WITH_LIBGKSU2) 193#if defined(WINDOWS) || defined(WITH_LIBGKSU2)
196 canStart = 1; 194 canStart = 1;
197#else 195#else
198 struct passwd *pws; 196 struct passwd *pws;
199 if (NULL == (pws = getpwnam (user))) 197 if (NULL == (pws = getpwnam (user)))
200 { 198 {
201 canStart = 0; 199 canStart = 0;
@@ -246,9 +244,9 @@ cronCheckDaemon (void *dummy)
246 int ret; 244 int ret;
247 245
248 if (GNUNET_OK == GNUNET_test_daemon_running (ectx, cfg)) 246 if (GNUNET_OK == GNUNET_test_daemon_running (ectx, cfg))
249 ret = 1; 247 ret = 1;
250 else 248 else
251 ret = 0; 249 ret = 0;
252 GNUNET_GTK_save_call (&doUpdateMenus, &ret); 250 GNUNET_GTK_save_call (&doUpdateMenus, &ret);
253} 251}
254 252
@@ -287,42 +285,41 @@ on_startDaemon_clicked_daemon (GtkWidget * widget, gpointer data)
287 if (0 != GNUNET_GC_parse_configuration (dcfg, fn)) 285 if (0 != GNUNET_GC_parse_configuration (dcfg, fn))
288 user = NULL; 286 user = NULL;
289 GNUNET_GC_get_configuration_value_string (dcfg, 287 GNUNET_GC_get_configuration_value_string (dcfg,
290 "GNUNETD", 288 "GNUNETD", "USER", "", &user);
291 "USER", "", &user);
292#ifdef WITH_LIBGKSU2 289#ifdef WITH_LIBGKSU2
293 char *command; 290 char *command;
294 GError *gerror = NULL; 291 GError *gerror = NULL;
295 struct passwd *pws; 292 struct passwd *pws;
296 if (strlen (user) > 0) 293 if (strlen (user) > 0)
297 { 294 {
298 pws = getpwnam (user); 295 pws = getpwnam (user);
299 if (pws->pw_uid != getuid ()) 296 if (pws->pw_uid != getuid ())
300 { 297 {
301 command = g_strconcat ("gnunetd -c ", fn, NULL); 298 command = g_strconcat ("gnunetd -c ", fn, NULL);
302 code = gksu_run (command, &gerror); 299 code = gksu_run (command, &gerror);
303 GNUNET_free (command); 300 GNUNET_free (command);
304 if (gerror) 301 if (gerror)
305 { 302 {
306 GNUNET_GTK_add_log_entry (_("Launching gnunetd failed\n")); 303 GNUNET_GTK_add_log_entry (_("Launching gnunetd failed\n"));
307 304
308 g_error_free (gerror); 305 g_error_free (gerror);
309 } 306 }
310 else 307 else
311 { 308 {
312 GNUNET_GTK_add_log_entry (_("Launched gnunetd\n")); 309 GNUNET_GTK_add_log_entry (_("Launched gnunetd\n"));
313 } 310 }
314 g_free (fn); 311 g_free (fn);
315 cronCheckDaemon (NULL); 312 cronCheckDaemon (NULL);
316 return; 313 return;
317 } 314 }
318 else 315 else
319 code = GNUNET_daemon_start (ectx, cfg, fn, GNUNET_YES); 316 code = GNUNET_daemon_start (ectx, cfg, fn, GNUNET_YES);
320 } 317 }
321#else 318#else
322 code = GNUNET_daemon_start (ectx, cfg, fn, GNUNET_YES); 319 code = GNUNET_daemon_start (ectx, cfg, fn, GNUNET_YES);
323#endif 320#endif
324 321
325 if (GNUNET_SYSERR != code) 322 if (GNUNET_SYSERR != code)
326 { 323 {
327 GNUNET_GTK_add_log_entry (_("Launched gnunetd\n")); 324 GNUNET_GTK_add_log_entry (_("Launched gnunetd\n"));
328 } 325 }
@@ -331,8 +328,8 @@ on_startDaemon_clicked_daemon (GtkWidget * widget, gpointer data)
331 GNUNET_GTK_add_log_entry (_("Launching gnunetd failed\n")); 328 GNUNET_GTK_add_log_entry (_("Launching gnunetd failed\n"));
332 } 329 }
333 if (fn != NULL) 330 if (fn != NULL)
334 g_free (fn); 331 g_free (fn);
335 cronCheckDaemon (NULL); 332 cronCheckDaemon (NULL);
336 } 333 }
337} 334}
338 335
@@ -432,17 +429,17 @@ init_daemon (struct GNUNET_GE_Context *e, struct GNUNET_GC_Configuration *c)
432 ("Configuration file for GNUnet daemon `%s' does not exist! Run `gnunet-setup -d'.\n"), 429 ("Configuration file for GNUnet daemon `%s' does not exist! Run `gnunet-setup -d'.\n"),
433 daemon_config); 430 daemon_config);
434 } 431 }
435 432
436#ifndef WITH_LIBGKSU2 433#ifndef WITH_LIBGKSU2
437 GtkWidget *startDaemonConfWizard; 434 GtkWidget *startDaemonConfWizard;
438 GtkWidget *startDaemonConfTool; 435 GtkWidget *startDaemonConfTool;
439 436
440 startDaemonConfWizard 437 startDaemonConfWizard
441 = glade_xml_get_widget (GNUNET_GTK_get_main_glade_XML (), 438 = glade_xml_get_widget (GNUNET_GTK_get_main_glade_XML (),
442 "startDaemonConfWizard"); 439 "startDaemonConfWizard");
443 startDaemonConfTool 440 startDaemonConfTool
444 = glade_xml_get_widget (GNUNET_GTK_get_main_glade_XML (), 441 = glade_xml_get_widget (GNUNET_GTK_get_main_glade_XML (),
445 "startDaemonConfTool"); 442 "startDaemonConfTool");
446 if (0 != ACCESS (daemon_config, W_OK)) 443 if (0 != ACCESS (daemon_config, W_OK))
447 { 444 {
448 gtk_widget_set_sensitive (startDaemonConfWizard, FALSE); 445 gtk_widget_set_sensitive (startDaemonConfWizard, FALSE);
@@ -471,7 +468,9 @@ done_daemon ()
471 "applicationList"); 468 "applicationList");
472 gtk_tree_view_set_model (GTK_TREE_VIEW (w), NULL); 469 gtk_tree_view_set_model (GTK_TREE_VIEW (w), NULL);
473 470
474 w = glade_xml_get_widget (GNUNET_GTK_get_main_glade_XML (), "applicationList"); 471 w =
472 glade_xml_get_widget (GNUNET_GTK_get_main_glade_XML (),
473 "applicationList");
475 gtk_tree_view_set_model (GTK_TREE_VIEW (w), NULL); 474 gtk_tree_view_set_model (GTK_TREE_VIEW (w), NULL);
476 475
477} 476}
@@ -480,15 +479,16 @@ done_daemon ()
480* Launch 'gnunet-setup -d wizard-gtk' with needed rights 479* Launch 'gnunet-setup -d wizard-gtk' with needed rights
481*/ 480*/
482void 481void
483on_startDaemonConfWizard_clicked_daemon (GtkWidget *widget, gpointer data) 482on_startDaemonConfWizard_clicked_daemon (GtkWidget * widget, gpointer data)
484{ 483{
485 GtkWidget *filechooserbutton; 484 GtkWidget *filechooserbutton;
486 char *conffile; 485 char *conffile;
487 486
488 filechooserbutton 487 filechooserbutton
489 = glade_xml_get_widget (GNUNET_GTK_get_main_glade_XML (), 488 = glade_xml_get_widget (GNUNET_GTK_get_main_glade_XML (),
490 "gnunetdconfigFileChooserButton"); 489 "gnunetdconfigFileChooserButton");
491 conffile = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER(filechooserbutton)); 490 conffile =
491 gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (filechooserbutton));
492 GNUNET_GTK_run_gnunet_setup (conffile, TRUE); 492 GNUNET_GTK_run_gnunet_setup (conffile, TRUE);
493 GNUNET_free (conffile); 493 GNUNET_free (conffile);
494} 494}
@@ -497,15 +497,16 @@ on_startDaemonConfWizard_clicked_daemon (GtkWidget *widget, gpointer data)
497* Launch 'gnunet-setup -d gconfig' with needed rights 497* Launch 'gnunet-setup -d gconfig' with needed rights
498*/ 498*/
499void 499void
500on_startDaemonConfTool_clicked_daemon (GtkWidget *widget, gpointer data) 500on_startDaemonConfTool_clicked_daemon (GtkWidget * widget, gpointer data)
501{ 501{
502 GtkWidget *filechooserbutton; 502 GtkWidget *filechooserbutton;
503 char *conffile; 503 char *conffile;
504 504
505 filechooserbutton 505 filechooserbutton
506 = glade_xml_get_widget (GNUNET_GTK_get_main_glade_XML (), 506 = glade_xml_get_widget (GNUNET_GTK_get_main_glade_XML (),
507 "gnunetdconfigFileChooserButton"); 507 "gnunetdconfigFileChooserButton");
508 conffile = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER(filechooserbutton)); 508 conffile =
509 gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (filechooserbutton));
509 GNUNET_GTK_run_gnunet_setup (conffile, FALSE); 510 GNUNET_GTK_run_gnunet_setup (conffile, FALSE);
510 GNUNET_free (conffile); 511 GNUNET_free (conffile);
511} 512}
@@ -514,8 +515,7 @@ on_startDaemonConfTool_clicked_daemon (GtkWidget *widget, gpointer data)
514* Update sensitivity of daemon buttons 515* Update sensitivity of daemon buttons
515*/ 516*/
516void 517void
517on_gnunetdconfigfile_set_daemon (GtkWidget *filechooserbutton, 518on_gnunetdconfigfile_set_daemon (GtkWidget * filechooserbutton, gpointer data)
518 gpointer data)
519{ 519{
520#ifndef WITH_LIBGKSU2 520#ifndef WITH_LIBGKSU2
521 GtkWidget *startDaemonConfWizard; 521 GtkWidget *startDaemonConfWizard;
@@ -524,18 +524,19 @@ on_gnunetdconfigfile_set_daemon (GtkWidget *filechooserbutton,
524 int ret; 524 int ret;
525 525
526 startDaemonConfWizard 526 startDaemonConfWizard
527 = glade_xml_get_widget (GNUNET_GTK_get_main_glade_XML (), 527 = glade_xml_get_widget (GNUNET_GTK_get_main_glade_XML (),
528 "startDaemonConfWizard"); 528 "startDaemonConfWizard");
529 startDaemonConfTool 529 startDaemonConfTool
530 = glade_xml_get_widget (GNUNET_GTK_get_main_glade_XML (), 530 = glade_xml_get_widget (GNUNET_GTK_get_main_glade_XML (),
531 "startDaemonConfTool"); 531 "startDaemonConfTool");
532 conffile = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER(filechooserbutton)); 532 conffile =
533 gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (filechooserbutton));
533 if (0 == ACCESS (conffile, W_OK)) 534 if (0 == ACCESS (conffile, W_OK))
534 { 535 {
535 gtk_widget_set_sensitive (startDaemonConfWizard, TRUE); 536 gtk_widget_set_sensitive (startDaemonConfWizard, TRUE);
536 gtk_widget_set_sensitive (startDaemonConfTool, TRUE); 537 gtk_widget_set_sensitive (startDaemonConfTool, TRUE);
537 } 538 }
538 else 539 else
539 { 540 {
540 gtk_widget_set_sensitive (startDaemonConfWizard, FALSE); 541 gtk_widget_set_sensitive (startDaemonConfWizard, FALSE);
541 gtk_widget_set_sensitive (startDaemonConfTool, FALSE); 542 gtk_widget_set_sensitive (startDaemonConfTool, FALSE);