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