On Mon, Dec 26, 2005 at 02:52:34AM +0100, Marcus Glocker wrote:

> Felix Kronlage did already some successfull testing, setting up fresh
> ppp conections and monitored them.  I don't have the ability to test
> ppp connections from here, so some more testing on the functionality
> of the application would be welcome.

Couple of things I had to do in order to have yawwppp start connections
for me. Of course the user needs to have the permissions to run pppd.
Furthermore yawmppp offers the configuration option 'usepeerdns', which
the OpenBSD pppd does not have, so the pppd complains about it. The
attached modification of patch-src-gtksetup_applet.c patches the 
'usepeerdns' option field away (I don't know jack about gtk, so 
don't know wether there is any nicer way besides janking it out).

-fkr
-- 
GPG/PGP:  D9AC74D0 / 076E 1E87 3E05 1C7F B1A0  8A48 0D31 9BD3 D9AC 74D0
http://hazardous.org/~fkr - [EMAIL PROTECTED] - [EMAIL PROTECTED]|irc - FKR-RIPE
--- src/gtksetup/applet.c.orig  Sat Apr 21 20:29:33 2001
+++ src/gtksetup/applet.c       Mon Dec 26 09:41:33 2005
@@ -465,23 +465,31 @@
   if (selected_entry<0)
     return;
 
-  strcpy(pref_entries[selected_entry].LongName,
-        gtk_entry_get_text(GTK_ENTRY(right_pane[0])));
-  strcpy(pref_entries[selected_entry].ShortName,
-        gtk_entry_get_text(GTK_ENTRY(right_pane[1])));
-  strcpy(pref_entries[selected_entry].Phone,
-        gtk_entry_get_text(GTK_ENTRY(right_pane[2])));
-  strcpy(pref_entries[selected_entry].Device,
-        gtk_entry_get_text(GTK_ENTRY(right_pane[3])));
-  strcpy(pref_entries[selected_entry].Username,
-        gtk_entry_get_text(GTK_ENTRY(right_pane[4])));
-  strcpy(pref_entries[selected_entry].Password,
-        gtk_entry_get_text(GTK_ENTRY(right_pane[5])));
+  strlcpy(pref_entries[selected_entry].LongName,
+        gtk_entry_get_text(GTK_ENTRY(right_pane[0])),
+        sizeof(pref_entries[selected_entry].LongName));
+  strlcpy(pref_entries[selected_entry].ShortName,
+        gtk_entry_get_text(GTK_ENTRY(right_pane[1])),
+        sizeof(pref_entries[selected_entry].ShortName));
+  strlcpy(pref_entries[selected_entry].Phone,
+        gtk_entry_get_text(GTK_ENTRY(right_pane[2])),
+        sizeof(pref_entries[selected_entry].Phone));
+  strlcpy(pref_entries[selected_entry].Device,
+        gtk_entry_get_text(GTK_ENTRY(right_pane[3])),
+        sizeof(pref_entries[selected_entry].Device));
+  strlcpy(pref_entries[selected_entry].Username,
+        gtk_entry_get_text(GTK_ENTRY(right_pane[4])),
+        sizeof(pref_entries[selected_entry].Username));
+  strlcpy(pref_entries[selected_entry].Password,
+        gtk_entry_get_text(GTK_ENTRY(right_pane[5])),
+        sizeof(pref_entries[selected_entry].Password));
 
   if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(right_pane[6])))
-    strcpy(pref_entries[selected_entry].PulseDial,"1");
+    strlcpy(pref_entries[selected_entry].PulseDial, "1",
+       sizeof(pref_entries[selected_entry].PulseDial));
   else
-    strcpy(pref_entries[selected_entry].PulseDial,"0");
+    strlcpy(pref_entries[selected_entry].PulseDial, "0",
+       sizeof(pref_entries[selected_entry].PulseDial));
 }
 
 void
@@ -491,7 +499,7 @@
   int i;
 
   q=getenv("HOME");
-  sprintf(p,"%s/.yawmppp2/yawmppprc",q);
+  snprintf(p, sizeof(p), "%s/.yawmppp2/yawmppprc", q);
   isp_count=GetISPInfo(p,&rc_entries[0],MAX_ISPS);
 
   read_ppp_options_from_rc(p);
@@ -513,22 +521,22 @@
 
   /* defaults if we need to jump out of the train */
   memset(pii,0,sizeof(struct PREF_ISP_INFO));
-  strcpy(pii->Device,"/dev/modem");
+  strlcpy(pii->Device, "/dev/modem", sizeof(pii->Device));
   if ((p=getenv("USER"))!=NULL)
-    strcpy(pii->Username,p);
-  strcpy(pii->ModemInit1,"ATZ");
-  strcpy(pii->ModemInit2,"ATM1L2");
-  strcpy(pii->PulseDial,"0");
-  strcpy(pii->UserString,"ogin:");
-  strcpy(pii->PassString,"word:");
-  strcpy(pii->ModemSpeed,"115200");
+    strlcpy(pii->Username, p, sizeof(pii->Username));
+  strlcpy(pii->ModemInit1, "ATZ", sizeof(pii->ModemInit1));
+  strlcpy(pii->ModemInit2, "ATM1L2", sizeof(pii->ModemInit2));
+  strlcpy(pii->PulseDial, "0", sizeof(pii->PulseDial));
+  strlcpy(pii->UserString, "ogin:", sizeof(pii->UserString));
+  strlcpy(pii->PassString, "word:", sizeof(pii->PassString));
+  strlcpy(pii->ModemSpeed, "115200", sizeof(pii->ModemSpeed));
   pii->nExpectPairs=0;
 
   memcpy(&(pii->ppp),&(wii->ppp),sizeof(struct ISP_PPP));
 
   /* entry name */
