Balaji Punnuru | 9 Feb 18:23 2016
Picon

[PATCH V2]networking: Allow dot at the end of the domain name in dhcp response

When a dhcp server responds with a domain name that ends with a ".",
domain name validation is failing which leads to populating domain bad in resolv.conf

Domain name ending with . is a valid syntax according RFC-1034.

The Patch fixes the domain name validation which ends with "."
The test results are as follows:

1. if DNS server returns with domain name "foo.test.com." , resolv.conf gets populated with "domain foo.test.com."

2. if DNS server returns with domain name "foo.test.com" , resolv.conf gets populated with "domain foo.test.com"

Without this Patch:
1. if DNS server returns with domain name "foo.test.com." , resolv.conf gets populated with "domain bad"

2. if DNS server returns with domain name "foo.test.com" , resolv.conf gets populated with "domain foo.test.com"


Details: In Some instances where DNS Servers sends out domain name
         in answer with a terminating ".", the validation logic for
         domain name is returning as bad domain.

         According to RFC 1034 Section 3.1, a character string
         which represents a complete domain name(often called "absolute").
         For example, "poneria.ISI.EDU."

         The fix done is to add a check for end of string after
         processing node which allows for presence of "." at the end of the string

Signed-off-by: Balaji Punnuru <balaji_punnuru <at> cable.comcast.com>
---
 networking/udhcp/dhcpc.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c
index 915f659..3d5b245 100644
--- a/networking/udhcp/dhcpc.c
+++ b/networking/udhcp/dhcpc.c
<at> <at> -201,6 +201,18 <at> <at> static int good_hostname(const char *name)
             //Do we want this?
             //return ((name - start) < 1025); /* NS_MAXDNAME */
         name++;
+                /*
+                   According to RFC 1034, section 3.1, trailing dots is allowed,
+
+                   Quoting from RFC 1034:
+                   ----------------------
+                   The most common interpretation uses the root "." as either the
+                   single origin or as one of the members of the search list, so
+                   a multi-label relative name is often one where the trailing dot
+                   has been omitted to save typing.
+                */
+        if (*name == '\0')
+            return 1;
     }
 }
 #else
--
2.1.4

_______________________________________________
busybox mailing list
busybox <at> busybox.net
http://lists.busybox.net/mailman/listinfo/busybox
Felix Fietkau | 7 Feb 21:13 2016

[PATCH] networking/libiproute: fix displaying route table for rules

r->rtm_table only supports a 8 bit table id, prefer RTA_TABLE if
present.

Signed-off-by: Felix Fietkau <nbd <at> openwrt.org>
---
 networking/libiproute/iprule.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/networking/libiproute/iprule.c b/networking/libiproute/iprule.c
index dba6434..64f4909 100644
--- a/networking/libiproute/iprule.c
+++ b/networking/libiproute/iprule.c
 <at>  <at>  -114,7 +114,9  <at>  <at>  static int FAST_FUNC print_rule(const struct sockaddr_nl *who UNUSED_PARAM,
 		printf("iif %s ", (char*)RTA_DATA(tb[RTA_IIF]));
 	}

