[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r825 - in GNUnet/src: conf include util/win
From: |
durner |
Subject: |
[GNUnet-SVN] r825 - in GNUnet/src: conf include util/win |
Date: |
Fri, 27 May 2005 12:16:04 -0700 (PDT) |
Author: durner
Date: 2005-05-27 12:15:00 -0700 (Fri, 27 May 2005)
New Revision: 825
Added:
GNUnet/src/conf/wizard_gtk.h
Modified:
GNUnet/src/conf/Makefile.am
GNUnet/src/conf/conf.c
GNUnet/src/conf/confdata.c
GNUnet/src/conf/gconf.c
GNUnet/src/conf/gnunet-setup.c
GNUnet/src/conf/gnunet-win-tool.c
GNUnet/src/conf/mconf.c
GNUnet/src/conf/mconf_dialog.h
GNUnet/src/conf/mconf_util.c
GNUnet/src/conf/menu.c
GNUnet/src/conf/wizard.c
GNUnet/src/conf/wizard.glade
GNUnet/src/conf/wizard_callbacks.c
GNUnet/src/conf/wizard_callbacks.h
GNUnet/src/conf/wizard_curs.c
GNUnet/src/conf/wizard_interface.c
GNUnet/src/conf/wizard_interface.h
GNUnet/src/conf/wizard_support.h
GNUnet/src/conf/wizard_util.c
GNUnet/src/conf/wizard_util.h
GNUnet/src/include/gnunet_util.h
GNUnet/src/include/winproc.h
GNUnet/src/util/win/win.cc
GNUnet/src/util/win/winproc.c
Log:
- kill warnings
- add GNUnet as system service
- add GNUnet user & group
Modified: GNUnet/src/conf/Makefile.am
===================================================================
--- GNUnet/src/conf/Makefile.am 2005-05-27 18:41:45 UTC (rev 824)
+++ GNUnet/src/conf/Makefile.am 2005-05-27 19:15:00 UTC (rev 825)
@@ -21,7 +21,8 @@
lkc_proto.h \
qconf.h \
bool.h \
- wizard_util.h
+ wizard_util.h \
+ wizard_gtk.h
if HAVE_CURSES
if HAVE_PDCURSES
Modified: GNUnet/src/conf/conf.c
===================================================================
--- GNUnet/src/conf/conf.c 2005-05-27 18:41:45 UTC (rev 824)
+++ GNUnet/src/conf/conf.c 2005-05-27 19:15:00 UTC (rev 825)
@@ -546,7 +546,6 @@
}
conf_parse(configFile);
- FREE(configFile);
switch (input_mode) {
case set_default:
Modified: GNUnet/src/conf/confdata.c
===================================================================
--- GNUnet/src/conf/confdata.c 2005-05-27 18:41:45 UTC (rev 824)
+++ GNUnet/src/conf/confdata.c 2005-05-27 19:15:00 UTC (rev 825)
@@ -141,8 +141,8 @@
sym_calc_value_ext(sym, 1);
sym_calc_value_ext(defFile, 1);
- path =
sym_get_string_value(sym);
- file =
sym_get_string_value(defFile);
+ path = (char *)
sym_get_string_value(sym);
+ file = (char *)
sym_get_string_value(defFile);
key = realloc(key, strlen(path)
+ strlen(file) + 2);
sprintf(key, "%s%c%s", path,
DIR_SEPARATOR, file);
@@ -303,7 +303,7 @@
fclose(out);
cur_tmpl = menu->file->name;
- prefix = cur_tmpl + strlen(cur_tmpl);
+ prefix = (char *) cur_tmpl +
strlen(cur_tmpl);
while(*prefix != '/' && *prefix != '\\')
prefix--;
prefix++;
Modified: GNUnet/src/conf/gconf.c
===================================================================
--- GNUnet/src/conf/gconf.c 2005-05-27 18:41:45 UTC (rev 824)
+++ GNUnet/src/conf/gconf.c 2005-05-27 19:15:00 UTC (rev 825)
@@ -1694,6 +1694,7 @@
{
const char * LANG;
char * configFile;
+ struct menu *root;
#ifndef LKC_DIRECT_LINK
kconfig_load();
@@ -1741,8 +1742,12 @@
LANG,
2);
}
- conf_parse(configFile);
- FREE(configFile);
+
+ /* This configurator is also called from the wizard configurator.
+ * Check whether the templates are already parsed. */
+ root = menu_get_root_menu(NULL);
+ if (!(root && root->prompt))
+ conf_parse(configFile);
fixup_rootmenu(&rootmenu);
conf_read(NULL);
Modified: GNUnet/src/conf/gnunet-setup.c
===================================================================
--- GNUnet/src/conf/gnunet-setup.c 2005-05-27 18:41:45 UTC (rev 824)
+++ GNUnet/src/conf/gnunet-setup.c 2005-05-27 19:15:00 UTC (rev 825)
@@ -42,10 +42,12 @@
#if HAVE_CURSES
int mconf_main(int ac, char **av);
+int wizard_curs_main(int argc, char *argv[]);
#endif
#if HAVE_GTK
int gconf_main(int ac, char *av[]);
+int wizard_main (int argc, char *argv[]);
#endif
int conf_main(int ac, char **av);
Modified: GNUnet/src/conf/gnunet-win-tool.c
===================================================================
--- GNUnet/src/conf/gnunet-win-tool.c 2005-05-27 18:41:45 UTC (rev 824)
+++ GNUnet/src/conf/gnunet-win-tool.c 2005-05-27 19:15:00 UTC (rev 825)
@@ -101,7 +101,7 @@
*/
void Install()
{
- switch(InstallAsService())
+ switch(InstallAsService(NULL))
{
case 0:
printf(_("GNUnet service installed successfully.\n"));
Modified: GNUnet/src/conf/mconf.c
===================================================================
--- GNUnet/src/conf/mconf.c 2005-05-27 18:41:45 UTC (rev 824)
+++ GNUnet/src/conf/mconf.c 2005-05-27 19:15:00 UTC (rev 825)
@@ -362,6 +362,7 @@
return 0;
}
+#ifndef MINGW
static void winch_handler(int sig)
{
static int lock;
@@ -379,6 +380,7 @@
lock = 0;
}
}
+#endif
static void build_conf(struct menu *menu)
{
@@ -843,7 +845,6 @@
root = menu_get_root_menu(NULL);
if (!(root && root->prompt))
conf_parse(configFile);
- FREE(configFile);
conf_read(NULL);
Modified: GNUnet/src/conf/mconf_dialog.h
===================================================================
--- GNUnet/src/conf/mconf_dialog.h 2005-05-27 18:41:45 UTC (rev 824)
+++ GNUnet/src/conf/mconf_dialog.h 2005-05-27 19:15:00 UTC (rev 825)
@@ -159,6 +159,7 @@
*/
void init_dialog (void);
+void init_wsize(void);
void end_dialog (void);
void resize_dialog(int rows, int cols);
void do_resize_dialog(void);
Modified: GNUnet/src/conf/mconf_util.c
===================================================================
--- GNUnet/src/conf/mconf_util.c 2005-05-27 18:41:45 UTC (rev 824)
+++ GNUnet/src/conf/mconf_util.c 2005-05-27 19:15:00 UTC (rev 825)
@@ -241,7 +241,7 @@
print_autowrap (WINDOW * win, const char *prompt, int width, int y, int x)
{
int newl, cur_x, cur_y;
- int i, prompt_len, room, wlen;
+ int prompt_len, room, wlen;
char tempstr[MAX_LEN + 1], *word, *sp, *sp2, *sp_nl;
strcpy (tempstr, prompt);
Modified: GNUnet/src/conf/menu.c
===================================================================
--- GNUnet/src/conf/menu.c 2005-05-27 18:41:45 UTC (rev 824)
+++ GNUnet/src/conf/menu.c 2005-05-27 19:15:00 UTC (rev 825)
@@ -389,7 +389,7 @@
file = malloc(sizeof(*file));
memset(file, 0, sizeof(*file));
- file->name = name;
+ file->name = (char *) name;
file->next = file_list;
file_list = file;
Modified: GNUnet/src/conf/wizard.c
===================================================================
--- GNUnet/src/conf/wizard.c 2005-05-27 18:41:45 UTC (rev 824)
+++ GNUnet/src/conf/wizard.c 2005-05-27 19:15:00 UTC (rev 825)
@@ -33,18 +33,19 @@
#include "wizard_interface.h"
#include "wizard_support.h"
+#include "wizard_util.h"
GtkWidget *curwnd;
GtkWidget *cmbNIC;
int doOpenEnhConfigurator = 0;
int doAutoStart = 0;
+char *user_name = NULL, *group_name = NULL;
+int gconf_main(int ac, char *av[]);
+
void insert_nic(char *name, int defaultNIC)
{
- struct symbol *sym;
- char *nic = NULL;
-
gtk_combo_box_append_text(GTK_COMBO_BOX(cmbNIC), name);
defaultNIC = wiz_is_nic_default(name, defaultNIC);
@@ -172,6 +173,32 @@
void load_step4()
{
+ GtkWidget *vbox18, *frame8, *vbox19, *table3, *entUser,
*entGroup;
+ int group;
+
+ vbox18 = lookup_widget(curwnd, "vbox18");
+ frame8 = lookup_widget(vbox18, "frame8");
+ vbox19 = lookup_widget(frame8, "vbox19");
+ table3 = lookup_widget(vbox19, "table3");
+ entUser = lookup_widget(table3, "entUser");
+ entGroup = lookup_widget(table3, "entGroup");
+
+ if (user_name)
+ gtk_entry_set_text(GTK_ENTRY(entUser), user_name);
+ else
+ user_name = strdup("gnunet");
+
+ if (group_name)
+ gtk_entry_set_text(GTK_ENTRY(entGroup), group_name);
+
+ gtk_widget_set_sensitive(entUser, wiz_useradd_capable());
+ gtk_widget_set_sensitive(entGroup, group =
wiz_groupadd_capable());
+ if (group && !group_name)
+ group_name = strdup("gnunet");
+}
+
+void load_step5()
+{
struct symbol *sym;
GtkWidget *vbox12, *frame7, *vbox13, *vbox14, *vbox15, *hbox53,
*chkMigr,
*entQuota, *chkEnh, *chkStart;
@@ -257,7 +284,8 @@
gtk_main ();
- FREE(configFile);
+ if (doOpenEnhConfigurator)
+ gconf_main(argc, argv);
return 0;
}
Modified: GNUnet/src/conf/wizard.glade
===================================================================
--- GNUnet/src/conf/wizard.glade 2005-05-27 18:41:45 UTC (rev 824)
+++ GNUnet/src/conf/wizard.glade 2005-05-27 19:15:00 UTC (rev 825)
@@ -1431,7 +1431,7 @@
</child>
</widget>
-<widget class="GtkWindow" id="assi_step4">
+<widget class="GtkWindow" id="assi_step5">
<property name="width_request">450</property>
<property name="height_request">350</property>
<property name="visible">True</property>
@@ -1702,13 +1702,13 @@
<property name="spacing">0</property>
<child>
- <widget class="GtkButton" id="step4_back">
+ <widget class="GtkButton" id="step5_back">
<property name="visible">True</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
- <signal name="clicked" handler="on_step4_back_clicked"
last_modification_time="Thu, 14 Apr 2005 17:47:34 GMT"/>
+ <signal name="clicked" handler="on_step5_back_clicked"
last_modification_time="Thu, 14 Apr 2005 17:47:34 GMT"/>
<child>
<widget class="GtkAlignment" id="alignment37">
@@ -1773,7 +1773,7 @@
</child>
<child>
- <widget class="GtkButton" id="step4_next">
+ <widget class="GtkButton" id="step5_next">
<property name="visible">True</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
@@ -1844,7 +1844,7 @@
</child>
<child>
- <widget class="GtkButton" id="step4_cancel">
+ <widget class="GtkButton" id="step5_cancel">
<property name="visible">True</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
@@ -2159,4 +2159,455 @@
</child>
</widget>
+<widget class="GtkWindow" id="assi_step4">
+ <property name="width_request">450</property>
+ <property name="height_request">350</property>
+ <property name="visible">True</property>
+ <property name="title" translatable="yes">GNUnet configuration
assistant</property>
+ <property name="type">GTK_WINDOW_TOPLEVEL</property>
+ <property name="window_position">GTK_WIN_POS_CENTER</property>
+ <property name="modal">False</property>
+ <property name="resizable">True</property>
+ <property name="destroy_with_parent">False</property>
+ <property name="decorated">True</property>
+ <property name="skip_taskbar_hint">False</property>
+ <property name="skip_pager_hint">False</property>
+ <property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
+ <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
+ <signal name="destroy" handler="on_assi_destroy"
last_modification_time="Fri, 15 Apr 2005 14:27:29 GMT"/>
+
+ <child>
+ <widget class="GtkVBox" id="vbox18">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">0</property>
+
+ <child>
+ <widget class="GtkFrame" id="frame8">
+ <property name="visible">True</property>
+ <property name="label_xalign">0</property>
+ <property name="label_yalign">0.5</property>
+ <property name="shadow_type">GTK_SHADOW_ETCHED_IN</property>
+
+ <child>
+ <widget class="GtkVBox" id="vbox19">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">0</property>
+
+ <child>
+ <widget class="GtkScrolledWindow" id="scrolledwindow8">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hscrollbar_policy">GTK_POLICY_NEVER</property>
+ <property
name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
+ <property name="shadow_type">GTK_SHADOW_NONE</property>
+ <property
name="window_placement">GTK_CORNER_TOP_LEFT</property>
+
+ <child>
+ <widget class="GtkTextView" id="textview12">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="editable">False</property>
+ <property name="overwrite">False</property>
+ <property name="accepts_tab">True</property>
+ <property name="justification">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap_mode">GTK_WRAP_WORD</property>
+ <property name="cursor_visible">False</property>
+ <property name="pixels_above_lines">0</property>
+ <property name="pixels_below_lines">0</property>
+ <property name="pixels_inside_wrap">0</property>
+ <property name="left_margin">2</property>
+ <property name="right_margin">0</property>
+ <property name="indent">0</property>
+ <property name="text" translatable="yes">Define the user
and the group owning the GNUnet service here.
+
+For security reasons, it is a good idea to let this setup create a new user
account and a new group under which the GNUnet service is started at system
startup.
+You can also specify existing ones.
+In any case, you should check its permissions to critical files on your
system.</property>
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkHSeparator" id="hseparator7">
+ <property name="visible">True</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkTable" id="table3">
+ <property name="border_width">5</property>
+ <property name="visible">True</property>
+ <property name="n_rows">2</property>
+ <property name="n_columns">2</property>
+ <property name="homogeneous">False</property>
+ <property name="row_spacing">5</property>
+ <property name="column_spacing">5</property>
+
+ <child>
+ <widget class="GtkLabel" id="label110">
+ <property name="visible">True</property>
+ <property name="label"
translatable="yes">Group:</property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">5</property>
+ <property name="ypad">0</property>
+ </widget>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="right_attach">1</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="x_options">fill</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkEntry" id="entUser">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="editable">True</property>
+ <property name="visibility">True</property>
+ <property name="max_length">0</property>
+ <property name="text">gnunet</property>
+ <property name="has_frame">True</property>
+ <property name="invisible_char">*</property>
+ <property name="activates_default">False</property>
+ </widget>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">0</property>
+ <property name="bottom_attach">1</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkEntry" id="entGroup">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="editable">True</property>
+ <property name="visibility">True</property>
+ <property name="max_length">0</property>
+ <property name="text">gnunet</property>
+ <property name="has_frame">True</property>
+ <property name="invisible_char">*</property>
+ <property name="activates_default">False</property>
+ </widget>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkLabel" id="label109">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">User
account:</property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">5</property>
+ <property name="ypad">0</property>
+ </widget>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="right_attach">1</property>
+ <property name="top_attach">0</property>
+ <property name="bottom_attach">1</property>
+ <property name="x_options">fill</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+
+ <child>
+ <widget class="GtkLabel" id="label101">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Other
settings</property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ </widget>
+ <packing>
+ <property name="type">label_item</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkHButtonBox" id="hbuttonbox8">
+ <property name="visible">True</property>
+ <property name="layout_style">GTK_BUTTONBOX_END</property>
+ <property name="spacing">0</property>
+
+ <child>
+ <widget class="GtkButton" id="step4_back">
+ <property name="visible">True</property>
+ <property name="can_default">True</property>
+ <property name="can_focus">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <signal name="clicked" handler="on_step4_back_clicked"
last_modification_time="Thu, 26 May 2005 17:57:25 GMT"/>
+
+ <child>
+ <widget class="GtkAlignment" id="alignment43">
+ <property name="visible">True</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xscale">0</property>
+ <property name="yscale">0</property>
+ <property name="top_padding">0</property>
+ <property name="bottom_padding">0</property>
+ <property name="left_padding">0</property>
+ <property name="right_padding">0</property>
+
+ <child>
+ <widget class="GtkHBox" id="hbox70">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">2</property>
+
+ <child>
+ <widget class="GtkImage" id="image79">
+ <property name="visible">True</property>
+ <property name="stock">gtk-go-back</property>
+ <property name="icon_size">4</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkLabel" id="label102">
+ <property name="visible">True</property>
+ <property name="label"
translatable="yes">Back</property>
+ <property name="use_underline">True</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+ </widget>
+ </child>
+ </widget>
+ </child>
+
+ <child>
+ <widget class="GtkButton" id="step4_next">
+ <property name="visible">True</property>
+ <property name="can_default">True</property>
+ <property name="can_focus">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <signal name="clicked" handler="on_step4_next_clicked"
last_modification_time="Thu, 26 May 2005 17:58:44 GMT"/>
+
+ <child>
+ <widget class="GtkAlignment" id="alignment48">
+ <property name="visible">True</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xscale">0</property>
+ <property name="yscale">0</property>
+ <property name="top_padding">0</property>
+ <property name="bottom_padding">0</property>
+ <property name="left_padding">0</property>
+ <property name="right_padding">0</property>
+
+ <child>
+ <widget class="GtkHBox" id="hbox78">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">2</property>
+
+ <child>
+ <widget class="GtkImage" id="image84">
+ <property name="visible">True</property>
+ <property name="stock">gtk-go-forward</property>
+ <property name="icon_size">4</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkLabel" id="label111">
+ <property name="visible">True</property>
+ <property name="label"
translatable="yes">Next</property>
+ <property name="use_underline">True</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+ </widget>
+ </child>
+ </widget>
+ </child>
+
+ <child>
+ <widget class="GtkButton" id="step4_abort">
+ <property name="visible">True</property>
+ <property name="can_default">True</property>
+ <property name="can_focus">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <signal name="clicked" handler="on_abort_clicked"
last_modification_time="Thu, 14 Apr 2005 17:42:07 GMT"/>
+
+ <child>
+ <widget class="GtkAlignment" id="alignment45">
+ <property name="visible">True</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xscale">0</property>
+ <property name="yscale">0</property>
+ <property name="top_padding">0</property>
+ <property name="bottom_padding">0</property>
+ <property name="left_padding">0</property>
+ <property name="right_padding">0</property>
+
+ <child>
+ <widget class="GtkHBox" id="hbox72">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">2</property>
+
+ <child>
+ <widget class="GtkImage" id="image81">
+ <property name="visible">True</property>
+ <property name="stock">gtk-cancel</property>
+ <property name="icon_size">4</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkLabel" id="label104">
+ <property name="visible">True</property>
+ <property name="label"
translatable="yes">Cancel</property>
+ <property name="use_underline">True</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+ </widget>
+ </child>
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+</widget>
+
</glade-interface>
Modified: GNUnet/src/conf/wizard_callbacks.c
===================================================================
--- GNUnet/src/conf/wizard_callbacks.c 2005-05-27 18:41:45 UTC (rev 824)
+++ GNUnet/src/conf/wizard_callbacks.c 2005-05-27 19:15:00 UTC (rev 825)
@@ -35,12 +35,15 @@
#include "wizard_callbacks.h"
#include "wizard_interface.h"
#include "wizard_support.h"
+#include "wizard_util.h"
+#include "wizard_gtk.h"
#include "lkc.h"
extern GtkWidget *curwnd;
extern int doOpenEnhConfigurator;
extern int doAutoStart;
+extern char *user_name, *group_name;
GtkWidget *msgSave;
GtkWidget *msgSaveFailed;
@@ -120,14 +123,14 @@
void
-on_step4_back_clicked (GtkButton * button, gpointer user_data)
+on_step5_back_clicked (GtkButton * button, gpointer user_data)
{
quit = 0;
gtk_widget_destroy(curwnd);
quit = 1;
- curwnd = create_assi_step3();
- load_step3();
+ curwnd = create_assi_step4();
+ load_step4();
gtk_widget_show(curwnd);
}
@@ -148,7 +151,10 @@
void
on_finish_clicked (GtkButton * button, gpointer user_data)
{
- wiz_autostart(doAutoStart);
+ if (doAutoStart && user_name)
+ wiz_addServiceAccount(group_name, user_name);
+
+ wiz_autostart(doAutoStart, user_name, group_name);
if (save_conf())
gtk_widget_destroy(curwnd);
@@ -311,3 +317,46 @@
{
doOpenEnhConfigurator = gtk_toggle_button_get_active(togglebutton);
}
+
+void
+on_step4_back_clicked (GtkButton * button, gpointer user_data)
+{
+ quit = 0;
+ gtk_widget_destroy(curwnd);
+ quit = 1;
+
+ curwnd = create_assi_step3();
+ load_step3();
+ gtk_widget_show(curwnd);
+}
+
+void
+on_step4_next_clicked (GtkButton * button, gpointer user_data)
+{
+ quit = 0;
+ gtk_widget_destroy(curwnd);
+ quit = 1;
+
+ curwnd = create_assi_step5();
+ load_step5();
+ gtk_widget_show(curwnd);
+}
+
+void
+on_entUser_changed (GtkEditable * editable, gpointer user_data)
+{
+ if (user_name)
+ free(user_name);
+
+ user_name = strdup(gtk_editable_get_chars(editable, 0, -1));
+}
+
+
+void
+on_entGroup_changed (GtkEditable * editable, gpointer user_data)
+{
+ if (user_name)
+ free(user_name);
+
+ group_name = strdup(gtk_editable_get_chars(editable, 0, -1));
+}
Modified: GNUnet/src/conf/wizard_callbacks.h
===================================================================
--- GNUnet/src/conf/wizard_callbacks.h 2005-05-27 18:41:45 UTC (rev 824)
+++ GNUnet/src/conf/wizard_callbacks.h 2005-05-27 19:15:00 UTC (rev 825)
@@ -16,7 +16,7 @@
void on_step3_next_clicked (GtkButton * button, gpointer user_data);
-void on_step4_back_clicked (GtkButton * button, gpointer user_data);
+void on_step5_back_clicked (GtkButton * button, gpointer user_data);
void on_finish_clicked (GtkButton * button, gpointer user_data);
@@ -52,3 +52,11 @@
void on_chkStart_toggled (GtkToggleButton * togglebutton, gpointer user_data);
void on_chkEnh_toggled (GtkToggleButton * togglebutton, gpointer user_data);
+
+void on_step4_back_clicked (GtkButton * button, gpointer user_data);
+
+void on_step4_next_clicked (GtkButton * button, gpointer user_data);
+
+void on_entUser_changed (GtkEditable * editable, gpointer user_data);
+
+void on_entGroup_changed (GtkEditable * editable, gpointer user_data);
Modified: GNUnet/src/conf/wizard_curs.c
===================================================================
--- GNUnet/src/conf/wizard_curs.c 2005-05-27 18:41:45 UTC (rev 824)
+++ GNUnet/src/conf/wizard_curs.c 2005-05-27 19:15:00 UTC (rev 825)
@@ -1,435 +1,511 @@
-/*
- This file is part of GNUnet.
- (C) 2005 Christian Grothoff (and other contributing authors)
-
- GNUnet is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published
- by the Free Software Foundation; either version 2, or (at your
- option) any later version.
-
- GNUnet is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with GNUnet; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
-*/
-
-/**
- * @file conf/wizard_curs.c
- * @brief A easy-to-use configuration assistant for curses
- * @author Nils Durner
- */
-
-#include "gnunet_util.h"
-
-#define LKC_DIRECT_LINK
-#include "lkc.h"
-
-#include "mconf_dialog.h"
-#include "wizard_util.h"
-
-extern int cols, rows;
-
-static struct dialog_list_item **nic_items;
-static int nic_item_count = 0;
-
-void insert_nic_curs(char *name, int defaultNIC)
-{
- struct dialog_list_item *item;
-
- /* Copy NIC data */
- nic_items = (nic_item_count) ?
- realloc(nic_items, (nic_item_count + 1) * sizeof(struct
dialog_list_item *)) :
- malloc(sizeof(struct dialog_list_item *));
-
- item = malloc(sizeof(struct dialog_list_item));
- memset(item, 0, sizeof(struct dialog_list_item));
- nic_items[nic_item_count] = item;
- item->name = strdup(name);
- item->namelen = strlen(name);
- item->selected = wiz_is_nic_default(name, defaultNIC);
-
- nic_item_count++;
-}
-
-int wizard_curs_main(int argc, char *argv[])
-{
- const char * LANG;
- char * configFile;
- void *active_ptr = NULL;
- int idx, ret, autostart, adv = 0;
- struct symbol *sym;
- char *defval;
-
- LANG = getenv("LANG");
- if (LANG == NULL)
- LANG = "en";
- if (strncmp(LANG, "en", 2) == 0)
- LANG = NULL;
- configFile = MALLOC(strlen(DATADIR"/config.in") + 4);
- strcpy(configFile,
- DATADIR"/config.in");
- if (LANG != NULL) {
- strcat(configFile, ".");
- strncat(configFile,
- LANG,
- 2);
- }
-
- conf_parse(configFile);
- FREE(configFile);
-
- conf_read(NULL);
-
- init_dialog();
- init_wsize();
- dialog_clear();
-
- if (dialog_msgbox(_("GNUnet configuration"),
- _("Welcome to GNUnet!\n\nThis assistant will ask you a few
basic questions "
- "in order to configure GNUnet.\n\nPlease visit our homepage
at\n\t"
- "http://www.gnunet.org\nand join our community at\n\t"
- "http://www.gnunet.org/drupal/\n\nHave a lot of fun,\n\nthe
GNUnet team"),
- rows, cols - 5, 1) == -1)
- goto end;
-
- dialog_clear();
-
- wiz_enum_nics(insert_nic_curs);
-
- /* Network interface */
- while (true) {
- ret = dialog_menu(_("GNUnet configuration"),
- _("Choose the network interface
that connects your computer to "
- "the internet from the
list below."), rows, cols - 5, 10,
- 0, active_ptr, nic_item_count -
1, nic_items);
-
- if (ret == 2) {
- /* Help */
- dialog_msgbox(_("Help"), _("The \"Network interface\"
is the device "
- "that connects your computer to the internet.
This is usually a modem, "
- "an ISDN card or a network card in case you are
using DSL."), rows,
- cols - 5, 1);
- }
- else if (ret <= 1) {
- /* Select or Exit */
- char *dst;
-#ifdef MINGW
- char nic[21];
-#else
- char *nic;
-#endif
- for(idx = 0; idx < nic_item_count; idx++) {
-
- if (nic_items[idx]->selected) {
-#ifdef MINGW
- char *src =
strrchr(nic_items[idx]->name, '-') + 2;
- dst = nic;
- while(*src)
- *dst++ = *src++;
- dst[-1] = 0;
-#else
- nic = nic_items[idx]->name;
-#endif
- sym = sym_lookup("INTERFACE",
"NETWORK", 0);
- sym_set_string_value(sym, nic);
- sym = sym_lookup("INTERFACES", "LOAD",
0);
- sym_set_string_value(sym, nic);
- }
-
- free(nic_items[idx]->name);
- free(nic_items[idx]);
- }
- free(nic_items);
-
- break;
- }
- }
-
- if (ret == 1 || ret == -1)
- goto end;
-
- dialog_clear();
-
- /* IP address */
- if (sym = sym_find("IP", "NETWORK")) {
- sym_calc_value_ext(sym, 1);
- defval = sym_get_string_value(sym);
- }
- else
- defval = NULL;
-
- while(true) {
- ret = dialog_inputbox(_("GNUnet configuration"), _("What is
this computer's "
- "public IP adress or hostname?\n\nIf in doubt, leave
this empty."),
- rows, cols - 5, defval ? defval : "");
-
- if (ret == 1) {
- /* Help */
- dialog_msgbox(_("Help"), _("If your provider always
assigns the same "
- "IP-Address to you (a \"static\" IP-Address),
enter it into the "
- "\"IP-Address\" field. If your IP-Address
changes every now and then "
- "(\"dynamic\" IP-Address) but there's a
hostname that always points "
- "to your actual IP-Address (\"Dynamic DNS\"),
you can also enter it "
- "here.\nIf in doubt, leave the field empty.
GNUnet will then try to "
- "determine your IP-Address."), rows, cols - 5,
1);
- }
- else if (ret <= 0)
- break;
- }
-
- if (ret == -1)
- goto end;
-
- sym_set_string_value(sym, dialog_input_result);
-
- dialog_clear();
-
- /* NAT? */
- while(true) {
- ret = dialog_yesno(_("GNUnet configuration"), _("Is this
machine behind "
- "NAT?\n\nIf you are connected to the internet
through another computer "
- "doing SNAT, a router or a \"hardware
firewall\" and other computers "
- "on the internet cannot connect to this
computer, say \"yes\" here. "
- "Answer \"no\" on direct connections through
modems, ISDN cards and "
- "DNAT (also known as \"port forwarding\")."),
rows, cols - 5);
-
- if (ret != -2)
- break;
- }
-
- if (ret == -1)
- goto end;
- else
- sym_set_tristate_value(sym, !ret); /* ret is inverted */
-
- /* Upstream */
- if (sym = sym_find("MAXNETUPBPSTOTAL", "LOAD")) {
- sym_calc_value_ext(sym, 1);
- defval = sym_get_string_value(sym);
- }
- else
- defval = NULL;
-
- while(true) {
- ret = dialog_inputbox(_("GNUnet configuration"), _("How much
upstream "
- "(Bytes/s) may be used?"), rows, cols - 5, defval ?
defval : "");
-
- if (ret == 1) {
- /* Help */
- dialog_msgbox(_("Help"), _("You can limit GNUnet's
ressource usage "
- "here.\n\nThe \"upstream\" is the data channel
through which data "
- "is *sent* to the internet. The limit is either
the total maximum "
- "for this computer or how much GNUnet itself is
allowed to use. You "
- "can specify that later. If you have a
flatrate, you can set it to "
- "the maximum speed of your internet
connection."), rows, cols - 5, 1);
- }
- else if (ret <= 0)
- break;
- }
-
- if (ret == -1)
- goto end;
-
- sym_set_string_value(sym, dialog_input_result);
-
- dialog_clear();
-
- /* Downstram */
- if (sym = sym_find("MAXNETDOWNBPSTOTAL", "LOAD")) {
- sym_calc_value_ext(sym, 1);
- defval = sym_get_string_value(sym);
- }
- else
- defval = NULL;
-
- while(true) {
- ret = dialog_inputbox(_("GNUnet configuration"), _("How much
downstream "
- "(Bytes/s) may be used?"), rows, cols - 5, defval ?
defval : "");
-
- if (ret == 1) {
- /* Help */
- dialog_msgbox(_("Help"), _("You can limit GNUnet's
ressource usage "
- "here.\n\nThe \"downstream\" is the data
channel through which data "
- "is *received* from the internet. The limit is
either the total maximum "
- "for this computer or how much GNUnet itself is
allowed to use. You "
- "can specify that later. If you have a flatrate
you can set it to "
- "the maximum speed of your internet
connection."), rows, cols - 5, 1);
- }
- else if (ret <= 0)
- break;
- }
-
- if (ret == -1)
- goto end;
-
- sym_set_string_value(sym, dialog_input_result);
-
- dialog_clear();
-
- /* Bandwidth allocation */
- while (true) {
- ret = dialog_yesno(_("GNUnet configuration"), _("Share denoted
bandwidth "
- "with other applications?\n\nSay \"yes\" here,
if you don't want other "
- "network traffic to interfere with GNUnet's
operation, but still wish to "
- "constrain GNUnet's bandwidth usage to values
entered in the previous "
- "steps, or if you can't reliably measure the
maximum capabilities "
- "of your connection. \"No\" can be very useful
if other applications "
- "are causing a lot of traffic on your LAN. In
this case, you do not "
- "want to limit the traffic that GNUnet can
inflict on your internet "
- "connection whenever your high-speed LAN gets
used (e.g. by NFS)."),
- rows, cols - 5);
-
- if (ret != -2)
- break;
- }
-
- if (ret == -1)
- goto end;
- else
- sym_set_tristate_value(sym, !ret); /* ret is inverted */
-
- dialog_clear();
-
- /* Max CPU */
- if (sym = sym_find("MAXCPULOAD", "LOAD")) {
- sym_calc_value_ext(sym, 1);
- defval = sym_get_string_value(sym);
- }
- else
- defval = NULL;
-
- while(true) {
- ret = dialog_inputbox(_("GNUnet configuration"), _("How much
CPU (in %) may "
- "be used?"), rows, cols - 5, defval ? defval : "");
-
- if (ret == 1) {
- /* Help */
- dialog_msgbox(_("Help"), _("You can limit GNUnet's
ressource usage "
- "here.\n\nThis is the percentage of processor
time GNUnet is allowed "
- "to use."), rows, cols - 5, 1);
- }
- else if (ret <= 0)
- break;
- }
-
- if (ret == -1)
- goto end;
-
- sym_set_string_value(sym, dialog_input_result);
-
- dialog_clear();
-
- /* Migration */
- while(true) {
- ret = dialog_yesno(_("GNUnet configuration"), _("Store migrated
content?"
- "\n\nGNUnet is able to store data from other
peers in your datastore. "
- "This is useful if an adversary has access to
your inserted content and "
- "you need to deny that the content is yours.
With \"content migration\" "
- "on, the content could have \"migrated\" over
the internet to your node"
- " without your knowledge.\nIt also helps to
spread popular content over "
- "different peers to enhance availability."),
rows, cols - 5);
-
- if (ret != -2)
- break;
- }
-
- if (ret == -1)
- goto end;
- else
- sym_set_tristate_value(sym, !ret); /* ret is inverted */
-
- dialog_clear();
-
- /* Quota */
- if (sym = sym_find("DISKQUOTA", "FS")) {
- sym_calc_value_ext(sym, 1);
- defval = sym_get_string_value(sym);
- }
- else
- defval = NULL;
-
- while(true) {
- ret = dialog_inputbox(_("GNUnet configuration"), _("What's the
maximum "
- "datastore size in MB?\n\nThe GNUnet datastore contains
all data that "
- "GNUnet generates (index data, inserted and migrated
content)."),
- rows, cols - 5, defval ? defval : "");
-
- if (ret == 1) {
- /* Help - not available */
- }
- else if (ret <= 0)
- break;
- }
-
- if (ret == -1)
- goto end;
-
- sym_set_string_value(sym, dialog_input_result);
-
- dialog_clear();
-
- /* Autostart */
- while(true) {
- ret = dialog_yesno(_("GNUnet configuration"), _("Do you want to
launch "
- "GNUnet as a system service?"
- "\n\nIf you say \"yes\" here, the GNUnet
background process will be "
- "automatically started when you turn on your
computer. If you say \"no\""
- " here, you have to launch GNUnet yourself each
time you want to use it."),
- rows, cols - 5);
-
- if (ret != -2)
- break;
- }
-
- if (ret == -1)
- goto end;
- else
- autostart = !ret; /* ret is inverted */
-
- dialog_clear();
-
- /* Advanced */
- while(true) {
- ret = dialog_yesno(_("GNUnet configuration"), _("If you are an
experienced "
- "user, you may want to tweak your GNUnet
installation using the enhanced "
- "configurator.\n\nDo you want to start it
now?"), rows, cols - 5);
-
- if (ret != -2)
- break;
- }
-
- if (ret == -1)
- goto end;
- else
- adv = !ret;
-
- /* Save config */
- wiz_autostart(autostart);
- while(true) {
- if (conf_write(NULL) != 0) {
- ret = dialog_yesno(_("GNUnet configuration"),
- _("Cannot save
configuration.\n\nTry again?"), rows, cols - 5);
- }
- else
- ret = 1;
-
- if (ret == 1 || ret == -1)
- break;
- }
-
-end:
- end_dialog();
-
- if (adv) {
- mconf_main(argc, argv);
- }
-
- return 0;
-}
-
-/* end of wizard_curs.c */
+/*
+ This file is part of GNUnet.
+ (C) 2005 Christian Grothoff (and other contributing authors)
+
+ GNUnet is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 2, or (at your
+ option) any later version.
+
+ GNUnet is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNUnet; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+/**
+ * @file conf/wizard_curs.c
+ * @brief A easy-to-use configuration assistant for curses
+ * @author Nils Durner
+ */
+
+#include "gnunet_util.h"
+
+#define LKC_DIRECT_LINK
+#include "lkc.h"
+
+#include "mconf_dialog.h"
+#include "wizard_util.h"
+
+extern int cols, rows;
+int mconf_main(int ac, char **av);
+
+static struct dialog_list_item **nic_items;
+static int nic_item_count = 0;
+
+void insert_nic_curs(char *name, int defaultNIC)
+{
+ struct dialog_list_item *item;
+
+ /* Copy NIC data */
+ nic_items = (nic_item_count) ?
+ realloc(nic_items, (nic_item_count + 1) * sizeof(struct
dialog_list_item *)) :
+ malloc(sizeof(struct dialog_list_item *));
+
+ item = malloc(sizeof(struct dialog_list_item));
+ memset(item, 0, sizeof(struct dialog_list_item));
+ nic_items[nic_item_count] = item;
+ item->name = strdup(name);
+ item->namelen = strlen(name);
+ item->selected = wiz_is_nic_default(name, defaultNIC);
+
+ nic_item_count++;
+}
+
+int wizard_curs_main(int argc, char *argv[])
+{
+ const char * LANG;
+ char * configFile;
+ void *active_ptr = NULL;
+ int idx, ret, autostart = 0, adv = 0;
+ struct symbol *sym;
+ char *defval, *user_name = NULL, *group_name = NULL;
+
+ LANG = getenv("LANG");
+ if (LANG == NULL)
+ LANG = "en";
+ if (strncmp(LANG, "en", 2) == 0)
+ LANG = NULL;
+ configFile = MALLOC(strlen(DATADIR"/config.in") + 4);
+ strcpy(configFile,
+ DATADIR"/config.in");
+ if (LANG != NULL) {
+ strcat(configFile, ".");
+ strncat(configFile,
+ LANG,
+ 2);
+ }
+
+ conf_parse(configFile);
+
+ conf_read(NULL);
+
+ init_dialog();
+ init_wsize();
+ dialog_clear();
+
+ if (dialog_msgbox(_("GNUnet configuration"),
+ _("Welcome to GNUnet!\n\nThis assistant will ask you a few
basic questions "
+ "in order to configure GNUnet.\n\nPlease visit our homepage
at\n\t"
+ "http://www.gnunet.org\nand join our community at\n\t"
+ "http://www.gnunet.org/drupal/\n\nHave a lot of fun,\n\nthe
GNUnet team"),
+ rows, cols - 5, 1) == -1)
+ goto end;
+
+ dialog_clear();
+
+ wiz_enum_nics(insert_nic_curs);
+
+ /* Network interface */
+ while (true) {
+ ret = dialog_menu(_("GNUnet configuration"),
+ _("Choose the network interface
that connects your computer to "
+ "the internet from the
list below."), rows, cols - 5, 10,
+ 0, active_ptr, nic_item_count -
1, nic_items);
+
+ if (ret == 2) {
+ /* Help */
+ dialog_msgbox(_("Help"), _("The \"Network interface\"
is the device "
+ "that connects your computer to the internet.
This is usually a modem, "
+ "an ISDN card or a network card in case you are
using DSL."), rows,
+ cols - 5, 1);
+ }
+ else if (ret <= 1) {
+ /* Select or Exit */
+ char *dst;
+#ifdef MINGW
+ char nic[21];
+#else
+ char *nic;
+#endif
+ for(idx = 0; idx < nic_item_count; idx++) {
+
+ if (nic_items[idx]->selected) {
+#ifdef MINGW
+ char *src =
strrchr(nic_items[idx]->name, '-') + 2;
+ dst = nic;
+ while(*src)
+ *dst++ = *src++;
+ dst[-1] = 0;
+#else
+ nic = nic_items[idx]->name;
+#endif
+ sym = sym_lookup("INTERFACE",
"NETWORK", 0);
+ sym_set_string_value(sym, nic);
+ sym = sym_lookup("INTERFACES", "LOAD",
0);
+ sym_set_string_value(sym, nic);
+ }
+
+ free(nic_items[idx]->name);
+ free(nic_items[idx]);
+ }
+ free(nic_items);
+
+ break;
+ }
+ }
+
+ if (ret == 1 || ret == -1)
+ goto end;
+
+ dialog_clear();
+
+ /* IP address */
+ if ((sym = sym_find("IP", "NETWORK"))) {
+ sym_calc_value_ext(sym, 1);
+ defval = (char *) sym_get_string_value(sym);
+ }
+ else
+ defval = NULL;
+
+ while(true) {
+ ret = dialog_inputbox(_("GNUnet configuration"), _("What is
this computer's "
+ "public IP adress or hostname?\n\nIf in doubt, leave
this empty."),
+ rows, cols - 5, defval ? defval : "");
+
+ if (ret == 1) {
+ /* Help */
+ dialog_msgbox(_("Help"), _("If your provider always
assigns the same "
+ "IP-Address to you (a \"static\" IP-Address),
enter it into the "
+ "\"IP-Address\" field. If your IP-Address
changes every now and then "
+ "(\"dynamic\" IP-Address) but there's a
hostname that always points "
+ "to your actual IP-Address (\"Dynamic DNS\"),
you can also enter it "
+ "here.\nIf in doubt, leave the field empty.
GNUnet will then try to "
+ "determine your IP-Address."), rows, cols - 5,
1);
+ }
+ else if (ret <= 0)
+ break;
+ }
+
+ if (ret == -1)
+ goto end;
+
+ sym_set_string_value(sym, dialog_input_result);
+
+ dialog_clear();
+
+ /* NAT? */
+ while(true) {
+ ret = dialog_yesno(_("GNUnet configuration"), _("Is this
machine behind "
+ "NAT?\n\nIf you are connected to the internet
through another computer "
+ "doing SNAT, a router or a \"hardware
firewall\" and other computers "
+ "on the internet cannot connect to this
computer, say \"yes\" here. "
+ "Answer \"no\" on direct connections through
modems, ISDN cards and "
+ "DNAT (also known as \"port forwarding\")."),
rows, cols - 5);
+
+ if (ret != -2)
+ break;
+ }
+
+ if (ret == -1)
+ goto end;
+ else
+ sym_set_tristate_value(sym, !ret); /* ret is inverted */
+
+ /* Upstream */
+ if ((sym = sym_find("MAXNETUPBPSTOTAL", "LOAD"))) {
+ sym_calc_value_ext(sym, 1);
+ defval = (char *) sym_get_string_value(sym);
+ }
+ else
+ defval = NULL;
+
+ while(true) {
+ ret = dialog_inputbox(_("GNUnet configuration"), _("How much
upstream "
+ "(Bytes/s) may be used?"), rows, cols - 5, defval ?
defval : "");
+
+ if (ret == 1) {
+ /* Help */
+ dialog_msgbox(_("Help"), _("You can limit GNUnet's
ressource usage "
+ "here.\n\nThe \"upstream\" is the data channel
through which data "
+ "is *sent* to the internet. The limit is either
the total maximum "
+ "for this computer or how much GNUnet itself is
allowed to use. You "
+ "can specify that later. If you have a
flatrate, you can set it to "
+ "the maximum speed of your internet
connection."), rows, cols - 5, 1);
+ }
+ else if (ret <= 0)
+ break;
+ }
+
+ if (ret == -1)
+ goto end;
+
+ sym_set_string_value(sym, dialog_input_result);
+
+ dialog_clear();
+
+ /* Downstram */
+ if ((sym = sym_find("MAXNETDOWNBPSTOTAL", "LOAD"))) {
+ sym_calc_value_ext(sym, 1);
+ defval = (char *) sym_get_string_value(sym);
+ }
+ else
+ defval = NULL;
+
+ while(true) {
+ ret = dialog_inputbox(_("GNUnet configuration"), _("How much
downstream "
+ "(Bytes/s) may be used?"), rows, cols - 5, defval ?
defval : "");
+
+ if (ret == 1) {
+ /* Help */
+ dialog_msgbox(_("Help"), _("You can limit GNUnet's
ressource usage "
+ "here.\n\nThe \"downstream\" is the data
channel through which data "
+ "is *received* from the internet. The limit is
either the total maximum "
+ "for this computer or how much GNUnet itself is
allowed to use. You "
+ "can specify that later. If you have a flatrate
you can set it to "
+ "the maximum speed of your internet
connection."), rows, cols - 5, 1);
+ }
+ else if (ret <= 0)
+ break;
+ }
+
+ if (ret == -1)
+ goto end;
+
+ sym_set_string_value(sym, dialog_input_result);
+
+ dialog_clear();
+
+ /* Bandwidth allocation */
+ while (true) {
+ ret = dialog_yesno(_("GNUnet configuration"), _("Share denoted
bandwidth "
+ "with other applications?\n\nSay \"yes\" here,
if you don't want other "
+ "network traffic to interfere with GNUnet's
operation, but still wish to "
+ "constrain GNUnet's bandwidth usage to values
entered in the previous "
+ "steps, or if you can't reliably measure the
maximum capabilities "
+ "of your connection. \"No\" can be very useful
if other applications "
+ "are causing a lot of traffic on your LAN. In
this case, you do not "
+ "want to limit the traffic that GNUnet can
inflict on your internet "
+ "connection whenever your high-speed LAN gets
used (e.g. by NFS)."),
+ rows, cols - 5);
+
+ if (ret != -2)
+ break;
+ }
+
+ if (ret == -1)
+ goto end;
+ else
+ sym_set_tristate_value(sym, !ret); /* ret is inverted */
+
+ dialog_clear();
+
+ /* Max CPU */
+ if ((sym = sym_find("MAXCPULOAD", "LOAD"))) {
+ sym_calc_value_ext(sym, 1);
+ defval = (char *) sym_get_string_value(sym);
+ }
+ else
+ defval = NULL;
+
+ while(true) {
+ ret = dialog_inputbox(_("GNUnet configuration"), _("How much
CPU (in %) may "
+ "be used?"), rows, cols - 5, defval ? defval : "");
+
+ if (ret == 1) {
+ /* Help */
+ dialog_msgbox(_("Help"), _("You can limit GNUnet's
ressource usage "
+ "here.\n\nThis is the percentage of processor
time GNUnet is allowed "
+ "to use."), rows, cols - 5, 1);
+ }
+ else if (ret <= 0)
+ break;
+ }
+
+ if (ret == -1)
+ goto end;
+
+ sym_set_string_value(sym, dialog_input_result);
+
+ dialog_clear();
+
+ /* Migration */
+ while(true) {
+ ret = dialog_yesno(_("GNUnet configuration"), _("Store migrated
content?"
+ "\n\nGNUnet is able to store data from other
peers in your datastore. "
+ "This is useful if an adversary has access to
your inserted content and "
+ "you need to deny that the content is yours.
With \"content migration\" "
+ "on, the content could have \"migrated\" over
the internet to your node"
+ " without your knowledge.\nIt also helps to
spread popular content over "
+ "different peers to enhance availability."),
rows, cols - 5);
+
+ if (ret != -2)
+ break;
+ }
+
+ if (ret == -1)
+ goto end;
+ else
+ sym_set_tristate_value(sym, !ret); /* ret is inverted */
+
+ dialog_clear();
+
+ /* Quota */
+ if ((sym = sym_find("DISKQUOTA", "FS"))) {
+ sym_calc_value_ext(sym, 1);
+ defval = (char *) sym_get_string_value(sym);
+ }
+ else
+ defval = NULL;
+
+ while(true) {
+ ret = dialog_inputbox(_("GNUnet configuration"), _("What's the
maximum "
+ "datastore size in MB?\n\nThe GNUnet datastore contains
all data that "
+ "GNUnet generates (index data, inserted and migrated
content)."),
+ rows, cols - 5, defval ? defval : "");
+
+ if (ret == 1) {
+ /* Help - not available */
+ }
+ else if (ret <= 0)
+ break;
+ }
+
+ if (ret == -1)
+ goto end;
+
+ sym_set_string_value(sym, dialog_input_result);
+
+ dialog_clear();
+
+ /* Autostart */
+ if (wiz_autostart_capable()) {
+ while(true) {
+ ret = dialog_yesno(_("GNUnet configuration"), _("Do you
want to launch "
+ "GNUnet as a system service?"
+ "\n\nIf you say \"yes\" here, the
GNUnet background process will be "
+ "automatically started when you turn on
your computer. If you say \"no\""
+ " here, you have to launch GNUnet
yourself each time you want to use it."),
+ rows, cols - 5);
+
+ if (ret != -2)
+ break;
+ }
+
+ if (ret == -1)
+ goto end;
+ else
+ autostart = !ret; /* ret is inverted */
+
+ dialog_clear();
+ }
+
+ /* User */
+ if (wiz_useradd_capable()) {
+ while(true) {
+ ret = dialog_inputbox(_("GNUnet configuration"),
+ _("Define the user owning the GNUnet
service.\n\n"
+ "For security reasons, it is a good
idea to let this setup create "
+ "a new user account under which the
GNUnet service is started "
+ "at system startup.\n\n"
+ "You can also specify an already
existant user account here.\n\n"
+ "In any case, you should check its
permissions to critical files "
+ "on your system.\n\nGNUnet user:"),
+ rows, cols - 5, "gnunet");
+
+ if (ret == 1) {
+ /* Help */
+ }
+ else if (ret <= 0) {
+ user_name = strdup("gnunet");
+ break;
+ }
+ }
+
+ if (ret == -1)
+ goto end;
+
+ dialog_clear();
+
+ /* Group */
+ if (wiz_groupadd_capable()) {
+ while(true) {
+ ret = dialog_inputbox(_("GNUnet configuration"),
+ _("Define the group owning the GNUnet
service.\n\n"
+ "For security reasons, it is a
good idea to let this setup create "
+ "a new group for the chosen
user account.\n\n"
+ "You can also specify a already
existant group here.\n\n"
+ "Only members of this group
will be allowed to start and stop the "
+ "the GNUnet server and have
access to GNUnet server data.\n\n"
+ "GNUnet group:"),
+ rows, cols - 5, "gnunet");
+
+ if (ret == 1) {
+ /* Help */
+ }
+ else if (ret <= 0) {
+ group_name =
strdup(dialog_input_result);
+ break;
+ }
+ }
+
+ if (ret == -1)
+ goto end;
+
+ dialog_clear();
+ }
+ }
+
+ dialog_clear();
+
+ /* Advanced */
+ while(true) {
+ ret = dialog_yesno(_("GNUnet configuration"), _("If you are an
experienced "
+ "user, you may want to tweak your GNUnet
installation using the enhanced "
+ "configurator.\n\nDo you want to start it after
saving your configuration?"),
+ rows, cols - 5);
+
+ if (ret != -2)
+ break;
+ }
+
+ if (ret == -1)
+ goto end;
+ else
+ adv = !ret;
+
+ dialog_clear();
+ end_dialog();
+
+ /* Save config */
+ if (user_name && strlen(user_name) > 0)
+ wiz_addServiceAccount(group_name, user_name);
+
+ wiz_autostart(autostart, user_name, group_name);
+
+ init_dialog();
+ dialog_clear();
+
+ while(true) {
+ if (conf_write(NULL) != 0) {
+ ret = dialog_yesno(_("GNUnet configuration"),
+ _("Cannot save
configuration.\n\nTry again?"), rows, cols - 5);
+ }
+ else
+ ret = 1;
+
+ if (ret == 1 || ret == -1)
+ break;
+ }
+
+end:
+ end_dialog();
+
+ if (user_name)
+ free(user_name);
+ if (group_name)
+ free(group_name);
+
+ if (adv) {
+ mconf_main(argc, argv);
+ }
+
+ return 0;
+}
+
+/* end of wizard_curs.c */
Added: GNUnet/src/conf/wizard_gtk.h
===================================================================
--- GNUnet/src/conf/wizard_gtk.h 2005-05-27 18:41:45 UTC (rev 824)
+++ GNUnet/src/conf/wizard_gtk.h 2005-05-27 19:15:00 UTC (rev 825)
@@ -0,0 +1,34 @@
+/*
+ This file is part of GNUnet.
+ (C) 2005 Christian Grothoff (and other contributing authors)
+
+ GNUnet is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 2, or (at your
+ option) any later version.
+
+ GNUnet is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNUnet; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+/**
+ * @file conf/wizard_gtk.h
+ * @author Nils Durner
+ */
+
+#ifndef _WIZARD_GTK_H_
+#define _WIZARD_GTK_H_
+
+void load_step2();
+void load_step3();
+void load_step4();
+void load_step5();
+
+#endif /*_WIZARD_GTK_H_ */
Modified: GNUnet/src/conf/wizard_interface.c
===================================================================
--- GNUnet/src/conf/wizard_interface.c 2005-05-27 18:41:45 UTC (rev 824)
+++ GNUnet/src/conf/wizard_interface.c 2005-05-27 19:15:00 UTC (rev 825)
@@ -742,9 +742,9 @@
}
GtkWidget *
-create_assi_step4 (void)
+create_assi_step5 (void)
{
- GtkWidget *assi_step4;
+ GtkWidget *assi_step5;
GtkWidget *vbox12;
GtkWidget *frame7;
GtkWidget *vbox13;
@@ -761,31 +761,31 @@
GtkWidget *chkEnh;
GtkWidget *label43;
GtkWidget *hbuttonbox5;
- GtkWidget *step4_back;
+ GtkWidget *step5_back;
GtkWidget *alignment37;
GtkWidget *hbox60;
GtkWidget *image70;
GtkWidget *label91;
- GtkWidget *step4_next;
+ GtkWidget *step5_next;
GtkWidget *alignment40;
GtkWidget *hbox63;
GtkWidget *image73;
GtkWidget *label94;
- GtkWidget *step4_cancel;
+ GtkWidget *step5_cancel;
GtkWidget *alignment39;
GtkWidget *hbox62;
GtkWidget *image72;
GtkWidget *label93;
- assi_step4 = gtk_window_new (GTK_WINDOW_TOPLEVEL);
- gtk_widget_set_size_request (assi_step4, 450, 350);
- gtk_window_set_title (GTK_WINDOW (assi_step4),
+ assi_step5 = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+ gtk_widget_set_size_request (assi_step5, 450, 350);
+ gtk_window_set_title (GTK_WINDOW (assi_step5),
_("GNUnet configuration assistant"));
- gtk_window_set_position (GTK_WINDOW (assi_step4), GTK_WIN_POS_CENTER);
+ gtk_window_set_position (GTK_WINDOW (assi_step5), GTK_WIN_POS_CENTER);
vbox12 = gtk_vbox_new (FALSE, 0);
gtk_widget_show (vbox12);
- gtk_container_add (GTK_CONTAINER (assi_step4), vbox12);
+ gtk_container_add (GTK_CONTAINER (assi_step5), vbox12);
frame7 = gtk_frame_new (NULL);
gtk_widget_show (frame7);
@@ -867,14 +867,14 @@
gtk_box_pack_start (GTK_BOX (vbox12), hbuttonbox5, FALSE, TRUE, 0);
gtk_button_box_set_layout (GTK_BUTTON_BOX (hbuttonbox5), GTK_BUTTONBOX_END);
- step4_back = gtk_button_new ();
- gtk_widget_show (step4_back);
- gtk_container_add (GTK_CONTAINER (hbuttonbox5), step4_back);
- GTK_WIDGET_SET_FLAGS (step4_back, GTK_CAN_DEFAULT);
+ step5_back = gtk_button_new ();
+ gtk_widget_show (step5_back);
+ gtk_container_add (GTK_CONTAINER (hbuttonbox5), step5_back);
+ GTK_WIDGET_SET_FLAGS (step5_back, GTK_CAN_DEFAULT);
alignment37 = gtk_alignment_new (0.5, 0.5, 0, 0);
gtk_widget_show (alignment37);
- gtk_container_add (GTK_CONTAINER (step4_back), alignment37);
+ gtk_container_add (GTK_CONTAINER (step5_back), alignment37);
hbox60 = gtk_hbox_new (FALSE, 2);
gtk_widget_show (hbox60);
@@ -888,14 +888,14 @@
gtk_widget_show (label91);
gtk_box_pack_start (GTK_BOX (hbox60), label91, FALSE, FALSE, 0);
- step4_next = gtk_button_new ();
- gtk_widget_show (step4_next);
- gtk_container_add (GTK_CONTAINER (hbuttonbox5), step4_next);
- GTK_WIDGET_SET_FLAGS (step4_next, GTK_CAN_DEFAULT);
+ step5_next = gtk_button_new ();
+ gtk_widget_show (step5_next);
+ gtk_container_add (GTK_CONTAINER (hbuttonbox5), step5_next);
+ GTK_WIDGET_SET_FLAGS (step5_next, GTK_CAN_DEFAULT);
alignment40 = gtk_alignment_new (0.5, 0.5, 0, 0);
gtk_widget_show (alignment40);
- gtk_container_add (GTK_CONTAINER (step4_next), alignment40);
+ gtk_container_add (GTK_CONTAINER (step5_next), alignment40);
hbox63 = gtk_hbox_new (FALSE, 2);
gtk_widget_show (hbox63);
@@ -909,14 +909,14 @@
gtk_widget_show (label94);
gtk_box_pack_start (GTK_BOX (hbox63), label94, FALSE, FALSE, 0);
- step4_cancel = gtk_button_new ();
- gtk_widget_show (step4_cancel);
- gtk_container_add (GTK_CONTAINER (hbuttonbox5), step4_cancel);
- GTK_WIDGET_SET_FLAGS (step4_cancel, GTK_CAN_DEFAULT);
+ step5_cancel = gtk_button_new ();
+ gtk_widget_show (step5_cancel);
+ gtk_container_add (GTK_CONTAINER (hbuttonbox5), step5_cancel);
+ GTK_WIDGET_SET_FLAGS (step5_cancel, GTK_CAN_DEFAULT);
alignment39 = gtk_alignment_new (0.5, 0.5, 0, 0);
gtk_widget_show (alignment39);
- gtk_container_add (GTK_CONTAINER (step4_cancel), alignment39);
+ gtk_container_add (GTK_CONTAINER (step5_cancel), alignment39);
hbox62 = gtk_hbox_new (FALSE, 2);
gtk_widget_show (hbox62);
@@ -930,7 +930,7 @@
gtk_widget_show (label93);
gtk_box_pack_start (GTK_BOX (hbox62), label93, FALSE, FALSE, 0);
- g_signal_connect ((gpointer) assi_step4, "destroy",
+ g_signal_connect ((gpointer) assi_step5, "destroy",
G_CALLBACK (on_assi_destroy), NULL);
g_signal_connect ((gpointer) chkMigr, "toggled",
G_CALLBACK (on_chkMigr_toggled), NULL);
@@ -940,48 +940,48 @@
G_CALLBACK (on_chkStart_toggled), NULL);
g_signal_connect ((gpointer) chkEnh, "toggled",
G_CALLBACK (on_chkEnh_toggled), NULL);
- g_signal_connect ((gpointer) step4_back, "clicked",
- G_CALLBACK (on_step4_back_clicked), NULL);
- g_signal_connect ((gpointer) step4_next, "clicked",
+ g_signal_connect ((gpointer) step5_back, "clicked",
+ G_CALLBACK (on_step5_back_clicked), NULL);
+ g_signal_connect ((gpointer) step5_next, "clicked",
G_CALLBACK (on_finish_clicked), NULL);
- g_signal_connect ((gpointer) step4_cancel, "clicked",
+ g_signal_connect ((gpointer) step5_cancel, "clicked",
G_CALLBACK (on_abort_clicked), NULL);
/* Store pointers to all widgets, for use by lookup_widget(). */
- GLADE_HOOKUP_OBJECT_NO_REF (assi_step4, assi_step4, "assi_step4");
- GLADE_HOOKUP_OBJECT (assi_step4, vbox12, "vbox12");
- GLADE_HOOKUP_OBJECT (assi_step4, frame7, "frame7");
- GLADE_HOOKUP_OBJECT (assi_step4, vbox13, "vbox13");
- GLADE_HOOKUP_OBJECT (assi_step4, scrolledwindow7, "scrolledwindow7");
- GLADE_HOOKUP_OBJECT (assi_step4, textview10, "textview10");
- GLADE_HOOKUP_OBJECT (assi_step4, hseparator5, "hseparator5");
- GLADE_HOOKUP_OBJECT (assi_step4, vbox14, "vbox14");
- GLADE_HOOKUP_OBJECT (assi_step4, vbox15, "vbox15");
- GLADE_HOOKUP_OBJECT (assi_step4, chkMigr, "chkMigr");
- GLADE_HOOKUP_OBJECT (assi_step4, hbox53, "hbox53");
- GLADE_HOOKUP_OBJECT (assi_step4, label84, "label84");
- GLADE_HOOKUP_OBJECT (assi_step4, entQuota, "entQuota");
- GLADE_HOOKUP_OBJECT (assi_step4, chkStart, "chkStart");
- GLADE_HOOKUP_OBJECT (assi_step4, chkEnh, "chkEnh");
- GLADE_HOOKUP_OBJECT (assi_step4, label43, "label43");
- GLADE_HOOKUP_OBJECT (assi_step4, hbuttonbox5, "hbuttonbox5");
- GLADE_HOOKUP_OBJECT (assi_step4, step4_back, "step4_back");
- GLADE_HOOKUP_OBJECT (assi_step4, alignment37, "alignment37");
- GLADE_HOOKUP_OBJECT (assi_step4, hbox60, "hbox60");
- GLADE_HOOKUP_OBJECT (assi_step4, image70, "image70");
- GLADE_HOOKUP_OBJECT (assi_step4, label91, "label91");
- GLADE_HOOKUP_OBJECT (assi_step4, step4_next, "step4_next");
- GLADE_HOOKUP_OBJECT (assi_step4, alignment40, "alignment40");
- GLADE_HOOKUP_OBJECT (assi_step4, hbox63, "hbox63");
- GLADE_HOOKUP_OBJECT (assi_step4, image73, "image73");
- GLADE_HOOKUP_OBJECT (assi_step4, label94, "label94");
- GLADE_HOOKUP_OBJECT (assi_step4, step4_cancel, "step4_cancel");
- GLADE_HOOKUP_OBJECT (assi_step4, alignment39, "alignment39");
- GLADE_HOOKUP_OBJECT (assi_step4, hbox62, "hbox62");
- GLADE_HOOKUP_OBJECT (assi_step4, image72, "image72");
- GLADE_HOOKUP_OBJECT (assi_step4, label93, "label93");
+ GLADE_HOOKUP_OBJECT_NO_REF (assi_step5, assi_step5, "assi_step5");
+ GLADE_HOOKUP_OBJECT (assi_step5, vbox12, "vbox12");
+ GLADE_HOOKUP_OBJECT (assi_step5, frame7, "frame7");
+ GLADE_HOOKUP_OBJECT (assi_step5, vbox13, "vbox13");
+ GLADE_HOOKUP_OBJECT (assi_step5, scrolledwindow7, "scrolledwindow7");
+ GLADE_HOOKUP_OBJECT (assi_step5, textview10, "textview10");
+ GLADE_HOOKUP_OBJECT (assi_step5, hseparator5, "hseparator5");
+ GLADE_HOOKUP_OBJECT (assi_step5, vbox14, "vbox14");
+ GLADE_HOOKUP_OBJECT (assi_step5, vbox15, "vbox15");
+ GLADE_HOOKUP_OBJECT (assi_step5, chkMigr, "chkMigr");
+ GLADE_HOOKUP_OBJECT (assi_step5, hbox53, "hbox53");
+ GLADE_HOOKUP_OBJECT (assi_step5, label84, "label84");
+ GLADE_HOOKUP_OBJECT (assi_step5, entQuota, "entQuota");
+ GLADE_HOOKUP_OBJECT (assi_step5, chkStart, "chkStart");
+ GLADE_HOOKUP_OBJECT (assi_step5, chkEnh, "chkEnh");
+ GLADE_HOOKUP_OBJECT (assi_step5, label43, "label43");
+ GLADE_HOOKUP_OBJECT (assi_step5, hbuttonbox5, "hbuttonbox5");
+ GLADE_HOOKUP_OBJECT (assi_step5, step5_back, "step5_back");
+ GLADE_HOOKUP_OBJECT (assi_step5, alignment37, "alignment37");
+ GLADE_HOOKUP_OBJECT (assi_step5, hbox60, "hbox60");
+ GLADE_HOOKUP_OBJECT (assi_step5, image70, "image70");
+ GLADE_HOOKUP_OBJECT (assi_step5, label91, "label91");
+ GLADE_HOOKUP_OBJECT (assi_step5, step5_next, "step5_next");
+ GLADE_HOOKUP_OBJECT (assi_step5, alignment40, "alignment40");
+ GLADE_HOOKUP_OBJECT (assi_step5, hbox63, "hbox63");
+ GLADE_HOOKUP_OBJECT (assi_step5, image73, "image73");
+ GLADE_HOOKUP_OBJECT (assi_step5, label94, "label94");
+ GLADE_HOOKUP_OBJECT (assi_step5, step5_cancel, "step5_cancel");
+ GLADE_HOOKUP_OBJECT (assi_step5, alignment39, "alignment39");
+ GLADE_HOOKUP_OBJECT (assi_step5, hbox62, "hbox62");
+ GLADE_HOOKUP_OBJECT (assi_step5, image72, "image72");
+ GLADE_HOOKUP_OBJECT (assi_step5, label93, "label93");
- return assi_step4;
+ return assi_step5;
}
GtkWidget *
@@ -1124,3 +1124,233 @@
return msgSaveFailed;
}
+
+GtkWidget *
+create_assi_step4 (void)
+{
+ GtkWidget *assi_step4;
+ GtkWidget *vbox18;
+ GtkWidget *frame8;
+ GtkWidget *vbox19;
+ GtkWidget *scrolledwindow8;
+ GtkWidget *textview12;
+ GtkWidget *hseparator7;
+ GtkWidget *table3;
+ GtkWidget *label110;
+ GtkWidget *entUser;
+ GtkWidget *entGroup;
+ GtkWidget *label109;
+ GtkWidget *label101;
+ GtkWidget *hbuttonbox8;
+ GtkWidget *step4_back;
+ GtkWidget *alignment43;
+ GtkWidget *hbox70;
+ GtkWidget *image79;
+ GtkWidget *label102;
+ GtkWidget *step4_next;
+ GtkWidget *alignment48;
+ GtkWidget *hbox78;
+ GtkWidget *image84;
+ GtkWidget *label111;
+ GtkWidget *step4_abort;
+ GtkWidget *alignment45;
+ GtkWidget *hbox72;
+ GtkWidget *image81;
+ GtkWidget *label104;
+
+ assi_step4 = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+ gtk_widget_set_size_request (assi_step4, 450, 350);
+ gtk_window_set_title (GTK_WINDOW (assi_step4),
+ _("GNUnet configuration assistant"));
+ gtk_window_set_position (GTK_WINDOW (assi_step4), GTK_WIN_POS_CENTER);
+
+ vbox18 = gtk_vbox_new (FALSE, 0);
+ gtk_widget_show (vbox18);
+ gtk_container_add (GTK_CONTAINER (assi_step4), vbox18);
+
+ frame8 = gtk_frame_new (NULL);
+ gtk_widget_show (frame8);
+ gtk_box_pack_start (GTK_BOX (vbox18), frame8, TRUE, TRUE, 0);
+
+ vbox19 = gtk_vbox_new (FALSE, 0);
+ gtk_widget_show (vbox19);
+ gtk_container_add (GTK_CONTAINER (frame8), vbox19);
+
+ scrolledwindow8 = gtk_scrolled_window_new (NULL, NULL);
+ gtk_widget_show (scrolledwindow8);
+ gtk_box_pack_start (GTK_BOX (vbox19), scrolledwindow8, TRUE, TRUE, 0);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow8),
+ GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
+
+ textview12 = gtk_text_view_new ();
+ gtk_widget_show (textview12);
+ gtk_container_add (GTK_CONTAINER (scrolledwindow8), textview12);
+ gtk_text_view_set_editable (GTK_TEXT_VIEW (textview12), FALSE);
+ gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (textview12), GTK_WRAP_WORD);
+ gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (textview12), FALSE);
+ gtk_text_view_set_left_margin (GTK_TEXT_VIEW (textview12), 2);
+ gtk_text_buffer_set_text (gtk_text_view_get_buffer
+ (GTK_TEXT_VIEW (textview12)),
+ _
+ ("Define the user and the group owning the GNUnet
service here.\n\nFor security reasons, it is a good idea to let this setup
create a new user account and a new group under which the GNUnet service is
started at system startup.\nYou can also specify existing ones.\nIn any case,
you should check its permissions to critical files on your system."),
+ -1);
+
+ hseparator7 = gtk_hseparator_new ();
+ gtk_widget_show (hseparator7);
+ gtk_box_pack_start (GTK_BOX (vbox19), hseparator7, FALSE, FALSE, 0);
+
+ table3 = gtk_table_new (2, 2, FALSE);
+ gtk_widget_show (table3);
+ gtk_box_pack_start (GTK_BOX (vbox19), table3, TRUE, TRUE, 0);
+ gtk_container_set_border_width (GTK_CONTAINER (table3), 5);
+ gtk_table_set_row_spacings (GTK_TABLE (table3), 5);
+ gtk_table_set_col_spacings (GTK_TABLE (table3), 5);
+
+ label110 = gtk_label_new (_("Group:"));
+ gtk_widget_show (label110);
+ gtk_table_attach (GTK_TABLE (table3), label110, 0, 1, 1, 2,
+ (GtkAttachOptions) (GTK_FILL),
+ (GtkAttachOptions) (0), 0, 0);
+ gtk_misc_set_alignment (GTK_MISC (label110), 0, 0.5);
+ gtk_misc_set_padding (GTK_MISC (label110), 5, 0);
+
+ entUser = gtk_entry_new ();
+ gtk_widget_show (entUser);
+ gtk_table_attach (GTK_TABLE (table3), entUser, 1, 2, 0, 1,
+ (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
+ (GtkAttachOptions) (0), 0, 0);
+ gtk_entry_set_text (GTK_ENTRY (entUser), "gnunet");
+
+ entGroup = gtk_entry_new ();
+ gtk_widget_show (entGroup);
+ gtk_table_attach (GTK_TABLE (table3), entGroup, 1, 2, 1, 2,
+ (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
+ (GtkAttachOptions) (0), 0, 0);
+ gtk_entry_set_text (GTK_ENTRY (entGroup), "gnunet");
+
+ label109 = gtk_label_new (_("User account:"));
+ gtk_widget_show (label109);
+ gtk_table_attach (GTK_TABLE (table3), label109, 0, 1, 0, 1,
+ (GtkAttachOptions) (GTK_FILL),
+ (GtkAttachOptions) (0), 0, 0);
+ gtk_misc_set_alignment (GTK_MISC (label109), 0, 0.5);
+ gtk_misc_set_padding (GTK_MISC (label109), 5, 0);
+
+ label101 = gtk_label_new (_("Other settings"));
+ gtk_widget_show (label101);
+ gtk_frame_set_label_widget (GTK_FRAME (frame8), label101);
+
+ hbuttonbox8 = gtk_hbutton_box_new ();
+ gtk_widget_show (hbuttonbox8);
+ gtk_box_pack_start (GTK_BOX (vbox18), hbuttonbox8, FALSE, TRUE, 0);
+ gtk_button_box_set_layout (GTK_BUTTON_BOX (hbuttonbox8), GTK_BUTTONBOX_END);
+
+ step4_back = gtk_button_new ();
+ gtk_widget_show (step4_back);
+ gtk_container_add (GTK_CONTAINER (hbuttonbox8), step4_back);
+ GTK_WIDGET_SET_FLAGS (step4_back, GTK_CAN_DEFAULT);
+
+ alignment43 = gtk_alignment_new (0.5, 0.5, 0, 0);
+ gtk_widget_show (alignment43);
+ gtk_container_add (GTK_CONTAINER (step4_back), alignment43);
+
+ hbox70 = gtk_hbox_new (FALSE, 2);
+ gtk_widget_show (hbox70);
+ gtk_container_add (GTK_CONTAINER (alignment43), hbox70);
+
+ image79 = gtk_image_new_from_stock ("gtk-go-back", GTK_ICON_SIZE_BUTTON);
+ gtk_widget_show (image79);
+ gtk_box_pack_start (GTK_BOX (hbox70), image79, FALSE, FALSE, 0);
+
+ label102 = gtk_label_new_with_mnemonic (_("Back"));
+ gtk_widget_show (label102);
+ gtk_box_pack_start (GTK_BOX (hbox70), label102, FALSE, FALSE, 0);
+
+ step4_next = gtk_button_new ();
+ gtk_widget_show (step4_next);
+ gtk_container_add (GTK_CONTAINER (hbuttonbox8), step4_next);
+ GTK_WIDGET_SET_FLAGS (step4_next, GTK_CAN_DEFAULT);
+
+ alignment48 = gtk_alignment_new (0.5, 0.5, 0, 0);
+ gtk_widget_show (alignment48);
+ gtk_container_add (GTK_CONTAINER (step4_next), alignment48);
+
+ hbox78 = gtk_hbox_new (FALSE, 2);
+ gtk_widget_show (hbox78);
+ gtk_container_add (GTK_CONTAINER (alignment48), hbox78);
+
+ image84 = gtk_image_new_from_stock ("gtk-go-forward", GTK_ICON_SIZE_BUTTON);
+ gtk_widget_show (image84);
+ gtk_box_pack_start (GTK_BOX (hbox78), image84, FALSE, FALSE, 0);
+
+ label111 = gtk_label_new_with_mnemonic (_("Next"));
+ gtk_widget_show (label111);
+ gtk_box_pack_start (GTK_BOX (hbox78), label111, FALSE, FALSE, 0);
+
+ step4_abort = gtk_button_new ();
+ gtk_widget_show (step4_abort);
+ gtk_container_add (GTK_CONTAINER (hbuttonbox8), step4_abort);
+ GTK_WIDGET_SET_FLAGS (step4_abort, GTK_CAN_DEFAULT);
+
+ alignment45 = gtk_alignment_new (0.5, 0.5, 0, 0);
+ gtk_widget_show (alignment45);
+ gtk_container_add (GTK_CONTAINER (step4_abort), alignment45);
+
+ hbox72 = gtk_hbox_new (FALSE, 2);
+ gtk_widget_show (hbox72);
+ gtk_container_add (GTK_CONTAINER (alignment45), hbox72);
+
+ image81 = gtk_image_new_from_stock ("gtk-cancel", GTK_ICON_SIZE_BUTTON);
+ gtk_widget_show (image81);
+ gtk_box_pack_start (GTK_BOX (hbox72), image81, FALSE, FALSE, 0);
+
+ label104 = gtk_label_new_with_mnemonic (_("Cancel"));
+ gtk_widget_show (label104);
+ gtk_box_pack_start (GTK_BOX (hbox72), label104, FALSE, FALSE, 0);
+
+ g_signal_connect ((gpointer) assi_step4, "destroy",
+ G_CALLBACK (on_assi_destroy), NULL);
+ g_signal_connect ((gpointer) entUser, "changed",
+ G_CALLBACK (on_entUser_changed), NULL);
+ g_signal_connect ((gpointer) entGroup, "changed",
+ G_CALLBACK (on_entGroup_changed), NULL);
+ g_signal_connect ((gpointer) step4_back, "clicked",
+ G_CALLBACK (on_step4_back_clicked), NULL);
+ g_signal_connect ((gpointer) step4_next, "clicked",
+ G_CALLBACK (on_step4_next_clicked), NULL);
+ g_signal_connect ((gpointer) step4_abort, "clicked",
+ G_CALLBACK (on_abort_clicked), NULL);
+
+ /* Store pointers to all widgets, for use by lookup_widget(). */
+ GLADE_HOOKUP_OBJECT_NO_REF (assi_step4, assi_step4, "assi_step4");
+ GLADE_HOOKUP_OBJECT (assi_step4, vbox18, "vbox18");
+ GLADE_HOOKUP_OBJECT (assi_step4, frame8, "frame8");
+ GLADE_HOOKUP_OBJECT (assi_step4, vbox19, "vbox19");
+ GLADE_HOOKUP_OBJECT (assi_step4, scrolledwindow8, "scrolledwindow8");
+ GLADE_HOOKUP_OBJECT (assi_step4, textview12, "textview12");
+ GLADE_HOOKUP_OBJECT (assi_step4, hseparator7, "hseparator7");
+ GLADE_HOOKUP_OBJECT (assi_step4, table3, "table3");
+ GLADE_HOOKUP_OBJECT (assi_step4, label110, "label110");
+ GLADE_HOOKUP_OBJECT (assi_step4, entUser, "entUser");
+ GLADE_HOOKUP_OBJECT (assi_step4, entGroup, "entGroup");
+ GLADE_HOOKUP_OBJECT (assi_step4, label109, "label109");
+ GLADE_HOOKUP_OBJECT (assi_step4, label101, "label101");
+ GLADE_HOOKUP_OBJECT (assi_step4, hbuttonbox8, "hbuttonbox8");
+ GLADE_HOOKUP_OBJECT (assi_step4, step4_back, "step4_back");
+ GLADE_HOOKUP_OBJECT (assi_step4, alignment43, "alignment43");
+ GLADE_HOOKUP_OBJECT (assi_step4, hbox70, "hbox70");
+ GLADE_HOOKUP_OBJECT (assi_step4, image79, "image79");
+ GLADE_HOOKUP_OBJECT (assi_step4, label102, "label102");
+ GLADE_HOOKUP_OBJECT (assi_step4, step4_next, "step4_next");
+ GLADE_HOOKUP_OBJECT (assi_step4, alignment48, "alignment48");
+ GLADE_HOOKUP_OBJECT (assi_step4, hbox78, "hbox78");
+ GLADE_HOOKUP_OBJECT (assi_step4, image84, "image84");
+ GLADE_HOOKUP_OBJECT (assi_step4, label111, "label111");
+ GLADE_HOOKUP_OBJECT (assi_step4, step4_abort, "step4_abort");
+ GLADE_HOOKUP_OBJECT (assi_step4, alignment45, "alignment45");
+ GLADE_HOOKUP_OBJECT (assi_step4, hbox72, "hbox72");
+ GLADE_HOOKUP_OBJECT (assi_step4, image81, "image81");
+ GLADE_HOOKUP_OBJECT (assi_step4, label104, "label104");
+
+ return assi_step4;
+}
Modified: GNUnet/src/conf/wizard_interface.h
===================================================================
--- GNUnet/src/conf/wizard_interface.h 2005-05-27 18:41:45 UTC (rev 824)
+++ GNUnet/src/conf/wizard_interface.h 2005-05-27 19:15:00 UTC (rev 825)
@@ -5,6 +5,7 @@
GtkWidget *create_assi_step1 (void);
GtkWidget *create_assi_step2 (void);
GtkWidget *create_assi_step3 (void);
-GtkWidget *create_assi_step4 (void);
+GtkWidget *create_assi_step5 (void);
GtkWidget *create_msgSave (void);
GtkWidget *create_msgSaveFailed (void);
+GtkWidget *create_assi_step4 (void);
Modified: GNUnet/src/conf/wizard_support.h
===================================================================
--- GNUnet/src/conf/wizard_support.h 2005-05-27 18:41:45 UTC (rev 824)
+++ GNUnet/src/conf/wizard_support.h 2005-05-27 19:15:00 UTC (rev 825)
@@ -9,6 +9,31 @@
#include <gtk/gtk.h>
/*
+ * Standard gettext macros.
+ */
+#ifdef ENABLE_NLS
+# include <libintl.h>
+# undef _
+# define _(String) dgettext (PACKAGE, String)
+# define Q_(String) g_strip_context ((String), gettext (String))
+# ifdef gettext_noop
+# define N_(String) gettext_noop (String)
+# else
+# define N_(String) (String)
+# endif
+#else
+# define textdomain(String) (String)
+# define gettext(String) (String)
+# define dgettext(Domain,Message) (Message)
+# define dcgettext(Domain,Message,Type) (Message)
+# define bindtextdomain(Domain,Directory) (Domain)
+# define _(String) (String)
+# define Q_(String) g_strip_context ((String), (String))
+# define N_(String) (String)
+#endif
+
+
+/*
* Public Functions.
*/
Modified: GNUnet/src/conf/wizard_util.c
===================================================================
--- GNUnet/src/conf/wizard_util.c 2005-05-27 18:41:45 UTC (rev 824)
+++ GNUnet/src/conf/wizard_util.c 2005-05-27 19:15:00 UTC (rev 825)
@@ -24,14 +24,12 @@
* @author Nils Durner
*/
+#include "platform.h"
#include "gnunet_util.h"
-#include "platform.h"
#define LKC_DIRECT_LINK
#include "lkc.h"
-#include "mconf_dialog.h"
-
/**
* @brief Enumerate all network interfaces
* @param callback the callback function
@@ -71,7 +69,7 @@
*dst = 0;
if (entry[0])
- insert_nic(entry, strcmp(entry, "eth0") == 0);
+ callback(entry, strcmp(entry, "eth0") == 0);
while(c != '\n' && c != EOF)
c = fgetc(f);
@@ -85,7 +83,7 @@
* @brief Determine whether a NIC makes a good default
*/
int wiz_is_nic_default(const char *name, int suggestion) {
- char *nic;
+ const char *nic = NULL;
struct symbol *sym = sym_find("INTERFACE", "NETWORK");
if (sym)
@@ -120,34 +118,60 @@
return suggestion;
}
-/* @brief Make GNUnet start automatically */
-void wiz_autostart(int doAutoStart) {
+/**
+ * @brief Checks if we can start GNUnet automatically
+ * @return 1 if yes, 0 otherwise
+ */
+int wiz_autostart_capable() {
#ifdef WINDOWS
+ return 1;
+#else
+ if (ACCESS("/usr/sbin/update-rc.d", X_OK) == 0) {
+ /* Debian */
+ if (ACCESS("/etc/init.d/", W_OK) == 0)
+ return 1;
+ }
+
+ return 0;
+#endif
+}
+
+/**
+ * @brief Make GNUnet start automatically
+ * @param doAutoStart true to enable autostart, false to disable it
+ * @param username name of the user account to use
+ * @param groupname name of the group to use
+ */
+int wiz_autostart(int doAutoStart, char *username, char *groupname) {
+#ifdef WINDOWS
if (doAutoStart)
{
if (IsWinNT())
{
char szErr[250];
+ DWORD dwErr;
- switch(InstallAsService())
+ switch(InstallAsService(username))
{
case 0:
case 1:
break;
case 2:
- SetErrnoFromWinError(GetLastError());
- sprintf(szErr, _("Error: can't open Service Control
Manager: %s\n"),
- _win_strerror(errno));
+ dwErr = GetLastError();
+ SetErrnoFromWinError(dwErr);
+ sprintf(szErr, _("Error: can't open Service Control
Manager: %s (%i)\n"),
+ _win_strerror(errno), dwErr);
MessageBox(GetActiveWindow(), szErr,
_("Error"), MB_ICONSTOP | MB_OK);
- return;
+ return 0;
case 3:
- SetErrnoFromWinError(GetLastError());
- sprintf(szErr, _("Error: can't create service:
%s\n"),
- _win_strerror(errno));
+ dwErr = GetLastError();
+ SetErrnoFromWinError(dwErr);
+ sprintf(szErr, _("Error: can't create service: %s
(#%i)\n"),
+ _win_strerror(errno), dwErr);
MessageBox(GetActiveWindow(), szErr,
_("Error"), MB_ICONSTOP | MB_OK);
- return;
+ return 0;
default:
MessageBox(GetActiveWindow(),
_("Unknown error"), _("Error"),
MB_ICONSTOP | MB_OK);
@@ -171,42 +195,36 @@
{
if (IsWinNT())
{
- char szErr[250];
- int iErr;
-
+ char *err = NULL;
+
switch (UninstallService())
{
case 0:
case 1:
break;
case 2:
- iErr = GetLastError();
- SetErrnoFromWinError(iErr);
- sprintf(szErr, _("Error: can't open Service Control
Manager: %s (#%i)\n"),
- _win_strerror(errno), iErr);
-
- MessageBox(GetActiveWindow(), szErr,
_("Error"), MB_ICONSTOP | MB_OK);
- return;
+ err = winErrorStr(_("Can't open Service
Control Manager"),
+ GetLastError());
+ return 0;
case 3:
- iErr = GetLastError();
- SetErrnoFromWinError(iErr);
- sprintf(szErr, _("Error: can't access the service:
%s (#%i)\n"),
- _win_strerror(errno), iErr);
-
- MessageBox(GetActiveWindow(), szErr,
_("Error"), MB_ICONSTOP | MB_OK);
- return;
+ err = winErrorStr(_("Can't access the
service"),
+ GetLastError());
+ return 0;
case 4:
- iErr = GetLastError();
- SetErrnoFromWinError(iErr);
- sprintf(szErr, _("Error: can't delete the service:
%s (#%i)\n"),
- _win_strerror(errno), iErr);
-
- MessageBox(GetActiveWindow(), szErr,
_("Error"), MB_ICONSTOP | MB_OK);
+ err = winErrorStr(_("Can't delete the
service"),
+ GetLastError());
break;
default:
MessageBox(GetActiveWindow(),
_("Unknown error"), _("Error"),
MB_ICONSTOP | MB_OK);
}
+
+ if (err)
+ {
+ MessageBox(GetActiveWindow(), err, _("Error"),
+ MB_ICONSTOP | MB_OK);
+ free(err);
+ }
}
else
{
@@ -222,7 +240,176 @@
}
}
}
+#else
+ /* Unix */
+ if (ACCESS("/usr/sbin/update-rc.d", X_OK) == 0) {
+ /* Debian */
+ if (doAutoStart) {
+ struct stat buf;
+ if (STAT("/etc/init.d/gnunetd", &buf) == -1) {
+ /* create init file */
+ FILE *f = FOPEN("/etc/init.d/gnunetd", "w");
+ if (! f)
+ return 0;
+
+ fputs(f, "#! /bin/sh\n"
+ "#\n"
+ "#
Automatically created by gnunet-setup\n"
+ "#\n"
+ "\n"
+
"PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin\n"
+
"PIDFILE=/var/run/gnunetd/gnunetd.pid\n"
+ "\n"
+ "case
\"$1\" in\n"
+ "
start)\n"
+ "
echo -n \"Starting GNUnet: \"\n"
+ "
gnunetd\n"
+ "
echo \"gnunetd\"\n"
+ "
;;\n"
+ "
stop)\n"
+ "
echo -n \"Stopping GNUnet: \"\n"
+ "
kill `cat $PIDFILE`\n"
+ "
echo \"gnunetd\"\n"
+ "
;;\n"
+ "
reload)\n"
+ "
echo -n \"Reloading GNUnet: \"\n"
+ "
kill -HUP `cat $PIDFILE`\n"
+ "
echo \"gnunetd\"\n"
+ "
;;\n"
+ "
restart|force-reload)\n"
+ "
echo \"Restarting GNUnet: gnunetd...\"\n"
+ "
$0 stop\n"
+ "
sleep 1\n"
+ "
$0 start\n"
+ "
;;\n"
+ "
*)\n"
+ "
echo \"Usage: /etc/init.d/gnunetd
{start|stop|reload|restart|force-reload}\" >&2\n"
+ "
exit 1\n"
+ "
;;\n"
+ "\n"
+ "esac\n"
+ "exit
0\n");
+ fclose(f);
+ chmod("/etc/init.d/gnunetd", S_IRWXU |
S_IRGRP | S_IXGRP |
+ S_IROTH | S_IXOTH);
+ }
+ system("/usr/sbin/update-rc.d gnunetd defaults");
+ }
+ else
+ system("/usr/sbin/update-rc.d gnunetd remove");
+ }
+ else
+ return 0;
+
#endif
+ return 1;
}
+/**
+ * @brief Checks if we can add an user for the GNUnet service
+ * @return 1 if yes, 0 otherwise
+ * @todo support for useradd(8)
+ */
+int wiz_useradd_capable(){
+#ifdef WINDOWS
+ return IsWinNT();
+#else
+ if (ACCESS("/usr/sbin/adduser", X_OK) == 0)
+ return 1;
+ else
+ /* TODO: useradd */
+ return 0;
+#endif
+}
+
+/**
+ * @brief Checks if we can add a group for the GNUnet service
+ * @return 1 if yes, 0 otherwise
+ * @todo support for groupadd(8)
+ */
+int wiz_groupadd_capable() {
+#ifndef MINGW
+ if (ACCESS("/usr/sbin/addgroup", X_OK) == 0) {
+ return 1;
+ }
+ /* TODO: groupadd */
+ else
+#endif
+ return 0;
+}
+
+/**
+ * @brief Add a service account for GNUnet
+ * @param group the group of the new user
+ * @param name the name of the new user
+ * @todo Check FreeBSD (adduser(8)), add support for useradd(8)
+ */
+int wiz_addServiceAccount(char *group_name, char *user_name) {
+#ifdef WINDOWS
+ if (IsWinNT())
+ {
+ char *err = NULL;
+
+ switch(CreateServiceAccount(user_name, "GNUnet service
account")) {
+ case 0:
+ ; /* OK */
+ break;
+ case 1:
+ MessageBox(0, _("This version of Windows does
not support "
+ "multiple users."), _("Error"),
MB_ICONSTOP | MB_OK);
+ return 0;
+ case 2:
+ err = winErrorStr(_("Error creating user"),
GetLastError());
+ break;
+ case 3:
+ err = winErrorStr(_("Error accessing local
security policy"), GetLastError());
+ break;
+ case 4:
+ err = winErrorStr(_("Error granting service
right to user"), GetLastError());
+ break;
+ default:
+ err = winErrorStr(_("Unknown error while
creating a new user"), GetLastError());
+ break;
+ }
+
+ if (err)
+ {
+ MessageBox(0, err, _("Error"), MB_ICONSTOP | MB_OK);
+ free(err);
+
+ return 0;
+ }
+ }
+ else
+ return 0;
+#else
+ int haveGroup;
+
+ if (ACCESS("/usr/sbin/adduser", X_OK) == 0) {
+ /* Debian */
+ /* TODO: FreeBSD?
http://www.freebsd.org/cgi/man.cgi?query=adduser&sektion=8 */
+ char *cmd;
+ cmd = MALLOC(strlen(group_name) + strlen(user_name) + 64);
+
+ haveGroup = group_name && strlen(group_name) > 0;
+ if (haveGroup) {
+ sprintf(cmd, "/usr/sbin/addgroup --quiet --system %s",
group_name);
+ system(cmd);
+ }
+
+ sprintf(cmd, "/usr/sbin/adduser --quiet --system %s %s "
+ "--no-create-home %s", haveGroup ? "--ingroup" : "",
+ haveGroup ? group_name : "", user_name);
+ system(cmd);
+
+ FREE(cmd);
+ }
+ /* TODO: useradd */
+ else
+ return 0;
+#endif
+
+ return 1;
+}
+
/* end of wizard_util.c */
Modified: GNUnet/src/conf/wizard_util.h
===================================================================
--- GNUnet/src/conf/wizard_util.h 2005-05-27 18:41:45 UTC (rev 824)
+++ GNUnet/src/conf/wizard_util.h 2005-05-27 19:15:00 UTC (rev 825)
@@ -31,7 +31,11 @@
int wiz_enum_nics(void (*callback) (char *, int));
int wiz_is_nic_default(const char *name, int suggestion);
-void wiz_autostart(int doAutoStart);
+int wiz_autostart_capable();
+int wiz_autostart(int doAutoStart, char *username, char *groupname);
+int wiz_useradd_capable();
+int wiz_groupadd_capable();
+int wiz_addServiceAccount(char *group_name, char *user_name);
#endif //_WIZARD_UTIL_H_
Modified: GNUnet/src/include/gnunet_util.h
===================================================================
--- GNUnet/src/include/gnunet_util.h 2005-05-27 18:41:45 UTC (rev 824)
+++ GNUnet/src/include/gnunet_util.h 2005-05-27 19:15:00 UTC (rev 825)
@@ -2312,8 +2312,15 @@
#ifdef WINDOWS
void EnumNICs(PMIB_IFTABLE *pIfTable, PMIB_IPADDRTABLE *pAddrTable);
int ListNICs(void (*callback) (char *, int));
-int InstallAsService(void);
+char *winErrorStr(char *prefix, DWORD dwErr);
+int InstallAsService(char *username);
int UninstallService(void);
+void _InitLsaString(PLSA_UNICODE_STRING LsaString, LPWSTR String);
+NTSTATUS _OpenPolicy(LPWSTR ServerName, DWORD DesiredAccess, PLSA_HANDLE
PolicyHandle);
+BOOL _GetAccountSid(LPTSTR SystemName, LPTSTR AccountName, PSID * Sid);
+NTSTATUS _SetPrivilegeOnAccount(LSA_HANDLE PolicyHandle, PSID AccountSid,
+ LPWSTR PrivilegeName, BOOL bEnable);
+int CreateServiceAccount(char *pszName, char *pszDesc);
#endif
/* ifndef GNUNET_UTIL_H */
Modified: GNUnet/src/include/winproc.h
===================================================================
--- GNUnet/src/include/winproc.h 2005-05-27 18:41:45 UTC (rev 824)
+++ GNUnet/src/include/winproc.h 2005-05-27 19:15:00 UTC (rev 825)
@@ -41,6 +41,8 @@
#include <shlobj.h>
#include <objbase.h>
#include <sys/param.h> /* #define BYTE_ORDER */
+#include <Ntsecapi.h>
+#include <lm.h>
#include "gnunet_util.h"
#include "platform.h"
@@ -48,6 +50,10 @@
extern "C" {
#endif
+#ifndef MAX_NAME_LENGTH
+ #define MAX_NAME_LENGTH 25
+#endif
+
typedef DWORD WINAPI (*TNtQuerySystemInformation) (int, PVOID, ULONG, PULONG);
typedef DWORD WINAPI (*TGetIfEntry) (PMIB_IFROW pIfRow);
typedef DWORD WINAPI (*TGetIpAddrTable) (PMIB_IPADDRTABLE pIpAddrTable,
@@ -81,8 +87,19 @@
DWORD dwDesiredAccess);
typedef DWORD WINAPI (*TGetBestInterface) (IPAddr dwDestAddr, PDWORD
pdwBestIfIndex);
typedef DWORD WINAPI (*TGetAdaptersInfo) (PIP_ADAPTER_INFO pAdapterInfo,
PULONG pOutBufLen);
+typedef NET_API_STATUS WINAPI (*TNetUserAdd) (LPCWSTR,DWORD,PBYTE,PDWORD);
+typedef NET_API_STATUS WINAPI (*TNetUserSetInfo) (LPCWSTR servername, LPCWSTR
username,
+ DWORD level, LPBYTE buf, LPDWORD parm_err);
+typedef NTSTATUS NTAPI (*TLsaOpenPolicy) (PLSA_UNICODE_STRING,
PLSA_OBJECT_ATTRIBUTES,
+ ACCESS_MASK,PLSA_HANDLE);
+typedef NTSTATUS NTAPI (*TLsaAddAccountRights)
(LSA_HANDLE,PSID,PLSA_UNICODE_STRING,ULONG);
+typedef NTSTATUS NTAPI (*TLsaRemoveAccountRights) (LSA_HANDLE,PSID,BOOLEAN,
+ PLSA_UNICODE_STRING,ULONG);
+typedef NTSTATUS NTAPI (*TLsaClose) (LSA_HANDLE);
+typedef BOOL WINAPI (*TLookupAccountName) (LPCTSTR lpSystemName, LPCTSTR
lpAccountName,
+ PSID Sid, LPDWORD cbSid, LPTSTR ReferencedDomainName,
+ LPDWORD cchReferencedDomainName, PSID_NAME_USE peUse);
-
extern TNtQuerySystemInformation GNNtQuerySystemInformation;
extern TGetIfEntry GNGetIfEntry;
extern TGetIpAddrTable GNGetIpAddrTable;
@@ -99,7 +116,15 @@
extern TOpenService GNOpenService;
extern TGetBestInterface GNGetBestInterface;
extern TGetAdaptersInfo GGetAdaptersInfo;
+extern TNetUserAdd GNNetUserAdd;
+extern TNetUserSetInfo GNNetUserSetInfo;
+extern TLsaOpenPolicy GNLsaOpenPolicy;
+extern TLsaAddAccountRights GNLsaAddAccountRights;
+extern TLsaRemoveAccountRights GNLsaRemoveAccountRights;
+extern TLsaClose GNLsaClose;
+extern TLookupAccountName GNLookupAccountName;
+
BOOL CreateShortcut(const char *pszSrc, const char *pszDest);
BOOL DereferenceShortcut(char *pszShortcut);
long QueryRegistry(HKEY hMainKey, char *pszKey, char *pszSubKey,
Modified: GNUnet/src/util/win/win.cc
===================================================================
--- GNUnet/src/util/win/win.cc 2005-05-27 18:41:45 UTC (rev 824)
+++ GNUnet/src/util/win/win.cc 2005-05-27 19:15:00 UTC (rev 825)
@@ -30,6 +30,8 @@
#include "winproc.h"
#include "gnunet_util.h"
+#include <ntdef.h>
+
extern "C" {
/**
@@ -187,15 +189,17 @@
/**
* @brief Installs the Windows service
+ * @param username the name of the service's user account
* @returns 0 on success
* 1 if the Windows version doesn't support services
* 2 if the SCM could not be opened
* 3 if the service could not be created
*/
-int InstallAsService()
+int InstallAsService(char *username)
{
SC_HANDLE hManager, hService;
char szEXE[_MAX_PATH + 17] = "\"";
+ char *user = NULL;
if (! GNOpenSCManager)
return 1;
@@ -206,9 +210,18 @@
if (! hManager)
return 2;
+ if (username)
+ {
+ user = (char *) malloc(strlen(username) + 3);
+ sprintf(user, ".\\%s", username);
+ }
+
hService = GNCreateService(hManager, "GNUnet", "GNUnet", 0,
SERVICE_WIN32_OWN_PROCESS, SERVICE_AUTO_START, SERVICE_ERROR_NORMAL, szEXE,
- NULL, NULL, NULL, NULL, NULL);
+ NULL, NULL, NULL, user, user);
+
+ if (user)
+ free(user);
if (! hService)
return 3;
@@ -252,6 +265,236 @@
return 0;
}
+/**
+ * @author Scott Field, Microsoft
+ * @see http://support.microsoft.com/?scid=kb;en-us;132958
+ * @date 12-Jul-95
+ */
+void _InitLsaString(PLSA_UNICODE_STRING LsaString, LPWSTR String)
+{
+ DWORD StringLength;
+
+ if(String == NULL)
+ {
+ LsaString->Buffer = NULL;
+ LsaString->Length = 0;
+ LsaString->MaximumLength = 0;
+ return;
+ }
+
+ StringLength = wcslen(String);
+ LsaString->Buffer = String;
+ LsaString->Length = (USHORT) StringLength *sizeof(WCHAR);
+ LsaString->MaximumLength = (USHORT) (StringLength + 1) * sizeof(WCHAR);
}
+
+/**
+ * @author Scott Field, Microsoft
+ * @see http://support.microsoft.com/?scid=kb;en-us;132958
+ * @date 12-Jul-95
+ */
+NTSTATUS _OpenPolicy(LPWSTR ServerName, DWORD DesiredAccess, PLSA_HANDLE
PolicyHandle)
+{
+ LSA_OBJECT_ATTRIBUTES ObjectAttributes;
+ LSA_UNICODE_STRING ServerString;
+ PLSA_UNICODE_STRING Server = NULL;
+
+ /* Always initialize the object attributes to all zeroes. */
+ ZeroMemory(&ObjectAttributes, sizeof(ObjectAttributes));
+
+ if(ServerName != NULL)
+ {
+ /* Make a LSA_UNICODE_STRING out of the LPWSTR passed in */
+ _InitLsaString(&ServerString, ServerName);
+ Server = &ServerString;
+ }
+
+ /* Attempt to open the policy. */
+ return GNLsaOpenPolicy(Server,
+ &ObjectAttributes, DesiredAccess, PolicyHandle);
+}
+
+/**
+ * @brief Obtain a SID representing the supplied account on the supplied system
+ * @return TRUE on success, FALSE on failure
+ * @author Scott Field, Microsoft
+ * @date 12-Jul-95
+ * @remarks A buffer is allocated which contains the SID representing the
+ * supplied account. This buffer should be freed when it is no longer
+ * needed by calling\n
+ * HeapFree(GetProcessHeap(), 0, buffer)
+ * @remarks Call GetLastError() to obtain extended error information.
+ * @see http://support.microsoft.com/?scid=kb;en-us;132958
+ */
+BOOL _GetAccountSid(LPTSTR SystemName, LPTSTR AccountName, PSID * Sid)
+{
+ LPTSTR ReferencedDomain = NULL;
+ DWORD cbSid = 128;
/* initial allocation attempt */
+ DWORD cchReferencedDomain = 16; /* initial allocation size */
+ SID_NAME_USE peUse;
+ BOOL bSuccess = FALSE; /*
assume this function will fail */
+
+ /* initial memory allocations */
+ if ((*Sid = HeapAlloc (GetProcessHeap (), 0, cbSid)) == NULL)
+ return FALSE;
+
+ if ((ReferencedDomain = (LPTSTR) HeapAlloc (GetProcessHeap (),
+ 0,
+ cchReferencedDomain *
+ sizeof (TCHAR))) == NULL)
+ return FALSE;
+
+ /* Obtain the SID of the specified account on the specified system. */
+ while (!GNLookupAccountName(SystemName, /* machine to lookup
account on */
+ AccountName,
/* account to lookup */
+ *Sid,
/* SID
of interest */
+ &cbSid,
/* size of SID
*/
+ ReferencedDomain,
/* domain account was found on */
+ &cchReferencedDomain, &peUse))
+ {
+ if (GetLastError() == ERROR_INSUFFICIENT_BUFFER)
+ {
+ /* reallocate memory */
+ if ((*Sid = HeapReAlloc (GetProcessHeap (), 0,
*Sid, cbSid)) == NULL)
+ return FALSE;
+
+ if ((ReferencedDomain = (LPTSTR) HeapReAlloc
(GetProcessHeap (),
+ 0,
+ ReferencedDomain,
+ cchReferencedDomain
+ * sizeof (TCHAR))) ==
NULL)
+ return FALSE;
+ }
+ else
+ goto end;
+ }
+
+ /* Indicate success. */
+ bSuccess = TRUE;
+
+end:
+ /* Cleanup and indicate failure, if appropriate. */
+ HeapFree (GetProcessHeap (), 0, ReferencedDomain);
+
+ if (!bSuccess)
+ {
+ if (*Sid != NULL)
+ {
+ HeapFree (GetProcessHeap (), 0, *Sid);
+ *Sid = NULL;
+ }
+ }
+
+ return bSuccess;
+}
+
+/**
+ * @author Scott Field, Microsoft
+ * @see http://support.microsoft.com/?scid=kb;en-us;132958
+ * @date 12-Jul-95
+ */
+NTSTATUS _SetPrivilegeOnAccount(LSA_HANDLE PolicyHandle,/* open policy handle
*/
+ PSID AccountSid,
/* SID to grant privilege to */
+ LPWSTR PrivilegeName, /* privilege to
grant (Unicode) */
+ BOOL bEnable
/* enable or disable */
+ )
+{
+ LSA_UNICODE_STRING PrivilegeString;
+
+ /* Create a LSA_UNICODE_STRING for the privilege name. */
+ _InitLsaString(&PrivilegeString, PrivilegeName);
+
+ /* grant or revoke the privilege, accordingly */
+ if(bEnable)
+ {
+ NTSTATUS i;
+
+ i = GNLsaAddAccountRights(PolicyHandle,
/* open policy handle */
+ AccountSid,
/* target SID */
+ &PrivilegeString, /* privileges */
+ 1
/* privilege count */
+ );
+ }
+ else
+ {
+ return GNLsaRemoveAccountRights(PolicyHandle,
/* open policy handle */
+ AccountSid,
/* target SID */
+ FALSE,
/* do not disable all rights */
+ &PrivilegeString, /*
privileges */
+ 1
/* privilege count */
+ );
+ }
+}
+
+/**
+ * @brief Create a Windows service account
+ * @return 0 on success, > 0 otherwise
+ * @param pszName the name of the account
+ * @param pszDesc description of the account
+ */
+int CreateServiceAccount(char *pszName, char *pszDesc)
+{
+ USER_INFO_1 ui;
+ USER_INFO_1008 ui2;
+ NET_API_STATUS nStatus;
+ wchar_t wszName[MAX_NAME_LENGTH], wszDesc[MAX_NAME_LENGTH];
+ DWORD dwErr;
+ LSA_HANDLE hPolicy;
+ PSID pSID;
+
+ if (! GNNetUserAdd)
+ return 1;
+ mbstowcs(wszName, pszName, strlen(pszName) + 1);
+ mbstowcs(wszDesc, pszDesc, strlen(pszDesc) + 1);
+
+ memset(&ui, 0, sizeof(ui));
+ ui.usri1_name = wszName;
+ ui.usri1_password = wszName; /* account is locked anyway */
+ ui.usri1_priv = USER_PRIV_USER;
+ ui.usri1_comment = wszDesc;
+ ui.usri1_flags = UF_SCRIPT;
+
+ nStatus = GNNetUserAdd(NULL, 1, (LPBYTE)&ui, NULL);
+
+ if (nStatus != NERR_Success && nStatus != NERR_UserExists)
+ return 2;
+
+ ui2.usri1008_flags = UF_ACCOUNTDISABLE | UF_PASSWD_CANT_CHANGE |
+ UF_DONT_EXPIRE_PASSWD;
+ GNNetUserSetInfo(NULL, wszName, 1008, (LPBYTE)&ui2, NULL);
+
+ if (_OpenPolicy(NULL, POLICY_ALL_ACCESS, &hPolicy) !=
+
STATUS_SUCCESS)
+ return 3;
+
+ _GetAccountSid(NULL, pszName, &pSID);
+
+ if (_SetPrivilegeOnAccount(hPolicy, pSID, L"SeServiceLogonRight", TRUE)
!= STATUS_SUCCESS)
+ return 4;
+
+ GNLsaClose(hPolicy);
+
+ return 0;
+}
+
+char *winErrorStr(char *prefix, DWORD dwErr)
+{
+ char *err, *ret;
+
+ FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM,
+ NULL, dwErr, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) &err,
+ 0, NULL );
+
+ ret = (char *) malloc(strlen(err) + strlen(prefix) + 20);
+
+ sprintf(ret, "%s: %s (#%u)", prefix, err, dwErr);
+
+ LocalFree(err);
+
+ return ret;
+}
+
+} /* extern "C" */
+
#endif
Modified: GNUnet/src/util/win/winproc.c
===================================================================
--- GNUnet/src/util/win/winproc.c 2005-05-27 18:41:45 UTC (rev 824)
+++ GNUnet/src/util/win/winproc.c 2005-05-27 19:15:00 UTC (rev 825)
@@ -31,7 +31,7 @@
#ifdef MINGW
-static HINSTANCE hNTDLL, hIphlpapi, hAdvapi;
+static HINSTANCE hNTDLL, hIphlpapi, hAdvapi, hNetapi;
TNtQuerySystemInformation GNNtQuerySystemInformation;
TGetIfEntry GNGetIfEntry;
TGetIpAddrTable GNGetIpAddrTable;
@@ -47,6 +47,13 @@
TOpenService GNOpenService;
TGetBestInterface GNGetBestInterface;
TGetAdaptersInfo GGetAdaptersInfo;
+TNetUserAdd GNNetUserAdd;
+TNetUserSetInfo GNNetUserSetInfo;
+TLsaOpenPolicy GNLsaOpenPolicy;
+TLsaAddAccountRights GNLsaAddAccountRights;
+TLsaRemoveAccountRights GNLsaRemoveAccountRights;
+TLsaClose GNLsaClose;
+TLookupAccountName GNLookupAccountName;
/**
* Log (panic) messages from PlibC
@@ -99,7 +106,7 @@
GGetAdaptersInfo = NULL;
}
- /* Service functions */
+ /* Service & Account functions */
hAdvapi = LoadLibrary("advapi32.dll");
if (hAdvapi)
{
@@ -121,7 +128,51 @@
GetProcAddress(hAdvapi, "ControlService");
GNOpenService = (TOpenService)
GetProcAddress(hAdvapi, "OpenServiceA");
+
+ GNLsaOpenPolicy = (TLsaOpenPolicy)
+ GetProcAddress(hAdvapi, "LsaOpenPolicy");
+ GNLsaAddAccountRights = (TLsaAddAccountRights)
+ GetProcAddress(hAdvapi, "LsaAddAccountRights");
+ GNLsaRemoveAccountRights = (TLsaRemoveAccountRights)
+ GetProcAddress(hAdvapi, "LsaRemoveAccountRights");
+ GNLsaClose = (TLsaClose)
+ GetProcAddress(hAdvapi, "LsaClose");
+ GNLookupAccountName = (TLookupAccountName)
+ GetProcAddress(hAdvapi, "LookupAccountNameA");
}
+ else
+ {
+ GNOpenSCManager = NULL;
+ GNCreateService = NULL;
+ GNCloseServiceHandle = NULL;
+ GNDeleteService = NULL;
+ GNRegisterServiceCtrlHandler = NULL;
+ GNSetServiceStatus = NULL;
+ GNStartServiceCtrlDispatcher = NULL;
+ GNControlService = NULL;
+ GNOpenService = NULL;
+
+ GNLsaOpenPolicy = NULL;
+ GNLsaAddAccountRights = NULL;
+ GNLsaRemoveAccountRights = NULL;
+ GNLsaClose = NULL;
+ GNLookupAccountName = NULL;
+ }
+
+ /* Account function */
+ hNetapi = LoadLibrary("netapi32.dll");
+ if (hNetapi)
+ {
+ GNNetUserAdd = (TNetUserAdd)
+ GetProcAddress(hNetapi, "NetUserAdd");
+ GNNetUserSetInfo = (TNetUserSetInfo)
+ GetProcAddress(hNetapi, "NetUserSetInfo");
+ }
+ else
+ {
+ GNNetUserAdd = NULL;
+ GNNetUserSetInfo = NULL;
+ }
}
/**
@@ -134,6 +185,7 @@
FreeLibrary(hNTDLL);
FreeLibrary(hIphlpapi);
FreeLibrary(hAdvapi);
+ FreeLibrary(hNetapi);
CoUninitialize();
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r825 - in GNUnet/src: conf include util/win,
durner <=