-  strcpy(pii->LongName,wii->LongName);
-  strcpy(pii->ShortName,wii->ShortName);
+  strlcpy(pii->LongName, wii->LongName, sizeof(pii->LongName));
+  strlcpy(pii->ShortName, wii->ShortName, sizeof(pii->ShortName));
   pii->nologin=wii->nologin;
   
   /* get device and chat script filename from "Start" file */
@@ -658,8 +666,9 @@
         sizeof(struct PREF_ISP_INFO));
   selected_entry=-1;
   clear_and_disable_right_pane();
-  sprintf(tmp,"copy of %s",pref_entries[isp_count].LongName);
-  strcpy(pref_entries[isp_count].LongName,tmp);
+  snprintf(tmp, sizeof(tmp), "copy of %s", pref_entries[isp_count].LongName);
+  strlcpy(pref_entries[isp_count].LongName, tmp,
+       sizeof(pref_entries[isp_count].LongName));
   isp_count++;
   fill_list();
   gtk_clist_select_row(GTK_CLIST(isp_list),i,0);
@@ -686,14 +695,14 @@
   ne=&pref_entries[isp_count];
   memset(ne,0,sizeof(struct PREF_ISP_INFO));
 
-  strcpy(ne->LongName,"New Entry");
-  strcpy(ne->ShortName,"ISP");
-  strcpy(ne->Device,"/dev/modem");
-  strcpy(ne->ModemInit1,"ATZ");
-  strcpy(ne->ModemInit2,"ATM1L2");
-  strcpy(ne->UserString,"ogin:");
-  strcpy(ne->PassString,"word:");
-  strcpy(ne->ModemSpeed,"57600");
+  strlcpy(ne->LongName, "New Entry", sizeof(ne->LongName));
+  strlcpy(ne->ShortName, "ISP", sizeof(ne->ShortName));
+  strlcpy(ne->Device, "/dev/modem", sizeof(ne->Device));
+  strlcpy(ne->ModemInit1, "ATZ", sizeof(ne->ModemInit1));
+  strlcpy(ne->ModemInit2, "ATM1L2", sizeof(ne->ModemInit2));
+  strlcpy(ne->UserString, "ogin:", sizeof(ne->UserString));
+  strlcpy(ne->PassString, "word:", sizeof(ne->PassString));
+  strlcpy(ne->ModemSpeed, "57600", sizeof(ne->ModemSpeed));
   ne->nExpectPairs=0;
 
   ne->ppp.override=0;
@@ -727,7 +736,8 @@
 
   advdlg=dlg=gtk_window_new(GTK_WINDOW_DIALOG);
   gtk_window_set_transient_for(GTK_WINDOW(advdlg),GTK_WINDOW(applet));
-  sprintf(tmp,"Settings: %s",pref_entries[selected_entry].LongName);
+  snprintf(tmp, sizeof(tmp), "Settings: %s",
+       pref_entries[selected_entry].LongName);
   gtk_window_set_title(GTK_WINDOW(dlg),tmp);
   gtk_window_set_policy(GTK_WINDOW(dlg),TRUE,TRUE,TRUE);
   gtk_container_set_border_width(GTK_CONTAINER(dlg),4);
@@ -918,11 +928,16 @@
   struct PREF_ISP_INFO *pii;  
 
   pii=&pref_entries[selected_entry];
-  strcpy(pii->ModemInit1,gtk_entry_get_text(GTK_ENTRY(adv_e[0])));
-  strcpy(pii->ModemInit2,gtk_entry_get_text(GTK_ENTRY(adv_e[1])));
-  strcpy(pii->ModemSpeed,gtk_entry_get_text(GTK_ENTRY(adv_e[2])));
-  strcpy(pii->UserString,gtk_entry_get_text(GTK_ENTRY(adv_e[3])));
-  strcpy(pii->PassString,gtk_entry_get_text(GTK_ENTRY(adv_e[4])));
+  strlcpy(pii->ModemInit1, gtk_entry_get_text(GTK_ENTRY(adv_e[0])),
+       sizeof(pii->ModemInit1));
+  strlcpy(pii->ModemInit2, gtk_entry_get_text(GTK_ENTRY(adv_e[1])),
+       sizeof(pii->ModemInit2));
+  strlcpy(pii->ModemSpeed, gtk_entry_get_text(GTK_ENTRY(adv_e[2])),
+       sizeof(pii->ModemSpeed));
+  strlcpy(pii->UserString, gtk_entry_get_text(GTK_ENTRY(adv_e[3])),
+       sizeof(pii->UserString));
+  strlcpy(pii->PassString, gtk_entry_get_text(GTK_ENTRY(adv_e[4])),
+       sizeof(pii->PassString));
 
   pii->nologin=gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(adv_nl));
 
@@ -967,8 +982,9 @@
 isp_rename(GtkEditable *ge,gpointer data)
 {
   if (selected_entry<0) return;
-  strcpy(pref_entries[selected_entry].LongName,
-        gtk_entry_get_text(GTK_ENTRY(ge)));
+  strlcpy(pref_entries[selected_entry].LongName,
+        gtk_entry_get_text(GTK_ENTRY(ge)),
+        sizeof(pref_entries[selected_entry].LongName));
   gtk_clist_set_text(GTK_CLIST(isp_list),selected_entry,1,
                     pref_entries[selected_entry].LongName);
 }
@@ -986,7 +1002,7 @@
   if (selected_entry>=0)
     commit_back_to_db();
 