-	if (r->rtm_table)
+	if (tb[RTA_TABLE])
+		printf("lookup %s ", rtnl_rttable_n2a(*(uint32_t*)RTA_DATA(tb[RTA_TABLE])));
+	else if (r->rtm_table)
 		printf("lookup %s ", rtnl_rttable_n2a(r->rtm_table));

 	if (tb[RTA_FLOW]) {
--

-- 
2.2.2
Mark O'Donovan | 4 Feb 14:43 2016
Picon

[PATCH 0/2] ntpd: retry name-resolution until success

This is an attempt to fix bug 8131:
  ntpd: should retry on name resolving error

ntpd init now waits for hostname-resolution to succeed instead of quitting.
If there is no network/dns available then the command will not daemonise so
the second patch moves the daemonise code before the peer-adding code.

Mark O'Donovan (2):
  ntpd: retry name-resolution until success
  ntpd: daemonise before adding peers

 networking/ntpd.c | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

--

-- 
1.9.1
Ari Sundholm | 4 Feb 14:03 2016

Re: [PATCH v3] blkdiscard: check that the file is a block device before opening

Hi!

On Mon, 2016-02-01 at 01:59 +0000, Denys Vlasenko wrote:
> I don't understand the problem you are trying to solve.

From the man page of open(2):
"In general, the behavior of O_EXCL is undefined if it is used without
O_CREAT. There is one exception: on Linux 2.6 and later, O_EXCL can be
used without O_CREAT if pathname refers to a block device."

My point is nothing more and nothing less than that opening a file with
O_EXCL without O_CREAT yields undefined behavior unless the file is a
block device. I know that this happens to work in practice with the
current Linux kernel versions, but theoretically future kernel versions
may validly do something entirely different. I am not convinced even the
"don't break userspace" rule would prevent this for cases of explicitly
stated undefined behavior. Or maybe it will, who knows? The key is the
uncertainty.

I'd err on the side of caution, but this is ultimately your call.

Best regards,
Ari Sundholm
ari <at> tuxera.com

> Let's try using blkdiscard on a regular file:
> 
> # strace ./busybox blkdiscard README
> execve("./busybox", ["./busybox", "blkdiscard", "README"], [/* 33 vars */]) = 0
> ioctl(0, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or
> TCGETS, {B38400 opost isig icanon echo ...}) = 0
> ioctl(1, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or
> TCGETS, {B38400 opost isig icanon echo ...}) = 0
> getuid32()                              = 0
> open("README", O_RDWR|O_EXCL|O_LARGEFILE) = 3
> ioctl(3, BLKGETSIZE64, 0xffcc5af0)      = -1 ENOTTY (Inappropriate
> ioctl for device)
> brk(0)                                  = 0x8129000
> brk(0x812a000)                          = 0x812a000
> write(2, "blkdiscard: ioctl 0x80041272 fai"..., 68blkdiscard: ioctl
> 0x80041272 failed: Inappropriate ioctl for device
> ) = 68
> _exit(1)                                = ?
> +++ exited with 1 +++
> 
> So, open(O_RDWR|O_EXCL) did work in practice, by ignoring O_EXCL.
Balaji Punnuru | 3 Feb 21:40 2016
Picon

[PATCH]networking: Allow dot at the end of the domain name in dhcp response

When a dhcp server responds with a domain name that ends with a ".",
domain name validation is failing which leads to populating domain bad in resolv.conf

Domain name ending with . is a valid syntax according RFC-1034.

The Patch fixes the domain name validation which ends with "."
The test results are as follows:

1. if DNS server returns with domain name "foo.test.com." , resolv.conf gets populated with "domain foo.test.com."

2. if DNS server returns with domain name "foo.test.com" , resolv.conf gets populated with "domain foo.test.com"

Without this Patch:
1. if DNS server returns with domain name "foo.test.com." , resolv.conf gets populated with "domain bad"

2. if DNS server returns with domain name "foo.test.com" , resolv.conf gets populated with "domain foo.test.com"

_______________________________________________
busybox mailing list
busybox <at> busybox.net
http://lists.busybox.net/mailman/listinfo/busybox
Nicolas CARRIER | 1 Feb 18:00 2016
Picon

[PATCH] init: allow to preserve init's command-line

When launched as PID 1 and after parsing it's arguments, init wipes all
all of them except argv[0] and rewrites argv[0] to contain only "init",
so that it's command-line appears solely as "init" in tools such as ps.

This patch adds the FEATURE_PRESERVE_CMDLINE which, if set to Y, will make
init preserve all it's arguments including argv[0], be they parsed or
ignored.
The original command-line used to launch init can then be retrieved in
/proc/1/cmdline on Linux, for example.

_______________________________________________
busybox mailing list
busybox <at> busybox.net
http://lists.busybox.net/mailman/listinfo/busybox
Nicolas CARRIER | 1 Feb 08:09 2016
Picon

Fwd: why are init's arguments wiped ?

I wrote a little patch which adds the option not to wipe the arguments, but the result is a little bit odd, some 0 are inserted between "init" and the rest of the arguments. I must be because "/bin/init" is replaced with "init".
So the proper patch should either :
 * inhibit this argv[0] modification too
 * perform a memmove to wipe those extra zeros

Which one do you think is best ?

<at> isaac: sorry for the double mail

2016-02-01 7:56 GMT+01:00 Isaac Dunham <ibid.ag <at> gmail.com>:
On Mon, Feb 01, 2016 at 12:21:00AM -0500, Mike Frysinger wrote:
> On 29 Jan 2016 21:10, Laurent Bercot wrote:
> > On 29/01/2016 17:50, Nicolas CARRIER wrote:
> > > I quite agree with dietmar, concerning uglyness...
> >
> >   <shrug> That doesn't change the fact that it's the behaviour of every
> > init binary since 1970 and that you should come with a better reason if
> > you want to change it, especially since it's so easy to accomplish what
> > you want with a little workaround.
>
> not really.  his proposal makes busybox smaller.  the only reason given
> for making busybox larger is "it makes `ps` 'nicer'".  if there's no real
> technical reason for it and nothing is impacted, then shrinking busybox
> is a no brainer.  at the very least, it makes sense to make it a config
> option that defaults to off.
>
> this was first changed here, but not really documented:
> https://git.busybox.net/busybox/commit/?id=e132f4b09e5c9aedaef97f65279e8702633fd425

Looking near that commit, I see that it moved the code in question, but
it seems the origin was instead this commit:

commit 3163821967821518cfa4c4315f775ec5301bb023
Author: Erik Andersen <andersen <at> codepoet.org>
Date:   Sat Jan 15 22:28:50 2000 +0000

    Sync up busybox with the latest and greatest.  This is not stuff for
    the Embedix release.
     -Erik

Nothing indicates what the reason was. Looking at that commit, it seems
that some of it was from Debian-related work, but debian.org has nada.

HTH,
Isaac Dunham

_______________________________________________
busybox mailing list
busybox <at> busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


_______________________________________________
busybox mailing list
busybox <at> busybox.net
http://lists.busybox.net/mailman/listinfo/busybox
Kylie McClain | 31 Jan 07:02 2016
Picon
Gravatar

[PATCH] Fix compiling with musl's utmp stubs

From 4d76d9b69503b1ad61cf857d83cb8c4d5d92465b Mon Sep 17 00:00:00 2001
From: Kylie McClain <somasis <at> exherbo.org>
Date: Sat, 30 Jan 2016 23:00:18 -0500
Subject: [PATCH] Fix compiling with musl's utmp stubs

This patch fixes compiling busybox with FEATURE_UTMP and _WTMP enabled.
musl, while not really support utmp/wtmp, provides stub functions, as well
as variables such as _PATH_UTMP, so that programs using utmp or wtmp can
still compile fine.

My reasoning for this patch is that on Exherbo, I'm currently trying to get
us to be able to use the same busybox config file for both glibc and musl
systems, using utmp/wtmp on systems that support it, and using the stubs
on musl without needing two different configs.

As of latest musl git, it provides all utmp functions needed; 1.1.12 doesn't,
but I sent a patch to Rich to add the utmp{,x}name functions expected to
exist, which was merged into musl upstream.
---
 include/libbb.h | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/include/libbb.h b/include/libbb.h
index a8ceb44..c1516a9 100644
--- a/include/libbb.h
+++ b/include/libbb.h
 <at>  <at>  -20,6 +20,7  <at>  <at> 
 #include <netdb.h>
 #include <setjmp.h>
 #include <signal.h>
+#include <paths.h>
 #if defined __UCLIBC__ /* TODO: and glibc? */
 /* use inlined versions of these: */
 # define sigfillset(s)    __sigfillset(s)
 <at>  <at>  -106,7 +107,11  <at>  <at> 
 #  define updwtmpx updwtmp
 #  define _PATH_UTMPX _PATH_UTMP
 # else
+#  include <utmp.h>
 #  include <utmpx.h>
+#  if defined _PATH_UTMP && !defined _PATH_UTMPX
+#   define _PATH_UTMPX _PATH_UTMP
+#  endif
 # endif
 #endif
 #if ENABLE_LOCALE_SUPPORT
--

-- 
2.7.0
Tim Tassonis | 31 Jan 00:15 2016
Picon

Implement "dG" in vi

Hi all

Being generally totally overwhelmed by the features of busybox, I was 
wondering if it would be possible to implement the feature in vi to 
delete everything from current line to buttom, e.g. the command

dG

Kind regards
Tim
Nicolas CARRIER | 28 Jan 18:02 2016
Picon

why are init's arguments wiped ?

Hello,
in init/init.c, l. 1144, there is the following code :

/* Wipe argv[1]-argv[N] so they don't clutter the ps listing */
while (*++argv)
         nuke_str(*argv);

Why are init's arguments wipe ?
I had the hope to pass init some arguments, then read them by looking into /proc/1/cmdline, but no luck...

Do anyone think it could be possible to remove these lines, at least with a config option ?

Thank you.
_______________________________________________
busybox mailing list
busybox <at> busybox.net
http://lists.busybox.net/mailman/listinfo/busybox
Rafał Miłecki | 28 Jan 15:26 2016
Picon

[PATCH] dd: support iflag=skip_bytes

It allows specifying amount of bytes directly (not only amount of
blocks) is also supported by GNU's Coreutils.

Signed-off-by: Rafał Miłecki <zajec5 <at> gmail.com>
---
 coreutils/dd.c             | 65 ++++++++++++++++++++++++++++++++++++++--------
 docs/posix_conformance.txt |  1 +
 2 files changed, 55 insertions(+), 11 deletions(-)

diff --git a/coreutils/dd.c b/coreutils/dd.c
index 6a5288d..de58cb3 100644
--- a/coreutils/dd.c
+++ b/coreutils/dd.c
 <at>  <at>  -55,7 +55,7  <at>  <at> 

 //usage:#define dd_trivial_usage
 //usage:       "[if=FILE] [of=FILE] " IF_FEATURE_DD_IBS_OBS("[ibs=N] [obs=N] ") "[bs=N] [count=N] [skip=N]\n"
-//usage:       "	[seek=N]" IF_FEATURE_DD_IBS_OBS(" [conv=notrunc|noerror|sync|fsync]")
+//usage:       "	[seek=N]" IF_FEATURE_DD_IBS_OBS(" [conv=notrunc|noerror|sync|fsync] [iflag=skip_bytes]")
 //usage:#define dd_full_usage "\n\n"
 //usage:       "Copy a file with converting and formatting\n"
 //usage:     "\n	if=FILE		Read from FILE instead of stdin"
 <at>  <at>  -76,6 +76,7  <at>  <at> 
 //usage:     "\n	conv=sync	Pad blocks with zeros"
 //usage:     "\n	conv=fsync	Physically write data out before finishing"
 //usage:     "\n	conv=swab	Swap every pair of bytes"
+//usage:     "\n	iflag=skip_bytes	Treat skip=N value as amount of bytes"
 //usage:	)
 //usage:	IF_FEATURE_DD_STATUS(
 //usage:     "\n	status=noxfer	Suppress rate output"
 <at>  <at>  -122,11 +123,15  <at>  <at>  enum {
 	FLAG_FSYNC   = (1 << 3) * ENABLE_FEATURE_DD_IBS_OBS,
 	FLAG_SWAB    = (1 << 4) * ENABLE_FEATURE_DD_IBS_OBS,
 	/* end of conv flags */
-	FLAG_TWOBUFS = (1 << 5) * ENABLE_FEATURE_DD_IBS_OBS,
-	FLAG_COUNT   = 1 << 6,
-	FLAG_STATUS  = 1 << 7,
-	FLAG_STATUS_NONE = 1 << 7,
-	FLAG_STATUS_NOXFER = 1 << 8,
+	/* start of input flags */
+	FLAG_IFLAG_FIRST = 5,
+	FLAG_SKIP_BYTES = (1 << 5) * ENABLE_FEATURE_DD_IBS_OBS,
+	/* end of input flags */
+	FLAG_TWOBUFS = (1 << 6) * ENABLE_FEATURE_DD_IBS_OBS,
+	FLAG_COUNT   = 1 << 7,
+	FLAG_STATUS  = 1 << 8,
+	FLAG_STATUS_NONE = 1 << 9,
+	FLAG_STATUS_NOXFER = 1 << 10,
 };

 static void dd_output_status(int UNUSED_PARAM cur_signal)
 <at>  <at>  -209,12 +214,14  <at>  <at>  int dd_main(int argc UNUSED_PARAM, char **argv)
 	static const char keywords[] ALIGN1 =
 		"bs\0""count\0""seek\0""skip\0""if\0""of\0"IF_FEATURE_DD_STATUS("status\0")
 #if ENABLE_FEATURE_DD_IBS_OBS
-		"ibs\0""obs\0""conv\0"
+		"ibs\0""obs\0""conv\0""iflag\0"
 #endif
 		;
 #if ENABLE_FEATURE_DD_IBS_OBS
 	static const char conv_words[] ALIGN1 =
 		"notrunc\0""sync\0""noerror\0""fsync\0""swab\0";
+	static const char iflag_words[] ALIGN1 =
+		"skip_bytes\0";
 #endif
 #if ENABLE_FEATURE_DD_STATUS
 	static const char status_words[] ALIGN1 =
 <at>  <at>  -232,6 +239,7  <at>  <at>  int dd_main(int argc UNUSED_PARAM, char **argv)
 		OP_ibs,
 		OP_obs,
 		OP_conv,
+		OP_iflag,
 		/* Must be in the same order as FLAG_XXX! */
 		OP_conv_notrunc = 0,
 		OP_conv_sync,
 <at>  <at>  -251,6 +259,7  <at>  <at>  int dd_main(int argc UNUSED_PARAM, char **argv)
 	//ibm           from ASCII to alternate EBCDIC
 	/* Partially implemented: */
 	//swab          swap every pair of input bytes: will abort on non-even reads
+		OP_iflag_skip_bytes,
 #endif
 	};
 	smallint exitcode = EXIT_FAILURE;
 <at>  <at>  -335,6 +344,27  <at>  <at>  int dd_main(int argc UNUSED_PARAM, char **argv)
 			}
 			/*continue;*/
 		}
