Re: [PATCH] util-linux/lsusb.c: print manufacturer/product strings if available

2023-12-17 Thread Peter Korsgaard
>>>>> "rep" == rep dot nop  writes:

 > On 14 December 2023 08:22:36 CET, Peter Korsgaard  
 > wrote:
 >>>>>>> "Aleksander" == Aleksander Mazur  writes:
 >> 
 >> > Hi,
 >> > AFAIR similar problem applies to util-linux/lspci.c.
 >> > Do you build busybox with shell enabled?
 >> > Instead of busybox's lspci/lsusb I use 2 quite simple shell scripts 
 >> > (working in hush).
 >> 
 >> Yes, lsusb/lspci are really simple applets, but given that they already
 >> exist we might as well make them more useful.
 >> 

 > Is it worth the wattage, though?
 > https://m.youtube.com/watch?v=SmZVhImx1pY

 > Maybe it is (not, so far)?

Well, not up to me to decide. My (obviously not objective) opinion is
that it is. It is a fairly big improvement for usability, and as the
bloat-o-meter output shows, it adds less than 400 bytes - Where
approximately half of those are libbb functions shared with other
applets.

-- 
Bye, Peter Korsgaard
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: [PATCH] util-linux/lsusb.c: print manufacturer/product strings if available

2023-12-13 Thread Peter Korsgaard
>>>>> "Aleksander" == Aleksander Mazur  writes:

 > Hi,
 > AFAIR similar problem applies to util-linux/lspci.c.
 > Do you build busybox with shell enabled?
 > Instead of busybox's lspci/lsusb I use 2 quite simple shell scripts (working 
 > in hush).

Yes, lsusb/lspci are really simple applets, but given that they already
exist we might as well make them more useful.

-- 
Bye, Peter Korsgaard
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


[PATCH] util-linux/lsusb.c: print manufacturer/product strings if available

2023-12-13 Thread Peter Korsgaard
Just listing the vendor/product IDs is not always very helpful, so add logic
to print the manufacturer and product strings similar to the "big" usbutils
versions.

Not all devices provide sensible strings though.  The usbutils version works
around this by falling back to looking up the vendor/product IDs in the hwdb
and using those strings instead, which is not an option here - Instead
simply trim() the strings for readability.

lsusb | sort
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 002: ID 0bda:5539 Realtek Semiconductor Corp. 
Integrated_Webcam_HD
Bus 001 Device 003: ID 0a5c:5842 Broadcom Corp. 58200
Bus 001 Device 030: ID 8087:0aaa Intel Corp. Bluetooth 9460/9560 Jefferson Peak 
(JfP)
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 005 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 006 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 006 Device 002: ID 0bda:5487 Realtek Semiconductor Corp. Dell dock
Bus 006 Device 003: ID 0bda:5413 Realtek Semiconductor Corp. Dell dock
Bus 006 Device 004: ID 413c:b06e Dell Computer Corp. Dell dock
Bus 006 Device 005: ID 0451:8142 Texas Instruments, Inc. TUSB8041 4-Port Hub
Bus 006 Device 006: ID 0bda:402e Realtek Semiconductor Corp. USB Audio
Bus 006 Device 007: ID 413c:1010 Dell Computer Corp. USB 2.0 Hub [MTT]
Bus 006 Device 008: ID 413c:b06f Dell Computer Corp. Dell dock
Bus 006 Device 009: ID 046d:c016 Logitech, Inc. Optical Wheel Mouse
Bus 006 Device 010: ID 413c:2110 Dell Computer Corp. Dell Wired Multimedia 
Keyboard
Bus 006 Device 011: ID 0451:8142 Texas Instruments, Inc. TUSB8041 4-Port Hub
Bus 006 Device 012: ID 0451:3410 Texas Instruments, Inc. TUSB3410 
Microcontroller
Bus 007 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 007 Device 002: ID 0bda:0487 Realtek Semiconductor Corp. Dell dock
Bus 007 Device 003: ID 0bda:0413 Realtek Semiconductor Corp. Dell dock
Bus 007 Device 004: ID 0bda:8153 Realtek Semiconductor Corp. RTL8153 Gigabit 
Ethernet Adapter

./busybox lsusb | sort
Bus 001 Device 001: ID 1d6b:0002 Linux 6.1.0-13-amd64 xhci-hcd xHCI Host 
Controller
Bus 001 Device 002: ID 0bda:5539 CNFHH53Q0324300ACA10 Integrated_Webcam_HD
Bus 001 Device 003: ID 0a5c:5842 Broadcom Corp 58200
Bus 001 Device 030: ID 8087:0aaa
Bus 002 Device 001: ID 1d6b:0003 Linux 6.1.0-13-amd64 xhci-hcd xHCI Host 
Controller
Bus 003 Device 001: ID 1d6b:0002 Linux 6.1.0-13-amd64 xhci-hcd xHCI Host 
Controller
Bus 004 Device 001: ID 1d6b:0003 Linux 6.1.0-13-amd64 xhci-hcd xHCI Host 
Controller
Bus 005 Device 001: ID 1d6b:0002 Linux 6.1.0-13-amd64 dummy_hcd Dummy host 
controller
Bus 006 Device 001: ID 1d6b:0002 Linux 6.1.0-13-amd64 xhci-hcd xHCI Host 
Controller
Bus 006 Device 002: ID 0bda:5487 Dell Inc. Dell dock
Bus 006 Device 003: ID 0bda:5413 Dell Inc. Dell dock
Bus 006 Device 004: ID 413c:b06e Dell dock
Bus 006 Device 005: ID 0451:8142
Bus 006 Device 006: ID 0bda:402e Generic USB Audio
Bus 006 Device 007: ID 413c:1010 USB 2.0 Hub [MTT]
Bus 006 Device 008: ID 413c:b06f Dell dock
Bus 006 Device 009: ID 046d:c016 Logitech Optical USB Mouse
Bus 006 Device 010: ID 413c:2110 Dell Dell Wired Multimedia Keyboard
Bus 006 Device 011: ID 0451:8142
Bus 006 Device 012: ID 0451:3410 Texas Instruments TUSB3410 Boot Device
Bus 007 Device 001: ID 1d6b:0003 Linux 6.1.0-13-amd64 xhci-hcd xHCI Host 
Controller
Bus 007 Device 002: ID 0bda:0487 Dell Inc. Dell dock
Bus 007 Device 003: ID 0bda:0413 Dell Inc. Dell dock
Bus 007 Device 004: ID 0bda:8153 Realtek USB 10/100/1000 LAN

./scripts/bloat-o-meter busybox_unstripped{_orig,}
function old new   delta
trim   - 101+101
fileAction   338 431 +93
add_sysfs_prop -  70 +70
open_read_close-  54 +54
read_close -  35 +35
.rodata 32683294 +26
--
(add/remove: 5/0 grow/shrink: 2/0 up/down: 379/0) Total: 379 bytes

Signed-off-by: Peter Korsgaard 
---
 util-linux/lsusb.c | 28 +++-
 1 file changed, 27 insertions(+), 1 deletion(-)

diff --git a/util-linux/lsusb.c b/util-linux/lsusb.c
index 262c70a1b..0a9e505f4 100644
--- a/util-linux/lsusb.c
+++ b/util-linux/lsusb.c
@@ -24,6 +24,24 @@
 
 #include "libbb.h"
 
+static char * FAST_FUNC add_sysfs_prop(const char *dir, const char *suffix,
+   char *buf, size_t size)
+{
+   char *filename;
+   ssize_t len;
+
+   filename = concat_path_file(dir, suffix);
+   len = open_read_close(filename, buf, size - 1);
+

Re: -o option for start-stop-daemon

2023-11-07 Thread Peter Korsgaard
>>>>> "Denys" == Denys Vlasenko  writes:

 > Applied with some edits, please test current git.

Looks sensible from a quick look. Notice that you added a s/PILE/FILE/
typo:

+//usage: "\n-O PILE Append stdout and stderr to FILE"

-- 
Bye, Peter Korsgaard
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: -o option for start-stop-daemon

2023-11-04 Thread Peter Korsgaard
>>>>> "Louai" == Louai Al-Khanji  writes:

 > On Wed, Nov 1, 2023 at 11:53 PM Louai Al-Khanji  wrote:
 >> 
 >> Hi,
 >> 
 >> I am interested in implementing the -o|--output option that the

NIT: It is -O, not -o.

 > +#if ENABLE_FEATURE_START_STOP_DAEMON_FANCY
 > +if (opt & OPT_OUTPUT) {
 > +int output_fd = xopen(output, O_CREAT | O_WRONLY);
 > +original_stdout = xdup(STDOUT_FILENO);
 > +original_stderr = xdup(STDERR_FILENO);
 > +xdup2(output_fd, STDOUT_FILENO);
 > +xdup2(output_fd, STDERR_FILENO);
 > +}

-O is documented to only work with the -b, so wouldn't it make more
sense to add this logic around bb_daemon_helper() instead, then you also
don't have to clean it up again?

-- 
Bye, Peter Korsgaard
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: Update Copyright 2023

2023-01-30 Thread Peter Korsgaard
>>>>> "Fred" == Fred Friedrich  writes:

 > Hello,
 > it seems like the copyright was not updated for a long time
 > :-). Consider this small fix for it:

Alternatively we could consider dropping the explicit copyright years
like we recently did in Buildroot:

https://gitlab.com/buildroot.org/buildroot/-/commit/f1d7155952d9abcad4d5d75b56508114469c2a1c

-- 
Bye, Peter Korsgaard
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: The busybox website is unbearably slow

2023-01-18 Thread Peter Korsgaard
>>>>> "Michael" == Michael D Setzer  writes:

 > Don't know if this has any info. I had downloaded whole 
 > site with wget2 the other day, and that seemed to have 
 > no problem, but was seein occassional timeouts just 
 > going to page. 

 > Do note that isitdown is now showing site as up, but 
 > another isitup.org is showing it as down?

 > Also, find that traceroute busybox.net doesn't reach site, 
 > but traceroute -I busybox.net does?

 > Redid download of https://busybox.net/index.html to see 
 > what it shows with the -dv option. It doesn't seem to 
 > show and error, but seems there are some lines that 
 > show if isn't finding what it wants.

Please don't load the web server any more than it already is. The old VM
/ low memory / CGI scripts for cgit / bugzilla limits the amount of
concurrent requests it can handle.

Apache is running, but it sometimes ends up running out of workers:

[mpm_worker:error] [pid 21136:tid 3080316736] AH00286: server reached
MaxRequestWorkers setting, consider raising the MaxRequestWorkers
setting

Raising MaxRequestWorkers has to be done carefully as otherwise the
machine OOM's under load.

-- 
Bye, Peter Korsgaard
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: The busybox website is unbearably slow

2023-01-18 Thread Peter Korsgaard
>>>>> "Maxim" == Maxim Kochetkov  writes:

 > On 18.01.2023 22:51, Xabier Oneca -- xOneca wrote:
 >> Thank you Peter, but still not improved... :/
 >> Trying HTTP is veeery laggy, and HTTPS just hangs on TLS
 >> handshake...
 >> $ curl --verbose https://busybox.net/ <https://busybox.net/>
 >> *   Trying 140.211.167.122:443...
 >> * Connected to busybox.net <http://busybox.net> (140.211.167.122)
 >> port 443 (#0)
 >> * ALPN: offers h2
 >> * ALPN: offers http/1.1
 >> * TLSv1.3 (OUT), TLS handshake, Client hello (1):
 >> 
 > The same for buildroot:

 > $ curl --verbose https://git.buildroot.net/
 > *   Trying 140.211.167.122:443...
 > curl --verbose https://busybox.net/
 > *   Trying 140.211.167.122:443...

Yes, it is the same machine.

-- 
Bye, Peter Korsgaard
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: The busybox website is unbearably slow

2023-01-18 Thread Peter Korsgaard
>>>>> "Xabier" == Xabier Oneca <--  xOneca > writes:

Hi,

 > Yes, I see the same in git.busybox.net since a while back. I thought it was
 > my browser's fault (because it sticks in "performing TLS handshake"), but
 > now tried with wget and it connects and waits too.

I've restarted Apache on the VM, which seems to have improved things
somewhat.

-- 
Bye, Peter Korsgaard
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: buildroot host builds with g++

2022-05-06 Thread Peter Korsgaard
>>>>> "Earthquake" == Earthquake   writes:

 > Hi,
 > building package for the host, ends with:
 > g++: error: /usr/bin/g++": No such file or directory

 > Building the same package for the target works

 > Package mk for host build calls generic-package and host-generic-package.

This sounds like a Buildroot question rather than a Busybox one, so
please followup on the Buildroot list (buildr...@buildroot.org).

With that said, if your package is written in C++ and you try to build
it for the host, then you need a C++ compiler on your host, but please
provide some more details about what exactly you are trying to do.

-- 
Bye, Peter Korsgaard
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: [PATCH] libarchive/get_header_ar.c: fix extraction of archives from binutils in deterministic mode

2021-12-10 Thread Peter Korsgaard
>>>>> "Peter" == Peter Korsgaard  writes:

 > GNU binutils in deterministic mode (ar rD or built with
 > --enable-deterministic-archives) hard codes file mode to 0644 (NOT 0100644)
 > since https://github.com/bminor/binutils-gdb/commit/36e4dce69dd2

 > This confuses busybox ar x (data_extract_all):

 > touch a; ar rD a.ar a
 > ar: creating a.ar

 > busybox ar x a.ar
 > ar: unrecognized file type
 > hexdump -C a.ar
 >   21 3c 61 72 63 68 3e 0a  61 2f 20 20 20 20 20 20  |!.a/  
 > |
 > 0010  20 20 20 20 20 20 20 20  30 20 20 20 20 20 20 20  |0   
 > |
 > 0020  20 20 20 20 30 20 20 20  20 20 30 20 20 20 20 20  |0 0 
 > |
 > 0030  36 34 34 20 20 20 20 20  30 20 20 20 20 20 20 20  |644 0   
 > |
 > 0040  20 20 60 0a   |  `.|

 > As a workaround, force the mode bits to S_IFREG, as nothing else makes sense
 > for ar.

Ping?

 > Signed-off-by: Peter Korsgaard 
 > ---
 >  archival/libarchive/get_header_ar.c | 6 +-
 >  1 file changed, 5 insertions(+), 1 deletion(-)

 > diff --git a/archival/libarchive/get_header_ar.c 
 > b/archival/libarchive/get_header_ar.c
 > index 3a19d6ff7..6bd897392 100644
 > --- a/archival/libarchive/get_header_ar.c
 > +++ b/archival/libarchive/get_header_ar.c
 > @@ -92,8 +92,12 @@ char FAST_FUNC get_header_ar(archive_handle_t 
 > *archive_handle)
 >  /* Only size is always present, the rest may be missing in
 >   * long filename pseudo file. Thus we decode the rest
 >   * after dealing with long filename pseudo file.
 > + *
 > + * GNU binutils in deterministic mode hard codes mode to 0644 (NOT
 > + * 0100644). AR archives can only contain files, so force file
 > + * mode.
 >   */
 > -typed->mode = read_num(ar.formatted.mode, 8, sizeof(ar.formatted.mode));
 > +typed->mode = read_num(ar.formatted.mode, 8, sizeof(ar.formatted.mode)) 
 > | S_IFREG;
 >  typed-> gid = read_num(ar.formatted.gid, 10, sizeof(ar.formatted.gid));
 >  typed-> uid = read_num(ar.formatted.uid, 10, sizeof(ar.formatted.uid));
 >  typed-> mtime = read_num(ar.formatted.date, 10, 
 > sizeof(ar.formatted.date));
 > -- 
 > 2.20.1

-- 
Bye, Peter Korsgaard
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


[PATCH] libarchive/get_header_ar.c: fix extraction of archives from binutils in deterministic mode

2021-11-26 Thread Peter Korsgaard
GNU binutils in deterministic mode (ar rD or built with
--enable-deterministic-archives) hard codes file mode to 0644 (NOT 0100644)
since https://github.com/bminor/binutils-gdb/commit/36e4dce69dd2

This confuses busybox ar x (data_extract_all):

touch a; ar rD a.ar a
ar: creating a.ar

busybox ar x a.ar
ar: unrecognized file type
hexdump -C a.ar
  21 3c 61 72 63 68 3e 0a  61 2f 20 20 20 20 20 20  |!.a/  |
0010  20 20 20 20 20 20 20 20  30 20 20 20 20 20 20 20  |0   |
0020  20 20 20 20 30 20 20 20  20 20 30 20 20 20 20 20  |0 0 |
0030  36 34 34 20 20 20 20 20  30 20 20 20 20 20 20 20  |644 0   |
0040  20 20 60 0a   |  `.|

As a workaround, force the mode bits to S_IFREG, as nothing else makes sense
for ar.

Signed-off-by: Peter Korsgaard 
---
 archival/libarchive/get_header_ar.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/archival/libarchive/get_header_ar.c 
b/archival/libarchive/get_header_ar.c
index 3a19d6ff7..6bd897392 100644
--- a/archival/libarchive/get_header_ar.c
+++ b/archival/libarchive/get_header_ar.c
@@ -92,8 +92,12 @@ char FAST_FUNC get_header_ar(archive_handle_t 
*archive_handle)
/* Only size is always present, the rest may be missing in
 * long filename pseudo file. Thus we decode the rest
 * after dealing with long filename pseudo file.
+*
+* GNU binutils in deterministic mode hard codes mode to 0644 (NOT
+* 0100644). AR archives can only contain files, so force file
+* mode.
 */
-   typed->mode = read_num(ar.formatted.mode, 8, sizeof(ar.formatted.mode));
+   typed->mode = read_num(ar.formatted.mode, 8, sizeof(ar.formatted.mode)) 
| S_IFREG;
typed->gid = read_num(ar.formatted.gid, 10, sizeof(ar.formatted.gid));
typed->uid = read_num(ar.formatted.uid, 10, sizeof(ar.formatted.uid));
typed->mtime = read_num(ar.formatted.date, 10, 
sizeof(ar.formatted.date));
-- 
2.20.1

___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: CVE-2021-28831

2021-04-28 Thread Peter Korsgaard
>>>>> "Mousaw," == Mousaw, Tim  writes:

 > Thanks for the quick replies.
 > So, once this was merged, did the 1.32.1 image tag of the BusyBox
 > docker image get rebuilt with it? From what I can tell, this is the
 > image tag that gets pulled when the "latest" tag is used.

Sorry, I have no idea who owns/builds that docker image, but given that
this was added after 1.32.1 was tagged, I would NOT expect it to be
included in a 1.32.1 build:

https://git.buildroot.org/busybox/log/?h=1_32_stable

-- 
Bye, Peter Korsgaard
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: CVE-2021-28831

2021-04-28 Thread Peter Korsgaard
>>>>> "Christophe" == Christophe Leroy  writes:

Hi,

 > As far as I can see, that commit is in 1_32_stable

 > See https://git.busybox.net/busybox/commit/?h=1_32_stable

But strangely enough not in 1_33_stable.

-- 
Bye, Peter Korsgaard
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: git smart http for busybox repo

2020-05-15 Thread Peter Korsgaard
>>>>> "Bernhard" == Bernhard Reutner-Fischer  writes:

 > On Mon, 13 Apr 2020 at 16:43, Yannik Sembritzki  wrote:
 >> 
 >> Hi,
 >> 
 >> currently, the busybox git server is only providing "dumb http"
 >> functionality.
 >> This is, for example, demonstrated when trying to make shallow clone:
 >> 
 >> $ git clone --depth=1 https://git.busybox.net/busybox/
 >> Cloning into 'busybox'...
 >> fatal: dumb http transport does not support shallow capabilities

 > please retry.

Hmm, did something change afterwards? I just got a report about issues
accessing the Buildroot repo over https, and it indeed doesn't seem to
work:

git clone https://git.busybox.net/busybox/
Cloning into 'busybox'...
fatal: unable to access 'https://git.busybox.net/busybox/': The requested URL 
returned error: 403

Running that with GIT_CURL_VERBOSE=1 I see the 403 comes from here:

GET /busybox/info/refs?service=git-upload-pack HTTP/1.1
Host: git.busybox.net
User-Agent: git/2.20.1
Accept: */*
Accept-Encoding: deflate, gzip
Accept-Language: en-US, en;q=0.9, *;q=0.8
Pragma: no-cache

< HTTP/1.1 403 Forbidden
< Date: Fri, 15 May 2020 21:54:11 GMT
< Server: Apache
< Strict-Transport-Security: max-age=63072000; includeSubDomains
< Content-Length: 292
< Content-Type: text/html; charset=iso-8859-1

Any ideas?

-- 
Bye, Peter Korsgaard
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: Regarding [PATCH] sysklogd: add -Z option to adjust message timezones

2020-02-04 Thread Peter Korsgaard
>>>>> "Venkat" == Venkat K  writes:

 > Hi Busybox team,
 > I was using busybox version 1.15.2. One of my requirement  is I need a
 > timestamp in syslog message as localtime zone instead of GMT. I found below
 > patch link to adjust the timezones.
 > http://lists.busybox.net/pipermail/busybox/2017-May/085437.html .

 >> * + if (G.adjustTimezone && strptime(msg, "%b %e %T", )) {
 > *>* +now = mktime() - timezone;
 > *>* +timestamp = ctime() + 4; /* skip day of 
 > week */
 > *>* +} else {
 > *>* +now = 0;
 > *>* +timestamp = msg;
 > *>* +}*


 > But i didn't get where *timezone *is defined and what it is contained, Can
 > you help us where it is defined and what it is contained.