-  sprintf(tmp,"%s/.yawmppp2",getenv("HOME"));
+  snprintf(tmp, sizeof(tmp), "%s/.yawmppp2", getenv("HOME"));
 
   if (stat(tmp,&ss)<0) {
     if (mkdir(tmp,0700)<0) {
@@ -999,7 +1015,7 @@
     chmod(tmp,0700);
 
   /* the yawmppprc file */
-  sprintf(aux,"%s/yawmppprc",tmp);
+  snprintf(aux, sizeof(aux), "%s/yawmppprc", tmp);
   f=fopen(aux,"w");
   if (!f) {
     message_box(GTK_WINDOW(applet),ERR_CANT_WRITE,"Error",
@@ -1021,19 +1037,19 @@
       fprintf(f,"\t%s %s\n",KEY_LONGNAME,pref_entries[i].LongName);
       fprintf(f,"\t%s %s\n",KEY_SHORTNAME,pref_entries[i].ShortName);
 
-      sprintf(yet,"%s/start.%d",tmp,i);
+      snprintf(yet, sizeof(yet), "%s/start.%d", tmp, i);
       fprintf(f,"\t%s %s\n",KEY_STARTACTION,yet);
 
-      sprintf(yet,"%s/stop.%d",tmp,i);
+      snprintf(yet, sizeof(yet), "%s/stop.%d", tmp, i);
       fprintf(f,"\t%s %s\n",KEY_STOPACTION,yet);
 
-      sprintf(yet,"%s/ifdown.%d",tmp,i);
+      snprintf(yet, sizeof(yet), "%s/ifdown.%d", tmp, i);
       fprintf(f,"\t%s %s\n",KEY_IFDOWNACTION,yet);
 
-      sprintf(yet,"%s/opts.%d",tmp,i);
+      snprintf(yet, sizeof(yet), "%s/opts.%d", tmp, i);
       fprintf(f,"\t%s %s\n",KEY_PPPSTUFF,yet);
 
-      sprintf(yet,"%s/chat.%d",tmp,i);
+      snprintf(yet, sizeof(yet), "%s/chat.%d", tmp, i);
       fprintf(f,"\t%s %s\n",KEY_CHATSTUFF,yet);
 
       fprintf(f,"\t%s %s\n",KEY_IFDOWNACTION,yet);
@@ -1056,7 +1072,7 @@
     /* write ppp pane */
     fprintf(f,"Note: if you were meant to edit the line below I would have\n");
     fprintf(f,"made it readable by humans.\n");
-    fprintf(f,"PPPOPTIONS %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d 
%d\n",
+    fprintf(f,"PPPOPTIONS %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d\n",
            pppo.defaultroute,
            pppo.lock,
            pppo.passive,
@@ -1072,8 +1088,7 @@
            pppo.lcp[1],
            pppo.lcp[2],
            pppo.lcp[3],
-           pppo.lcp[4],
-           pppo.usepeerdns);
+           pppo.lcp[4]);
 
     fclose(f);
     chmod(aux,0600);
@@ -1084,7 +1099,7 @@
 
     /* FILE 2 : start.x mode 700 */
 
-    sprintf(aux,"%s/start.%d",tmp,i);
+    snprintf(aux, sizeof(aux), "%s/start.%d", tmp, i);
     f=fopen(aux,"w");
     if (!f) {
       message_box(GTK_WINDOW(applet),ERR_CANT_WRITE,"Error",
@@ -1102,7 +1117,7 @@
 
     /* FILE 3 : opts.x mode 600 */
 
-    sprintf(aux,"%s/opts.%d",tmp,i);
+    snprintf(aux, sizeof(aux), "%s/opts.%d", tmp, i);
     f=fopen(aux,"w");
     if (!f) {
       message_box(GTK_WINDOW(applet),ERR_CANT_WRITE,"Error",
@@ -1132,7 +1147,7 @@
 
     /* FILE 4 : stop.x mode 700 */
 
-    sprintf(aux,"%s/stop.%d",tmp,i);
+    snprintf(aux, sizeof(aux), "%s/stop.%d", tmp, i);
     f=fopen(aux,"w");
     if (!f) {
       message_box(GTK_WINDOW(applet),ERR_CANT_WRITE,"Error",
@@ -1163,7 +1178,7 @@
 
     /* FILE 5 : ifdown.x mode 700 */
 
-    sprintf(aux,"%s/ifdown.%d",tmp,i);
+    snprintf(aux, sizeof(aux), "%s/ifdown.%d", tmp, i);
     f=fopen(aux,"w");
     if (!f) {
       message_box(GTK_WINDOW(applet),ERR_CANT_WRITE,"Error",
@@ -1184,7 +1199,7 @@
 
     /* FILE 6 : user_chat.x mode 700 */
 
-    sprintf(aux,"%s/%s_chat.%d",tmp,getenv("USER"),i);
+    snprintf(aux, sizeof(aux), "%s/%s_chat.%d", tmp, getenv("USER"), i);
     f=fopen(aux,"w");
     if (!f) {
       message_box(GTK_WINDOW(applet),ERR_CANT_WRITE,"Error",
@@ -1234,7 +1249,7 @@
   /* FILE 7 : user_yawmppp_isp# mode 600 */
 
   for(i=0;i<isp_count;i++) {
-    sprintf(aux,"%s/%s_yawmppp_isp%d",tmp,getenv("USER"),i);
+    snprintf(aux, sizeof(aux), "%s/%s_yawmppp_isp%d", tmp, getenv("USER"), i);
     f=fopen(aux,"w");
     if (!f) {
       message_box(GTK_WINDOW(applet),ERR_CANT_WRITE,"Error",
@@ -1268,7 +1283,7 @@
   }
 
   /* FILE 8 : root_apply.sh mode 700 */
-  sprintf(aux,"%s/root_apply.sh",tmp);
+  snprintf(aux, sizeof(aux), "%s/root_apply.sh", tmp);
   f=fopen(aux,"w");
   if (!f) {
     message_box(GTK_WINDOW(applet),ERR_CANT_WRITE,"Error",
@@ -1284,8 +1299,8 @@
   fprintf(f,"# acknowledge input files in that directory.\n");
   fprintf(f,"#\n\n");
 
-  strcpy(v_user,getenv("USER"));
-  strcpy(v_home,getenv("HOME"));
+  strlcpy(v_user, getenv("USER"), sizeof(v_user));
+  strlcpy(v_home, getenv("HOME"), sizeof(v_home));
 
   fprintf(f,"# create /etc/ppp/peers if missing\n");
   fprintf(f,"if [ ! -d /etc/ppp/peers ]; then mkdir -m 0755 -p /etc/ppp/peers; 
fi\n\n");
@@ -1294,22 +1309,21 @@
 
     fprintf(f,"# ISP entry %d\n",i);
 
-    sprintf(yet,"%s_yawmppp_isp%d",v_user,i);    
+    snprintf(yet, sizeof(yet), "%s_yawmppp_isp%d", v_user, i);    
     fprintf(f,"chown root %s/.yawmppp2/%s\n",v_home,yet);
     fprintf(f,"cp -f %s/.yawmppp2/%s /etc/ppp/peers/%s\n",v_home,yet,yet);
     fprintf(f,"chown %s /etc/ppp/peers/%s\n",v_user,yet);
     fprintf(f,"chown %s %s/.yawmppp2/%s\n",v_user,v_home,yet);
     fprintf(f,"chmod 600 /etc/ppp/peers/%s\n\n",yet);
 
-    sprintf(yet,"%s_chat.%d",v_user,i);
+    snprintf(yet, sizeof(yet), "%s_chat.%d", v_user, i);
     fprintf(f,"chown root %s/.yawmppp2/%s\n",v_home,yet);
     fprintf(f,"cp -f %s/.yawmppp2/%s /etc/ppp/peers/%s\n",v_home,yet,yet);
     fprintf(f,"chown %s /etc/ppp/peers/%s\n",v_user,yet);
     fprintf(f,"chown %s %s/.yawmppp2/%s\n",v_user,v_home,yet);
     fprintf(f,"chmod 700 /etc/ppp/peers/%s\n\n",yet);
 
-  }
-
+  } 
   fprintf(f,"\n# remove tag file (to tell graphical interface this script did 
its job)\n");
   fprintf(f,"rm -f %s/.yawmppp2/.root_didnt_run_it\n",v_home);
 
@@ -1317,7 +1331,7 @@
   chmod(aux,0700);
 
   /* FILE 9 : consist check */
-  sprintf(aux,"%s/.root_didnt_run_it",tmp);
+  snprintf(aux, sizeof(aux), "%s/.root_didnt_run_it", tmp);
   f=fopen(aux,"w");
   if (f) {
     fprintf(f,"flag file\n");
@@ -1325,7 +1339,7 @@
   }
   
   /* send signal to yawmppp dock applet (so it rereads the config) */
-  sprintf(aux,"%s/yawmppp.pid",tmp);
+  snprintf(aux, sizeof(aux), "%s/yawmppp.pid", tmp);
   f=fopen(aux,"r");
   if (f) {
     fgets(aux,512,f);
@@ -1341,21 +1355,29 @@
      as the default shell. They even use the archaic BSD license. eek! */
   needroot=0;
   for(i=0;i<isp_count;i++) {
-    sprintf(aux,"/bin/sh -c \"diff -q /etc/ppp/peers/%s_yawmppp_isp%d 
%s/%s_yawmppp_isp%d >/dev/null 2>/dev/null\"",
-           v_user,i,tmp,v_user,i);
+    snprintf(aux, sizeof(aux),
+       "/bin/sh -c \"diff -q /etc/ppp/peers/%s_yawmppp_isp%d "
+       "%s/%s_yawmppp_isp%d >/dev/null 2>/dev/null\"",
+           v_user, i, tmp, v_user, i);
     if (system(aux)) {
-      sprintf(aux,"/bin/sh -c \"cp -f %s/%s_yawmppp_isp%d 
/etc/ppp/peers/%s_yawmppp_isp%d >/dev/null 2>/dev/null\"",
-             tmp,v_user,i,v_user,i);
+      snprintf(aux, sizeof(aux),
+       "/bin/sh -c \"cp -f %s/%s_yawmppp_isp%d "
+       "/etc/ppp/peers/%s_yawmppp_isp%d >/dev/null 2>/dev/null\"",
+             tmp, v_user, i, v_user, i);
       if (system(aux))
        needroot=1;
     }
     if (needroot)
       break;
-    sprintf(aux,"/bin/sh -c \"diff -q /etc/ppp/peers/%s_chat.%d %s/%s_chat.%d 
>/dev/null 2>/dev/null\"",
-           v_user,i,tmp,v_user,i);
+    snprintf(aux, sizeof(aux),
+       "/bin/sh -c \"diff -q /etc/ppp/peers/%s_chat.%d %s/%s_chat.%d "
+       ">/dev/null 2>/dev/null\"",
+           v_user, i, tmp, v_user, i);
     if (system(aux)) {
-      sprintf(aux,"/bin/sh -c \"cp -f %s/%s_chat.%d /etc/ppp/peers/%s_chat.%d 
>/dev/null 2>/dev/null\"",
-             tmp,v_user,i,v_user,i);
+      snprintf(aux, sizeof(aux),
+       "/bin/sh -c \"cp -f %s/%s_chat.%d "
+       "/etc/ppp/peers/%s_chat.%d >/dev/null 2>/dev/null\"",
+             tmp, v_user, i, v_user, i);
       if (system(aux))
        needroot=1;
     }
@@ -1364,18 +1386,18 @@
   }
 
   if (needroot) {
-    sprintf(aux,"%s/root_apply.sh",tmp);
+    snprintf(aux, sizeof(aux), "%s/root_apply.sh", tmp);
     run_as_root(aux);
-    sprintf(aux,"%s/.root_didnt_run_it",tmp);
+    snprintf(aux, sizeof(aux), "%s/.root_didnt_run_it", tmp);
     f=fopen(aux,"r");
     if (f!=NULL) {
       fclose(f);
       unlink(aux);  
     }
   } else {
-    sprintf(aux,"%s/root_apply.sh",tmp);
+    snprintf(aux, sizeof(aux), "%s/root_apply.sh", tmp);
     unlink(aux);
-    sprintf(aux,"%s/.root_didnt_run_it",tmp);
+    snprintf(aux, sizeof(aux), "%s/.root_didnt_run_it", tmp);
     unlink(aux);
   }
   return 0;
@@ -1408,8 +1430,8 @@
   FILE *f;
 
   p=getenv("HOME");
-  strcpy (temp, p);
-  strcat (temp, "/.yawmppp2/.delayedupdate");
+  strlcpy(temp, p, sizeof(temp));
+  strlcat(temp, "/.yawmppp2/.delayedupdate", sizeof(temp));
 
   usleep(100000L);
 
@@ -1440,29 +1462,29 @@
 void
 find_out_paths(void)
 {
-       strcpy(chat_path,"/usr/sbin/chat");
-       strcpy(pppd_path,"/usr/sbin/pppd");
+       strlcpy(chat_path,"/usr/sbin/chat", sizeof(chat_path));
+       strlcpy(pppd_path,"/usr/sbin/pppd", sizeof(pppd_path));
 
-       test_set_path(chat_path,"/bin/chat");
-       test_set_path(chat_path,"/usr/bin/chat");
-       test_set_path(chat_path,"/usr/local/bin/chat");
-       test_set_path(chat_path,"/usr/local/sbin/chat");
-       test_set_path(chat_path,"/sbin/chat");
-       test_set_path(chat_path,"/usr/sbin/chat");
+       test_set_path(chat_path, "/bin/chat", sizeof(chat_path));
+       test_set_path(chat_path, "/usr/bin/chat", sizeof(chat_path));
+       test_set_path(chat_path, "/usr/local/bin/chat", sizeof(chat_path));
+       test_set_path(chat_path, "/usr/local/sbin/chat", sizeof(chat_path));
+       test_set_path(chat_path, "/sbin/chat", sizeof(chat_path));
+       test_set_path(chat_path, "/usr/sbin/chat", sizeof(chat_path));
 
-       test_set_path(pppd_path,"/bin/pppd");
-       test_set_path(pppd_path,"/usr/bin/pppd");
-       test_set_path(pppd_path,"/usr/local/bin/pppd");
-       test_set_path(pppd_path,"/usr/local/sbin/pppd");
-       test_set_path(pppd_path,"/sbin/pppd");
-       test_set_path(pppd_path,"/usr/sbin/pppd");
+       test_set_path(pppd_path, "/bin/pppd", sizeof(chat_path));
+       test_set_path(pppd_path, "/usr/bin/pppd", sizeof(chat_path));
+       test_set_path(pppd_path, "/usr/local/bin/pppd", sizeof(chat_path));
+       test_set_path(pppd_path, "/usr/local/sbin/pppd", sizeof(chat_path));
+       test_set_path(pppd_path, "/sbin/pppd", sizeof(chat_path));
+       test_set_path(pppd_path, "/usr/sbin/pppd", sizeof(chat_path));
 }
 
 void
-test_set_path(char *dest,char *path)
+test_set_path(char *dest, char *path, const int len)
 {
        if (file_exists(path))
-               strcpy(dest,path);
+               strlcpy(dest, path, len);
 }
 
 /* PPP PANE */
@@ -1512,7 +1534,6 @@
   wi[6]=gtk_check_button_new_with_label("kdebug : send");
   wi[7]=gtk_check_button_new_with_label("noauth");
   wi[8]=gtk_check_button_new_with_label("noipdefault");
-  wi[30]=gtk_check_button_new_with_label("usepeerdns");
 
   gtk_tooltips_set_tip(tt,wi[0],
                       "add a default route to the system routing tables",
@@ -1542,9 +1563,6 @@
   gtk_tooltips_set_tip(tt,wi[8],
                       "require IP address to be negotiated via IPCP",
                       NULL);
-  gtk_tooltips_set_tip(tt,wi[30],
-                      "ask DNS server info to peer, requires pppd 2.3.10 or 
newer, 2.3.11 recommended",
-                      NULL);
 
   /* --- */
 
@@ -1644,13 +1662,11 @@
     gtk_box_pack_start(GTK_BOX(v[0]),wi[i],FALSE,FALSE,1);
     gtk_widget_show(wi[i]);
   }
-  gtk_box_pack_start(GTK_BOX(v[0]),wi[30],FALSE,FALSE,1);
-  gtk_widget_show(wi[30]);
 
   gtk_box_pack_start(GTK_BOX(v[1]),ew[2],FALSE,TRUE,4);
   gtk_box_pack_start(GTK_BOX(v[1]),ew[4],FALSE,TRUE,4);
 
-  for(i=9;i<30;i++)
+  for(i=9;i<29;i++)
     gtk_widget_show(wi[i]);
 
   for(i=0;i<6;i++)
@@ -1691,7 +1707,6 @@
   pppo.lcp[4]=3;
   pppo.chap=AUTH_DONTCARE;
   pppo.pap=AUTH_DONTCARE;
-  pppo.usepeerdns=1;
   if (w!=NULL)
     set_ppp_pane();
 }
@@ -1710,7 +1725,6 @@
   pppo.noipdefault 
=!!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ppp_pw[8]));
 
   pppo.linectl     
=!!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ppp_pw[10]));
-  pppo.usepeerdns  
=!!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ppp_pw[30]));
   
   for(i=11;i<15;i++)
     if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ppp_pw[i])))
@@ -1737,18 +1751,17 @@
   gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ppp_pw[6]),pppo.kdebug&0x04);
   gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ppp_pw[7]),pppo.noauth);
   gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ppp_pw[8]),pppo.noipdefault);
-  gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ppp_pw[30]),pppo.usepeerdns);
 
   gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ppp_pw[9+pppo.linectl]),TRUE);
   
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ppp_pw[11+pppo.flowctl]),TRUE);
 