+		if (what == OP_iflag) {
+			while (1) {
+				int n;
+				/* find ',', replace them with NUL so we can use val for
+				 * index_in_strings() without copying.
+				 * We rely on val being non-null, else strchr would fault.
+				 */
+				arg = strchr(val, ',');
+				if (arg)
+					*arg = '\0';
+				n = index_in_strings(iflag_words, val);
+				if (n < 0)
+					bb_error_msg_and_die(bb_msg_invalid_arg_to, val, "iflag");
+				G.flags |= (1 << (FLAG_IFLAG_FIRST + n));
+				if (!arg) /* no ',' left, so this was the last specifier */
+					break;
+				/* *arg = ','; - to preserve ps listing? */
+				val = arg + 1; /* skip this keyword and ',' */
+			}
+			/*continue;*/
+		}
 #endif
 		if (what == OP_bs) {
 			ibs = xatoul_range_sfx(val, 1, ((size_t)-1L)/2, cwbkMG_suffixes);
 <at>  <at>  -421,14 +451,27  <at>  <at>  int dd_main(int argc UNUSED_PARAM, char **argv)
 		outfile = bb_msg_standard_output;
 	}
 	if (skip) {
-		if (lseek(ifd, skip * ibs, SEEK_CUR) < 0) {
-			do {
-				ssize_t n = safe_read(ifd, ibuf, ibs);
+		bool skip_bytes = G.flags & FLAG_SKIP_BYTES;
+		size_t bytes = skip * (skip_bytes ? 1 : ibs);
+		ssize_t sought;
+
+		sought = lseek(ifd, bytes, SEEK_CUR);
+		if (sought > 0)
+			bytes -= sought;
+		if (sought < 0 || skip_bytes) {
+			while (bytes) {
+				size_t min = (skip_bytes && bytes < ibs) ? bytes : ibs;
+				ssize_t n = safe_read(ifd, ibuf, min);
 				if (n < 0)
 					goto die_infile;
 				if (n == 0)
 					break;
-			} while (--skip != 0);
+				if (skip_bytes) {
+					bytes -= n;
+				} else {
+					bytes -= ibs;
+				}
+			}
 		}
 	}
 	if (seek) {
diff --git a/docs/posix_conformance.txt b/docs/posix_conformance.txt
index 5b616d7..c0582dc 100644
--- a/docs/posix_conformance.txt
+++ b/docs/posix_conformance.txt
 <at>  <at>  -178,6 +178,7  <at>  <at>  dd POSIX options:
   conv=noerror    |  yes   |           |
   conv=notrunc    |  yes   |           |
   conv=sync       |  yes   |           |
+  iflag=skip_bytes|  yes   |           |
 dd Busybox specific options:
  conv=fsync

--

-- 
1.8.4.5

_______________________________________________
busybox mailing list
busybox <at> busybox.net
http://lists.busybox.net/mailman/listinfo/busybox

Gmane