Elf support for strings(1)
Diff below add elf support to (bsd) strings(1) and make it usable for architectures with ELF_TOOLCHAIN=Yes. I've been working on cross arch support for various build utils (ar, ranlib, nm...) and this diff is the first of a series. Tested on amd64, macppc and vax. It also gives a correct offset on my macppc machine where the actual (binutils) strings(1) always gives a negative offset. Elf bits are taken from nm(1)'s sources and I followed the same logic to process a.out/elf{32,64} files. I didn't reuse nm's elf.c because of the global variables. Some love may be needed to prevent duplication of code. This diff also includes some cosmetic modifications. If interested I can submit more organic patches. Here is the commit log that can be found on my git repo [0]: Uninitialized variable, found by llvm static analyzer. Improve error handling Correct format strings now that we use an off_t for the offset. Cosmetic, no functional change. File offset is no longer a global variable Small changes when printing filenames and offsets to behave like GNU strings(1). Add support for ELF format using OpenBSD's nm(1) elf functions. Rewrite find_strings() to use a `size` parameter instead of the global read_len variable. It will be used later to specify elf's section size. Use an union for file headers in order to support both elf and a.out formats. While here clean the header selection function. Move the strings search in a separate function, no functional change. Move the logic in a separate function, no functional change. Comments? Martin [0] https://gitorious.org/buildutils/strings Index: Makefile === RCS file: /cvs/src/usr.bin/strings/Makefile,v retrieving revision 1.3 diff -u -p -r1.3 Makefile --- Makefile21 Sep 1997 11:51:00 - 1.3 +++ Makefile5 Apr 2011 06:19:56 - @@ -1,5 +1,14 @@ # $OpenBSD: Makefile,v 1.3 1997/09/21 11:51:00 deraadt Exp $ PROG= strings +SRCS= strings.c elf32.c elf64.c + +CLEANFILES+= elf32.c elf64.c + +elf32.c: ${.CURDIR}/elf.c + echo '#define ELFSIZE 32' | cat - $ ${.TARGET} + +elf64.c: ${.CURDIR}/elf.c + echo '#define ELFSIZE 64' | cat - $ ${.TARGET} .include bsd.prog.mk Index: elf.c === RCS file: elf.c diff -N elf.c --- /dev/null 1 Jan 1970 00:00:00 - +++ elf.c 5 Apr 2011 06:19:56 - @@ -0,0 +1,172 @@ +/* $OpenBSD: elf.c,v 1.19 2009/10/27 23:59:41 deraadt Exp $*/ + +/* + * Copyright (c) 2003 Michael Shalayeff + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR OR HIS RELATIVES BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF MIND, USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include sys/param.h +#include sys/mman.h + +#include a.out.h +#include ctype.h +#include elf_abi.h +#include errno.h +#include err.h +#include stdio.h +#include stdlib.h +#include string.h +#include unistd.h + +#include elfuncs.h + +#if ELFSIZE == 32 +#defineswap_addr swap32 +#defineswap_offswap32 +#defineswap_sword swap32 +#defineswap_word swap32 +#defineswap_sxword swap32 +#defineswap_xword swap32 +#defineswap_half swap16 +#defineswap_quarterswap16 +#defineelf_fix_header elf32_fix_header +#defineelf_load_shdrs elf32_load_shdrs +#defineelf_fix_shdrs elf32_fix_shdrs +#elif ELFSIZE == 64 +#defineswap_addr swap64 +#defineswap_offswap64 +#ifdef __alpha__ +#defineswap_sword swap64 +#defineswap_word swap64 +#else +#defineswap_sword swap32 +#defineswap_word swap32 +#endif +#defineswap_sxword swap64 +#defineswap_xword
nm -s on symdef archives for 64bits and different endian archs
Two diffs below to fix the use of nm -s when reading a __symdef archive on a 64bits machine and/or with a different endianness (ie m68k on amd64 or vax on ppc). To detect the archive index endianness without looking at the first object I assumed that the first time we have a fseek error we should be trying with a wrong offset. So I try again the values swapped. It's a bit scary but I couldn't see a different approach without looking at the first object. As for strings(1), tested on macppc, amd64 and vax. Comments ? Martin commit 36d80b16fb2f5e2c5c345ed31caee4959bd30270 Author: Martin Pieuchot mpieuc...@nolizard.org Date: Fri Apr 8 17:19:21 2011 +0530 Support the -s option for 32bits symdef archives on 64bits machines with the same endianness. diff --git a/nm.c b/nm.c index 34e2f52..832e03a 100644 --- a/nm.c +++ b/nm.c @@ -76,6 +76,13 @@ struct nlist32 { u_int32_t value; } __packed; +struct ranlib32 { + union { + u_int32_t ran_strx; + } ran_un; + u_int32_t ran_off; +} __packed; + int armap; int demangle; int non_object_warning; @@ -408,7 +415,11 @@ show_symtab(off_t off, u_long len, const char *name, FILE *fp) int show_symdef(off_t off, u_long len, const char *name, FILE *fp) { +#ifdef __LP64__ + struct ranlib32 *prn, *eprn; +#else struct ranlib *prn, *eprn; +#endif struct ar_hdr ar_head; void *symdef; char *strtab, *p; @@ -429,9 +440,9 @@ show_symdef(off_t off, u_long len, const char *name, FILE *fp) } size = *(u_long *)symdef; - prn = symdef + sizeof(u_long); + prn = symdef + sizeof(u_int32_t); eprn = prn + size / sizeof(*prn); - strtab = symdef + sizeof(u_long) + size + sizeof(u_long); + strtab = symdef + sizeof(u_int32_t) + size + sizeof(u_int32_t); printf(\nArchive index:\n); for (; prn eprn; prn++) { commit 67409c3501f5aa9ea7c1e327faad2baab1eb2969 Author: Martin Pieuchot mpieuc...@nolizard.org Date: Fri Apr 8 21:16:22 2011 +0530 Add support for displaying the index (nm -s) of a.out archives on machine with a different endianess. diff --git a/nm.c b/nm.c index 832e03a..ff307b7 100644 --- a/nm.c +++ b/nm.c @@ -424,7 +424,8 @@ show_symdef(off_t off, u_long len, const char *name, FILE *fp) void *symdef; char *strtab, *p; u_long size; - int namelen, rval = 0; + long roff, rstrx; + int namelen, rval = 0, endianess = 0; MMAP(symdef, len, PROT_READ, MAP_PRIVATE|MAP_FILE, fileno(fp), off); if (symdef == MAP_FAILED) @@ -439,14 +440,31 @@ show_symdef(off_t off, u_long len, const char *name, FILE *fp) return (1); } - size = *(u_long *)symdef; + printf(\nArchive index:\n); +init: + if (endianess) + size = swap32(*(u_long *)symdef); + else + size = *(u_long *)symdef; + prn = symdef + sizeof(u_int32_t); eprn = prn + size / sizeof(*prn); strtab = symdef + sizeof(u_int32_t) + size + sizeof(u_int32_t); - printf(\nArchive index:\n); for (; prn eprn; prn++) { - if (fseeko(fp, prn-ran_off, SEEK_SET)) { + if (endianess) { + roff = swap32(prn-ran_off); + rstrx = swap32(prn-ran_un.ran_strx); + } else { + roff = prn-ran_off; + rstrx = prn-ran_un.ran_strx; + } + + if (fseeko(fp, roff, SEEK_SET)) { + if (!endianess) { + endianess = 1; + goto init; + } warn(%s: fseeko, name); rval = 1; break; @@ -454,6 +472,10 @@ show_symdef(off_t off, u_long len, const char *name, FILE *fp) if (fread(ar_head, sizeof(ar_head), 1, fp) != 1 || memcmp(ar_head.ar_fmag, ARFMAG, sizeof(ar_head.ar_fmag))) { + if (!endianess) { + endianess = 1; + goto init; + } warnx(%s: member fseeko, name); rval = 1; break; @@ -465,7 +487,7 @@ show_symdef(off_t off, u_long len, const char *name, FILE *fp) break; } - printf(%s in %s\n, strtab + prn-ran_un.ran_strx, p); + printf(%s in %s\n, strtab + rstrx, p); } free(p);
Hello
Hello, My issue is to count trafic of a session and then act on that session according to its volume . First, a session is defined as the following: *@source, @dest, Port source, Port dest, and protocole used TCP/UDP/ICMP. *Then after creating 3 queues* *using altq with different priorities, I want to redirect a session that exceeded a threshold to a less priority queue.To do that I need to modify the code of pf.c. I think I suceeded to fix some parts of the code that interest me : I found the function : *pf_test() in sys/net/pf.c and the line s-bytes[dirndx] += pd.tot_len; and then pqid will surely interest me.* But After focusing on that deeply,I found that this line will count all trafic (of all connections) that crosses the firewall... But in my case I need to count trafic of *sessions* and act on them. Any Idea ??? thanks in advance.
Re: Hello
On 2011/04/09 10:44, Ali Gouta wrote: Hello, My issue is to count trafic of a session and then act on that session according to its volume . First, a session is defined as the following: *@source, @dest, Port source, Port dest, and protocole used TCP/UDP/ICMP. *Then after creating 3 queues* *using altq with different priorities, I want to redirect a session that exceeded a threshold to a less priority queue.To do that I need to modify the code of pf.c. I think I suceeded to fix some parts of the code that interest me : I found the function : *pf_test() in sys/net/pf.c and the line s-bytes[dirndx] += pd.tot_len; and then pqid will surely interest me.* But After focusing on that deeply,I found that this line will count all trafic (of all connections) that crosses the firewall... But in my case I need to count trafic of *sessions* and act on them. Any Idea ??? thanks in advance. The sane way to define traffic of a session in PF is traffic matching a state. And s-bytes does contain this, you can see it with pfctl -ss -v. int pqid (as used in pf_test) is a flag set for high-priority packets (empty acks, packets with LOWDELAY tos) telling altq whether to use the second queue of a rule definition / state (pf_state.pqid) instead of the first normal one (pf_state.qid). I think to do what you're asking for, you'd need an analogous lowpriorityqid (and infrastructure in pfctl to set a third queue, somewhere to pass the number of bytes through from rules, and changes to the pf_state and pf_rule structures to hold all of this). So it's adding a lot more complexity and I'm not convinced it's useful enough to be worth it. There's a big problem which makes it not generally useful: if your users have multithreaded downloads/uploads or P2P traffic with many peers, bandwidth will just split across a larger number of sessions. In that case queueing per source address (probably with hfsc linkshare which can reduce the speed of traffic after a certain time) would be a much better idea. (Though yes you do have to define a large number of queues if you have a lot of users behind it - in that case the config can be awkward to handle, so you might want some program to generate your pf.conf) If you want to play around with HFSC (and I'd recommend this before considering changing code), here's some suggested reading... http://forum.pfsense.org/index.php/topic,2718.msg48336.html#msg48336 http://www.probsd.net/pf/index.php/Hednod's_HFSC_explained http://forum.pfsense.org/index.php?topic=33950.0 http://forum.pfsense.org/index.php/topic,3050.0.html Building firewalls with OpenBSD and PF (slightly outdated as it pre-dates PF nat changes - in particular I think the queuing incoming packets section talking about needing two boxes no longer applies - but on the whole the altq section in here is rather good).
last patch, idea
Hi, while going through my wtmp with last(1) I noticed there could be a better way than always gunzip'ing wtmp files and then using last -f. I've made a patch for your consideration that does the following: a) it checks if the file is a gzipped file by looking at the wtmp's file magic b) it writes the gzipped file to a /tmp location uncompressed so that the normal way of operation can be done on the tmp file. I didn't want to start the discussion empty handed whether this is a good patch or not, so I made the patch but it needs cleanup and probably a manpage change. Let me know if this could go in, before I do any more work. -peter --- last.c.orig Sat Apr 9 22:33:55 2011 +++ last.c Sat Apr 9 23:49:39 2011 @@ -45,10 +45,12 @@ #include tzfile.h #include unistd.h #include utmp.h +#include zlib.h #defineNO 0 /* false/no */ #defineYES 1 /* true/yes */ #define ATOI2(ar) ((ar)[0] - '0') * 10 + ((ar)[1] - '0'); (ar) += 2; +#define GZIP \037\213 /* gzipped file */ static struct utmp buf[1024]; /* utmp read buffer */ @@ -74,6 +76,7 @@ static time_t snaptime = 0; /* report only at this time */ static int calculate = 0; static int seconds = 0; +static char*tmpdir = NULL; voidaddarg(int, char *); struct ttytab *addtty(char *); @@ -85,6 +88,10 @@ voidwtmp(void); voidcheckargs(void); voidusage(void); +char *create_tmp(char *); +void cleanup_tmp(char *); +intisgzipped(void); +void gzcopy(void); #define NAME_WIDTH 9 #define HOST_WIDTH 24 @@ -161,8 +168,18 @@ } } + if (isgzipped()) { + tmpdir = create_tmp(file); + gzcopy(); + file = tmpdir; + } + + checkargs(); wtmp(); + + if (tmpdir != NULL) + cleanup_tmp(tmpdir); exit(0); } @@ -624,6 +641,10 @@ snprintf(str, sizeof str, \ninterrupted %10.10s %8.8s \n, ct, ct + 11); write(STDOUT_FILENO, str, strlen(str)); + + if (tmpdir != NULL) + cleanup_tmp(tmpdir); + if (signo == SIGINT) _exit(1); } @@ -637,4 +658,103 @@ usage: %s [-csT] [-d date] [-f file] [-h host] [-n number] [-t tty] [user ...]\n, __progname); exit(1); +} + +/* + * create a temporary directory where a temporary file can be put in + */ + +char * +create_tmp(char *file) +{ + static char tmpfile[MAXPATHLEN]; + char d0[MAXPATHLEN]; + + char *p; + char *basename; + + snprintf(d0, sizeof(d0), /tmp/last.); + mkdtemp(d0); + + basename = strrchr(file, '/'); + snprintf(tmpfile, sizeof(tmpfile), %s/%s, d0, basename); + p = strrchr(tmpfile, '.'); + *p = '\0'; + + return ((char *)tmpfile); +} + +/* + * clean temporary file and directory in /tmp + */ + +void +cleanup_tmp(char *tmpfile) +{ + char *sep; + + unlink(tmpfile); + sep = strrchr(tmpfile, '/'); + *sep = '\0'; + + rmdir(tmpfile); +} + +/* + * determine if a wtmp file is gzipped or not, taken from /etc/magic + */ + +int +isgzipped(void) +{ + char buf[2]; + char *cmp = GZIP; + int fd; + + if ((fd = open(file, O_RDONLY, 0)) 0) { + perror(open); + exit(1); + } + + if (read(fd, buf, sizeof(buf)) != sizeof(buf)) { + perror(read); + exit(1); + } + + close(fd); + + if (memcmp(cmp, buf, sizeof(buf)) == 0) { + return (1); + } + + return (0); +} + +/* + * copy gzipped file to file tmpdir + */ +void +gzcopy(void) +{ + int fd, len; + + char buf[512]; + gzFile *gzt; + + fd = open(tmpdir, O_WRONLY | O_CREAT, 0600); + if (fd 0) { + perror(open); + exit(1); + } + + gzt = gzopen(file, r); + while ((len = gzread(gzt, buf, sizeof(buf))) 0) { + if (write(fd, buf, len) 0) { + perror(write); + exit(1); + } + } + + gzclose(gzt); + close(fd); }
Re: allow usermod to remove user from secondary groups
On 2011-04-08, Landry Breuil lan...@rhaalovely.net wrote: On Fri, Apr 08, 2011 at 07:53:51PM +0200, Frank Brodbeck wrote: Hi, lately I was reading on misc@ [1] that there's no way to remove a user from secondary groups but by hand. I also searched for a PR but couldn't find one. The attached diff remedies the problem: # id test uid=1001(test) gid=10(users) groups=10(users), 9(wsrc), 69(network), 117(dialer) # usermod -G wsrc,network test # id test uid=1001(test) gid=10(users) groups=10(users), 9(wsrc), 69(network) # usermod -G wsrc,network,dialer test # id test uid=1001(test) gid=10(users) groups=10(users), 9(wsrc), 69(network), 117(dialer) Hmm.. please no. Don't know if it's a bug or not, but i'm very used to -G to _add_ groups to the existing group list for a user. If i understand your diff correctly, one has to list all the groups it wants the user to be in, whereas now you just list the groups you want to add. I don't know if the current behaviour is a bug, but it's not what I expect from the manpage: -G secondary-group[,group,...] Sets the secondary groups the user will be a member of in the /etc/group file. sets, not adds to. So say i just installed a machine, i'm in users+wheel, i want to add myself to wsrc, if i do usermod -G wsrc like im used to, that'll remove me from users/wheel. Bye bye sudo etc. That happens to me everytime i use usermod on linux. Linux usermod has a '-a' flag to say 'the list after -G is the list of group i want to add', but i never remember it, and each time it removes the bazillion of default group a user needs to be in (audio, dev, video, etc etc) So please don't change that behaviour. If you want to remove a group for a user, you can still edit /etc/group. Considering the current behaviour of OpenBSD's usermod(8) I agree it's dangerous to change this now. But it's certainly something people need to do on occasion (for example some of Samba's features need this), and usermod(8) is the natural place to implement it. Having the capability there in some form would discourage scary things like http://marc.info/?l=openbsd-miscm=129232689002840 So I would like to see this in usermod, in some way that doesn't change existing behaviour of -G.
Re: Hello
Thanks fo answering, Yes Indeed I already thougt about using HSCF!!! And then I can manage the bandwidth between queues and give for example one 60% then the second 30% then the third 10%. But Stuart, I am not dealing with simple traffic a domestic one. But I will replay a capture of traffic that contains thousands of sessions. That's why I need in real time detect the volume of a session and then redirect sessions that exceeded a threshold to the second then the third queue.However, I liked what you said about pfctl although it would be quit complicate... I have to fetch more in that direction, thanks. On Sat, Apr 9, 2011 at 1:05 PM, Stuart Henderson s...@spacehopper.orgwrote: On 2011/04/09 10:44, Ali Gouta wrote: Hello, My issue is to count trafic of a session and then act on that session according to its volume . First, a session is defined as the following: *@source, @dest, Port source, Port dest, and protocole used TCP/UDP/ICMP. *Then after creating 3 queues* *using altq with different priorities, I want to redirect a session that exceeded a threshold to a less priority queue.To do that I need to modify the code of pf.c. I think I suceeded to fix some parts of the code that interest me : I found the function : *pf_test() in sys/net/pf.c and the line s-bytes[dirndx] += pd.tot_len; and then pqid will surely interest me.* But After focusing on that deeply,I found that this line will count all trafic (of all connections) that crosses the firewall... But in my case I need to count trafic of *sessions* and act on them. Any Idea ??? thanks in advance. The sane way to define traffic of a session in PF is traffic matching a state. And s-bytes does contain this, you can see it with pfctl -ss -v. int pqid (as used in pf_test) is a flag set for high-priority packets (empty acks, packets with LOWDELAY tos) telling altq whether to use the second queue of a rule definition / state (pf_state.pqid) instead of the first normal one (pf_state.qid). I think to do what you're asking for, you'd need an analogous lowpriorityqid (and infrastructure in pfctl to set a third queue, somewhere to pass the number of bytes through from rules, and changes to the pf_state and pf_rule structures to hold all of this). So it's adding a lot more complexity and I'm not convinced it's useful enough to be worth it. There's a big problem which makes it not generally useful: if your users have multithreaded downloads/uploads or P2P traffic with many peers, bandwidth will just split across a larger number of sessions. In that case queueing per source address (probably with hfsc linkshare which can reduce the speed of traffic after a certain time) would be a much better idea. (Though yes you do have to define a large number of queues if you have a lot of users behind it - in that case the config can be awkward to handle, so you might want some program to generate your pf.conf) If you want to play around with HFSC (and I'd recommend this before considering changing code), here's some suggested reading... http://forum.pfsense.org/index.php/topic,2718.msg48336.html#msg48336 http://www.probsd.net/pf/index.php/Hednod's_HFSC_explained http://forum.pfsense.org/index.php?topic=33950.0 http://forum.pfsense.org/index.php/topic,3050.0.html Building firewalls with OpenBSD and PF (slightly outdated as it pre-dates PF nat changes - in particular I think the queuing incoming packets section talking about needing two boxes no longer applies - but on the whole the altq section in here is rather good).
Re: Hello
Stuart Henderson s...@spacehopper.org writes: There's a big problem which makes it not generally useful: if your users have multithreaded downloads/uploads or P2P traffic with many peers, bandwidth will just split across a larger number of sessions. In that case queueing per source address (probably with hfsc linkshare which can reduce the speed of traffic after a certain time) would be a much better idea. hfsc has a lot going for it, true. And there's a number of ways to achieve roughly what Ali is asking for in near-realtime with some scriptery and pfctl output parsing (plus a few other approaches), but for the use case he describes it *might* make sense to have max-src-* state tracking options that trigger on number of bytes or packets passed. We record those per state anyway, so as a gedankenexperiment, say we could implement max-src-bytes B/s and max-src-packets P/s modeled on max-src-conn-rate and have rules like pass proto tcp to $somewhere port $wanted \ keep state (max-src-bytes 15G/86400, \ overload bytehogs flush global) that is, no source address allowed more than 15GB per day, or we bump to table bytehogs for whatever treatment is appropriate or pass proto tcp to $somewhere port $wanted \ keep state (max-src-packets 1G/86400, \ overload packethogs flush global) to trigger on some insane number of packets instead. Not sure if it stands out as a screaming must-have feature, but after about half an hour mulling the idea I kinda like it for now. - Peter -- Peter N. M. Hansteen, member of the first RFC 1149 implementation team http://bsdly.blogspot.com/ http://www.bsdly.net/ http://www.nuug.no/ Remember to set the evil bit on all malicious network traffic delilah spamd[29949]: 85.152.224.147: disconnected after 42673 seconds.
Re: ksh completion
Delivered-To: marty...@venck.us Received: by 10.231.147.205 with SMTP id m13cs105662ibv; Tue, 15 Mar 2011 01:48:25 -0700 (PDT) Received: by 10.43.46.135 with SMTP id uo7mr4936656icb.50.1300178905343; Tue, 15 Mar 2011 01:48:25 -0700 (PDT) Return-Path: owner-tech+m23...@openbsd.org Received: from shear.ucar.edu (lists.openbsd.org [192.43.244.163]) by mx.google.com with ESMTP id yd20si10108737icb.5.2011.03.15.01.48.25; Tue, 15 Mar 2011 01:48:25 -0700 (PDT) Received-SPF: pass (google.com: manual fallback record for domain of owner-tech+m23...@openbsd.org designates 192.43.244.163 as permitted sender) client-ip=192.43.244.163; Authentication-Results: mx.google.com; spf=pass (google.com: manual fallback record for domain of owner-tech+m23...@openbsd.org designates 192.43.244.163 as permitted sender) smtp.mail=owner-tech+m23...@openbsd.org Received: from openbsd.org (localhost.ucar.edu [127.0.0.1]) by shear.ucar.edu (8.14.3/8.14.3) with ESMTP id p2F8lBju030637; Tue, 15 Mar 2011 02:47:11 -0600 (MDT) Received: from clam.khaoz.org (clam.khaoz.org [64.90.163.62]) by shear.ucar.edu (8.14.3/8.14.3) with ESMTP id p2F8jjJq003536 (version=TLSv1/SSLv3 cipher=DHE-DSS-AES256-SHA bits=256 verify=FAIL); Tue, 15 Mar 2011 02:45:46 -0600 (MDT) Received: from clam.khaoz.org (okan@localhost [IPv6:::1]) by clam.khaoz.org (8.14.3/8.14.3) with ESMTP id p2F8jhx2026590 (version=TLSv1/SSLv3 cipher=DHE-DSS-AES256-SHA bits=256 verify=NO); Tue, 15 Mar 2011 04:45:44 -0400 (EDT) Date: Tue, 15 Mar 2011 04:45:43 -0400 From: Okan Demirmen o...@openbsd.org To: tech@openbsd.org Cc: r...@openbsd.org Subject: ksh completion Message-ID: 20110315084543.ga17...@clam.khaoz.org Mail-Followup-To: tech@openbsd.org, r...@openbsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii List-Help: mailto:majord...@openbsd.org?body=help List-Owner: mailto:tech-ow...@openbsd.org List-Post: mailto:tech@openbsd.org List-Subscribe: mailto:majord...@openbsd.org?body=sub%20tech List-Unsubscribe: mailto:majord...@openbsd.org?body=unsub%20tech X-Loop: tech@openbsd.org Precedence: list Sender: owner-t...@openbsd.org hi, (this is a re-post) make tab completion work for '=', '`', '[', ':', and '$' - pulled from mksh by Alexander Polakov (also posted to tech recently). closes pr 6006 too. comments/ok? The diff is a workaround and even wrong. Ksh lexical analyzer itself has the ability to deal with escapes properly (see yylex). I believe we shouldn't remove backward slashes before passing it for analysis, this would fix all cases, including: $ touch aabbcc aa\*cc $ echo aa\*cctab aa*cc aabbcc $ echo aa\*cc aa*cc Index: edit.c === RCS file: /home/okan/hack/open/cvs/src/bin/ksh/edit.c,v retrieving revision 1.34 diff -u -p -r1.34 edit.c --- edit.c20 May 2010 01:13:07 - 1.34 +++ edit.c14 Mar 2011 09:59:27 - @@ -365,6 +365,11 @@ x_file_glob(int flags, const char *str, continue; } + /* specially escape escaped [ or $ or ` for globbing */ + if (escaping (toglob[i] == '[' || + toglob[i] == '$' || toglob[i] == '`')) + toglob[idx++] = QCHAR; + toglob[idx] = toglob[i]; idx++; if (escaping) escaping = 0; @@ -378,7 +383,7 @@ x_file_glob(int flags, const char *str, s = pushs(SWSTR, ATEMP); s-start = s-str = toglob; source = s; - if (yylex(ONEWORD) != LWORD) { + if (yylex(ONEWORD|LQCHAR) != LWORD) { source = sold; internal_errorf(0, fileglob: substitute error); return 0; @@ -821,7 +826,7 @@ x_escape(const char *s, size_t len, int int rval = 0; for (add = 0, wlen = len; wlen - add 0; add++) { - if (strchr(\#$'()*;=?[\\]`{|}, s[add]) || + if (strchr(\#$'()*:;=?[\\]`{|}, s[add]) || strchr(ifs, s[add])) { if (putbuf_func(s, add) != 0) { rval = -1; Index: lex.c === RCS file: /home/okan/hack/open/cvs/src/bin/ksh/lex.c,v retrieving revision 1.45 diff -u -p -r1.45 lex.c --- lex.c 9 Mar 2011 09:30:39 - 1.45 +++ lex.c 14 Mar 2011 09:59:27 - @@ -411,6 +411,13 @@ yylex(int cf) } } break; + case QCHAR: + if (cf LQCHAR) { + *wp++ = QCHAR; + *wp++ = getsc(); + break; + } + /* FALLTHROUGH */
Re: system/6586: rdist (file larger than 2GB) times out but will not die -- Testers needed
Hi folks. Current rdist will timeout with files 2GB, log as finished, but will not die. The bug (system/6586) was originally noted by IBM (AIX) in 2006: https://www-304.ibm.com/support/docview.wss?uid=isg1IY85396 I have patches for the client rdist and server rdistd. I have tested i386 and amd64, in both directions. Please continue this. Testing on alpha would be especially welcomed. Thanks to everyone in advance. Steven client.c I did check into the comparison at line 689. Basically, it is ASSUMED that link files (not the actual files) will be tiny. The only attributes returned from an lstat() that refer to the symbolic link itself are the file type (S_IFLNK), size, blocks, and link count (always 1). That code is safe FOR NOW ... IF the (meta)data in the link grows a lot THEN it could be a problem. This should be a good state. 1. FIXED bug of filesize 2GB -- calculations and messages 2. FIXED similar in minimum freespace (and free files) 3. verified/fixed system write (and read) calls 4. TODO improve buffering i386 - i386install BIG file OK i386 - i386BIG file already installedOK amd64 - i386 install BIG file OK amd64 - i386 BIG file already installedOK i386 - amd64 install BIG file OK i386 - amd64 BIG file already installedOK i386 - macppc OK richardtoo...@paradise.net.nz i386 - amd64 OK richardtoo...@paradise.net.nz macppc - amd64 OK richardtoo...@paradise.net.nz amd64 - i386 OK richardtoo...@paradise.net.nz diff -uw /usr/src/usr.bin/rdist/Makefile rdist/Makefile --- /usr/src/usr.bin/rdist/Makefile Sun Jan 4 21:55:28 2004 +++ rdist/Makefile Mon Mar 28 22:03:24 2011 @@ -3,6 +3,7 @@ PROG= rdist CFLAGS+=-I. -I${.CURDIR} -DOS_H=\os-openbsd.h\ +#CFLAGS+=-Wall -pedantic SRCS= gram.y child.c client.c common.c distopt.c docmd.c expand.c \ isexec.c lookup.c message.c rdist.c CLEANFILES+=gram.c y.tab.h diff -uw /usr/src/usr.bin/rdist/child.c rdist/child.c --- /usr/src/usr.bin/rdist/child.c Thu Oct 29 00:34:05 2009 +++ rdist/child.c Sun Mar 27 16:36:19 2011 @@ -177,7 +177,7 @@ readchild(CHILD *child) { char rbuf[BUFSIZ]; - int amt; + ssize_t amt; debugmsg(DM_CALL, [readchild(%s, %d, %d) start], child-c_name, child-c_pid, child-c_readfd); @@ -196,7 +196,7 @@ */ while ((amt = read(child-c_readfd, rbuf, sizeof(rbuf))) 0) { /* XXX remove these debug calls */ - debugmsg(DM_MISC, [readchild(%s, %d, %d) got %d bytes], + debugmsg(DM_MISC, [readchild(%s, %d, %d) got %ld bytes], child-c_name, child-c_pid, child-c_readfd, amt); (void) xwrite(fileno(stdout), rbuf, amt); @@ -205,7 +205,7 @@ child-c_name, child-c_pid, child-c_readfd); } - debugmsg(DM_MISC, readchild(%s, %d, %d) done: amt = %d errno = %d\n, + debugmsg(DM_MISC, readchild(%s, %d, %d) done: amt = %ld errno = %d\n, child-c_name, child-c_pid, child-c_readfd, amt, errno); /* diff -uw /usr/src/usr.bin/rdist/client.c rdist/client.c --- /usr/src/usr.bin/rdist/client.c Thu Oct 29 00:34:06 2009 +++ rdist/client.c Sun Mar 27 16:05:15 2011 @@ -399,8 +399,8 @@ */ ENCODE(ername, rname); - (void) sendcmd(C_RECVREG, %o %04o %ld %ld %ld %s %s %s, - opts, stb-st_mode 0, (long) stb-st_size, + (void) sendcmd(C_RECVREG, %o %04o %lld %ld %ld %s %s %s, + opts, stb-st_mode 0, stb-st_size, stb-st_mtime, stb-st_atime, user, group, ername); if (response() 0) { @@ -409,8 +409,8 @@ } - debugmsg(DM_MISC, Send file '%s' %ld bytes\n, rname, -(long) stb-st_size); + debugmsg(DM_MISC, Send file '%s' %lld bytes\n, rname, + stb-st_size); /* * Set remote time out alarm handler. @@ -666,8 +666,8 @@ * Gather and send basic link info */ ENCODE(ername, rname); - (void) sendcmd(C_RECVSYMLINK, %o %04o %ld %ld %ld %s %s %s, - opts, stb-st_mode 0, (long) stb-st_size, + (void) sendcmd(C_RECVSYMLINK, %o %04o %lld %ld %ld %s %s %s, + opts, stb-st_mode 0, stb-st_size, stb-st_mtime, stb-st_atime, user, group, ername); if (response() 0) @@ -869,7 +869,7 @@ /* * Parse size */ - size = (off_t) strtol(cp, (char **)cp, 10); + size = (off_t) strtoll(cp, (char **)cp, 10); if
Re: Elf support for strings(1)
On Fri, Apr 8, 2011 at 11:04 PM, Martin Pieuchot mpieuc...@nolizard.org wrote: Diff below add elf support to (bsd) strings(1) and make it usable for architectures with ELF_TOOLCHAIN=Yes. Wait, why? I don't get it. This seems out of scope for strings(1). +elf32.c: ${.CURDIR}/elf.c + echo '#define ELFSIZE 32' | cat - $ ${.TARGET} + +elf64.c: ${.CURDIR}/elf.c + echo '#define ELFSIZE 64' | cat - $ ${.TARGET} Why not just create elf32.c with: #define ELFSIZE 32 #include elf.c and similar for elf64.c?
Caterer's Warehouse Daily Special
If you are having trouble viewing this e-mail, Visit www.catererswarehouse.com Caterer's Warehouse Weekly Specials Caterer's Warehouse Special Offers Home | Catering Supplies | Restaurant Equipment | Tabletop Specialties Bakery Supplies | Bar Supplies | Kitchen Supplies | Commercial Furniture | Hot Deals Valid 4/10/2011 Caterer's Warehouse Hot Deal Items This offer cannot be combined with any other promotional offers, flyers, discounted prices, coupons, or specials. Live Chat Find Us On FacebookFind Us On Facebook Follow Us On TwitterFollow Us On Twitter Share With FriendsShare With Friends [IMAGE] Contact Us 1-800-858-4255 If you would like to discontinue receiving our e-mails, click here www.catererswarehouse.com * 1030A Stafford St, Box 400 * Rochdale, MA 01542 [IMAGE]