-  sprintf(b,"%d",pppo.mtu);
+  snprintf(b, sizeof(b), "%d", pppo.mtu);
   gtk_entry_set_text(GTK_ENTRY(ppp_pw[22]),b);
-  sprintf(b,"%d",pppo.mru);
+  snprintf(b, sizeof(b), "%d", pppo.mru);
   gtk_entry_set_text(GTK_ENTRY(ppp_pw[23]),b);
 
   for(i=0;i<5;i++) {
-    sprintf(b,"%d",pppo.lcp[i]);
+    snprintf(b, sizeof(b), "%d", pppo.lcp[i]);
     gtk_entry_set_text(GTK_ENTRY(ppp_pw[24+i]),b);
   }
 }
@@ -1761,100 +1774,96 @@
 
   here[0]=0;
   if (modi->defaultroute) {
-    strcat(here,"defaultroute");
-    strcat(here,sep);
+    strlcat(here, "defaultroute", sizeof(here));
+    strlcat(here, sep, sizeof(here));
   }
   if (modi->lock) {
-    strcat(here,"lock");
-    strcat(here,sep);
+    strlcat(here, "lock", sizeof(here));
+    strlcat(here, sep, sizeof(here));
   }
   if (modi->passive) {
-    strcat(here,"passive");
-    strcat(here,sep);
+    strlcat(here, "passive", sizeof(here));
+    strlcat(here, sep, sizeof(here));
   }
   if (modi->debug) {
-    strcat(here,"debug");
-    strcat(here,sep);
+    strlcat(here, "debug", sizeof(here));
+    strlcat(here, sep, sizeof(here));
   }
   if (modi->kdebug) {
-    sprintf(local,"kdebug %d",modi->kdebug);
-    strcat(here,local);
-    strcat(here,sep);
+    snprintf(local, sizeof(local), "kdebug %d", modi->kdebug);
+    strlcat(here, local, sizeof(here));
+    strlcat(here, sep, sizeof(here));
   }
   if (modi->noauth) {
-    strcat(here,"noauth");
-    strcat(here,sep);
+    strlcat(here, "noauth", sizeof(here));
+    strlcat(here, sep, sizeof(here));
   }
   if (modi->noipdefault) {
-    strcat(here,"noipdefault");
-    strcat(here,sep);
+    strlcat(here, "noipdefault", sizeof(here));
+    strlcat(here, sep, sizeof(here));
   }
 
   switch(modi->chap) {
   case AUTH_REQUIRE:
-    strcat(here,"require-chap");
-    strcat(here,sep);
+    strlcat(here, "require-chap", sizeof(here));
+    strlcat(here, sep, sizeof(here));
     break;
   case AUTH_REFUSE:
-    strcat(here,"refuse-chap");
-    strcat(here,sep);
+    strlcat(here, "refuse-chap", sizeof(here));
+    strlcat(here, sep, sizeof(here));
     break;
   }
 
   switch(modi->pap) {
   case AUTH_REQUIRE:
-    strcat(here,"require-pap");
-    strcat(here,sep);
+    strlcat(here, "require-pap", sizeof(here));
+    strlcat(here, sep, sizeof(here));
     break;
   case AUTH_REFUSE:
-    strcat(here,"refuse-pap");
-    strcat(here,sep);
+    strlcat(here, "refuse-pap", sizeof(here));
+    strlcat(here, sep, sizeof(here));
     break;
   }
 
   if (modi->linectl)
