Changeset 3295

Show
Ignore:
Timestamp:
07/20/07 13:49:20 (1 year ago)
Author:
tg
Message:

refresh netmsg patch, integrate my diff, use strlcpy, simplify

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/freewrt/package/busybox/patches/300-netmsg.patch

    r1904 r3295  
    1 diff -Nur busybox-1.4.1.orig/include/applets.h busybox-1.4.1/include/applets.h 
    2 --- busybox-1.4.1.orig/include/applets.h       2007-01-24 22:34:48.000000000 +0100 
    3 +++ busybox-1.4.1/include/applets.h    2007-02-05 13:11:49.000000000 +0100 
    4 @@ -209,6 +209,7 @@ 
     1$FreeWRT$ 
     2--- busybox-1.4.2.orig/include/applets.h       Sun Mar 18 16:59:11 2007 
     3+++ busybox-1.4.2/include/applets.h    Fri Jul 20 11:39:04 2007 
     4@@ -209,6 +209,7 @@ USE_MT(APPLET(mt, _BB_DIR_BIN, _BB_SUID_ 
    55 USE_MV(APPLET(mv, _BB_DIR_BIN, _BB_SUID_NEVER)) 
    66 USE_NAMEIF(APPLET(nameif, _BB_DIR_SBIN, _BB_SUID_NEVER)) 
     
    1010 USE_NICE(APPLET(nice, _BB_DIR_BIN, _BB_SUID_NEVER)) 
    1111 USE_NMETER(APPLET(nmeter, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) 
    12 diff -Nur busybox-1.4.1.orig/networking/Config.in busybox-1.4.1/networking/Config.in 
    13 --- busybox-1.4.1.orig/networking/Config.in     2007-01-24 22:34:34.000000000 +0100 
    14 +++ busybox-1.4.1/networking/Config.in  2007-02-05 13:12:25.000000000 +0100 
    15 @@ -458,7 +458,7 @@ 
    16         help 
    17           A simple Unix utility which reads and writes data across network 
    18           connections. 
    19 
    20 +          
    21  config NC_SERVER 
    22         bool "Netcat server options (-lp)" 
    23         default n 
    24 @@ -475,6 +475,12 @@ 
    25           making or receiving a successful connection), -i (delay interval for 
    26           lines sent), -w (timeout for initial connection). 
    27   
    28 +config NETMSG 
    29 +       bool "netmsg" 
    30 +       default n 
    31 +       help 
    32 +         simple program for sending udp broadcast messages 
    33 
    34  config NETSTAT 
    35         bool "netstat" 
    36         default n 
    37 diff -Nur busybox-1.4.1.orig/networking/Kbuild busybox-1.4.1/networking/Kbuild 
    38 --- busybox-1.4.1.orig/networking/Kbuild        2007-01-24 22:34:34.000000000 +0100 
    39 +++ busybox-1.4.1/networking/Kbuild     2007-02-05 13:11:49.000000000 +0100 
    40 @@ -27,6 +27,7 @@ 
     12--- busybox-1.4.2.orig/networking/Kbuild        Sun Mar 18 16:59:01 2007 
     13+++ busybox-1.4.2/networking/Kbuild     Fri Jul 20 11:39:04 2007 
     14@@ -27,6 +27,7 @@ lib-$(CONFIG_IPRULE)       += iprule.o 
    4115 lib-$(CONFIG_IPTUNNEL)     += iptunnel.o 
    4216 lib-$(CONFIG_NAMEIF)       += nameif.o 
     
    4620 lib-$(CONFIG_NSLOOKUP)     += nslookup.o 
    4721 lib-$(CONFIG_PING)         += ping.o 
    48 diff -Nur busybox-1.4.1.orig/networking/netmsg.c busybox-1.4.1/networking/netmsg.c 
    49 --- busybox-1.4.1.orig/networking/netmsg.c      1970-01-01 01:00:00.000000000 +0100 
    50 +++ busybox-1.4.1/networking/netmsg.c   2007-02-05 13:11:49.000000000 +0100 
    51 @@ -0,0 +1,63 @@ 
     22--- busybox-1.4.2.orig/networking/Config.in     Sun Mar 18 16:59:01 2007 
     23+++ busybox-1.4.2/networking/Config.in  Fri Jul 20 11:39:04 2007 
     24@@ -474,6 +474,12 @@ config NC_EXTRA 
     25          Add -e (support for executing the rest of the command line after 
     26          making or receiving a successful connection), -i (delay interval for 
     27          lines sent), -w (timeout for initial connection). 
     28
     29+config NETMSG 
     30+       bool "netmsg" 
     31+       default n 
     32+       help 
     33+         simple program for sending udp broadcast messages 
     34  
     35 config NETSTAT 
     36        bool "netstat" 
     37--- busybox-1.4.2.orig/networking/netmsg.c      Thu Jan  1 00:00:00 1970 
     38+++ busybox-1.4.2/networking/netmsg.c   Fri Jul 20 11:45:58 2007 
     39@@ -0,0 +1,67 @@ 
    5240+/* 
    5341+ * Copyright (C) 2006 Felix Fietkau <nbd@openwrt.org> 
     42+ * Copyright (c) 2007 Thorsten Glaser <tg@mirbsd.org> 
    5443+ * 
    55 + * This is free software, licensed under the GNU General Public License v2. 
     44+ * This is free software, licenced under the GNU General Public License v2. 
    5645+ */ 
     46+ 
    5747+#include <sys/types.h> 
    5848+#include <sys/socket.h> 
     
    6454+#include "busybox.h" 
    6555+ 
    66 + 
    6756+#ifndef CONFIG_NETMSG 
    6857+int main(int argc, char **argv) 
     
    7160+#endif 
    7261+{ 
    73 +       int s
     62+       int s, optval = -1, rv = 1
    7463+       struct sockaddr_in addr; 
    75 +       int optval = 1; 
    7664+       unsigned char buf[1001]; 
    7765+ 
    7866+       if (argc != 3) { 
    7967+               fprintf(stderr, "usage: %s <ip> \"<message>\"\n", argv[0]); 
    80 +               exit(1); 
     68+               return (1); 
    8169+       } 
    8270+ 
    8371+       if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { 
    8472+               perror("Opening socket"); 
    85 +               exit(1); 
     73+               return (1); 
    8674+       } 
    8775+ 
    88 +       memset(&addr, 0, sizeof(addr)); 
     76+       memset(&addr, 0, sizeof (addr)); 
    8977+       addr.sin_family = AF_INET; 
    9078+       addr.sin_addr.s_addr = inet_addr(argv[1]); 
    9179+       addr.sin_port = htons(0x1337); 
    9280+ 
    93 +       memset(buf, 0, 1001); 
    94 +       buf[0] = 0xde; 
    95 +       buf[1] = 0xad; 
     81+       while (strlen(argv[2]) > 0) { 
     82+               memset(buf, 0, sizeof (buf)); 
    9683+ 
    97 +       strncpy(buf + 2, argv[2], 998); 
     84+               buf[0] = 0xde; 
     85+               buf[1] = 0xad; 
     86+               strlcpy(buf + 2, argv[2], sizeof (buf) - 2); 
     87+               argv[2] += strlen(buf + 2); 
    9888+ 
    99 +       if (setsockopt (s, SOL_SOCKET, SO_BROADCAST, (caddr_t) &optval, sizeof (optval)) < 0) { 
    100 +               perror("setsockopt()"); 
    101 +               goto fail; 
     89+               if (setsockopt(s, SOL_SOCKET, SO_BROADCAST, 
     90+                   (caddr_t)&optval, sizeof (optval)) < 0) { 
     91+                       perror("setsockopt()"); 
     92+                       goto fail; 
     93+               } 
     94
     95+               if (sendto(s, buf, 1001, 0, (struct sockaddr *)&addr, 
     96+                   sizeof (addr)) < 0) { 
     97+                       perror("sendto()"); 
     98+                       goto fail; 
     99+               } 
    102100+       } 
     101+       rv = 0; 
    103102+ 
    104 +       if (sendto(s, buf, 1001, 0, (struct sockaddr *) &addr, sizeof(addr)) < 0) { 
    105 +               perror("sendto()"); 
    106 +               goto fail; 
    107 +       } 
    108 
    109 +       return 0; 
    110 +        
    111 +fail: 
     103+ fail: 
    112104+       close(s); 
    113 +       exit(1); 
     105+       return (rv); 
    114106+} 
  • trunk/freewrt/package/busybox/patches/980-crontab-use-editor.patch

    r2748 r3295  
    1 --- busybox-1.4.2/miscutils/crontab.c.orig      Thu May 24 11:11:37 2007 
    2 +++ busybox-1.4.2/miscutils/crontab.c   Fri May 25 13:44:07 2007 
     1$FreeWRT$ 
     2--- busybox-1.4.2.orig/miscutils/crontab.c      Sun Mar 18 16:59:11 2007 
     3+++ busybox-1.4.2/miscutils/crontab.c   Fri Jul 20 11:39:04 2007 
    34@@ -297,6 +297,8 @@ static void EditFile(const char *user, c 
    45                        exit(0); 
     
    1011  
    1112                snprintf(visual, sizeof(visual), "%s %s", ptr, file); 
    12 --- busybox-1.4.2/networking/netmsg.c.orig      Wed Jun  6 15:28:44 2007 
    13 +++ busybox-1.4.2/networking/netmsg.c   Fri Jun  8 13:12:08 2007 
    14 @@ -34,6 +34,8 @@ int netmsg_main(int argc, char **argv) 
    15                 exit(1); 
    16         } 
    17   
    18 +       while (strlen(argv[2]) > 0) { 
    19 + 
    20         memset(&addr, 0, sizeof(addr)); 
    21         addr.sin_family = AF_INET; 
    22         addr.sin_addr.s_addr = inet_addr(argv[1]); 
    23 @@ -44,6 +46,7 @@ int netmsg_main(int argc, char **argv) 
    24         buf[1] = 0xad; 
    25   
    26         strncpy(buf + 2, argv[2], 998); 
    27 +       argv[2] += strlen(buf + 2); 
    28   
    29         if (setsockopt (s, SOL_SOCKET, SO_BROADCAST, (caddr_t) &optval, sizeof (optval)) < 0) { 
    30                 perror("setsockopt()"); 
    31 @@ -53,6 +56,8 @@ int netmsg_main(int argc, char **argv) 
    32         if (sendto(s, buf, 1001, 0, (struct sockaddr *) &addr, sizeof(addr)) < 0) { 
    33                 perror("sendto()"); 
    34                 goto fail; 
    35 +       } 
    36 + 
    37         } 
    38   
    39         return 0;