summaryrefslogtreecommitdiff
path: root/gpe-conf/gpe-conf-0.1.20/password-if.patch
blob: 1e1b578cd3aa5ae6764d7f2dca88c1a0301b43c8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
Index: cfgfile.c
===================================================================
RCS file: /cvs/gpe/base/gpe-conf/cfgfile.c,v
retrieving revision 1.13
diff -u -r1.13 cfgfile.c
--- cfgfile.c	29 Aug 2004 13:20:25 -0000	1.13
+++ cfgfile.c	16 Oct 2004 15:50:30 -0000
@@ -436,26 +436,28 @@
 	iflen = l;
 
 	fd = fopen(_PATH_PROCNET_WIRELESS, "r");
-	fgets(buffer, 256, fd);		// chuck first two lines;
-	fgets(buffer, 256, fd);
-	while (!feof(fd)) {
-		if (fgets(buffer, 256, fd) == NULL)
-			break;
-		name = buffer;
-		sep = strrchr(buffer, ':');
-		if (sep) *sep = 0;
-		while(*name == ' ') name++;
-
-		for (i = 0; i < iflen; i++)
-		{
-			if (!strcmp (name, iflist[i].name))
+	if (fd)
+	{
+		fgets(buffer, 256, fd);		// chuck first two lines;
+		fgets(buffer, 256, fd);
+		while (!feof(fd)) {
+			if (fgets(buffer, 256, fd) == NULL)
+				break;
+			name = buffer;
+			sep = strrchr(buffer, ':');
+			if (sep) *sep = 0;
+			while(*name == ' ') name++;
+	
+			for (i = 0; i < iflen; i++)
 			{
-				iflist[i].iswireless = TRUE;
+				if (!strcmp (name, iflist[i].name))
+				{
+					iflist[i].iswireless = TRUE;
+				}
 			}
 		}
+		fclose(fd);
 	}
-	fclose(fd);
-
 	return l;
 }
 
Index: main.c
===================================================================
RCS file: /cvs/gpe/base/gpe-conf/main.c,v
retrieving revision 1.69
diff -u -r1.69 main.c
--- main.c	10 Oct 2004 21:48:39 -0000	1.69
+++ main.c	16 Oct 2004 15:50:30 -0000
@@ -188,6 +188,9 @@
   self.cur_applet = i;
 
   self.applet = applets[i].Build_Objects(useronly);
+ 
+  if (self.applet)
+  {
   gtk_container_add(GTK_CONTAINER(self.viewport),self.applet);
 	
   gtk_window_set_title(GTK_WINDOW(self.w), applets[i].frame_label);
@@ -220,6 +223,7 @@
   }
   else
     gtk_widget_hide(self.cancel);
+  }
 }
 
 
@@ -289,9 +293,11 @@
 void main_one(int argc, char **argv,int applet)
 {
   int handled = FALSE;
-  gboolean user_only_setup = FALSE; /* Don't change to suid mode. */  
+  gboolean special_flag = FALSE; /* Don't change to suid mode or similar. */  
+  gboolean standalone = FALSE; /* applet creates its own window */
 	
   self.alone_applet = 1;
+  self.applet = NULL;
 
   my_icons[count_icons - 1].filename = applets[applet].icon_file;
 	
@@ -315,7 +321,12 @@
 	  }
 	  if (!strcmp(argv[2],"user_only"))
 	  {
-		  user_only_setup = TRUE;
+		  special_flag = TRUE;
+	  }
+	  if (!strcmp(argv[2],"password"))
+	  {
+		  special_flag = TRUE;
+		  standalone = TRUE;
 	  }
 	  if (!strcmp(argv[1],"task_sound"))
 	  {
@@ -331,23 +342,23 @@
   /* If no task? - start applet */
   if (!handled)
   { 
-	  initwindow();
-	
-	  self.vbox = gtk_vbox_new(FALSE,0);
-	  gtk_container_add(GTK_CONTAINER(self.w),self.vbox);
-	
 	  self.cur_applet = -1;
-	  self.applet = NULL;
-	
-	  make_container();
-	
-	  gpe_set_window_icon(self.w, "icon");
-	  gtk_widget_show_all(self.w);
-	 
-	  gtk_widget_show(self.w);
-	
+	  self.applet = NULL;	  if (!standalone)
+	  {
+		  initwindow();
+		
+		  self.vbox = gtk_vbox_new(FALSE,0);
+		  gtk_container_add(GTK_CONTAINER(self.w),self.vbox);
+				
+		  make_container();
+		
+		  gpe_set_window_icon(self.w, "icon");
+		  gtk_widget_show_all(self.w);
+		 
+		  gtk_widget_show(self.w);
+	  }
 	   
-	  item_select(user_only_setup, (gpointer)applet);
+	  item_select(special_flag, (gpointer)applet);
 	  gtk_main();
 	  gtk_exit(0);
   }
Index: network.c
===================================================================
RCS file: /cvs/gpe/base/gpe-conf/network.c,v
retrieving revision 1.37
diff -u -r1.37 network.c
--- network.c	8 Sep 2004 22:14:12 -0000	1.37
+++ network.c	16 Oct 2004 15:50:30 -0000
@@ -123,9 +123,34 @@
 	free (buffer);
 }
 