-    strcat(here,"local");
+    strlcat(here, "local", sizeof(here));
   else
-    strcat(here,"modem");
-  strcat(here,sep);
+    strlcat(here, "modem", sizeof(here));
+  strlcat(here, sep, sizeof(here));
 
   switch(modi->flowctl) {
-    case 0: strcat(here,"crtscts"); break;
-    case 1: strcat(here,"xonxoff"); break;
-    case 2: strcat(here,"nocrtscts"); break;
+    case 0: strlcat(here, "crtscts", sizeof(here)); break;
+    case 1: strlcat(here, "xonxoff", sizeof(here)); break;
+    case 2: strlcat(here, "nocrtscts", sizeof(here)); break;
   }
-  strcat(here,sep);
+  strlcat(here, sep, sizeof(here));
 
-  sprintf(local,"mtu %d%smru %d%s",
+  snprintf(local, sizeof(local), "mtu %d%smru %d%s",
          modi->mtu,sep,
          modi->mru,sep);
 
-  strcat(here,local);
+  strlcat(here, local, sizeof(here));
 
   if (modi->lcp[0]) {
-    sprintf(local,"lcp-echo-failure %d",modi->lcp[0]);
-    strcat(here,local);
-    strcat(here,sep);
+    snprintf(local, sizeof(local), "lcp-echo-failure %d", modi->lcp[0]);
+    strlcat(here, local, sizeof(here));
+    strlcat(here, sep, sizeof(here));
   }
   if (modi->lcp[1]) {
-    sprintf(local,"lcp-echo-interval %d",modi->lcp[1]);
-    strcat(here,local);
-    strcat(here,sep);
+    snprintf(local, sizeof(local), "lcp-echo-interval %d", modi->lcp[1]);
+    strlcat(here, local, sizeof(here));
+    strlcat(here, sep, sizeof(here));
   }
-  sprintf(local,"lcp-max-configure %d",modi->lcp[2]);
-  strcat(here,local);
-  strcat(here,sep);
-  sprintf(local,"lcp-max-terminate %d",modi->lcp[3]);
-  strcat(here,local);
-  strcat(here,sep);
-  sprintf(local,"lcp-restart %d",modi->lcp[4]);
-  strcat(here,local);
-  strcat(here,sep);
+  snprintf(local, sizeof(local), "lcp-max-configure %d", modi->lcp[2]);
+  strlcat(here, local, sizeof(here));
+  strlcat(here, sep, sizeof(here));
+  snprintf(local, sizeof(local), "lcp-max-terminate %d", modi->lcp[3]);
+  strlcat(here, local, sizeof(here));
+  strlcat(here, sep, sizeof(here));
+  snprintf(local, sizeof(local), "lcp-restart %d", modi->lcp[4]);
+  strlcat(here, local, sizeof(here));
+  strlcat(here, sep, sizeof(here));
 
-  if (modi->usepeerdns) {
-    strcat(here,"usepeerdns");
-    strcat(here,sep);
-  }
   return(here);
 }
 