I don't know about that patch (which hasn't been merged), but you can
run syslogd with the -t option to get it to re-timestamp syslog messages
with the timestamp using whatever timezone syslogd is running under.

-- 
Bye, Peter Korsgaard
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


[PATCH] syslogd: add config option to include milliseconds in timestamps

2020-01-27 Thread Peter Korsgaard
For some use cases, having logs with more than 1 second accuracy can be
helpful.  Add an option to include milliseconds when adding a timestamp in
HH:MM:SS.mmm format, similar to syslog-ng with fraq_digits(3) or journalctl
-o short-precise.

For simplicity, abuse the remaining space in the buffer used by ctime to add
the millieconds (overwriting year).

/scripts/bloat-o-meter busybox_old busybox
function old new   delta
.rodata 83538360  +7
--
(add/remove: 0/0 grow/shrink: 1/0 up/down: 7/0) Total: 7 bytes

Signed-off-by: Peter Korsgaard 
---
 sysklogd/syslogd.c | 27 ---
 1 file changed, 24 insertions(+), 3 deletions(-)

diff --git a/sysklogd/syslogd.c b/sysklogd/syslogd.c
index 0e226124a..95e213a0a 100644
--- a/sysklogd/syslogd.c
+++ b/sysklogd/syslogd.c
@@ -64,6 +64,14 @@
 //config:  help
 //config:  Supports restricted syslogd config. See docs/syslog.conf.txt
 //config:
+//config:config FEATURE_SYSLOGD_PRECISE_TIMESTAMPS
+//config:  bool "Include milliseconds in timestamps"
+//config:  default n
+//config:  depends on SYSLOGD
+//config:  help
+//config:  Includes milliseconds (HH:MM:SS.mmm) in timestamp when
+//config:  timestamps are added.
+//config:
 //config:config FEATURE_SYSLOGD_READ_BUFFER_SIZE
 //config:  int "Read buffer size in bytes"
 //config:  default 256
@@ -276,7 +284,7 @@ struct globals {
/* ...then copy to parsebuf, escaping control chars */
/* (can grow x2 max) */
char parsebuf[MAX_READ*2];
-   /* ...then sprintf into printbuf, adding timestamp (15 chars),
+   /* ...then sprintf into printbuf, adding timestamp (15 or 19 chars),
 * host (64), fac.prio (20) to the message */
/* (growth by: 15 + 64 + 20 + delims = ~110) */
char printbuf[MAX_READ*2 + 128];
@@ -833,11 +841,24 @@ static void timestamp_and_log(int pri, char *msg, int len)
}
 
if (!timestamp) {
+#if ENABLE_FEATURE_SYSLOGD_PRECISE_TIMESTAMPS
+   struct timeval tv;
+   gettimeofday(, NULL);
+   now = tv.tv_sec;
+#else
time();
+#endif
timestamp = ctime() + 4; /* skip day of week */
-   }
 
-   timestamp[15] = '\0';
+#if ENABLE_FEATURE_SYSLOGD_PRECISE_TIMESTAMPS
+   /* overwrite year by milliseconds, zero terminate */
+   sprintf(timestamp + 15, ".%03ld", tv.tv_usec / 1000);
+#else
+   timestamp[15] = '\0';
+#endif
+   }
+   else
+   timestamp[15] = '\0';
 
