patch: basedir takeII




I applied my basedir patch against 0.1.49, and made it actually work.
It doesn't fix:
* gpilotd aborts if there is no basedir, even though it sees there is no
  base dir. something to do with conduit load which i don't grok

* druid. it's trivial though to fix that once you feel confortable with
  changing druid code (which i don't)

The patch is attached. I will upload patched .49 (s)rpms to
chbm.nu/gnome-pilot.

cheers


-- 
Carlos Morgado - chbm(at)chbm(dot)nu - http://chbm.nu/ -- gpgkey: 0x1FC57F0A 
http://wwwkeys.pgp.net/ FP:0A27 35D3 C448 3641 0573 6876 2A37 4BB2 1FC5 7F0A
RSA in 3 lines of PERL :
#!/bin/perl -sp0777i<X+d*lMLa^*lN%0]dsXx++lMlN/dsM0<j]dsj
$/=unpack('H*',$_);$_=cho 16dio\U$k"SK$/SM$n\EsN0p[lN*1
lK[d2%Sa2/d0$^Ixp"|dc;s/\W//g;$_=pack('H*',/((..)*)$/)
Index: capplet/gpilotd-control-applet.c
===================================================================
RCS file: /cvs/gnome/gnome-pilot/capplet/gpilotd-control-applet.c,v
retrieving revision 1.56
diff -u -r1.56 gpilotd-control-applet.c
--- capplet/gpilotd-control-applet.c	2000/03/01 05:57:49	1.56
+++ capplet/gpilotd-control-applet.c	2000/03/25 00:19:49
@@ -9,6 +9,10 @@
 #include <sys/types.h>
 #include <signal.h>
 #include <ctype.h>
+#include <errno.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <unistd.h>
 #include <gnome.h>
 
 #include <config.h>
@@ -512,6 +516,46 @@
 			run_error_dialog(_("Pilot with this id or name already exists."));
 			g_free(pilot);
 		} else {
+			/* check basedir validity */
+			gchar *errstr;
+			
+			if( mkdir(pilot->sync_options.basedir, 0700) < 0 ) {
+				struct stat statbuf; 
+				errstr = strerror(errno);
+				switch(errno) {
+				case EEXIST: 
+					stat(pilot->sync_options.basedir, &statbuf);
+					if(S_ISDIR(statbuf.st_mode)) {  
+						if(!(statbuf.st_mode & (S_IRUSR | S_IWUSR |S_IXUSR))) {
+							run_error_dialog(_("The specified base directory exists but has the wrong permissions. Please fix or choose another directory."));
+							g_free(pilot);
+							continue;
+						}
+					} else {
+						run_error_dialog(_("The specified base directory exists but it's not a directory. Please make it a directory or choose another directory."));
+						g_free(pilot);
+						continue;
+					}
+					break;
+					
+				case EACCES:
+					break;
+					run_error_dialog(_("It wasn't possible to create the specified base directory. Please verify the permitions on the specified path or choose another directory"));
+					g_free(pilot);
+					continue;
+				case ENOENT:
+					run_error_dialog(_("The path specified for the base directory is invalid. Please choose another directory"));
+					g_free(pilot);
+					continue; 
+					break;
+				default:
+					
+					run_error_dialog(errstr);
+					g_free(pilot);
+					continue;
+					}
+			};
+		
 			row[0]=pilot->name;
 			g_snprintf(buf,sizeof(buf),"%d",pilot->pilot_id);
 			row[1]=buf;
@@ -544,6 +588,48 @@
 					      (GCompareFunc)compare_pilot_info)!=NULL) {
 				run_error_dialog(_("Pilot with this id or name already exists."));
 			} else {
+				/* check basedir validity */
+				gchar *errstr;
+				
+				if(!mkdir(pilot->sync_options.basedir, 0700) ) {
+					struct stat statbuf;
+
+					errstr = strerror(errno);
+					switch(errno) {
+					case EEXIST: 
+						stat(pilot->sync_options.basedir, &statbuf);
+						if(S_ISDIR(statbuf.st_mode)) {  
+							if(!(statbuf.st_mode & (S_IRUSR | S_IWUSR |S_IXUSR))) {
+								run_error_dialog(_("The specified base directory exists but has the wrong permissions. Please fix or choose another directory."));
+								g_free(pilot);
+								continue;
+							}
+						} else {
+							run_error_dialog(_("The specified base directory exists but it's not a directory. Please make it a directory or choose another directory."));
+							g_free(pilot);
+							continue;
+						}
+						free(buf);
+						break;
+						
+					case EACCES:
+						break;
+						run_error_dialog(_("It wasn't possible to create the specified base directory. Please verify the permitions on the specified path or choose another directory"));
+						g_free(pilot);
+						continue;
+					case ENOENT:
+						run_error_dialog(_("The path specified for the base directory is invalid. Please choose another directory"));
+						g_free(pilot);
+						continue;
+						break;
+					default:
+						
+						run_error_dialog(errstr);
+						g_free(pilot);
+						continue;
+					}
+				};
+				
 				gtk_clist_set_text(GTK_CLIST(clist),pilots_selected,0,pilot->name);
 				g_snprintf(buf,sizeof(buf),"%d",pilot->pilot_id);
 				gtk_clist_set_text(GTK_CLIST(clist),pilots_selected,1,buf);
Index: gpilotd/gpilotd.c
===================================================================
RCS file: /cvs/gnome/gnome-pilot/gpilotd/gpilotd.c,v
retrieving revision 1.83
diff -u -r1.83 gpilotd.c
--- gpilotd/gpilotd.c	2000/03/20 15:04:37	1.83
+++ gpilotd/gpilotd.c	2000/03/25 00:19:50
@@ -403,8 +403,22 @@
 					gpilot_gui_warning_dialog(_("Unknown pilot - no pilots matches ID %ld\n"
 								    "Use gnomecc to set pilot's ID"),pu.userID);
 				} else {
+					struct stat buf; 
+
 					/* Pilot is known, make connect notifications */
 					orbed_notify_connect(pilot->name,pu);
+
+					stat(pilot->sync_options.basedir, &buf); 
+					if(!( S_ISDIR(buf.st_mode) && (buf.st_mode & (S_IRUSR | S_IWUSR |S_IXUSR))) ) {
+
+						fprintf(stderr, "no %s\n", pilot->sync_options.basedir);
+						pilot_disconnect(pfd);
+						orbed_notify_disconnect(pilot->name);
+						gpilot_gui_warning_dialog(_("The base directory %s is invalid.\n"
+									    "Please fix it or use gnomecc to chose another directory."),
+									  pilot->sync_options.basedir);	
+					}
+					
 
 					/* If pilot has password, check against the encrypted version
 					   on the pilot */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]