@@ -1889,7 +1898,6 @@
        t=wrapped_strtok(NULL," \t\n");
        pppo.lcp[i]=atoi(t);
       }
-      t=wrapped_strtok(NULL," \t\n"); pppo.usepeerdns=atoi(t);
       break;
     }
   }
@@ -1943,7 +1951,8 @@
   v1=gtk_vbox_new(FALSE,1);
   gtk_container_add(GTK_CONTAINER(dlg),v1);
 
-  sprintf(tmp,"Conversation: %s",pref_entries[selected_entry].LongName);
+  snprintf(tmp, sizeof(tmp), "Conversation: %s",
+       pref_entries[selected_entry].LongName);
   gtk_window_set_title(GTK_WINDOW(dlg),tmp);
   gtk_window_set_policy(GTK_WINDOW(dlg),TRUE,TRUE,TRUE);
   gtk_container_set_border_width(GTK_CONTAINER(dlg),4);
@@ -2122,13 +2131,17 @@
 
   pii=&pref_entries[selected_entry];
 
-  strcpy(aux[0],pii->s_expect[exp_sel]);
-  strcpy(aux[1],pii->s_send[exp_sel]);
+  strlcpy(aux[0], pii->s_expect[exp_sel], sizeof(aux[0]));
+  strlcpy(aux[1], pii->s_send[exp_sel], sizeof(aux[1]));
 