if (option_mask32 & OPT_kmsg) {
log_to_kmsg(pri, msg);
-- 
2.20.1

___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: 1.31.1 release

2019-10-27 Thread Peter Korsgaard
>>>>> "Denys" == Denys Vlasenko  writes:

 > Should be fixed now (web page updates in ~1 hour)

Thanks!

-- 
Bye, Peter Korsgaard
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


1.31.1 release

2019-10-27 Thread Peter Korsgaard
Hi,

I see there is a 1.31.1 tarball
(https://busybox.net/downloads/busybox-1.31.1.tar.bz2), but no git tag
or any mention of it on the website?

Denys, did you perhaps forget to push the tag?

-- 
Bye, Peter Korsgaard
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: [PATCH] ash: only catch unexpected exceptions in PS1 expansion

2019-10-21 Thread Peter Korsgaard
>>>>> "Denys" == Denys Vlasenko  writes:

 > On Sun, Oct 20, 2019 at 12:13 PM Bastian Bittorf  wrote:
 >> 
 >> On Sun, Oct 20, 2019 at 09:54:01AM +0100, Ron Yorston wrote:
 >> > Bastian Bittorf wrote:
 >> > >Maybe i am a "victim" of this patch:
 >> >
 >> > 1.30.0 has the faulty commit d1a2fa2a4 (ash: catch error in arithmetic
 >> > expansion in PS1) but not the subsequent correction in commit 943e81f5d
 >> > (ash: only catch unexpected exceptions in PS1 expansion).
 >> >
 >> > Commit 943e81f5d should be backported to the stable branch.  It applies
 >> > as-is.
 >> 
 >> very good, this fits my observation - see bugreport:
 >> https://bugs.busybox.net/show_bug.cgi?id=12266

 > Applied to 1_31_stable, do you guys want the 1.31.1 release?

Yes please (for Buildroot).

-- 
Bye, Peter Korsgaard
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: [PATCH 1/3] date: Use 64 prefix syscall if we have to

2019-08-28 Thread Peter Korsgaard
>>>>> "Alistair" == Alistair Francis  writes:

 > Some 32-bit architectures no longer have the 32-bit time_t syscalls.
 > Instead they have suffixed syscalls that returns a 64-bit time_t. If
 > the architecture doesn't have the non-suffixed syscall and is using a
 > 64-bit time_t let's use the suffixed syscall instead.

 > This fixes build issues when building for RISC-V 32-bit with 5.1+ kernel
 > headers.

 > If an architecture only supports the suffixed syscalls, but is still
 > using a 32-bit time_t fall back to the libc call.

 > Signed-off-by: Alistair Francis 
 > ---
 >  coreutils/date.c | 11 +--
 >  1 file changed, 9 insertions(+), 2 deletions(-)

 > diff --git a/coreutils/date.c b/coreutils/date.c
 > index feb400430..4ef1cbf4a 100644
 > --- a/coreutils/date.c
 > +++ b/coreutils/date.c
 > @@ -36,7 +36,7 @@
 >  //config:# defaults to "no": stat's nanosecond field is a bit non-portable
 >  //config:config FEATURE_DATE_NANO
 >  //config:   bool "Support %[num]N nanosecond format specifier"
 > -//config:   default n  # syscall(__NR_clock_gettime)
 > +//config:   default n  # syscall(__NR_clock_gettime) or 
 > syscall(__NR_clock_gettime64)
 >  //config:   depends on DATE
 >  //config:   select PLATFORM_LINUX
 >  //config:   help
 > @@ -271,10 +271,17 @@ int date_main(int argc UNUSED_PARAM, char **argv)
 >   */
 >  #endif
 >  } else {
 > -#if ENABLE_FEATURE_DATE_NANO
 > +#if ENABLE_FEATURE_DATE_NANO && defined(__NR_clock_gettime)
 >  /* libc has incredibly messy way of doing this,
 >   * typically requiring -lrt. We just skip all this mess */
 >  syscall(__NR_clock_gettime, CLOCK_REALTIME, );
 > +#elif ENABLE_FEATURE_DATE_NANO && __TIMESIZE == 64
 > +/* Let's only suppor the 64 suffix syscalls for 64-bit time_t.

s/suppor/support/

-- 
Bye, Peter Korsgaard
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: [PATCH] tftp: introduce CONFIG_FEATURE_TFTP_UMASK

2019-06-11 Thread Peter Korsgaard
>>>>> "Markus" == Markus Mayer  writes:

 > On Sun, 9 Jun 2019 at 00:54, Denys Vlasenko  wrote:
 >> 
 >> Imagining myself in the situation where I need to download
 >> executables over tftp, the first solution which comes to mind
 >> is to just chmod them after download.
 >> 
 >> Why that does not work for you?

 > I am working on a reference root file system that is used internally
 > and possibly also by customers. Unbeknownst to me, for years we had an
 > internal hack to TFTP that caused the TFTP client to apply execute
 > permissions to transferred files. Presumably this was a user request
 > at some point.

 > A recent root file system modernization did away with this TFTP
 > customization, which promptly triggered a regression being filed
 > against TFTP. Since I had to come up with a new way to apply our old
 > patch, I figured I'd share it with the community in case it is useful
 > to others.

Why not just add a shell script wrapper that does the chmod after tftp
get?

-- 
Bye, Peter Korsgaard
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: [PATCH] package/busybox: add dependency on dosfstools

2019-06-06 Thread Peter Korsgaard
>>>>> "Markus" == Markus Mayer  writes:

 > dosfstools and busybox may each install mkfs.vfat, so dosfstools must
 > be installed before busybox.

 > Signed-off-by: Markus Mayer 
 > ---

 > I hope I am using the dependency feature correctly. Based it on "attr" and
 > "busybox".

Committed to 2019.02.x and 2019.05.x, thanks.

-- 
Bye, Peter Korsgaard
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: [PATCH] package/busybox: add dependency on dosfstools

2019-06-03 Thread Peter Korsgaard
>>>>> "Markus" == Markus Mayer  writes:

 > dosfstools and busybox may each install mkfs.vfat, so dosfstools must
 > be installed before busybox.

 > Signed-off-by: Markus Mayer 

Committed, thanks.

-- 
Bye, Peter Korsgaard
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: [PATCH 3/3] mdev: add support to run as daemon

2019-05-04 Thread Peter Korsgaard
>>>>> "Jan" == Jan Klötzke  writes:

 > Adds the -s option to run mdev in daemon mode handling hotplug events
 > from the kernel like udev. If the system generates many hotplug events
 > this mode of operation will consume less resources than registering
 > mdev as hotplug helper or using the uevent applet.

-s is already scan. Did you mean -d?

-- 
Bye, Peter Korsgaard
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: bb_daemonize_or_rexec(DAEMON_CLOSE_EXTRA_FDS) does not close extra fds

2019-03-14 Thread Peter Korsgaard
On Thu, Mar 14, 2019 at 4:35 PM Arnout Vandecappelle  wrote:

>  The problem is that the assumption that open() returns an fd that is larger
> than all existing fds is simply wrong.
>
>  I think that there is no other way to close all open fds than to iterate over
> /proc/self/fd. But that is of course not very portable.

This particular issue could be fixed by rewriting the logic to something like:

int keep = 2;

if (flags & DAEMON_DEVNULL_STDIO)
   keep = -1;

fd = open(bb_dev_null, O_RDWR);
..
while (fd > keep) {
  close(fd--);
}

But yeah, the other problem persists. I don't know of any other
solutions besides using a hardcoded max-fd. I believe the classic
limit used by select is 1024.

-- 
Bye, Peter Korsgaard
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: [PATCH] sysklogd: add timestamp option to ignore message timestamps

2018-08-19 Thread Peter Korsgaard
>>>>> "Peter" == Peter Korsgaard  writes:

Ping?

Comments, feedback?

 > Some syslog producers provide inconsistent timestamps, so provide an option
 > to ignore the message timestamps and always locally timestamp.  In order to
 > implement this, invert the valid-timestamp check, but only use the timestamp
 > if this option is not enabled.

 > This is in line with what what other syslogd implementations do:

 > From sysklogd syslogd.c:
 >  * Sun Nov  7 12:28:47 CET 2004: Martin Schulze 
 >  *  Discard any timestamp information found in received syslog
 >  *  messages.  This will affect local messages sent from a
 >  *  different timezone.

 > rsyslog's imuxsock module similary has an (enabled by default)
 > IgnoreTimestamp option:

 > https://www.rsyslog.com/doc/v8-stable/configuration/modules/imuxsock.html

 > function old new   delta
 > .rodata14706   14738 +32
 > usage_messages  23422373 +31
 > timestamp_and_log709 724 +15
 > syslogd_main21872190  +3
 > --
 > (add/remove: 0/0 grow/shrink: 4/0 up/down: 81/0)   Total: 81 
 > bytes

 > Signed-off-by: Peter Korsgaard 
 > ---
 >  sysklogd/syslogd.c | 25 +
 >  1 file changed, 17 insertions(+), 8 deletions(-)

 > diff --git a/sysklogd/syslogd.c b/sysklogd/syslogd.c
 > index 4265f4f90..e966208c2 100644
 > --- a/sysklogd/syslogd.c
 > +++ b/sysklogd/syslogd.c
 > @@ -140,6 +140,7 @@
 >  //usage:)
 >  //usage: "\n-l NLog only messages more urgent than prio 
 > N (1-8)"
 >  //usage: "\n-S  Smaller output"
 > +//usage: "\n-t  Ignore message timestamps"
 >  //usage:IF_FEATURE_SYSLOGD_DUP(
 >  //usage: "\n-D  Drop duplicates"
 >  //usage:)
 > @@ -316,6 +317,7 @@ enum {
 >  OPTBIT_outfile, // -O
 >  OPTBIT_loglevel, // -l
 >  OPTBIT_small, // -S
 > +OPTBIT_timestamp, // -t
 >  IF_FEATURE_ROTATE_LOGFILE(OPTBIT_filesize   ,)  // -s
 >  IF_FEATURE_ROTATE_LOGFILE(OPTBIT_rotatecnt  ,)  // -b
 >  IF_FEATURE_REMOTE_LOG(OPTBIT_remotelog  ,)  // -R
 > @@ -330,6 +332,7 @@ enum {
 >  OPT_outfile = 1 << OPTBIT_outfile ,
 >  OPT_loglevel= 1 << OPTBIT_loglevel,
 >  OPT_small   = 1 << OPTBIT_small   ,
 > +OPT_timestamp   = 1 << OPTBIT_timestamp,
 >  OPT_filesize= IF_FEATURE_ROTATE_LOGFILE((1 << OPTBIT_filesize   )) 
 > + 0,
 >  OPT_rotatecnt   = IF_FEATURE_ROTATE_LOGFILE((1 << OPTBIT_rotatecnt  )) 
 > + 0,
 >  OPT_remotelog   = IF_FEATURE_REMOTE_LOG((1 << OPTBIT_remotelog  )) 
 > + 0,
 > @@ -339,7 +342,7 @@ enum {
 >  OPT_cfg = IF_FEATURE_SYSLOGD_CFG(   (1 << OPTBIT_cfg)) 
 > + 0,
 >  OPT_kmsg= IF_FEATURE_KMSG_SYSLOG(   (1 << OPTBIT_kmsg   )) 
 > + 0,
 >  };
 > -#define OPTION_STR "m:nO:l:S" \
 > +#define OPTION_STR "m:nO:l:St" \
 >  IF_FEATURE_ROTATE_LOGFILE("s:" ) \
 >  IF_FEATURE_ROTATE_LOGFILE("b:" ) \
 >  IF_FEATURE_REMOTE_LOG("R:*") \
 > @@ -813,21 +816,27 @@ static void parse_fac_prio_20(int pri, char *res20)
 >   * that there is no timestamp, short-circuiting the test. */
 >  static void timestamp_and_log(int pri, char *msg, int len)
 >  {
 > -char *timestamp;
 > +char *timestamp = NULL;
 >  time_t now;
 
 >  /* Jan 18 00:11:22 msg... */
 >  /* 01234567890123456 */
 > -if (len < 16 || msg[3] != ' ' || msg[6] != ' '
 > - || msg[9] != ':' || msg[12] != ':' || msg[15] != ' '
 > +if (len >= 16 && msg[3] == ' ' && msg[6] == ' '
 > + && msg[9] == ':' && msg[12] == ':' && msg[15] == ' '
 >  ) {
 > +if (!(option_mask32 & OPT_timestamp)) {
 > +/* use message timestamp */
 > +    timestamp = msg;
 > +now = 0;
 > +}
 > +msg += 16;
 > +}
 > +
 > +if (!timestamp) {
 >  time();
 >  timestamp = ctime() + 4; /* skip day of week */
 > -} else {
 > -now = 0;
 > -timestamp = msg;
 > -msg += 16;
 >  }
 > +
 >  timestamp[15] = '\0';
 
 >  if (option_mask32 & OPT_kmsg) {
 > -- 
 > 2.11.0


-- 
Bye, Peter Korsgaard
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


[PATCH] sysklogd: add timestamp option to ignore message timestamps

2018-08-09 Thread Peter Korsgaard
Some syslog producers provide inconsistent timestamps, so provide an option
to ignore the message timestamps and always locally timestamp.  In order to
implement this, invert the valid-timestamp check, but only use the timestamp
if this option is not enabled.

This is in line with what what other syslogd implementations do:

>From sysklogd syslogd.c:
 * Sun Nov  7 12:28:47 CET 2004: Martin Schulze 
 *  Discard any timestamp information found in received syslog
 *  messages.  This will affect local messages sent from a
 *  different timezone.

rsyslog's imuxsock module similary has an (enabled by default)
IgnoreTimestamp option:

https://www.rsyslog.com/doc/v8-stable/configuration/modules/imuxsock.html

function old new   delta
.rodata14706   14738 +32
usage_messages  23422373 +31
timestamp_and_log709 724 +15
syslogd_main21872190  +3
--
(add/remove: 0/0 grow/shrink: 4/0 up/down: 81/0)   Total: 81 bytes

Signed-off-by: Peter Korsgaard 
---
 sysklogd/syslogd.c | 25 +
 1 file changed, 17 insertions(+), 8 deletions(-)

diff --git a/sysklogd/syslogd.c b/sysklogd/syslogd.c
index 4265f4f90..e966208c2 100644
--- a/sysklogd/syslogd.c
+++ b/sysklogd/syslogd.c
@@ -140,6 +140,7 @@
 //usage:   )
 //usage: "\n   -l NLog only messages more urgent than prio 
N (1-8)"
 //usage: "\n   -S  Smaller output"
+//usage: "\n   -t  Ignore message timestamps"
 //usage:   IF_FEATURE_SYSLOGD_DUP(
 //usage: "\n   -D  Drop duplicates"
 //usage:   )
@@ -316,6 +317,7 @@ enum {
OPTBIT_outfile, // -O
OPTBIT_loglevel, // -l
OPTBIT_small, // -S
+   OPTBIT_timestamp, // -t
IF_FEATURE_ROTATE_LOGFILE(OPTBIT_filesize   ,)  // -s
IF_FEATURE_ROTATE_LOGFILE(OPTBIT_rotatecnt  ,)  // -b
IF_FEATURE_REMOTE_LOG(OPTBIT_remotelog  ,)  // -R
@@ -330,6 +332,7 @@ enum {
OPT_outfile = 1 << OPTBIT_outfile ,
OPT_loglevel= 1 << OPTBIT_loglevel,
OPT_small   = 1 << OPTBIT_small   ,
+   OPT_timestamp   = 1 << OPTBIT_timestamp,
OPT_filesize= IF_FEATURE_ROTATE_LOGFILE((1 << OPTBIT_filesize   )) 
+ 0,
OPT_rotatecnt   = IF_FEATURE_ROTATE_LOGFILE((1 << OPTBIT_rotatecnt  )) 
+ 0,
OPT_remotelog   = IF_FEATURE_REMOTE_LOG((1 << OPTBIT_remotelog  )) 
+ 0,
@@ -339,7 +342,7 @@ enum {
OPT_cfg = IF_FEATURE_SYSLOGD_CFG(   (1 << OPTBIT_cfg)) 
+ 0,
OPT_kmsg= IF_FEATURE_KMSG_SYSLOG(   (1 << OPTBIT_kmsg   )) 
+ 0,
 };
-#define OPTION_STR "m:nO:l:S" \
+#define OPTION_STR "m:nO:l:St" \
IF_FEATURE_ROTATE_LOGFILE("s:" ) \
IF_FEATURE_ROTATE_LOGFILE("b:" ) \
IF_FEATURE_REMOTE_LOG("R:*") \
@@ -813,21 +816,27 @@ static void parse_fac_prio_20(int pri, char *res20)
  * that there is no timestamp, short-circuiting the test. */
 static void timestamp_and_log(int pri, char *msg, int len)
 {
-   char *timestamp;
+   char *timestamp = NULL;
time_t now;
 
/* Jan 18 00:11:22 msg... */
/* 01234567890123456 */
-   if (len < 16 || msg[3] != ' ' || msg[6] != ' '
-|| msg[9] != ':' || msg[12] != ':' || msg[15] != ' '
+   if (len >= 16 && msg[3] == ' ' && msg[6] == ' '
+&& msg[9] == ':' && msg[12] == ':' && msg[15] == ' '
) {
+   if (!(option_mask32 & OPT_timestamp)) {
+   /* use message timestamp */
+   timestamp = msg;
+   now = 0;
+   }
+   msg += 16;
+   }
+
+   if (!timestamp) {
time();
timestamp = ctime() + 4; /* skip day of week */
-   } else {
-   now = 0;
-   timestamp = msg;
-   msg += 16;
}
+
timestamp[15] = '\0';
 
if (option_mask32 & OPT_kmsg) {
-- 
2.11.0

___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: [PATCH v2] busybox: Update udhcpc.script for DHCPv6

2018-06-19 Thread Peter Korsgaard
>>>>> "Samuel" == Samuel Mendoza-Jonas  writes:

Hi,

 > udhcpc6 will call the default script with the address set in the "ipv6"
 > variable. Set "ip" to this address if present.

 > Also from Rob, if handling a DHCPv6 address wait a moment for the IPv6
 > route to be configured; this doesn't come from DHCPv6 but rather the
 > IPv6 Router Advertisement (RA).

 > (wait for IPv6 route)
 > From: Robert Lippert 
 > Signed-off-by: Samuel Mendoza-Jonas 
 > ---
 > v2: Avoid bashisms

 >  package/busybox/udhcpc.script | 14 ++
 >  1 file changed, 14 insertions(+)

 > diff --git a/package/busybox/udhcpc.script b/package/busybox/udhcpc.script

You are sending this to the busybox list, but it looks to be a Buildroot
patch?

> index ad110d3a7f..65114b6cd0 100755
 > --- a/package/busybox/udhcpc.script
 > +++ b/package/busybox/udhcpc.script
 > @@ -8,6 +8,16 @@ RESOLV_CONF="/etc/resolv.conf"
 >  [ -e $RESOLV_CONF ] || touch $RESOLV_CONF
 >  [ -n "$broadcast" ] && BROADCAST="broadcast $broadcast"
 >  [ -n "$subnet" ] && NETMASK="netmask $subnet"
 > +[ -n "$ipv6" ] && ip="$ipv6/128"

Why /128?

I'm far from an IPv6 expert, but I take it this is for stateful DHCPv6,
right? Please mention that in the commit message.

> +
 > +wait_for_ipv6_default_route() {
 > +attempts=10
 > +while [ $attempts != 0 ] && [ -z "$(ip -6 route list | grep default)" ] 
 > ; do
 > +sleep 1
 > +attempts=$(($attempts-1))
 > +done
 > +[ $attempts = 0 ] && echo "failed to get default ipv6 route"
 > +}
 
 >  case "$1" in
 >  deconfig)
 > @@ -37,6 +47,10 @@ case "$1" in
 >  /usr/sbin/avahi-autoipd -k $interface
 >  fi
 >  /sbin/ifconfig $interface $ip $BROADCAST $NETMASK
 > +if [ -n "$ipv6" ] ; then
 > +echo "waiting for default ipv6 route set"
 > +    wait_for_ipv6_default_route
 > +fi
 
 >  if [ -n "$router" ] ; then
 >  echo "deleting routers"
 > -- 
 > 2.17.1

 > ___
 > busybox mailing list
 > busybox@busybox.net
 > http://lists.busybox.net/mailman/listinfo/busybox

-- 
Bye, Peter Korsgaard
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


[PATCH] fbsplash: support configurable image position

2018-03-29 Thread Peter Korsgaard
For some setups (E.G. for supporting different screen resolutions),
positioning the image somewhere else than the top left corner may be
interesting.

Add support for IMG_LEFT/IMG_TOP settings to specify the image location,
similar to how it is done for the progress bar.

Signed-off-by: Peter Korsgaard <pe...@korsgaard.com>
---
 miscutils/fbsplash.c | 21 -
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/miscutils/fbsplash.c b/miscutils/fbsplash.c
index 5b2e5ac56..bc3c61055 100644
--- a/miscutils/fbsplash.c
+++ b/miscutils/fbsplash.c
@@ -54,7 +54,7 @@
 //usage: "\n   -d  Framebuffer device (default /dev/fb0)"
 //usage: "\n   -i  Config file (var=value):"
 //usage: "\n   BAR_LEFT,BAR_TOP,BAR_WIDTH,BAR_HEIGHT"
-//usage: "\n   BAR_R,BAR_G,BAR_B"
+//usage: "\n   BAR_R,BAR_G,BAR_B,IMG_LEFT,IMG_TOP"
 //usage: "\n   -f  Control pipe (else exit after drawing image)"
 //usage: "\n   commands: 'NN' (% for progress bar) or 
'exit'"
 
@@ -73,7 +73,7 @@ struct globals {
FILE *logfile_fd;   // log file
 #endif
unsigned char *addr;// pointer to framebuffer memory
-   unsigned ns[7]; // n-parameters
+   unsigned ns[9]; // n-parameters
const char *image_filename;
struct fb_var_screeninfo scr_var;
struct fb_fix_screeninfo scr_fix;
@@ -95,6 +95,8 @@ struct globals {
 #define nbar_colr  ns[4]   // progress bar color red component
 #define nbar_colg  ns[5]   // progress bar color green component
 #define nbar_colb  ns[6]   // progress bar color blue component
+#define img_posx   ns[7]   // image horizontal position
+#define img_posy   ns[8]   // image vertical position
 
 #if DEBUG
 #define DEBUG_MESSAGE(strMessage, args...) \
@@ -426,10 +428,10 @@ static void fb_drawimage(void)
line_size = width*3;
pixline = xmalloc(line_size);
 
-   if (width > G.scr_var.xres)
-   width = G.scr_var.xres;
-   if (height > G.scr_var.yres)
-   height = G.scr_var.yres;
+   if ((width + G.img_posx) > G.scr_var.xres)
+   width = G.scr_var.xres - G.img_posx;
+   if ((height + G.img_posy) > G.scr_var.yres)
+   height = G.scr_var.yres - G.img_posy;
for (j = 0; j < height; j++) {
unsigned char *pixel;
unsigned char *src;
@@ -437,7 +439,7 @@ static void fb_drawimage(void)
if (fread(pixline, 1, line_size, theme_file) != line_size)
bb_error_msg_and_die("bad PPM file '%s'", 
G.image_filename);
pixel = pixline;
-   src = G.addr + j * G.scr_fix.line_length;
+   src = G.addr + (G.img_posy + j) * G.scr_fix.line_length + 
G.img_posx * G.bytes_per_pixel;
for (i = 0; i < width; i++) {
unsigned thispix = fb_pixel_value(pixel[0], pixel[1], 
pixel[2]);
fb_write_pixel(src, thispix);
@@ -460,6 +462,7 @@ static void init(const char *cfg_filename)
"BAR_WIDTH\0" "BAR_HEIGHT\0"
"BAR_LEFT\0" "BAR_TOP\0"
"BAR_R\0" "BAR_G\0" "BAR_B\0"
+   "IMG_LEFT\0" "IMG_TOP\0"
 #if DEBUG
"DEBUG\0"
 #endif
@@ -472,10 +475,10 @@ static void init(const char *cfg_filename)
int i = index_in_strings(param_names, token[0]);
if (i < 0)
bb_error_msg_and_die("syntax error: %s", token[0]);
-   if (i >= 0 && i < 7)
+   if (i >= 0 && i < 9)
G.ns[i] = val;
 #if DEBUG
-   if (i == 7) {
+   if (i == 9) {
G.bdebug_messages = val;
if (G.bdebug_messages)
G.logfile_fd = 
xfopen_for_write("/tmp/fbsplash.log");
-- 
2.11.0

___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


[PATCH] dpkg: fix CONFIG_FEATURE_CLEAN_UP handling

2017-07-05 Thread Peter Korsgaard
dpkg moved to away from dynamically allocating the hashtables in commit
c87339d584 (dpkg: trivial code shrinkage, and redo G trick correctly) almost
ten years ago, but the cleanup code was never adjusted to match.

Glibc loudly complains about this:

*** Error in `dpkg': free(): invalid pointer: 0x007fac3478c0 ***

Signed-off-by: Peter Korsgaard <pe...@korsgaard.com>
---
 archival/dpkg.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/archival/dpkg.c b/archival/dpkg.c
index 1cd45eda4..da3b0864e 100644
--- a/archival/dpkg.c
+++ b/archival/dpkg.c
@@ -1938,10 +1938,6 @@ int dpkg_main(int argc UNUSED_PARAM, char **argv)
for (i = 0; i < STATUS_HASH_PRIME; i++) {
free(status_hashtable[i]);
}
-
-   free(status_hashtable);
-   free(package_hashtable);
-   free(name_hashtable);
}
 
return EXIT_SUCCESS;
-- 
2.11.0

___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: mdev change no longer supporting v2.6.2x kernels by using /sys/dev

2017-03-30 Thread Peter Korsgaard
>>>>> "Ralf" == Ralf Friedl <ralf.fri...@online.de> writes:

Hi,

>> /sys/dev support got added in 2.6.27-rc1 (July 2008), E.G. ~9 years ago:

 > Busybox is often used in embedded devices, where kernels (and other
 > software) are not changed that often. Firmware may contain kernel
 > modules without full source, so a change to a newer kernel is not an
 > option. As an example, I have a router with kernel 2.6.13. I can't
 > update the kernel, but I can replace the busybox with a newer version
 > (and much more applets) than the original.

True, but generally you will run into a number of issues when you
combine SW components of significant different "age". E.G. lots of
modern user space requires new kernel features, either explicitly or
simply because nobody has tested it on such old systems.

-- 
Bye, Peter Korsgaard
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: mdev change no longer supporting v2.6.2x kernels by using /sys/dev

2017-03-23 Thread Peter Korsgaard
>>>>> "Richard" == Richard Moore <r...@richud.com> writes:

 > Hi,
 > Would it be possible to please make the recent mdev change in v1.26 an
 > option?

 > * mdev (mdev: create devices from /sys/dev) commit 20a3262 (Sep 7, 2016)

 > I am stuck with a v2.6.2x kernel and I am sure other people must be too
 > who have no /sys/dev support in their kernel ?

/sys/dev support got added in 2.6.27-rc1 (July 2008), E.G. ~9 years ago:

commit e105b8bfc769b0545b6f0f395179d1e43cbee822
Author: Dan Williams <dan.j.willi...@intel.com>
Date:   Mon Apr 21 10:51:07 2008 -0700

sysfs: add /sys/dev/{char,block} to lookup sysfs path by major:minor

Why?:
There are occasions where userspace would like to access sysfs
attributes for a device but it may not know how sysfs has named the
device or the path.  For example what is the sysfs path for
/dev/disk/by-id/ata-ST3160827AS_5MT004CK?  With this change a call to
stat(2) returns the major:minor then userspace can see that
/sys/dev/block/8:32 links to /sys/block/sdc.

What are the alternatives?:
1/ Add an ioctl to return the path: Doable, but sysfs is meant to reduce
   the need to proliferate ioctl interfaces into the kernel, so this
   seems counter productive.

2/ Use udev to create these symlinks: Also doable, but it adds a
   udev dependency to utilities that might be running in a limited
   environment like an initramfs.

3/ Do a full-tree search of sysfs.

[kay.siev...@vrfy.org: fix duplicate registrations]
[kay.siev...@vrfy.org: cleanup suggestions]

Cc: Neil Brown <ne...@suse.de>
Cc: Tejun Heo <hte...@gmail.com>
Acked-by: Kay Sievers <kay.siev...@vrfy.org>
Reviewed-by: SL Baur <st...@xemacs.org>
Acked-by: Kay Sievers <kay.siev...@vrfy.org>
Acked-by: Mark Lord <l...@rtr.ca>
Acked-by: H. Peter Anvin <h...@zytor.com>
Signed-off-by: Dan Williams <dan.j.willi...@intel.com>
Signed-off-by: Greg Kroah-Hartman <gre...@suse.de>

Does it really make sense to mix such an ancient kernel with a modern
busybox? Why not just backport this kernel commit?

-- 
Bye, Peter Korsgaard
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: Question on mdev's custom command invocation

2016-11-17 Thread Peter Korsgaard
On Thu, Nov 17, 2016 at 11:02 AM, Didier Kryn <k...@in2p3.fr> wrote:
>> I'm assuming you already use environment variables in your script,
>> e.g. $MDEV, $SEQNUM, etc Maybe you missed $ACTION, sounds like what
>> you're looking for.
>
> Good to know that; https://git.busybox.net/busybox/plain/docs/mdev.txt
> only mentions $MDEV .

That is because those environment variables comes from the kernel when
it invokes the hotplug helper (mdev):

http://lxr.free-electrons.com/source/Documentation/driver-model/porting.txt#L375

--
Bye, Peter Korsgaard
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: ifup dependency

2016-09-26 Thread Peter Korsgaard
>>>>> "Denys" == Denys Vlasenko <vda.li...@googlemail.com> writes:

Hi,

 >> > No it should not. It's perfectly fine to use another run-parts. The
 >> > help-text should mention that any run-parts has to be installed
 >> > though.
 >> 
 >> True.

 > It's already in the help since about 2003:

 > config IFUPDOWN
 > bool "ifupdown"
 > default y
 > help
 >   Activate or deactivate the specified interfaces. This applet makes
 >   use of either "ifconfig" and "route" or the "ip" command to 
 > actually
 >   configure network interfaces. Therefore, you will probably also 
 > want
 >   to enable either IFCONFIG and ROUTE, or enable
 >   FEATURE_IFUPDOWN_IP and the various IP options.
 >   Of course you could use non-busybox versions of these programs, so
 >   against my better judgement (since this will surely result in 
 > plenty
 >   of support questions on the mailing list), I do not force you to
 >   enable these additional options. It is up to you to supply either
 >   "ifconfig", "route" and "run-parts" or the "ip" command, either
 >   via busybox or via standalone utilities.


heh, indeed.

 > It's possible to add that sometimes udhcpc, bootpc, pon, poff,
 > start-stop-daemon, wvdial, and run-parts can be used,
 > but the list gets somewhat unwieldy.

yes, keeping it like this is imho ok.

-- 
Bye, Peter Korsgaard
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: ifup dependency

2016-09-26 Thread Peter Korsgaard
>>>>> "Bernhard" == Bernhard Reutner-Fischer <rep.dot@gmail.com> writes:

 > On 17 September 2016 08:07:01 CEST, Peter Korsgaard <pe...@korsgaard.com> 
 > wrote:
 >>>>>>> "David" == David Henderson <dhender...@digital-pipe.com> writes:
 >> 
 >> > Hey Peter, thanks for the reply.  I was more or less referring to
 >> > should the 'menuconfig' portion of BB automatically add that in as a
 >> > dependency if ifup/down has been selected, and not should I add this
 >> > applet into my BB compile.  I was just letting the community know
 >> > about the "problem".
 >> 
 >> Yes indeed, I think CONFIG_IFUPDOWN should select CONFIG_RUN_PARTS.

 > No it should not. It's perfectly fine to use another run-parts. The
 > help-text should mention that any run-parts has to be installed
 > though.

True.

-- 
Bye, Peter Korsgaard
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: dhcp with /etc/network/interfaces

2016-09-19 Thread Peter Korsgaard
>>>>> "David" == David Henderson <dhender...@digital-pipe.com> writes:

 > Good morning Peter, thanks for your reply.  C/C++ is not my forte and
 > while it may be readable for you, it may not be for others.

Then use strace as I suggested.

-- 
Bye, Peter Korsgaard
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: dhcp with /etc/network/interfaces

2016-09-19 Thread Peter Korsgaard
>>>>> "David" == David Henderson <dhender...@digital-pipe.com> writes:

 > Good morning all, just following up with this!

Please just have a look at networking/ifupdown.c, it is IMHO quite
readable.

Alternative, run strace -f -e execve ifup  to see the exact
commands executed.

-- 
Bye, Peter Korsgaard
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: ifup dependency

2016-09-17 Thread Peter Korsgaard
>>>>> "David" == David Henderson <dhender...@digital-pipe.com> writes:

 > Hey Peter, thanks for the reply.  I was more or less referring to
 > should the 'menuconfig' portion of BB automatically add that in as a
 > dependency if ifup/down has been selected, and not should I add this
 > applet into my BB compile.  I was just letting the community know
 > about the "problem".

Yes indeed, I think CONFIG_IFUPDOWN should select CONFIG_RUN_PARTS.

-- 
Bye, Peter Korsgaard
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: ifup dependency

2016-09-16 Thread Peter Korsgaard
>>>>> "David" == David Henderson <dhender...@digital-pipe.com> writes:

 > Good afternoon all, I had re-compiled my busybox to add in the some
 > commands including the ifup/down.  When I attempted to run that
 > applet, it said that 'run-parts' was not installed.  Should this
 > applet the automatically added to the config when the ifup/down
 > commands were added?

As the errors executing run-parts aren't ignored, I would say yes.

-- 
Bye, Peter Korsgaard
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: [PATCH] svlogd: strip leading '!' from processor lines

2016-09-14 Thread Peter Korsgaard
>>>>> "Francis" == Francis Rounds <francis.rou...@4bridgeworks.com> writes:

 > When using svlogd's processor functionality to run arbitrary commands
 > on log rotation, the line in the config is executed verbatim, i.e. the
 > exclamation mark is included.

 > For example, if the config file contains:

 > s100
 > !cat

 > then when it's time to rotate the log files after each 100 bytes, sh -c
 > "!cat" will be run, instead of sh -c "cat" as intended. The result is
 > svlogd logging

 > /bin/bash: !cat: command not found
 > svlogd: warning: processor failed, restart: /tmp/svlogd/

 > over and over again as it keeps attempting to execute the processor and
 > failing (unless you happen to have a "!cat" binary around :)).

 > Skipping the exclamation mark when performing the wstrdup() fixes the
 > issue.

 > Signed-off-by: Francis Rounds <francis.rou...@4bridgeworks.com>

Argh, indeed :/

Acked-by: Peter Korsgaard <pe...@korsgaard.com>

-- 
Bye, Peter Korsgaard
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: [PATCH 0/2] configs: Add ts4900 basic board support

2016-09-01 Thread Peter Korsgaard
>>>>> "Mathieu" == Mathieu Audat <mathieu.au...@savoirfairelinux.com> writes:

 > This serie of patches add the support for the TS-4900 SoM manufactured by
 > Technologic Systems based on an i.MX6 SoC from Freescale.

 > Mathieu Audat (2):
 >   ts4900-fpga: add ts4900-fpga package
 >   configs: add defconfig for TS-4900

Ehh, I think you wanted to mail buildr...@buildroot.org, not
busybox@busybox.net ;)

-- 
Bye, Peter Korsgaard
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


[PATCH] udhcpc: perform_release(): Unconditionally call deconfig script

2016-08-24 Thread Peter Korsgaard
The udhcpc script may be used to setup fallback configuration (E.G. IPv4LL,
fixed IP address, ..) that also needs to be cleaned up on release (E.G.
when SIGUSR2 is called or on shutdown with -R), so unconditionally call
deconfig.

Signed-off-by: Peter Korsgaard <pe...@korsgaard.com>
---
 networking/udhcp/dhcpc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c
index 8a16e98..799a7f9 100644
--- a/networking/udhcp/dhcpc.c
+++ b/networking/udhcp/dhcpc.c
@@ -1129,9 +1129,9 @@ static void perform_release(uint32_t server_addr, 
uint32_t requested_ip)
bb_error_msg("unicasting a release of %s to %s",
inet_ntoa(temp_addr), buffer);
send_release(server_addr, requested_ip); /* unicast */
-   udhcp_run_script(NULL, "deconfig");
}
bb_error_msg("entering released state");
+   udhcp_run_script(NULL, "deconfig");
 
change_listen_mode(LISTEN_NONE);
state = RELEASED;
-- 
2.8.1

___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: Parallel make bug in busybox

2016-08-15 Thread Peter Korsgaard
>>>>> "Richard" == Richard Purdie <rpur...@rpsys.net> writes:

Hi,

Sorry for the slow response, I've been away during the weekend. I see
Denys has committed a fix, so that's great!

 >> http://autobuild.buildroot.org/?reason=busybox-1.25.0
 >> http://autobuild.buildroot.org/?reason=busybox-1.24.1

 > I assume you run builds with parallel make (-j X) enabled?

Yes. If you click on the 'end log' links you can see the exact
invocation. Most of our autobuilders afaik use -j4.

-- 
Bye, Peter Korsgaard
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: Parallel make bug in busybox

2016-08-12 Thread Peter Korsgaard
>>>>> "Richard" == Richard Purdie <rpur...@rpsys.net> writes:

 > We (as in the Yocto Project/OpenEmbedded) do a lot of builds of busybox
 > and one of the failures we've seen recently was:

 > https://autobuilder.yoctoproject.org/main/builders/poky-tiny/builds/908
 > /steps/BuildImages/logs/stdio

Interesting. We afaik haven't seen that kind of build issues on the
Buildroot autobuilders:

http://autobuild.buildroot.org/?reason=busybox-1.25.0
http://autobuild.buildroot.org/?reason=busybox-1.24.1

What is "recent'? Do you only see this with 1.24.1? Do you apply any
patches on top of 1.24.1?

-- 
Bye, Peter Korsgaard
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: Busybox web site ??

2016-07-15 Thread Peter Korsgaard
>>>>> "Michael" == Michael D Setzer <mi...@kuentos.guam.net> writes:

 > Getting Unable to connect

The VM hosting Busybox (and uClibc and Buildroot) has been offline
because of a DDoS attack. The machine is running again, but something is
wrong with the Apache config.

Mike, have you had a chance to look into it?

-- 
Bye, Peter Korsgaard
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: busybox.net SSL cert has expired

2016-05-12 Thread Peter Korsgaard
>>>>> "Joel" == Joel Holdsworth <j...@airwebreathe.org.uk> writes:

 > Looks like the letsencrypt certificate has expired.
 > On my personal website, I've had great mileage doing the update with a
 > cron job.

Yes, something went wrong with the letsencrypt cronjob :/ Mike, care to
take a look?

-- 
Bye, Peter Korsgaard
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: [PATCH] mdev: create devices from /sys/dev

2016-04-11 Thread Peter Korsgaard
>>>>> "Mike" == Mike Frysinger <vap...@gentoo.org> writes:

 >> Tested on kernel v4.6-rc2 with a bunch of devices, including
 >> some IIO and gpiochip devices.

 > if you're using 4.6, why aren't you using devtmpfs ?  there's no
 > real good reason anymore to keep using mdev+coldplug.

.. except if you want to run custom scripts when devices are created and
these devices may or may not be added before mdev is configured as the
hotplug handler.

-- 
Bye, Peter Korsgaard
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: [PATCH] udhcpc: obtain hostname from OS by default

2016-04-01 Thread Peter Korsgaard
Hi,

On Wed, Mar 16, 2016 at 12:03 PM, Jens Rehsack <rehs...@gmail.com> wrote:
>
> Doesn't require the 'hostname' option in /etc/network/interfaces, and thus
> makes udhcpc behave like other clients.

Sounds sensible to me.

> +++ b/networking/udhcp/dhcpc.c
> @@ -1405,6 +1405,18 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
> logmode |= LOGMODE_SYSLOG;
> }
>
> +   /* try to get hostname from OS */
> +   if (!client_config.hostname) {
> +   char *hostname = safe_gethostname();

Have you tried simply initializing client_config.hostname to the
hostname and move alloc_dhcp_option further down? It might end up with
smaller code.

> +   /*
> +* Tito's safe_gethostname is finally a 
> "safe_visible_gethostname",
> +* but that's the most seen use-case.
> +*/
> +   if (hostname[0] && hostname[0] != '?')

safe_gethostname() already ensures that hostname[0] isn't 0, so the
first check can be removed.

-- 
Bye, Peter Korsgaard
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: [PATCH] modprobe: handle module arguments containing spaces

2015-09-09 Thread Peter Korsgaard
>>>>> "Denys" == Denys Vlasenko <vda.li...@googlemail.com> writes:

Hi,

>> +/* like strsep(, "\n\t ") but handles quotes (") */
 >> +static char *split_quotes(char **stringp)
 >> +{
 >> +   char *s, *start = *stringp;
 >> +
 >> +   if (!start)
 >> +   return NULL;
 >> +
 >> +   for (s = start; ; s++) {
 >> +   switch (*s) {
 >> +   case '"':
 >> +   s = strchr(s + 1, '"'); /* find trailing quote */
 >> +   if (*s != '\0')
 >> +   s++; /* skip trailing quote */

 > bug, you must be thinking about using strchrnul().

Argh, indeed - Sorry about that.

 > Applied with small changes, thanks

Thanks!

-- 
Peter Korsgaard 
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


[PATCH] dmesg: add -r option to print raw format even when FEATURE_DMESG_PRETTY is enabled

2015-08-24 Thread Peter Korsgaard
Similar to the big util-linux version. For !DMESG_PRETTY, the option is 
accepted
(but ignored) as well, for compatibility reasons.

Signed-off-by: Peter Korsgaard pe...@korsgaard.com
---
 util-linux/dmesg.c | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/util-linux/dmesg.c b/util-linux/dmesg.c
index 81ba1c9..e543446 100644
--- a/util-linux/dmesg.c
+++ b/util-linux/dmesg.c
@@ -16,6 +16,7 @@
 //usage: \n   -c  Clear ring buffer after printing
 //usage: \n   -n LEVELSet console logging level
 //usage: \n   -s SIZE Buffer size
+//usage: \n   -r  Print raw message buffer
 
 #include sys/klog.h
 #include libbb.h
@@ -29,11 +30,12 @@ int dmesg_main(int argc UNUSED_PARAM, char **argv)
enum {
OPT_c = 1  0,
OPT_s = 1  1,
-   OPT_n = 1  2
+   OPT_n = 1  2,
+   OPT_r = 1  3
};
 
opt_complementary = s+:n+; /* numeric */
-   opts = getopt32(argv, cs:n:, len, level);
+   opts = getopt32(argv, cs:n:r, len, level);
if (opts  OPT_n) {
if (klogctl(8, NULL, (long) level))
bb_perror_msg_and_die(klogctl);
@@ -55,7 +57,7 @@ int dmesg_main(int argc UNUSED_PARAM, char **argv)
return EXIT_SUCCESS;
 
 
-   if (ENABLE_FEATURE_DMESG_PRETTY) {
+   if (ENABLE_FEATURE_DMESG_PRETTY  !(opts  OPT_r)) {
int last = '\n';
int in = 0;
 
-- 
2.1.4

___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


[PATCH] flash_eraseall: use full chip erase if possible

2014-05-05 Thread Peter Korsgaard
From: Peter Korsgaard pe...@korsgaard.com

Similar to the optimization in flashcp. On a Micron n25q128, this speeds up
flash erase from ~180s to ~120s, and allows userspace to do useful work
while erasing as the kernel driver returns as soon as the erase command is
sent to the chip.

bloat-o-meter busybox_unstripped{,_new}
function old new   delta
flash_eraseall_main  848 861 +13
--
(add/remove: 0/0 grow/shrink: 1/0 up/down: 13/0)   Total: 13 bytes

Signed-off-by: Peter Korsgaard pe...@korsgaard.com
---
 miscutils/flash_eraseall.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/miscutils/flash_eraseall.c b/miscutils/flash_eraseall.c
index bf9b739..34e2d68 100644
--- a/miscutils/flash_eraseall.c
+++ b/miscutils/flash_eraseall.c
@@ -138,8 +138,12 @@ int flash_eraseall_main(int argc UNUSED_PARAM, char **argv)
/* Don't want to destroy progress indicator by bb_error_msg's */
applet_name = xasprintf(\n%s: %s, applet_name, mtd_name);
 
+   /* optimization: if not verbose/badblock/jffs, erase in one go */
+   if (flags == OPTION_Q)
+   erase.length = meminfo.size;
+
for (erase.start = 0; erase.start  meminfo.size;
-erase.start += meminfo.erasesize) {
+erase.start += erase.length) {
if (!(flags  OPTION_N)) {
int ret;
loff_t offset = erase.start;
-- 
1.8.5.2

___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: [PATCH] ping: try SOCK_DGRAM if no root privileges

2014-01-09 Thread Peter Korsgaard
 Cathey, == Cathey, Jim jcat...@ciena.com writes:

  This is on a read-only root filesystem that is built the way we want it.
  (Squashfs, I believe.)  There aren't any, and can't be, any links to names
  we don't wish to give suid permission to.

And no writable storage anywhere (E.G. a tmpfs for /tmp or similar)
where you can add a handy symlink to the wrapper?

-- 
Bye, Peter Korsgaard
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: [PATCH] ar: read_num(): fix reading fields using the entire width

2013-09-11 Thread Peter Korsgaard
 walter == walter harms wha...@bfs.de writes:

 walter Am 10.09.2013 11:52, schrieb Peter Korsgaard:
  ar fields are fixed length text strings (padded with spaces). Ensure
  bb_strtou doesn't read past the field in case the full width is used.
  
  The fields are only read once, so the simplest/smallest solution to me
  seems to be to just pass the length to read_num() and then zero terminate
  the string before passing it to bb_strtou. This does mean that the fields
  MUST be read in reverse order, so some minor reshuffling was needed.
  
  -static unsigned read_num(const char *str, int base)
  +/* WARNING: Clobbers str[len], so fields must be read in reverse order! */
  +static unsigned read_num(char *str, int base, int len)
  {
  +   int err;
  +
  +   /* ar fields are fixed length text strings (padded with spaces).
  +* Ensure bb_strtou doesn't read past the field in case the full
  +* width is used. */
  +   str[len] = 0;
  +

 walter should this be len-1 ?

No. We want to terminate the string so we don't read past len ([0..len-1]).

-- 
Bye, Peter Korsgaard
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


[PATCH] ar: read_num(): fix reading fields using the entire width

2013-09-10 Thread Peter Korsgaard
ar fields are fixed length text strings (padded with spaces). Ensure
bb_strtou doesn't read past the field in case the full width is used.

The fields are only read once, so the simplest/smallest solution to me
seems to be to just pass the length to read_num() and then zero terminate
the string before passing it to bb_strtou. This does mean that the fields
MUST be read in reverse order, so some minor reshuffling was needed.

Bloat-o-meter:
function old new   delta
get_header_ar394 414 +20
read_num  29  36  +7
--
(add/remove: 0/0 grow/shrink: 2/0 up/down: 27/0)   Total: 27 bytes

Signed-off-by: Peter Korsgaard jac...@sunsite.dk
---
If we don't want the field order restriction we can alternatively save/restore
the trailing byte in read_num() with some minor size overhead (12 bytes).

 archival/libarchive/get_header_ar.c |   32 
 1 file changed, 20 insertions(+), 12 deletions(-)

diff --git a/archival/libarchive/get_header_ar.c 
b/archival/libarchive/get_header_ar.c
index 23c4124..5fad1e0 100644
--- a/archival/libarchive/get_header_ar.c
+++ b/archival/libarchive/get_header_ar.c
@@ -8,11 +8,19 @@
 #include bb_archive.h
 #include ar.h
 
-static unsigned read_num(const char *str, int base)
+/* WARNING: Clobbers str[len], so fields must be read in reverse order! */
+static unsigned read_num(char *str, int base, int len)
 {
+   int err;
+
+   /* ar fields are fixed length text strings (padded with spaces).
+* Ensure bb_strtou doesn't read past the field in case the full
+* width is used. */
+   str[len] = 0;
+
/* This code works because
 * on misformatted numbers bb_strtou returns all-ones */
-   int err = bb_strtou(str, NULL, base);
+   err = bb_strtou(str, NULL, base);
if (err == -1)
bb_error_msg_and_die(invalid ar header);
return err;
@@ -51,11 +59,8 @@ char FAST_FUNC get_header_ar(archive_handle_t 
*archive_handle)
if (ar.formatted.magic[0] != '`' || ar.formatted.magic[1] != '\n')
bb_error_msg_and_die(invalid ar header);
 
-   /* FIXME: more thorough routine would be in order here
-* (we have something like that in tar)
-* but for now we are lax. */
-   ar.formatted.magic[0] = '\0'; /* else 4G-2 file will have 
size=4294967294`\n... */
-   typed-size = size = read_num(ar.formatted.size, 10);
+   typed-size = size = read_num(ar.formatted.size, 10,
+ sizeof(ar.formatted.size));
 
/* special filenames have '/' as the first character */
if (ar.formatted.name[0] == '/') {
@@ -86,11 +91,13 @@ char FAST_FUNC get_header_ar(archive_handle_t 
*archive_handle)
/* Only size is always present, the rest may be missing in
 * long filename pseudo file. Thus we decode the rest
 * after dealing with long filename pseudo file.
+* Notice that the fields MUST be read in reverse order as
+* read_num() clobbers the next byte after the field!
 */
-   typed-mode = read_num(ar.formatted.mode, 8);
-   typed-mtime = read_num(ar.formatted.date, 10);
-   typed-uid = read_num(ar.formatted.uid, 10);
-   typed-gid = read_num(ar.formatted.gid, 10);
+   typed-mode = read_num(ar.formatted.mode, 8, sizeof(ar.formatted.mode));
+   typed-gid = read_num(ar.formatted.gid, 10, sizeof(ar.formatted.gid));
+   typed-uid = read_num(ar.formatted.uid, 10, sizeof(ar.formatted.uid));
+   typed-mtime = read_num(ar.formatted.date, 10, 
sizeof(ar.formatted.date));
 
 #if ENABLE_FEATURE_AR_LONG_FILENAMES
if (ar.formatted.name[0] == '/') {
@@ -98,7 +105,8 @@ char FAST_FUNC get_header_ar(archive_handle_t 
*archive_handle)
 
/* The number after the '/' indicates the offset in the ar data 
section
 * (saved in ar_long_names) that conatains the real filename */
-   long_offset = read_num(ar.formatted.name[1], 10);
+   long_offset = read_num(ar.formatted.name[1], 10,
+  sizeof(ar.formatted.name) - 1);
if (long_offset = ar_long_name_size) {
bb_error_msg_and_die(can't resolve long filename);
}
-- 
1.7.10.4

___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: Best way to use dhcpc / avahi without delaying other init scripts ?

2013-04-30 Thread Peter Korsgaard
 Mark == Mark Jackson mpfj-l...@newflow.co.uk writes:

 Mark I'm trying (and failing !!) to work out how best to use dhcpc and avahi
 Mark together.

 Mark Ideally I'd like udhcpc to start up, try to get a lease and, if the
 Mark lease request fails, use avahi to get a local ip address.

 Mark I have this working, but the dhcp request can taken some time (or even
 Mark fail if no dhcp server is present), and I am seeing delays of several
 Mark seconds before my other init scripts run.  I have dual ethernet ports
 Mark leading to about a 10seconf delay if no dhcp server is present.

 Mark To prevent other init scripts from being delayed, udhcpc should
 Mark instantly go into background mode (see [1]).

The normal approach is to use ifplugd (the busybox applet) to run the
ifup in the background when it detects a link, and not stall the rest of
the boot process.

-- 
Bye, Peter Korsgaard
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: Best way to use dhcpc / avahi without delaying other init scripts ?

2013-04-30 Thread Peter Korsgaard
 Mark == Mark Jackson mpfj-l...@newflow.co.uk writes:

 Mark Aha ... excellent.

 Mark Is there any docs / examples, or should it be (fairly) self-explanatory ?

You can look at the original (non busybox) version for docs:

http://0pointer.de/lennart/projects/ifplugd/

But ifplugd basically just calls /etc/ifplugd/ifplugd.action iface up|down
when there's a link change, so you can just write a small script to exec
ifup $1 / ifdown $1.

Ifplugd has a number of optional arguments to select the link status
detection method / polling interval / .. I use it with:

ifplugd -fI -u0 -d1 -i eth0

-- 
Bye, Peter Korsgaard
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: [PATCH] run-parts: add --exit-on-error | -e support

2013-02-28 Thread Peter Korsgaard
 Denys == Denys Vlasenko vda.li...@googlemail.com writes:

 Denys On Wed, Feb 27, 2013 at 2:14 PM, Peter Korsgaard jac...@sunsite.dk 
wrote:
  The big run-parts supports a handy --exit-on-error to stop execution on
  errors, so lets support it as well.
  
  Upstream doesn't have a short option for it, but I've used '-e' for busybox.
  
  Signed-off-by: Peter Korsgaard jac...@sunsite.dk

 Denys Applied, thanks!

Thanks. Your followup patch to drop the short options did something
funky to the dashes though. I'll send a patch to fix.

-- 
Bye, Peter Korsgaard
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


[PATCH] run-parts: correct usage after 1e43a381b2

2013-02-28 Thread Peter Korsgaard
Commit 1e43a381 (run-parts: stop providing incompatible short options)
replaced some of the dashes in the usage output with funky unicode versions,
causing garbled output on simple terminals.

Signed-off-by: Peter Korsgaard jac...@sunsite.dk
---
 debianutils/run_parts.c |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/debianutils/run_parts.c b/debianutils/run_parts.c
index 916aa90..2c2b032 100644
--- a/debianutils/run_parts.c
+++ b/debianutils/run_parts.c
@@ -25,16 +25,16 @@
 
 //usage:#define run_parts_trivial_usage
 //usage:   [-a ARG]... [-u UMASK] 
-//usage:   IF_FEATURE_RUN_PARTS_LONG_OPTIONS([--reverse] [--test] 
[-−exit−on−error] IF_FEATURE_RUN_PARTS_FANCY([--list] ))
+//usage:   IF_FEATURE_RUN_PARTS_LONG_OPTIONS([--reverse] [--test] 
[--exit-on-error] IF_FEATURE_RUN_PARTS_FANCY([--list] ))
 //usage:   DIRECTORY
 //usage:#define run_parts_full_usage \n\n
 //usage:   Run a bunch of scripts in DIRECTORY\n
 //usage: \n   -a ARG  Pass ARG as argument to scripts
 //usage: \n   -u UMASKSet UMASK before running scripts
 //usage:   IF_FEATURE_RUN_PARTS_LONG_OPTIONS(
-//usage: \n   -−reverse   Reverse execution order
+//usage: \n   --reverse   Reverse execution order
 //usage: \n   --test  Dry run
-//usage: \n   -−exit−on−error Exit if a script exits with non-zero
+//usage: \n   --exit-on-error Exit if a script exits with non-zero
 //usage:   IF_FEATURE_RUN_PARTS_FANCY(
 //usage: \n   --list  Print names of matching files even if 
they are not executable
 //usage:   )
-- 
1.7.10.4

___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox

[PATCH] run-parts: add --exit-on-error | -e support

2013-02-27 Thread Peter Korsgaard
The big run-parts supports a handy --exit-on-error to stop execution on
errors, so lets support it as well.

Upstream doesn't have a short option for it, but I've used '-e' for busybox.

Signed-off-by: Peter Korsgaard jac...@sunsite.dk
---
 debianutils/run_parts.c |   13 ++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/debianutils/run_parts.c b/debianutils/run_parts.c
index 005b304..6be83ed 100644
--- a/debianutils/run_parts.c
+++ b/debianutils/run_parts.c
@@ -27,10 +27,11 @@
  * -a ARG   argument. Pass ARG as an argument the program executed. It can
  *  be repeated to pass multiple arguments.
  * -u MASK  umask. Set the umask of the program executed to MASK.
+ * -e   exit as soon as a script returns with a non-zero exit code
  */
 
 //usage:#define run_parts_trivial_usage
-//usage:   [-tIF_FEATURE_RUN_PARTS_FANCY(l)] [-a ARG]... [-u MASK] 
DIRECTORY
+//usage:   [-tIF_FEATURE_RUN_PARTS_FANCY(l)] [-a ARG]... [-u MASK] 
[-e] DIRECTORY
 //usage:#define run_parts_full_usage \n\n
 //usage:   Run a bunch of scripts in DIRECTORY\n
 //usage: \n   -t  Dry run
@@ -39,6 +40,7 @@
 //usage:   )
 //usage: \n   -a ARG  Pass ARG as argument to programs
 //usage: \n   -u MASK Set umask to MASK before running programs
+//usage: \n   -e  Exit as soon as a script returns with a 
non-zero exit code
 //usage:
 //usage:#define run_parts_example_usage
 //usage:   $ run-parts -a start /etc/init.d\n
@@ -74,7 +76,8 @@ enum {
OPT_a = (1  1),
OPT_u = (1  2),
OPT_t = (1  3),
-   OPT_l = (1  4) * ENABLE_FEATURE_RUN_PARTS_FANCY,
+   OPT_e = (1  4),
+   OPT_l = (1  5) * ENABLE_FEATURE_RUN_PARTS_FANCY,
 };
 
 #if ENABLE_FEATURE_RUN_PARTS_FANCY
@@ -127,6 +130,7 @@ static const char runparts_longopts[] ALIGN1 =
arg\0 Required_argument a
umask\0   Required_argument u
test\0No_argument   t
+   exit-on-error\0 No_argument e
 #if ENABLE_FEATURE_RUN_PARTS_FANCY
list\0No_argument   l
reverse\0 No_argument   r
@@ -150,7 +154,7 @@ int run_parts_main(int argc UNUSED_PARAM, char **argv)
 #endif
/* We require exactly one argument: the directory name */
opt_complementary = =1:a::;
-   getopt32(argv, ra:u:tIF_FEATURE_RUN_PARTS_FANCY(l), arg_list, 
umask_p);
+   getopt32(argv, ra:u:teIF_FEATURE_RUN_PARTS_FANCY(l), arg_list, 
umask_p);
 
umask(xstrtou_range(umask_p, 8, 0, 0));
 
@@ -193,6 +197,9 @@ int run_parts_main(int argc UNUSED_PARAM, char **argv)
bb_perror_msg(can't execute '%s', name);
else /* ret  0 */
bb_error_msg(%s exited with code %d, name, ret  
0xff);
+
+   if (option_mask32  OPT_e)
+   xfunc_die();
}
 
return n;
-- 
1.7.10.4

___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: 1.21.0 is released

2013-01-22 Thread Peter Korsgaard
 Denys == Denys Vlasenko vda.li...@googlemail.com writes:

 Denys 21 January 2013 -- BusyBox 1.21.0 (unstable)
 Denys Sizes of busybox-1.20.2 and busybox-1.21.0 (with equivalent config,
 Denys static uclibc build):

Thanks. Notice that the patches link for 1.21.0 points to the 1.20.0
ones, which will probably cause some confusion.

-- 
Bye, Peter Korsgaard
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: [PATCH 3/3] syslogd: add option to log to Linux kernel printk buffer

2013-01-06 Thread Peter Korsgaard
 Mike == Mike Frysinger vap...@gentoo.org writes:

 Mike On Saturday 05 January 2013 18:07:19 Peter Korsgaard wrote:
  +#else
  +void kmsg_init(void);
  +void kmsg_cleanup(void);
  +void log_to_kmsg(int pri, const char *msg);
  +#endif /* FEATURE_KMSG_SYSLOG */
  ...
  +   if (ENABLE_FEATURE_KMSG_SYSLOG  (option_mask32  OPT_kmsg)) {
  +   log_to_kmsg(pri, msg);
  +   return;
  +   }

 Mike if you had the fallback funcs be static inline stubs, i think you
 Mike could delete the constant ENABLE_FEATURE_KMSG_SYSLOG checks.

True. I kept it similar to the ipcsyslog_*() ones. Do you want me to
send a followup patch to convert both?

-- 
Bye, Peter Korsgaard
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: [PATCH 3/3] syslogd: add option to log to Linux kernel printk buffer

2013-01-06 Thread Peter Korsgaard
 Mike == Mike Frysinger vap...@gentoo.org writes:

Hi,

 Mike On Saturday 05 January 2013 18:07:19 Peter Korsgaard wrote:
  Why invent our own shared memory circular buffer when the kernel has a
  perfectly fine one already?
  
  This can be used as a smaller/simpler alternative to the syslogd IPC
  support (as IPC shmem/klogd/logread aren't needed), while also allowing
  centralised logging of everything (kernel messages, userspace bootup and
  syslog) when used together with ttyprintk.
  
  Notice that kernel 3.5+ is needed to store syslog facility in printk
  buffer, otherwise only the priority is stored.

 Mike pushed since the patch follows existing style

Thanks!

What happened to Denys? I haven't seen any mails from him the last month
or so. There's quite a bit of new features waiting in git, and 1.20 is 9
months old, so a 1.21 release would be very nice.

-- 
Bye, Peter Korsgaard
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: [PATCH 1/3] dmesg: handle multi-char log levels

2013-01-05 Thread Peter Korsgaard
 Mike == Mike Frysinger vap...@gentoo.org writes:

Hi,

 Mike doesn't seem to work

 Mike allnoconfig + dmesg + dmesg pretty enabled

 Mike $ ./busybox dmesg
  Peer 86.165.245.161:29833/59757 unexpectedly shrunk window 
  2138950115:2138952928 (repaired)
  Peer 86.165.245.161:29833/59757 unexpectedly shrunk window 
  2138950115:2138952928 (repaired)
  Peer 86.165.245.161:29833/59757 unexpectedly shrunk window 
  2138950115:2138952928 (repaired)

 Mike $ strace -ewrite,syslog ./busybox dmesg /dev/null 
 Mike syslog(SYSLOG_ACTION_SIZE_BUFFER, 0, 0) = 131072
 Mike syslog(SYSLOG_ACTION_READ_ALL, 7Peer 86.165.245.161:29833/597..., 
131072) = 285
 Mike write(1, Peer 86.165.245.161:29833/59757..., 279) = 279

 Mike maybe the buf[++in] should be buf[in++]

Argh, indeed. So much for last minute fixups. Thanks for the review,
will fixup and resend.

-- 
Bye, Peter Korsgaard
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: [PATCH 3/3] syslogd: add option to log to Linux kernel printk buffer

2013-01-05 Thread Peter Korsgaard
 Mike == Mike Frysinger vap...@gentoo.org writes:

 Mike On Tuesday 18 December 2012 14:49:20 Peter Korsgaard wrote:
  +   /*
  + kernel  3.5 expects single char printk KERN_* priority prefix,
  + from 3.5 onwards the full syslog facility/priority format is supported
  +   */

 Mike comment style is slightly off.  needs '*' at the start of each line.

Ok, will fix.

  +   if (get_linux_version_code()  KERNEL_VERSION(3,5,0))
  +   pri = LOG_PRIMASK;
  +
  +   write(G.kmsgfd, G.printbuf, sprintf(G.printbuf, %d%s\n, pri, msg));

 Mike so this calls uname() every time we write() ?  can't this be
 Mike optimized a bit ?

Sure, I'll move it to an init function.

Thanks for review, will fixup and resend.

-- 
Bye, Peter Korsgaard
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


[PATCH 2/3] klogd: handle multi-char log levels

2013-01-05 Thread Peter Korsgaard
Since Linux 3.5 (7ff9554bb5: printk: convert byte-buffer to variable-length
record buffer), klog buffer can now contain log lines with multi-char
loglevel indicators ([0-9]+) - So use strtoul to parse it.

function old new   delta
klogd_main   490 525 +35
--
(add/remove: 0/0 grow/shrink: 1/0 up/down: 35/0)   Total: 35 bytes

Signed-off-by: Peter Korsgaard jac...@sunsite.dk
---
 sysklogd/klogd.c |7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/sysklogd/klogd.c b/sysklogd/klogd.c
index f59a155..432ded1 100644
--- a/sysklogd/klogd.c
+++ b/sysklogd/klogd.c
@@ -240,11 +240,8 @@ int klogd_main(int argc UNUSED_PARAM, char **argv)
priority = LOG_INFO;
if (*start == '') {
start++;
-   if (*start) {
-   /* kernel never generates multi-digit 
prios */
-   priority = (*start - '0');
-   start++;
-   }
+   if (*start)
+   priority = strtoul(start, start, 10);
if (*start == '')
start++;
}
-- 
1.7.10.4

___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


[PATCH 1/3] dmesg: handle multi-char log levels

2013-01-05 Thread Peter Korsgaard
Since Linux 3.5 (7ff9554bb5: printk: convert byte-buffer to variable-length
record buffer), klog buffer can now contain log lines with multi-char
loglevel indicators ([0-9]+) - So we can no longer just skip 3 bytes.

Instead skip past the terminating '' like util-linux does.

function old new   delta
dmesg_main   266 280 +13
--
(add/remove: 0/0 grow/shrink: 1/0 up/down: 13/0)   Total: 13 bytes

Signed-off-by: Peter Korsgaard jac...@sunsite.dk
---
 util-linux/dmesg.c |   13 ++---
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/util-linux/dmesg.c b/util-linux/dmesg.c
index 6505da5..81ba1c9 100644
--- a/util-linux/dmesg.c
+++ b/util-linux/dmesg.c
@@ -59,16 +59,15 @@ int dmesg_main(int argc UNUSED_PARAM, char **argv)
int last = '\n';
int in = 0;
 
-   /* Skip # at the start of lines */
+   /* Skip [0-9]+ at the start of lines */
while (1) {
if (last == '\n'  buf[in] == '') {
-   in += 3;
-   if (in = len)
-   break;
+   while (buf[in++] != ''  in  len)
+   ;
+   } else {
+   last = buf[in++];
+   putchar(last);
}
-   last = buf[in];
-   putchar(last);
-   in++;
if (in = len)
break;
}
-- 
1.7.10.4

___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


[PATCH 3/3] syslogd: add option to log to Linux kernel printk buffer

2013-01-05 Thread Peter Korsgaard
Why invent our own shared memory circular buffer when the kernel has a
perfectly fine one already?

This can be used as a smaller/simpler alternative to the syslogd IPC support
(as IPC shmem/klogd/logread aren't needed), while also allowing centralised
logging of everything (kernel messages, userspace bootup and syslog)
when used together with ttyprintk.

Notice that kernel 3.5+ is needed to store syslog facility in printk buffer,
otherwise only the priority is stored.

bloat-o-meter compared to IPC+klogd+logread:
function old new   delta
get_linux_version_code -  84 +84
lbb_prepare   25  90 +65
applet_nameofs 6   -  -6
static.stdout@@GLIBC_2 8   -  -8
applet_names  23   9 -14
bb_msg_standard_output16   - -16
init_sem  18   - -18
xatoull_range 19   - -19
overlapping_strcpy21   - -21
init_data 56  32 -24
applet_main   24   - -24
main 124  99 -25
full_write2_str   26   - -26
error_exit26   - -26
bb_basename   30   - -30
sem_up32   - -32
interrupted   35   - -35
fflush_stdout_and_exit38   - -38
bb_banner 46   - -46
find_applet_by_name   59   - -59
bb_signals_recursive_norestart90   - -90
run_applet_no_and_exit   104   --104
timestamp_and_log651 523-128
syslogd_main 798 581-217
xstrtoull_range_sfx  267   --267
run_applet_and_exit  432   --432
klogd_main   490   --490
logread_main 508   --508
.rodata 1870 937-933
bb_common_bufsiz1   8193   -   -8193
--
(add/remove: 2/26 grow/shrink: 1/6 up/down: 149/-11829)Total: -11680 bytes

Signed-off-by: Peter Korsgaard jac...@sunsite.dk
---
 sysklogd/Config.src |   16 ++
 sysklogd/syslogd.c  |   61 ++-
 2 files changed, 76 insertions(+), 1 deletion(-)

diff --git a/sysklogd/Config.src b/sysklogd/Config.src
index b7a494e..fcf9930 100644
--- a/sysklogd/Config.src
+++ b/sysklogd/Config.src
@@ -113,6 +113,19 @@ config FEATURE_LOGREAD_REDUCED_LOCKING
  from circular buffer, minimizing semaphore
  contention at some minor memory expense.
 
+config FEATURE_KMSG_SYSLOG
+   bool Linux kernel printk buffer support
+   default y
+   depends on SYSLOGD
+   select PLATFORM_LINUX
+   help
+ When you enable this feature, the syslogd utility will
+ write system log message to the Linux kernel's printk buffer.
+ This can be used as a smaller alternative to the syslogd IPC
+ support, as klogd and logread aren't needed.
+
+ NOTICE: Syslog facilities in log entries needs kernel 3.5+.
+
 config KLOGD
bool klogd
default y
@@ -123,6 +136,9 @@ config KLOGD
  you wish to record the messages produced by the kernel,
  you should enable this option.
 
+comment klogd should not be used together with syslog to kernel printk buffer
+   depends on KLOGD  FEATURE_KMSG_SYSLOG
+
 config FEATURE_KLOGD_KLOGCTL
bool Use the klogctl() interface
default y
diff --git a/sysklogd/syslogd.c b/sysklogd/syslogd.c
index 5854bcd..ad54e22 100644
--- a/sysklogd/syslogd.c
+++ b/sysklogd/syslogd.c
@@ -43,6 +43,9 @@
 //usage: \n   -f FILE Use FILE as config 
(default:/etc/syslog.conf)
 //usage:   )
 /* //usage:  \n   -m MIN  Minutes between MARK lines (default:20, 
0=off) */
+//usage:   IF_FEATURE_KMSG_SYSLOG(
+//usage: \n   -K  Log to kernel printk buffer (use dmesg 
to read it)
+//usage:   )
 //usage:
 //usage:#define syslogd_example_usage
 //usage:   $ syslogd -R masterlog:514\n
@@ -140,6 +143,10

v2: Kernel printk buffer handling updates

2013-01-05 Thread Peter Korsgaard
Hi,

Linux 3.5 extended the /dev/kmsg interface for injecting log messages
from user space into the kernel printk buffer to accept (and store) the
full syslog facility/priority value.

The following patch series updates dmesg and klogd to handle this, and
adds an alternative to the syslogd ipc support which uses it.

Changes since v1:
- Rebased against master
- Reworked based on Mike's feedback:
  - Fixed off-by-one in dmesg
  - Move kernel version check to kmsg_init()
- Added kmsg_cleanup() similar to ipcsyslog_cleanup()

--
Bye, Peter Korsgaard
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: Kernel printk buffer handling updates

2013-01-04 Thread Peter Korsgaard
On Tue, Dec 18, 2012 at 8:49 PM, Peter Korsgaard jac...@sunsite.dk wrote:
 Hi,

 Linux 3.5 extended the /dev/kmsg interface for injecting log messages
 from user space into the kernel printk buffer to accept (and store) the
 full syslog facility/priority value.

 The following patch series updates dmesg and klogd to handle this, and
 adds an alternative to the syslogd ipc support which uses it.

Ping?

-- 
Bye, Peter Korsgaard
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: [PATCH 2/4] gstreamer: port to gstreamer-1.0

2012-12-19 Thread Peter Korsgaard
 bogdan == bogdan  bog...@nimblex.org writes:

 bogdan From: Bogdan Radulescu bog...@nimblex.net
 bogdan Initial commit of updated gstreamer + plugins which compile

Thanks. I wonder if we want to completely drop 0.10 already, or provide
both 0.10 and 1.0 (E.G. add a BR2_PACKAGE_GSTREAMER_10 package)? Arnout,
you mentioned something about a gst-fsl package, which presumably only
works with gstreamer 0.1?

-- 
Bye, Peter Korsgaard
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: [PATCH 2/4] gstreamer: port to gstreamer-1.0

2012-12-19 Thread Peter Korsgaard
 bogdan == bogdan  bog...@nimblex.org writes:

 bogdan From: Bogdan Radulescu bog...@nimblex.net
 bogdan Initial commit of updated gstreamer + plugins which compile

Oh and btw - You're on the wrong mailing list ;)

Could you please resend the series to buildr...@uclibc.org - Thanks.

-- 
Bye, Peter Korsgaard
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: [PATCH 2/4] gstreamer: port to gstreamer-1.0

2012-12-19 Thread Peter Korsgaard
 Tito == Tito  farmat...@tiscali.it writes:

Hi,

 Tito Are sure this is busybox stuff? ;-)

Yeah, I also just noticed ;)

-- 
Bye, Peter Korsgaard
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


[PATCH 2/3] klogd: handle multi-char log levels

2012-12-18 Thread Peter Korsgaard
Since Linux 3.5 (7ff9554bb5: printk: convert byte-buffer to variable-length
record buffer), klog buffer can now contain log lines with multi-char
loglevel indicators ([0-9]+) - So use strtoul to parse it.

function old new   delta
klogd_main   490 525 +35
--
(add/remove: 0/0 grow/shrink: 1/0 up/down: 35/0)   Total: 35 bytes

Signed-off-by: Peter Korsgaard jac...@sunsite.dk
---
 sysklogd/klogd.c |7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/sysklogd/klogd.c b/sysklogd/klogd.c
index efa0e53..fb71557 100644
--- a/sysklogd/klogd.c
+++ b/sysklogd/klogd.c
@@ -238,11 +238,8 @@ int klogd_main(int argc UNUSED_PARAM, char **argv)
priority = LOG_INFO;
if (*start == '') {
start++;
-   if (*start) {
-   /* kernel never generates multi-digit 
prios */
-   priority = (*start - '0');
-   start++;
-   }
+   if (*start)
+   priority = strtoul(start, start, 10);
if (*start == '')
start++;
}
-- 
1.7.10.4

___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


[PATCH 3/3] syslogd: add option to log to Linux kernel printk buffer

2012-12-18 Thread Peter Korsgaard
Why invent our own shared memory circular buffer when the kernel has a
perfectly fine one already?

This can be used as a smaller/simpler alternative to the syslogd IPC support
(as IPC shmem/klogd/logread aren't needed), while also allowing centralised
logging of everything (kernel messages, userspace bootup and syslog)
when used together with ttyprintk.

Notice that kernel 3.5+ is needed to store syslog facility in printk buffer,
otherwise only the priority is stored.

bloat-o-meter compared to IPC+klogd+logread:
function old new   delta
get_linux_version_code -  84 +84
applet_nameofs 8   4  -4
static.stdout@@GLIBC_2 8   -  -8
applet_names  29  15 -14
bb_msg_standard_output16   - -16
applet_main   32  16 -16
init_sem  18   - -18
xatoull_range 19   - -19
overlapping_strcpy21   - -21
error_exit26   - -26
sem_up32   - -32
init_data 56  24 -32
interrupted   35   - -35
fflush_stdout_and_exit38   - -38
bb_signals_recursive_norestart90   - -90
timestamp_and_log651 546-105
syslogd_main 798 555-243
xstrtoull_range_sfx  267   --267
.rodata 18981577-321
logread_main 508   --508
klogd_main   525   --525
bb_common_bufsiz1   8193   -   -8193
--
(add/remove: 2/17 grow/shrink: 0/7 up/down: 84/-10531) Total: -10447 bytes

Signed-off-by: Peter Korsgaard jac...@sunsite.dk
---
 sysklogd/Config.src |   16 
 sysklogd/syslogd.c  |   39 ++-
 2 files changed, 54 insertions(+), 1 deletion(-)

diff --git a/sysklogd/Config.src b/sysklogd/Config.src
index b7a494e..fcf9930 100644
--- a/sysklogd/Config.src
+++ b/sysklogd/Config.src
@@ -113,6 +113,19 @@ config FEATURE_LOGREAD_REDUCED_LOCKING
  from circular buffer, minimizing semaphore
  contention at some minor memory expense.
 
+config FEATURE_KMSG_SYSLOG
+   bool Linux kernel printk buffer support
+   default y
+   depends on SYSLOGD
+   select PLATFORM_LINUX
+   help
+ When you enable this feature, the syslogd utility will
+ write system log message to the Linux kernel's printk buffer.
+ This can be used as a smaller alternative to the syslogd IPC
+ support, as klogd and logread aren't needed.
+
+ NOTICE: Syslog facilities in log entries needs kernel 3.5+.
+
 config KLOGD
bool klogd
default y
@@ -123,6 +136,9 @@ config KLOGD
  you wish to record the messages produced by the kernel,
  you should enable this option.
 
+comment klogd should not be used together with syslog to kernel printk buffer
+   depends on KLOGD  FEATURE_KMSG_SYSLOG
+
 config FEATURE_KLOGD_KLOGCTL
bool Use the klogctl() interface
default y
diff --git a/sysklogd/syslogd.c b/sysklogd/syslogd.c
index fc380d9..f1d4136 100644
--- a/sysklogd/syslogd.c
+++ b/sysklogd/syslogd.c
@@ -43,6 +43,9 @@
 //usage: \n   -f FILE Use FILE as config 
(default:/etc/syslog.conf)
 //usage:   )
 /* //usage:  \n   -m MIN  Minutes between MARK lines (default:20, 
0=off) */
+//usage:   IF_FEATURE_KMSG_SYSLOG(
+//usage: \n   -K  Log to kernel printk buffer (use dmesg 
to read it)
+//usage:   )
 //usage:
 //usage:#define syslogd_example_usage
 //usage:   $ syslogd -R masterlog:514\n
@@ -140,6 +143,9 @@ IF_FEATURE_IPC_SYSLOG( \
 ) \
 IF_FEATURE_SYSLOGD_CFG( \
logRule_t *log_rules; \
+) \
+IF_FEATURE_KMSG_SYSLOG( \
+   int kmsgfd; \
 )
 
 struct init_globals {
@@ -212,6 +218,7 @@ enum {
IF_FEATURE_IPC_SYSLOG(OPTBIT_circularlog,)  // -C
IF_FEATURE_SYSLOGD_DUP(   OPTBIT_dup,)  // -D
IF_FEATURE_SYSLOGD_CFG(   OPTBIT_cfg,)  // -f
+   IF_FEATURE_KMSG_SYSLOG(   OPTBIT_kmsg   ,)  // -K
 
OPT_mark= 1  OPTBIT_mark,
OPT_nofork  = 1  OPTBIT_nofork  ,
@@ -225,6 +232,8 @@ enum {
OPT_circularlog

[PATCH 1/3] dmesg: handle multi-char log levels

2012-12-18 Thread Peter Korsgaard
Since Linux 3.5 (7ff9554bb5: printk: convert byte-buffer to variable-length
record buffer), klog buffer can now contain log lines with multi-char
loglevel indicators ([0-9]+) - So we can no longer just skip 3 bytes.

Instead skip up to the terminating '' like util-linux does.

function old new   delta
dmesg_main   266 280 +14
--
(add/remove: 0/0 grow/shrink: 1/0 up/down: 14/0)   Total: 14 bytes

Signed-off-by: Peter Korsgaard jac...@sunsite.dk
---
 util-linux/dmesg.c |   13 ++---
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/util-linux/dmesg.c b/util-linux/dmesg.c
index 6505da5..8641ed6 100644
--- a/util-linux/dmesg.c
+++ b/util-linux/dmesg.c
@@ -59,16 +59,15 @@ int dmesg_main(int argc UNUSED_PARAM, char **argv)
int last = '\n';
int in = 0;
 
-   /* Skip # at the start of lines */
+   /* Skip [0-9]+ at the start of lines */
while (1) {
if (last == '\n'  buf[in] == '') {
-   in += 3;
-   if (in = len)
-   break;
+   while (buf[++in] != ''  in  len)
+   ;
+   } else {
+   last = buf[in++];
+   putchar(last);
}
-   last = buf[in];
-   putchar(last);
-   in++;
if (in = len)
break;
}
-- 
1.7.10.4

___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: [PATCH 1/2] fbsplash: fix regression from e4fa7b7

2012-10-15 Thread Peter Korsgaard
 Peter == Peter Korsgaard jac...@sunsite.dk writes:

Hi Denys,

It seems this never got committed?

 Timo == Timo Teräs timo.te...@iki.fi writes:
 Timo commit e4fa7b7 (limit progress bar flicker) made the progress bar
 Timo counter unsigned causing i=0 to never come true.

 Peter s/true/false/.

 Peter With that changed:
 Peter Acked-by: Peter Korsgaard jac...@sunsite.dk

 Peter Notice: This bug was not in the patch I submitted, but got introduced in
 Peter the size optimization Denys did while committing:

 Peter http://lists.busybox.net/pipermail/busybox/2011-October/076789.html

-- 
Bye, Peter Korsgaard
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox

Re: [PATCH 1/2] fbsplash: fix regression from e4fa7b7

2012-09-20 Thread Peter Korsgaard
 Timo == Timo Teräs timo.te...@iki.fi writes:

 Timo commit e4fa7b7 (limit progress bar flicker) made the progress bar
 Timo counter unsigned causing i=0 to never come true.

s/true/false/.

With that changed:
Acked-by: Peter Korsgaard jac...@sunsite.dk

Notice: This bug was not in the patch I submitted, but got introduced in
the size optimization Denys did while committing:

http://lists.busybox.net/pipermail/busybox/2011-October/076789.html

-- 
Bye, Peter Korsgaard
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox

Re: Bug in busybox sed - this one is real

2012-06-04 Thread Peter Korsgaard
 Sedat == Sedat Dilek sedat.di...@googlemail.com writes:

 Sedat [1] does NOT show recent commits to busybox in Git-Web whereas
 Sedat buildroot commits are displayed.

 Sedat Can you or an admin please check this?

Yes, there's something funky going on - We have it as well with
buildroot if you forget the trailing '/' - E.G. compare

http://git.buildroot.net/buildroot/ vs
http://git.buildroot.net/buildroot

Neither I or the osuosl guys have been able to figure out what the
problem is though :/

-- 
Bye, Peter Korsgaard
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: [PATCH] ubi_tools: fix for kernel headers released with undefined __packed macro

2012-03-02 Thread Peter Korsgaard
 Rob == Rob Walker rwal...@rwalker.com writes:

 Rob See: https://lkml.org/lkml/2011/6/22/25
 Rob Temporary hack until ubi-user.h is correctly installed without
 Rob __packed, or kernel guys correct this another way (releasing a
 Rob compiler header??).

FYI, this is only a problem for Linux 3.0.x (the only release having
__packed before headers_install.pl was taught to convert it).

This is the commit fixing it:

http://git.buildroot.net/buildroot/tree/toolchain/kernel-headers/linux-3.0.23-headers_install-fix-__packed-in-exported-kernel-head.patch

You could argue this should have been fixed in one of the 3.0.x stable
releases, but that didn't happen.

-- 
Bye, Peter Korsgaard
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: devtmpfs and mdev

2012-02-02 Thread Peter Korsgaard
 Natanael == Natanael Copa natanael.c...@gmail.com writes:

Hi,

 Natanael I have got a new challenge with udev. Since version 176 devtmpfs is
 Natanael *required* in kernel[1]. As I understand this will not work very well
 Natanael with mdev, our primary /dev handler.

Is that a problem? Devtmpfs doesn't add much bloat to the kernel and is
very nice.

 Natanael Unfortunally, if you want/need hotplugging in xorg today you don't
 Natanael have any choices.

 Natanael I wonder if it would be difficult to add devtmpfs support to
 Natanael mdev? As I understand, mdev will no longer need do mknod, but
 Natanael will only need to set permissions and create symlinks. Maybe
 Natanael also remove device nodes.

Yes, if we change the permissions / rename, then we afaik need to remove
the nodes ourselves.

What exactly is the problem with using mdev together with devtmpfs? (I
always use pure devtmpfs on the embedded devices, but don't right away
see what the problem is).

-- 
Bye, Peter Korsgaard
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: devtmpfs and mdev

2012-02-02 Thread Peter Korsgaard
 Natanael == Natanael Copa natanael.c...@gmail.com writes:

Hi,

  What exactly is the problem with using mdev together with devtmpfs? (I
  always use pure devtmpfs on the embedded devices, but don't right away
  see what the problem is).

 Natanael Overlapping functionallity? I googled a bit and got the impression
 Natanael that they don't work together?

 Natanael Maybe I was wrong.

We're atleast doing devtmpfs together with mdev in Buildroot, but as I
mentioned it isn't a configuration that I use personally.

-- 
Bye, Peter Korsgaard
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: devtmpfs and mdev

2012-02-02 Thread Peter Korsgaard
 Laurent == Laurent Bercot ska-dietl...@skarnet.org writes:

Hi,

 Laurent  Apart from the silly idea that init is sacred and can't be
 Laurent replaced with a script, there is basically no good technical
 Laurent reason to use devtmpfs;

Ehh, yes - For embedded (root only) systems where the default root:root
660 permissions / names are enough, you can get rid of mdev/udev and
still not have to mess around with static device nodes in your rootfs.

-- 
Bye, Peter Korsgaard
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: [SOLVED] busybox sh does not run and cannot login when eabi enable d

2012-01-16 Thread Peter Korsgaard
 cytan == cytan299@netzero com cytan...@netzero.com writes:

 cytan Unbelievable: The problem was in uClibc config. FPU must *not* be 
 cytan Here's the uClibc config snippet:

 cytan UCLIBC_HAS_FLOATS=y
 cytan # UCLIBC_HAS_FPU is not set
 cytan UCLIBC_HAS_SOFT_FLOAT=y

Why is that hard to understand? If you target doesn't have a FPU (and
you don't build your kernel with FPU emulation) things are bound to go
wrong when you configure uClibc to use one.

-- 
Bye, Peter Korsgaard
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: [PATCHv2] httpd: don't drop QUERY_STRING when /cgi-bin/index.cgi is used

2011-12-19 Thread Peter Korsgaard
 Denys == Denys Vlasenko vda.li...@googlemail.com writes:

Hi,

 Denys Both look sensible to me. Pick whatever solution you like.

I'll go for REQUEST_URI then, as it seems most standard and we already
set it.

 Denys Please change networking/httpd_indexcgi.c correspondingly (and test it).

Ok, I'll send an updated patch shortly.

-- 
Bye, Peter Korsgaard
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


[PATCHv3] httpd: don't drop/abuse QUERY_STRING when /cgi-bin/index.cgi is used

2011-12-19 Thread Peter Korsgaard
The memory pointed to by g_query gets overwritten when the index_page
is used, causing URL arguments to get dropped when we fall back to
/cgi-bin/index.cgi. QUERY_STRING if furthermore hijacked to pass the
original (DIR/) URI to the CGI script, which is quite non-standard
and disallows use of URL arguments.

Fix it by instead passing the original URI in REQUEST_URI, and make a
deep copy of the URL arguments before they get overwritten, if needed.

Also update httpd_indexcgi to take the directory location from
REQUEST_URI instead.

function old new   delta
handle_incoming_and_exit28142829 +15
send_cgi_and_exit983 986  +3
--
(add/remove: 0/0 grow/shrink: 2/0 up/down: 18/0)   Total: 18 bytes

Signed-off-by: Peter Korsgaard jac...@sunsite.dk
---
 networking/httpd.c  |   27 +++
 networking/httpd_indexcgi.c |   25 +++--
 2 files changed, 34 insertions(+), 18 deletions(-)

diff --git a/networking/httpd.c b/networking/httpd.c
index e9cd213..b500307 100644
--- a/networking/httpd.c
+++ b/networking/httpd.c
@@ -1265,18 +1265,21 @@ static void setenv1(const char *name, const char *value)
  *
  * Parameters:
  * const char *url  The requested URL (with leading /).
+ * const char *orig_uri The original URI before rewriting (if any)
  * int post_len Length of the POST body.
  * const char *cookie   For set HTTP_COOKIE.
  * const char *content_type For set CONTENT_TYPE.
  */
 static void send_cgi_and_exit(
const char *url,
+   const char *orig_uri,
const char *request,
int post_len,
const char *cookie,
const char *content_type) NORETURN;
 static void send_cgi_and_exit(
const char *url,
+   const char *orig_uri,
const char *request,
int post_len,
const char *cookie,
@@ -1314,9 +1317,9 @@ static void send_cgi_and_exit(
setenv1(PATH_INFO, script);   /* set to /PATH_INFO or  */
setenv1(REQUEST_METHOD, request);
if (g_query) {
-   putenv(xasprintf(%s=%s?%s, REQUEST_URI, url, g_query));
+   putenv(xasprintf(%s=%s?%s, REQUEST_URI, orig_uri, g_query));
} else {
-   setenv1(REQUEST_URI, url);
+   setenv1(REQUEST_URI, orig_uri);
}
if (script != NULL)
*script = '\0'; /* cut off /PATH_INFO */
@@ -2248,12 +2251,21 @@ static void handle_incoming_and_exit(const 
len_and_sockaddr *fromAddr)
/* protect listing cgi-bin/ */
send_headers_and_exit(HTTP_FORBIDDEN);
}
-   send_cgi_and_exit(urlcopy, prequest, length, cookie, 
content_type);
+   send_cgi_and_exit(urlcopy, urlcopy, prequest, length, cookie, 
content_type);
}
 #endif
 
-   if (urlp[-1] == '/')
+   if (urlp[-1] == '/') {
+   /* when index_page string is appended to dir/ URL, it 
overwrites
+  the query string. If we fallback to call /cgi-bin/index.cgi,
+  query string would be lost and not available to the CGI.
+  Work around it by making a deep copy instead.
+   */
+   if (ENABLE_FEATURE_HTTPD_CGI)
+   g_query = xstrdup(g_query);
+
strcpy(urlp, index_page);
+   }
if (stat(tptr, sb) == 0) {
 #if ENABLE_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR
char *suffix = strrchr(tptr, '.');
@@ -2261,7 +2273,7 @@ static void handle_incoming_and_exit(const 
len_and_sockaddr *fromAddr)
Htaccess *cur;
for (cur = script_i; cur; cur = cur-next) {
if (strcmp(cur-before_colon + 1, suffix) == 0) 
{
-   send_cgi_and_exit(urlcopy, prequest, 
length, cookie, content_type);
+   send_cgi_and_exit(urlcopy, urlcopy, 
prequest, length, cookie, content_type);
}
}
}
@@ -2274,9 +2286,8 @@ static void handle_incoming_and_exit(const 
len_and_sockaddr *fromAddr)
/* It's a dir URL and there is no index.html
 * Try cgi-bin/index.cgi */
if (access(/cgi-bin/index.cgi+1, X_OK) == 0) {
-   urlp[0] = '\0';
-   g_query = urlcopy;
-   send_cgi_and_exit(/cgi-bin/index.cgi, prequest, 
length, cookie, content_type);
+   urlp[0] = '\0'; /* remove index_page */
+   send_cgi_and_exit(/cgi-bin/index.cgi, urlcopy, 
prequest

Re: [PATCHv3] httpd: don't drop/abuse QUERY_STRING when /cgi-bin/index.cgi is used

2011-12-19 Thread Peter Korsgaard
 Denys == Denys Vlasenko vda.li...@googlemail.com writes:

Hi,

  The memory pointed to by g_query gets overwritten when the index_page
  is used, causing URL arguments to get dropped when we fall back to
  /cgi-bin/index.cgi. QUERY_STRING if furthermore hijacked to pass the
  original (DIR/) URI to the CGI script, which is quite non-standard
  and disallows use of URL arguments.
  
  Fix it by instead passing the original URI in REQUEST_URI, and make a
  deep copy of the URL arguments before they get overwritten, if needed.
  
  Also update httpd_indexcgi to take the directory location from
  REQUEST_URI instead.

 Denys Applied, thanks!

Thanks. Any reason why you dropped most of my commit message? Don't you
use 'git am -s' to apply it?

-- 
Bye, Peter Korsgaard
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: bug in busybox with http redirects

2011-12-18 Thread Peter Korsgaard
 Denys == Denys Vlasenko vda.li...@googlemail.com writes:

Hi,

  so looks like wget does something strange with the host header on
  the redirection.

 Denys Should be fixed by commit 93b4a605263612cf32ad9de746a4fafaf4515115

Something for fixes-1.19.3?

-- 
Bye, Peter Korsgaard
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: [PATCHv2] httpd: don't drop QUERY_STRING when /cgi-bin/index.cgi is used

2011-12-18 Thread Peter Korsgaard
 Denys == Denys Vlasenko vda.li...@googlemail.com writes:

Hi,

 Denys I propose to move it to the site of aforementioned appending:

 Denys This way, it's more obvoius, and only done when needed (= only
 Denys for dirs).

Yes, that makes sense.

 Denys However, there is another problem. Check
 Denys /usr/srcdevel/bbox/fix/busybox.3/networking/httpd_indexcgi.c
 Denys See how it is determining _which directory_ to list.
 Denys It looks at $QUERY_STRING.

 Denys IOW: g_query = urlcopy; assignment you nuked wasn't a quick fix
 Denys for query string is overwritten bug. It was a way to give
 Denys cgi-bin/index.cgi a way to find the directory it is meant to list.

Ahh, I didn't know that. I do find the
pass-original-request-in-QUERY_STRING quite nonstandard and limiting
(E.G. it means you cannot easily support Apache-style selectable
directory sorting by DIR/?..). I personally don't use the
/cgi-bin/index.cgi fallback for directory listing, but simply to have a
nicer looking URL for the main (CGI based) webpage, without having to
mess with a dummy index.html and a HTML level redirect.

I think a better approach would be to let REQUEST_URI be the original
(DIR/) location requested, and then leave QUERY_STRING for arguments
like normal. Alternatively we could add SCRIPT_URL, which seems to be
what Apache's mod_rewrite provides:

https://httpd.apache.org/docs/current/mod/mod_rewrite.html#EnvVar

Let me know what you prefer and I'll cook up a patch to add an
additional orig_uri argument to send_cgi_and_exit() and use it to set
the environment variable correctly.

-- 
Bye, Peter Korsgaard
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: [PATCHv2] httpd: don't drop QUERY_STRING when /cgi-bin/index.cgi is used

2011-12-17 Thread Peter Korsgaard
 walter == walter harms wha...@bfs.de writes:

Hi,

  +#if ENABLE_FEATURE_HTTPD_CGI
  +   /* when index_page string is appended to dir/ URL, it 
  overwrites
  +  the query string. If we fallback to call /cgi-bin/index.cgi,
  +  query string would be lost and not available to the CGI.
  +  Work around it by making a deep copy instead.
  +   */
  +   g_query = xstrdup(tptr);
  +#else
  g_query = tptr;
  +#endif
  }
  

 walter Would it hurt to call xstrdup() all time ?
 walter that would save us from the #if
 walter and simplify to code.

True. query strings are fairly short, so it probably wouldn't be
significant (and only for the few people using httpd without CGI
support) - Denys, what do you say?

-- 
Bye, Peter Korsgaard
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: [PATCH] httpd: don't drop QUERY_STRING when /cgi-bin/index.cgi is used

2011-12-16 Thread Peter Korsgaard
 Denys == Denys Vlasenko vda.li...@googlemail.com writes:

  The memory pointed to by g_query gets overwritten when the index_page
  is used,

 Denys Where exactly this happens? Here? -

 Denys if (urlp[-1] == '/')
 Denys strcpy(urlp, index_page);

Yes, If you use the /?blah - /cgi-bin/index.cgi?blah translation, the
URL arguments gets overwritten by the first /?blah - /index_page
translation.

You probably noticed it when you added it back in 2006, as you updated
urlp / g_query to set it to the empty string rather than ndex.html.

 Denys Better comment?

 Denys When index.html string is appended to ...dir/ URL, it writes over
 Denys query string. If we later call index.cgi, query string would be lost
 Denys and not available to that CGI. ...

Ok, will update and resend.

  +   g_query = alloca(strlen(tptr) + 1);
  +   strcpy((char *)g_query, tptr);
  +#else
  g_query = tptr;
  +#endif

 Denys Let's just use xstrcpy().

I don't see any xstrcpy in busybox. Did you perhaps mean xstrdup or
strdupa?

-- 
Bye, Peter Korsgaard
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: [PATCH] httpd: don't drop QUERY_STRING when /cgi-bin/index.cgi is used

2011-12-16 Thread Peter Korsgaard
 Denys == Denys Vlasenko vda.li...@googlemail.com writes:

   Denys Let's just use xstrcpy().
  
  I don't see any xstrcpy in busybox. Did you perhaps mean xstrdup or
  strdupa?

 Denys Oops. I meant xstrdup.

But then we would have to take care to not leak memory, which is a bit
complicated because of send_file_and_exit() / send_cgi_and_exit(). What
is the reason you don't like alloca / strdupa?

-- 
Bye, Peter Korsgaard
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox

[PATCHv2] httpd: don't drop QUERY_STRING when /cgi-bin/index.cgi is used

2011-12-16 Thread Peter Korsgaard
The memory pointed to by g_query gets overwritten when the index_page
is used, causing  URL arguments to get dropped when we fall back to
/cgi-bin/index.cgi.

Work around it by making g_query a deep copy of urlp when CGI support
is enabled, rather than silently dropping them.

Signed-off-by: Peter Korsgaard jac...@sunsite.dk
---
 Changes since v1:
 - Use xstrdup and extend comment as suggested by Denys.

 networking/httpd.c |   11 +--
 1 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/networking/httpd.c b/networking/httpd.c
index f52785b..61e06ff 100644
--- a/networking/httpd.c
+++ b/networking/httpd.c
@@ -1996,7 +1996,16 @@ static void handle_incoming_and_exit(const 
len_and_sockaddr *fromAddr)
tptr = strchr(urlcopy, '?');
if (tptr) {
*tptr++ = '\0';
+#if ENABLE_FEATURE_HTTPD_CGI
+   /* when index_page string is appended to dir/ URL, it 
overwrites
+  the query string. If we fallback to call /cgi-bin/index.cgi,
+  query string would be lost and not available to the CGI.
+  Work around it by making a deep copy instead.
+   */
+   g_query = xstrdup(tptr);
+#else
g_query = tptr;
+#endif
}
 
/* Decode URL escape sequences */
@@ -2271,8 +2280,6 @@ static void handle_incoming_and_exit(const 
len_and_sockaddr *fromAddr)
/* It's a dir URL and there is no index.html
 * Try cgi-bin/index.cgi */
if (access(/cgi-bin/index.cgi+1, X_OK) == 0) {
-   urlp[0] = '\0';
-   g_query = urlcopy;
send_cgi_and_exit(/cgi-bin/index.cgi, prequest, 
length, cookie, content_type);
}
}
-- 
1.7.7.1

___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


[PATCH] httpd: don't drop QUERY_STRING when /cgi-bin/index.cgi is used

2011-12-15 Thread Peter Korsgaard
The memory pointed to by g_query gets overwritten when the index_page
is used, causing URL arguments to get dropped when we fall back to
/cgi-bin/index.cgi.

Work around it by making g_query a deep copy of urlp when CGI support
is enabled, rather than silently dropping them.

Signed-off-by: Peter Korsgaard jac...@sunsite.dk
---
 networking/httpd.c |9 +++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/networking/httpd.c b/networking/httpd.c
index 0356e4c..37d6577 100644
--- a/networking/httpd.c
+++ b/networking/httpd.c
@@ -1996,7 +1996,14 @@ static void handle_incoming_and_exit(const 
len_and_sockaddr *fromAddr)
tptr = strchr(urlcopy, '?');
if (tptr) {
*tptr++ = '\0';
+#if ENABLE_FEATURE_HTTPD_CGI
+   /* tptr gets overwritten by index_page, so do deep copy
+  for /cgi-bin/index.cgi */
+   g_query = alloca(strlen(tptr) + 1);
+   strcpy((char *)g_query, tptr);
+#else
g_query = tptr;
+#endif
}
 
/* Decode URL escape sequences */
@@ -2265,8 +2272,6 @@ static void handle_incoming_and_exit(const 
len_and_sockaddr *fromAddr)
/* It's a dir URL and there is no index.html
 * Try cgi-bin/index.cgi */
if (access(/cgi-bin/index.cgi+1, X_OK) == 0) {
-   urlp[0] = '\0';
-   g_query = urlcopy;
send_cgi_and_exit(/cgi-bin/index.cgi, prequest, 
length, cookie, content_type);
}
}
-- 
1.7.7.1

___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: [PATCH] httpd: don't drop QUERY_STRING when /cgi-bin/index.cgi is used

2011-12-15 Thread Peter Korsgaard
 Paulius == Paulius Zaleckas paulius.zalec...@gmail.com writes:

Hi,

  +#if ENABLE_FEATURE_HTTPD_CGI
  +   /* tptr gets overwritten by index_page, so do deep copy
  +  for /cgi-bin/index.cgi */
  +   g_query = alloca(strlen(tptr) + 1);
  +   strcpy((char *)g_query, tptr);

 Paulius Why not use strdup() instead?

Because we then need to cleanup. We're already using alloca for urlcopy
just above.

-- 
Bye, Peter Korsgaard
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: [PATCH] httpd: don't drop QUERY_STRING when /cgi-bin/index.cgi is used

2011-12-15 Thread Peter Korsgaard
 walter == walter harms wha...@bfs.de writes:

Hi,

  Why not use strdup() instead?

 walter Why not use strdupa() instead?

Because I wasn't aware of it. I see we aren't using it anywhere in
busybox today, how portable is it?

-- 
Bye, Peter Korsgaard
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: [PATCH] bb_daemonize: double-fork to ensure child doesn't get controlling tty

2011-11-09 Thread Peter Korsgaard
 Denys == Denys Vlasenko vda.li...@googlemail.com writes:

Hi,

 Denys Fork is expensive. vfork+exec on NOMMU doubly so.
 Denys In many cases, callers know that they will never try open a tty.
 Denys Let's make this second fork_or_rexec() optional:

 Denys if (flags  DAEMON_DOUBLE_FORK) ...

Ok. From a quick look it only seems to only be needed for
start-stop-daemon as the other users either don't exec or do another
fork before executing programs.

I'll send an updated patch shortly.

-- 
Bye, Peter Korsgaard
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


[PATCH] bb_daemonize: add flag to double-fork and use in start-stop-daemon

2011-11-09 Thread Peter Korsgaard
Add a DAEMON_DOUBLE_FORK flag to make bb_daemonize double-fork so it isn't a
session leader, and hence doesn't get a controlling tty on Linux if a tty is
ever opened, similar to how libdaemon's daemon_fork or the big
start-stop-daemon does it - And use it in start-stop-daemon.

For details, see http://www.win.tue.nl/~aeb/linux/lk/lk-10.html#ss10.3

Signed-off-by: Peter Korsgaard jac...@sunsite.dk
---
 debianutils/start_stop_daemon.c |2 +-
 include/libbb.h |1 +
 libbb/vfork_daemon_rexec.c  |7 +++
 3 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/debianutils/start_stop_daemon.c b/debianutils/start_stop_daemon.c
index 02609c0..495ed0a 100644
--- a/debianutils/start_stop_daemon.c
+++ b/debianutils/start_stop_daemon.c
@@ -474,7 +474,7 @@ int start_stop_daemon_main(int argc UNUSED_PARAM, char 
**argv)
*--argv = startas;
if (opt  OPT_BACKGROUND) {
 #if BB_MMU
-   bb_daemonize(DAEMON_DEVNULL_STDIO + DAEMON_CLOSE_EXTRA_FDS);
+   bb_daemonize(DAEMON_DEVNULL_STDIO + DAEMON_CLOSE_EXTRA_FDS + 
DAEMON_DOUBLE_FORK);
/* DAEMON_DEVNULL_STDIO is superfluous -
 * it's always done by bb_daemonize() */
 #else
diff --git a/include/libbb.h b/include/libbb.h
index 53224fa..09e8d28 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -966,6 +966,7 @@ enum {
DAEMON_DEVNULL_STDIO = 2,
DAEMON_CLOSE_EXTRA_FDS = 4,
DAEMON_ONLY_SANITIZE = 8, /* internal use */
+   DAEMON_DOUBLE_FORK = 16, /* double fork to avoid controlling tty */
 };
 #if BB_MMU
   enum { re_execed = 0 };
diff --git a/libbb/vfork_daemon_rexec.c b/libbb/vfork_daemon_rexec.c
index a75eafb..c7da675 100644
--- a/libbb/vfork_daemon_rexec.c
+++ b/libbb/vfork_daemon_rexec.c
@@ -258,6 +258,13 @@ void FAST_FUNC bb_daemonize_or_rexec(int flags, char 
**argv)
dup2(fd, 0);
dup2(fd, 1);
dup2(fd, 2);
+
+   if (flags  DAEMON_DOUBLE_FORK) {
+   /* double-fork to ensure child doesn't get controlling 
tty
+  on Linux if a tty is opened */
+   if (fork_or_rexec(argv))
+   exit(EXIT_SUCCESS); /* parent */
+   }
}
while (fd  2) {
close(fd--);
-- 
1.7.6.3

___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


[PATCH] bb_daemonize: double-fork to ensure child doesn't get controlling tty

2011-11-07 Thread Peter Korsgaard
bb_daemonize should double-fork so it isn't a session leader, and hence
doesn't get a controlling tty on Linux if a tty is ever opened, similar to
how libdaemon's daemon_fork or the big start-stop-daemon does it.

For details, see http://www.win.tue.nl/~aeb/linux/lk/lk-10.html#ss10.3

Signed-off-by: Peter Korsgaard jac...@sunsite.dk
---
 libbb/vfork_daemon_rexec.c |2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/libbb/vfork_daemon_rexec.c b/libbb/vfork_daemon_rexec.c
index a75eafb..40a82e3 100644
--- a/libbb/vfork_daemon_rexec.c
+++ b/libbb/vfork_daemon_rexec.c
@@ -258,6 +258,8 @@ void FAST_FUNC bb_daemonize_or_rexec(int flags, char **argv)
dup2(fd, 0);
dup2(fd, 1);
dup2(fd, 2);
+   if (fork_or_rexec(argv))
+   exit(EXIT_SUCCESS); /* parent */
}
while (fd  2) {
close(fd--);
-- 
1.7.6.3

___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: [PATCH 2/2] fbsplash: support 8bit mode

2011-10-17 Thread Peter Korsgaard
 Denys == Denys Vlasenko vda.li...@googlemail.com writes:

  +
  +   /* RGB:332 */
  +   for (i = 0; i  256; i++)
  +   {
  +   red[i]   = ((i  0xe0)  8)  + ((i  0x20) ? 0x1fff : 0);
  +   green[i] = ((i  0x1c)  11) + ((i  0x04) ? 0x1fff : 0);
  +   blue[i]  = ((i  0x03)  14) + ((i  0x01) ? 0x3fff : 0);
  +   }

 Denys This doesn't map values entirely correctly.
 Denys How about this?

Intuitively I would say that using anything else than the least
significant bit of the 2/3 MSB to extimate the missing bits doesn't make
sense, but then I found:

http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.17.5503rep=rep1type=pdf

Which does exactly like you propose - So I'll shut up ;)

Thanks!

-- 
Bye, Peter Korsgaard
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


  1   2   3   >