+void
+copy_new_interfaces(void)
+{
+	struct interface *ife;
+	struct interface *int_list;
+		
+	int_list = if_getlist ();
+	
+	system_printf ("/bin/cp %s %s", NET_NEWFILE, NET_CONFIGFILE);
+	system_printf ("chmod 0644 %s", NET_CONFIGFILE);
+	system_printf ("/bin/rm -f %s", NET_NEWFILE);
+	
+	for (ife = int_list; ife; ife = ife->next)
+	{
+		if ((ife->flags & IFF_UP) && !(ife->flags & IFF_LOOPBACK))
+		{
+			gchar *cmd = g_strdup_printf("/sbin/ifdown %s", ife->name);
+			system(cmd);
+			g_free(cmd);
+			cmd = g_strdup_printf("/sbin/ifup %s", ife->name);
+			system(cmd);
+			g_free(cmd);
+		}
+	}
+}
 
 static GList *
-get_unconfigured_interfaces ()
+get_unconfigured_interfaces (void)
 {
 #define num_suggestions 3	
 	
@@ -139,34 +164,34 @@
 	gchar suggestions[num_suggestions][6] = {"eth0", "wlan0", "bnep0"};
 	
 	fd = fopen(_PATH_PROCNET_DEV, "r");
-	fgets(buffer, 256, fd);		// chuck first two lines;
-	fgets(buffer, 256, fd);
-	while (!feof(fd)) {
-		if (fgets(buffer, 256, fd) == NULL)
-			break;
-		name = buffer;
-		sep = strrchr(buffer, ':');
-		if (sep) *sep = 0;
-		while(*name == ' ') name++;
-
-		found = FALSE;
-		for (i = 0; i < iflen; i++)
-		{
-			if (!strcmp (name, iflist[i].name))
-			{
-				found = TRUE;
+	if (fd)
+	{
+		fgets(buffer, 256, fd);		// chuck first two lines;
+		fgets(buffer, 256, fd);
+		while (!feof(fd)) {
+			if (fgets(buffer, 256, fd) == NULL)
 				break;
+			name = buffer;
+			sep = strrchr(buffer, ':');
+			if (sep) *sep = 0;
+			while(*name == ' ') name++;
+	
+			found = FALSE;
+			for (i = 0; i < iflen; i++)
+			{
+				if (!strcmp (name, iflist[i].name))
+				{
+					found = TRUE;
+					break;
+				}
+			}
+			if (!found)
+			{
+				result = g_list_append (result, g_strdup (name));
 			}
 		}
-		if (!found)
-		{
-			result = g_list_append (result, g_strdup (name));
-		}
-
-
+		fclose(fd);
 	}
-	fclose(fd);
-	
 	for (j = 0; j < num_suggestions; j++)
 	{
 		found = FALSE;
Index: suid.c
===================================================================
RCS file: /cvs/gpe/base/gpe-conf/suid.c,v
retrieving revision 1.51
diff -u -r1.51 suid.c
--- suid.c	12 Oct 2004 21:07:02 -0000	1.51
+++ suid.c	16 Oct 2004 15:50:30 -0000
@@ -45,6 +45,7 @@
 #include "cardinfo.h"
 #include "timeanddate.h"
 #include "users/passwd.h"
+#include "network.h"
 
 static GtkWidget *passwd_entry;
 static int retv;
@@ -359,13 +360,7 @@
 				else if (strcmp (cmd, "CPIF") == 0)  // installs a new interfaces file
 				{
 					fscanf (in, "%100s", arg2);	// to forget soon...
-					strcpy (arg1, "/tmp/interfaces");
-					strcpy (arg2, "/etc/network/interfaces");
-					system ("/etc/init.d/networking stop");
-					system_printf ("/bin/cp %s %s", arg1, arg2);
-					system_printf ("chmod 0644 %s", arg2);
-					system_printf ("/bin/rm -f %s", arg1);
-					system ("/etc/init.d/networking start");
+					copy_new_interfaces();
 				}
 				else if (strcmp (cmd, "CPOI") == 0)  // rewrites owner information data
 				{
Index: network.h
===================================================================
RCS file: /cvs/gpe/base/gpe-conf/network.h,v
retrieving revision 1.4
diff -u -r1.4 network.h
--- network.h	25 Aug 2004 10:16:31 -0000	1.4
+++ network.h	16 Oct 2004 15:50:30 -0000
@@ -1,3 +1,6 @@
+#ifndef _GPE_CONF_NETWORK_H
+#define _GPE_CONF_NETWORK_H
+
 #define _PATH_PROCNET_DEV	"/proc/net/dev"
 #define _PATH_PROCNET_WIRELESS	"/proc/net/wireless" 
 
@@ -5,3 +8,6 @@
 void Network_Save();
 void Network_Free_Objects();
 void Network_Restore();
+void copy_new_interfaces(void);
+
+#endif
Index: users.h
===================================================================
RCS file: /cvs/gpe/base/gpe-conf/users.h,v
retrieving revision 1.2
diff -u -r1.2 users.h
--- users.h	7 Sep 2002 22:34:06 -0000	1.2
+++ users.h	16 Oct 2004 15:50:30 -0000
@@ -1,4 +1,4 @@
-GtkWidget *Users_Build_Objects();
+GtkWidget *Users_Build_Objects(gboolean password_only);
 void Users_Save();
 void Users_Free_Objects();
 void Users_Restore();
Index: users/interface.c
===================================================================
RCS file: /cvs/gpe/base/gpe-conf/users/interface.c,v
retrieving revision 1.22
diff -u -r1.22 interface.c
--- users/interface.c	8 Sep 2004 22:14:12 -0000	1.22
+++ users/interface.c	16 Oct 2004 15:50:30 -0000
@@ -202,15 +202,15 @@
 }
 
 GtkWidget*
-Users_Build_Objects (void)
+Users_Build_Objects (gboolean password_only)
 {
-  GtkWidget *vbox1;
-  GtkWidget *pw;
-  GtkWidget *toolbar;
-  GtkWidget *button1;
-  GtkWidget *button2;
-  GtkWidget *button3;
-  GtkWidget *button4;
+  GtkWidget *vbox1 = NULL;
+  GtkWidget *pw = NULL;
+  GtkWidget *toolbar = NULL;
+  GtkWidget *button1 = NULL;
+  GtkWidget *button2 = NULL;
+  GtkWidget *button3 = NULL;
+  GtkWidget *button4 = NULL;
 
   listTitles[0] = _("User Name");
   listTitles[1] = _("User Info");
@@ -218,6 +218,8 @@
 
   InitSpacings ();
 
+  if (!password_only)
+  {
   vbox1 = gtk_vbox_new (FALSE, 0);
   gtk_container_set_border_width (GTK_CONTAINER (vbox1), border_width);
 
@@ -254,28 +256,40 @@
   gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(pw),
                                  GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
   gtk_container_add (GTK_CONTAINER (pw), user_list);
+  }
   
   InitPwList();
-  ReloadList();
+  if (!password_only)
+    {
+      ReloadList();
 
-  gtk_widget_show (user_list);
- 
-  gtk_box_pack_start (GTK_BOX (vbox1), pw, TRUE, TRUE, 0);
+      gtk_widget_show (user_list);
+      gtk_box_pack_start (GTK_BOX (vbox1), pw, TRUE, TRUE, 0);
   
-  /* check if we have the permissions to change users */
-  if (suid_exec("CHEK",""))
-  {
-	  gtk_widget_set_sensitive(user_list, FALSE);
-	  gtk_widget_set_sensitive(button1, FALSE);
-	  gtk_widget_set_sensitive(button2, FALSE);
-	  gtk_widget_set_sensitive(button3, FALSE);
-	  have_access = FALSE;
-  }
+      /* check if we have the permissions to change users */
+      if (suid_exec("CHEK",""))
+        {
+	      gtk_widget_set_sensitive(user_list, FALSE);
+	      gtk_widget_set_sensitive(button1, FALSE);
+	      gtk_widget_set_sensitive(button2, FALSE);
+	      gtk_widget_set_sensitive(button3, FALSE);
+	      have_access = FALSE;
+        }
+      else
+        {
+	      have_access = TRUE;
+        }
+    }
   else
-  {
-	  have_access = TRUE;
-  }
-  return vbox1;
+	have_access = FALSE;
+  
+  if (password_only)
+    {
+      gtk_widget_show(create_passwindow(pwroot, NULL));
+      return NULL; 
+    }
+  else
+  	return vbox1;
 }
 
 GtkWidget*
@@ -440,7 +454,7 @@
 }
 
 GtkWidget*
-create_passwindow (pwlist *init,GtkWidget *parent)
+create_passwindow (pwlist *init, GtkWidget *parent)
 {
   GtkWidget *passwindow;
   GtkWidget *vbox3;
@@ -463,9 +477,8 @@
   gtk_window_set_transient_for (GTK_WINDOW(passwindow), GTK_WINDOW(parent));
   gtk_window_set_title (GTK_WINDOW (passwindow), _("Change Password"));
   gtk_window_set_modal (GTK_WINDOW (passwindow), TRUE);
-
   vbox3 = GTK_DIALOG (passwindow)->vbox;
-
+  
   table3 = gtk_table_new (3, 3, FALSE);
 
   gtk_widget_show (table3);
@@ -561,9 +574,12 @@
                       GTK_SIGNAL_FUNC (users_on_changepasswd_clicked),
                       (gpointer)self);
 
-  /* in case of destruction by close (X) button */
-  gtk_signal_connect (GTK_OBJECT(passwindow) , "destroy", 
+  if (parent)
+ 	 gtk_signal_connect (GTK_OBJECT(passwindow) , "destroy", 
 		      (GtkSignalFunc) freedata, (gpointer)self);
+  else
+ 	 gtk_signal_connect (GTK_OBJECT(passwindow) , "destroy", 
+		      gtk_main_quit, NULL);
 
   return passwindow;
 }