-  strcpy(pii->s_expect[exp_sel],pii->s_expect[exp_sel-1]);
-  strcpy(pii->s_send[exp_sel],pii->s_send[exp_sel-1]);
-  strcpy(pii->s_expect[exp_sel-1],aux[0]);
-  strcpy(pii->s_send[exp_sel-1],aux[1]);
+  strlcpy(pii->s_expect[exp_sel], pii->s_expect[exp_sel - 1],
+       sizeof(pii->s_expect[exp_sel]));
+  strlcpy(pii->s_send[exp_sel], pii->s_send[exp_sel - 1],
+       sizeof(pii->s_send[exp_sel]));
+  strlcpy(pii->s_expect[exp_sel - 1], aux[0],
+       sizeof(pii->s_expect[exp_sel - 1]));
+  strlcpy(pii->s_send[exp_sel - 1], aux[1],
+       sizeof(pii->s_send[exp_sel - 1]));
   nsel=--exp_sel;
   exp_update();
   gtk_clist_select_row(GTK_CLIST(exp_cl),nsel,0);
@@ -2142,13 +2155,17 @@
   int nsel;
   pii=&pref_entries[selected_entry];
 
-  strcpy(aux[0],pii->s_expect[exp_sel]);
-  strcpy(aux[1],pii->s_send[exp_sel]);
+  strlcpy(aux[0], pii->s_expect[exp_sel], sizeof(aux[0]));
+  strlcpy(aux[1], pii->s_send[exp_sel], sizeof(aux[1]));
 
-  strcpy(pii->s_expect[exp_sel],pii->s_expect[exp_sel+1]);
-  strcpy(pii->s_send[exp_sel],pii->s_send[exp_sel+1]);
-  strcpy(pii->s_expect[exp_sel+1],aux[0]);
-  strcpy(pii->s_send[exp_sel+1],aux[1]);
+  strlcpy(pii->s_expect[exp_sel],pii->s_expect[exp_sel + 1],
+       sizeof(pii->s_expect[exp_sel]));
+  strlcpy(pii->s_send[exp_sel], pii->s_send[exp_sel + 1],
+       sizeof(pii->s_send[exp_sel]));
+  strlcpy(pii->s_expect[exp_sel + 1], aux[0],
+       sizeof(pii->s_expect[exp_sel + 1]));
+  strlcpy(pii->s_send[exp_sel + 1], aux[1],
+       sizeof(pii->s_send[exp_sel + 1]));
   nsel=++exp_sel;
   exp_update();
   gtk_clist_select_row(GTK_CLIST(exp_cl),nsel,0);
@@ -2208,8 +2225,8 @@
   pii=&pref_entries[selected_entry];  
   pii->nExpectPairs--;
   for(i=exp_sel;i<pii->nExpectPairs;i++) {
-    strcpy(pii->s_send[i],pii->s_send[i+1]);
-    strcpy(pii->s_expect[i],pii->s_expect[i+1]);
+    strlcpy(pii->s_send[i], pii->s_send[i + 1], sizeof(pii->s_send[i]));
+    strlcpy(pii->s_expect[i], pii->s_expect[i + 1], sizeof(pii->s_expect[i]));
   }
   exp_sel=-1;
   exp_update();
@@ -2490,7 +2507,7 @@
     return;
   }
 
-  sprintf(line,"man %s",manpage);
+  snprintf(line, sizeof(line), "man %s", manpage);
   man=popen(line,"r");
 
   while(gtk_events_pending()) /* let man,troff,etc. work a little */
@@ -2502,7 +2519,7 @@
     buf[0]=0; tlen=0;
     while(fgets(line,511,man)) {
       unman(line);
-      strcat(buf,line);
+      strlcat(buf, line, blen);
       tlen+=strlen(line);
       if (tlen>(blen-(4<<10)))
        buf=(char *)g_realloc(buf,blen+=(10<<10));
@@ -2539,7 +2556,7 @@
     return;
   }
 
-  sprintf(line,"%s/doc/yawmppp-%s/%s",IPREFIX,VERSION,source);
+  snprintf(line, sizeof(line), "/usr/local/share/doc/yawmppp/%s", source);
   f=fopen(line,"r");
 
   gtk_text_freeze(GTK_TEXT(text));
@@ -2547,7 +2564,7 @@
     buf=(char *)g_malloc(blen=(128<<10));
     buf[0]=0; tlen=0;
     while(fgets(line,511,f)) {
-      strcat(buf,line);
+      strlcat(buf, line, blen);
       tlen+=strlen(line);
       if (tlen>(blen-(4<<10)))
        buf=(char *)g_realloc(buf,blen+=(10<<10));
@@ -2591,7 +2608,7 @@
   GdkBitmap *mask;
   GtkStyle *style;
 
-  strcpy(cmdtorun,what);
+  strlcpy(cmdtorun, what, sizeof(cmdtorun));
 
   wpwd=gtk_window_new(GTK_WINDOW_DIALOG);
   gtk_window_set_transient_for(GTK_WINDOW(wpwd),GTK_WINDOW(applet));
@@ -2608,7 +2625,7 @@
   mv=gtk_vbox_new(FALSE,2);
   gtk_container_add(GTK_CONTAINER(wpwd),mv);
 
-  sprintf(z,"To commit the changes made to the configuration\n"\
+  snprintf(z, sizeof(z), "To commit the changes made to the configuration\n"\
          "YAWMPPP must run some actions with superuser\n"\
          "privileges to write down PPP configuration to the\n"\
          "/etc/ppp/peers directory. The script that will be\n"\
@@ -2728,7 +2745,7 @@
 
   fixed=gdk_font_load("-*-fixed-medium-r-normal--14-*-*-*-*-*-*");  
 
-  sprintf(z,"View Script: %s",cmdtorun);
+  snprintf(z, sizeof(z), "View Script: %s", cmdtorun);
 
   swnd=gtk_window_new(GTK_WINDOW_DIALOG);
   gtk_window_set_default_size(GTK_WINDOW(swnd),600,500);
@@ -2820,7 +2837,8 @@
        return 0;
 
     /* check if script ran successfully */
-    sprintf(aux,"%s/.yawmppp2/.root_didnt_run_it",getenv("HOME"));
+    snprintf(aux, sizeof(aux), "%s/.yawmppp2/.root_didnt_run_it",
+       getenv("HOME"));
     f=fopen(aux,"r");
     if (f) {
       fclose(f);
@@ -2830,28 +2848,29 @@
     return 1;
   } else {
     /* child */
-    sprintf(fcmd,"echo \"(YAWMPPP)\" ; echo \"Enter root password for running 
%s\" ; su -c %s",
-           cmd,cmd);
+    snprintf(fcmd, sizeof(fcmd),
+       "echo \"(YAWMPPP)\" ; echo \"Enter root password for running %s\" ; "
+       "su -c %s", cmd, cmd);
     execlp("xterm","xterm",
           "-geometry","75x10",
           "-fn","-*-fixed-medium-r-normal--15-*-*-*-*-*-*",
           "-title","xterm - YAWMPPP [Apply Changes]",
-          "-e","/bin/sh","-c",fcmd,0);
+          "-e","/bin/sh","-c",fcmd, (char *) NULL);
     execlp("rxvt","rxvt",
           "-geometry","75x10",
           "-fn","-*-fixed-medium-r-normal--15-*-*-*-*-*-*",
           "-title","xterm - YAWMPPP [Apply Changes]",
-          "-e","/bin/sh","-c",fcmd,0);
+          "-e","/bin/sh","-c",fcmd, (char *) NULL);
     execlp("aterm","aterm",
           "-geometry","75x10",
           "-fn","-*-fixed-medium-r-normal--15-*-*-*-*-*-*",
           "-title","xterm - YAWMPPP [Apply Changes]",
-          "-e","/bin/sh","-c",fcmd,0);
+          "-e","/bin/sh","-c",fcmd, (char *) NULL);
     execlp("eterm","eterm",
           "-geometry","75x10",
           "-fn","-*-fixed-medium-r-normal--15-*-*-*-*-*-*",
           "-title","xterm - YAWMPPP [Apply Changes]",
-          "-e","/bin/sh","-c",fcmd,0);
+          "-e","/bin/sh","-c",fcmd, (char *) NULL);
     /* well, we really tried ... */
     exit(1);
   }

Attachment: pgpAqmQcCOCCb.pgp
Description: PGP signature

Reply via email to