automatic login with xdm
My attempts at modifying /etc/ttys gave results inferior to the supported xdm_flags="", so... 1. Have xdm_flags="" in /etc/rc.conf.local 2. Apply this diff, then cd xenocara/app/xdm && make -f Makefile.bsd-wrapper build 3. Add printf '%s\0%s' username password > /var/xdm-auto-login to /etc/rc.local I grant this diff to the public domain. Index: xenocara/app/xdm/greeter/greet.c === RCS file: /cvs/xenocara/app/xdm/greeter/greet.c,v retrieving revision 1.1.1.2 diff -u -r1.1.1.2 greet.c --- xenocara/app/xdm/greeter/greet.c5 Aug 2007 19:01:03 - 1.1.1.2 +++ xenocara/app/xdm/greeter/greet.c9 Dec 2008 08:34:46 - @@ -69,6 +69,9 @@ # include "config.h" #endif +#include +#include + #include #include #include @@ -354,6 +357,21 @@ { XEvent event; Argarglist[3]; + +{ + const char *s = "/var/xdm-auto-login"; + FILE *f; + static char b[50]; + + if ((f = fopen(s, "r")) != NULL) { + bzero(b + fread(b, 1, sizeof(b) - 2, f), 2); + fclose(f); + remove(s); + greet->name = b; + greet->password = strchr(b, 0) + 1; + return 0; + } +} XtSetArg (arglist[0], XtNallowAccess, False); XtSetValues (login, arglist, 1);
Re: I found a sort bug! - How to sort big files?
> Current sort(1) is unmaintanable in many ways. I say switch. I've seen with gdb that the current sort(1) somehow manages to make radixsort(3) do the work when the sort key is somewhere in the middle of the line. I don't even want to know... (and my reading comprehension of C is too weak to go and look). Yes, switch, please!
2^64 - 39 ...
... is the greatest composite OpenBSD prime. $ uname -srm OpenBSD 5.7 amd64 $ n=$(echo "2^64 - 39" | bc) $ /usr/games/factor $n 18446744073709551577: 18446744073709551577 $ /usr/local/bin/gfactor $n 18446744073709551577: 139646831 132095686967
Re: ctrl+alt+backspace bypasses xlock and allows terminal access
This is what I do on 5.0/i386. I have this line in /etc/ttys: ttyC5 "/bin/Lock" vt220 on secure To lock the computer I run this executable /bin/Lock: #!/bin/sh pass=sparken exe=/bin/Lock fifo=/var/Lock case "$1" in ttyC*) t=/dev/$1 tty=$t exec $exe exe < $t > $t 2> $t ;; exe);; *) echo > $fifo exit ;; esac mknod -m 0666 $fifo p for i in eof intr kill quit susp start stop \ dsusp lnext reprint status; do stty $i undef done stty -echo while :; do jot 200 echo -n computing cat < $fifo > /dev/null focus=$(wsconsctl display.focus) t=${tty#/dev/ttyC} wsconsctl display.focus=$t > /dev/null map=$(wsconsctl keyboard.map | grep Cmd_) map2=$(echo "$map" | sed 's/=.*/= x/') wsconsctl keyboard.map+="$map2" while :; do read -r r [ _"$r" = _"$pass" ] && break echo -n . done wsconsctl keyboard.map+="$map" wsconsctl $focus > /dev/null done
feature req: vnconfig should work on readonly fs
The patch appears to work for me on OpenBSD 3.9 i386. --- sys/dev/vnd.c.orig Fri Sep 8 03:41:21 2006 +++ sys/dev/vnd.c Fri Sep 8 04:56:05 2006 @@ -817,7 +817,7 @@ * have to worry about them. */ NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, vio->vnd_file, p); - if ((error = vn_open(&nd, FREAD|FWRITE, 0)) != 0) { + if ((error = vn_open(&nd, FREAD|FWRITE, 0)) != 0 && (error != EROFS || (error = vn_open(&nd, FREAD, 0)) != 0)) { vndunlock(vnd); return (error); }
feature req: vnconfig should work on readonly fs; round 2
The patch appears to work for me on 3.9 i386, and I do need your comments on it. Thank you, Joachim. --- sys/dev/vnd.c.orig Fri Sep 8 03:41:21 2006 +++ sys/dev/vnd.c Sat Sep 9 05:09:38 2006 @@ -142,7 +142,10 @@ #defineVNF_HAVELABEL 0x0400 #defineVNF_BUSY0x0800 #defineVNF_SIMPLE 0x1000 +#defineVNF_READONLY0x2000 +#define FLG(vnd) (vnd->sc_flags & VNF_READONLY ? FREAD : FREAD|FWRITE) + struct vnd_softc *vnd_softc; int numvnd = 0; @@ -231,6 +234,9 @@ return (ENXIO); sc = &vnd_softc[unit]; + if (flags & FWRITE && sc->sc_flags & VNF_READONLY) + return (EROFS); + if ((error = vndlock(sc)) != 0) return (error); @@ -817,14 +823,15 @@ * have to worry about them. */ NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, vio->vnd_file, p); - if ((error = vn_open(&nd, FREAD|FWRITE, 0)) != 0) { + vnd->sc_flags &= ~VNF_READONLY; + if ((error = vn_open(&nd, FREAD|FWRITE, 0)) != 0 && (error != EROFS || (vnd->sc_flags |= VNF_READONLY, (error = vn_open(&nd, FREAD, 0)) != 0))) { vndunlock(vnd); return (error); } error = VOP_GETATTR(nd.ni_vp, &vattr, p->p_ucred, p); if (error) { VOP_UNLOCK(nd.ni_vp, 0, p); - (void) vn_close(nd.ni_vp, FREAD|FWRITE, p->p_ucred, p); + (void) vn_close(nd.ni_vp, FLG(vnd), p->p_ucred, p); vndunlock(vnd); return (error); } @@ -832,7 +839,7 @@ vnd->sc_vp = nd.ni_vp; vnd->sc_size = btodb(vattr.va_size);/* note truncation */ if ((error = vndsetcred(vnd, p->p_ucred)) != 0) { - (void) vn_close(nd.ni_vp, FREAD|FWRITE, p->p_ucred, p); + (void) vn_close(nd.ni_vp, FLG(vnd), p->p_ucred, p); vndunlock(vnd); return (error); } @@ -845,7 +852,7 @@ if ((error = copyin(vio->vnd_key, key, vio->vnd_keylen)) != 0) { - (void) vn_close(nd.ni_vp, FREAD|FWRITE, + (void) vn_close(nd.ni_vp, FLG(vnd), p->p_ucred, p); vndunlock(vnd); return (error); @@ -1082,7 +1089,7 @@ vnd->sc_flags &= ~VNF_INITED; if (vp == (struct vnode *)0) panic("vndioctl: null vp"); - (void) vn_close(vp, FREAD|FWRITE, vnd->sc_cred, p); + (void) vn_close(vp, FLG(vnd), vnd->sc_cred, p); crfree(vnd->sc_cred); vnd->sc_vp = (struct vnode *)0; vnd->sc_cred = (struct ucred *)0; --- usr.sbin/vnconfig/vnconfig.c.orig Sat Sep 9 04:37:15 2006 +++ usr.sbin/vnconfig/vnconfig.cSat Sep 9 04:59:25 2006 @@ -159,7 +159,7 @@ char *rdev; int rv; - if (opendev(dev, O_RDWR, OPENDEV_PART, &rdev) < 0) + if (opendev(dev, O_RDONLY, OPENDEV_PART, &rdev) < 0) err(4, "%s", rdev); f = fopen(rdev, "rw"); if (f == NULL) {
a question about concurrency
Quoting sys/dev/vnd.c rev 1.62: 1121 /* 1122 * Wait interruptibly for an exclusive lock. 1123 * 1124 * XXX 1125 * Several drivers do this; it should be abstracted and made MP-safe. 1126 */ 1127 int 1128 vndlock(sc) 1129 struct vnd_softc *sc; 1130 { 1131 int error; 1132 1133 while ((sc->sc_flags & VNF_LOCKED) != 0) { 1134 sc->sc_flags |= VNF_WANTED; 1135 if ((error = tsleep(sc, PRIBIO | PCATCH, "vndlck", 0)) != 0) 1136 return (error); 1137 } 1138 sc->sc_flags |= VNF_LOCKED; 1139 return (0); 1140 } Is it possible for a process to have the cpu taken away from it between lines 1137 and 1138? If so, is the comment "Several drivers do this" serious?
feature req: vnconfig should work on readonly fs; round 3
Let's see if I can get this closer to right. The patch is against and tested on -current. Thank you, Pedro, for your help. --- sys/dev/vnd.c.orig Sun Sep 10 19:18:28 2006 +++ sys/dev/vnd.c Mon Sep 11 15:54:30 2006 @@ -142,7 +142,10 @@ #defineVNF_HAVELABEL 0x0400 #defineVNF_BUSY0x0800 #defineVNF_SIMPLE 0x1000 +#defineVNF_READONLY0x2000 +#define FLG(vnd) (vnd->sc_flags & VNF_READONLY ? FREAD : FREAD|FWRITE) + struct vnd_softc *vnd_softc; int numvnd = 0; @@ -234,6 +237,11 @@ if ((error = vndlock(sc)) != 0) return (error); + if (flags & FWRITE && sc->sc_flags & VNF_READONLY) { + error = EROFS; + goto bad; + } + if ((sc->sc_flags & VNF_INITED) && (sc->sc_flags & VNF_HAVELABEL) == 0) { sc->sc_flags |= VNF_HAVELABEL; @@ -817,20 +825,25 @@ } /* -* Always open for read and write. -* This is probably bogus, but it lets vn_open() +* Open for read and write first. This lets vn_open() * weed out directories, sockets, etc. so we don't * have to worry about them. */ NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, vio->vnd_file, p); - if ((error = vn_open(&nd, FREAD|FWRITE, 0)) != 0) { + vnd->sc_flags &= ~VNF_READONLY; + error = vn_open(&nd, FREAD|FWRITE, 0); + if (EROFS == error) { + vnd->sc_flags |= VNF_READONLY; + error = vn_open(&nd, FREAD, 0); + } + if (error) { vndunlock(vnd); return (error); } error = VOP_GETATTR(nd.ni_vp, &vattr, p->p_ucred, p); if (error) { VOP_UNLOCK(nd.ni_vp, 0, p); - (void) vn_close(nd.ni_vp, FREAD|FWRITE, p->p_ucred, p); + (void) vn_close(nd.ni_vp, FLG(vnd), p->p_ucred, p); vndunlock(vnd); return (error); } @@ -838,7 +851,7 @@ vnd->sc_vp = nd.ni_vp; vnd->sc_size = btodb(vattr.va_size);/* note truncation */ if ((error = vndsetcred(vnd, p->p_ucred)) != 0) { - (void) vn_close(nd.ni_vp, FREAD|FWRITE, p->p_ucred, p); + (void) vn_close(nd.ni_vp, FLG(vnd), p->p_ucred, p); vndunlock(vnd); return (error); } @@ -851,7 +864,7 @@ if ((error = copyin(vio->vnd_key, key, vio->vnd_keylen)) != 0) { - (void) vn_close(nd.ni_vp, FREAD|FWRITE, + (void) vn_close(nd.ni_vp, FLG(vnd), p->p_ucred, p); vndunlock(vnd); return (error); @@ -1087,7 +1100,7 @@ vnd->sc_flags &= ~VNF_INITED; if (vp == (struct vnode *)0) panic("vndioctl: null vp"); - (void) vn_close(vp, FREAD|FWRITE, vnd->sc_cred, p); + (void) vn_close(vp, FLG(vnd), vnd->sc_cred, p); crfree(vnd->sc_cred); vnd->sc_vp = (struct vnode *)0; vnd->sc_cred = (struct ucred *)0; --- usr.sbin/vnconfig/vnconfig.c.orig Sun Sep 10 19:19:25 2006 +++ usr.sbin/vnconfig/vnconfig.cMon Sep 11 15:28:27 2006 @@ -226,7 +226,7 @@ char *rdev; int rv; - if (opendev(dev, O_RDWR, OPENDEV_PART, &rdev) < 0) + if (opendev(dev, O_RDONLY, OPENDEV_PART, &rdev) < 0) err(4, "%s", rdev); f = fopen(rdev, "rw"); if (f == NULL) {
kernel profiling boot startup call graph kgmon gprof
The kernel profiling facility does not currently provide a call graph of system startup. With the patch below, it does. Time profiling is not the purpose of this patch and remains limited. One printf() is lost. The information it provided can be gathered at build time. A kernel that would previously have printed "No memory for profiling" will probably not boot. The address of etext is used as a compile-time constant by less-than-pure means. I don't know if it works on all platforms. Tested on -current i386. --- /dev/null Sat Sep 23 02:15:07 2006 +++ sys/conf/gen_addr_etext Sat Sep 23 00:36:45 2006 @@ -0,0 +1,19 @@ +#!/bin/sh +f=addr_etext.h +l='#define ADDR_ETEXT 0x\' +if [ $# = 0 ]; then + echo "$l" > $f + echo '0 + KERNBASE + (1<<16)' >> $f + exit 0 +fi +if [ $# = 1 ]; then + a=$(objdump -t "$1" | awk '/ etext$/{print $1}') + [ -z "$a" ] && exit 2 + b=$(sed -n 2p < $f) + [ -z "$b" ] && exit 2 + [ x"$a" = x"$b" ] && exit 1 + echo "$l" > $f + echo "$a" >> $f + exit 0 +fi +exit 2 Index: sys/kern/init_main.c === RCS file: /cvs/src/sys/kern/init_main.c,v retrieving revision 1.130 diff -u -r1.130 init_main.c --- sys/kern/init_main.c6 May 2006 23:02:36 - 1.130 +++ sys/kern/init_main.c23 Sep 2006 02:15:08 - @@ -191,6 +191,11 @@ extern void endtsleep(void *); extern void realitexpire(void *); +#ifdef GPROF + /* Initialize kernel profiling. */ + kmstartup(); +#endif + /* * Initialize the current process pointer (curproc) before * any possible traps/probes to simplify trap processing. @@ -347,6 +352,9 @@ /* Start real time and statistics clocks. */ initclocks(); +#ifdef GPROF + startprofclock(&proc0); +#endif /* Lock the kernel on behalf of proc0. */ KERNEL_PROC_LOCK(p); @@ -385,11 +393,6 @@ domaininit(); if_attachdomain(); splx(s); - -#ifdef GPROF - /* Initialize kernel profiling. */ - kmstartup(); -#endif #if !defined(NO_PROPOLICE) { Index: sys/kern/subr_prof.c === RCS file: /cvs/src/sys/kern/subr_prof.c,v retrieving revision 1.15 diff -u -r1.15 subr_prof.c --- sys/kern/subr_prof.c9 Dec 2005 09:09:52 - 1.15 +++ sys/kern/subr_prof.c23 Sep 2006 02:15:08 - @@ -45,52 +45,49 @@ #ifdef GPROF #include #include -#include +#include "addr_etext.h" /* * Froms is actually a bunch of unsigned shorts indexing tos */ struct gmonparam _gmonparam = { GMON_PROF_OFF }; -extern char etext[]; - +#define LOWPC ROUNDDOWN(KERNBASE, HISTFRACTION * sizeof(HISTCOUNTER)) +#define HIGHPC ROUNDUP((ADDR_ETEXT), HISTFRACTION * sizeof(HISTCOUNTER)) +#define TEXTSIZE (HIGHPC - LOWPC) +#define KCOUNTSIZE (TEXTSIZE / HISTFRACTION) +#define FROMSSIZE (TEXTSIZE / HASHFRACTION) +#define TOLIM (TEXTSIZE * ARCDENSITY / 100) +#define TOLIMIT (TOLIM < MINARCS ? MINARCS : TOLIM > MAXARCS ? MAXARCS : TOLIM) +#define TOSSIZE (TOLIMIT * sizeof(struct tostruct)) +#define SIZE (KCOUNTSIZE + FROMSSIZE + TOSSIZE) void kmstartup(void) { + static char buf[round_page(SIZE)]; char *cp; struct gmonparam *p = &_gmonparam; - int size; /* * Round lowpc and highpc to multiples of the density we're using * so the rest of the scaling (here and in gprof) stays in ints. */ - p->lowpc = ROUNDDOWN(KERNBASE, HISTFRACTION * sizeof(HISTCOUNTER)); - p->highpc = ROUNDUP((u_long)etext, HISTFRACTION * sizeof(HISTCOUNTER)); - p->textsize = p->highpc - p->lowpc; - printf("Profiling kernel, textsize=%ld [%lx..%lx]\n", - p->textsize, p->lowpc, p->highpc); - p->kcountsize = p->textsize / HISTFRACTION; + p->lowpc = LOWPC; + p->highpc = HIGHPC; + p->textsize = TEXTSIZE; + p->kcountsize = KCOUNTSIZE; p->hashfraction = HASHFRACTION; - p->fromssize = p->textsize / HASHFRACTION; - p->tolimit = p->textsize * ARCDENSITY / 100; - if (p->tolimit < MINARCS) - p->tolimit = MINARCS; - else if (p->tolimit > MAXARCS) - p->tolimit = MAXARCS; - p->tossize = p->tolimit * sizeof(struct tostruct); - size = p->kcountsize + p->fromssize + p->tossize; - cp = (char *)uvm_km_zalloc(kernel_map, round_page(size)); - if (cp == 0) { - printf("No memory for profiling.\n"); - return; - } + p->fromssize = FROMSSIZE; + p->tolimit = TOLIMIT; + p->tossize = TOSSIZE; + cp = buf; p->tos = (struct tostruct *)cp; cp += p->tossize; p->kcount = (u_short *)cp; cp += p->kcountsize; p->froms = (u_short *)cp; + p->state = GMON_PROF_ON; } /* Index: usr.sbin/config/mkmakefile.c =
Re: kernel profiling boot startup call graph kgmon gprof
(update of http://marc.theaimsgroup.com/?l=openbsd-misc&m=115898040215357&w=2) Here's an improved version of the patch. It does away with kmstartup(), completing the coverage of the recorded call graph. --- /dev/null Sun Sep 24 23:24:37 2006 +++ sys/conf/gen_addr_etext Sat Sep 23 00:36:45 2006 @@ -0,0 +1,19 @@ +#!/bin/sh +f=addr_etext.h +l='#define ADDR_ETEXT 0x\' +if [ $# = 0 ]; then + echo "$l" > $f + echo '0 + KERNBASE + (1<<16)' >> $f + exit 0 +fi +if [ $# = 1 ]; then + a=$(objdump -t "$1" | awk '/ etext$/{print $1}') + [ -z "$a" ] && exit 2 + b=$(sed -n 2p < $f) + [ -z "$b" ] && exit 2 + [ x"$a" = x"$b" ] && exit 1 + echo "$l" > $f + echo "$a" >> $f + exit 0 +fi +exit 2 Index: sys/kern/init_main.c === RCS file: /cvs/src/sys/kern/init_main.c,v retrieving revision 1.130 diff -u -r1.130 init_main.c --- sys/kern/init_main.c6 May 2006 23:02:36 - 1.130 +++ sys/kern/init_main.c24 Sep 2006 23:24:42 - @@ -347,6 +347,9 @@ /* Start real time and statistics clocks. */ initclocks(); +#ifdef GPROF + startprofclock(&proc0); +#endif /* Lock the kernel on behalf of proc0. */ KERNEL_PROC_LOCK(p); @@ -385,11 +388,6 @@ domaininit(); if_attachdomain(); splx(s); - -#ifdef GPROF - /* Initialize kernel profiling. */ - kmstartup(); -#endif #if !defined(NO_PROPOLICE) { Index: sys/kern/subr_prof.c === RCS file: /cvs/src/sys/kern/subr_prof.c,v retrieving revision 1.15 diff -u -r1.15 subr_prof.c --- sys/kern/subr_prof.c9 Dec 2005 09:09:52 - 1.15 +++ sys/kern/subr_prof.c24 Sep 2006 23:24:42 - @@ -45,53 +45,40 @@ #ifdef GPROF #include #include -#include +#include "addr_etext.h" /* - * Froms is actually a bunch of unsigned shorts indexing tos + * Round lowpc and highpc to multiples of the density we're using + * so the rest of the scaling (here and in gprof) stays in ints. */ -struct gmonparam _gmonparam = { GMON_PROF_OFF }; - -extern char etext[]; - +#define LOWPC ROUNDDOWN(KERNBASE, HISTFRACTION * sizeof(HISTCOUNTER)) +#define HIGHPC ROUNDUP((ADDR_ETEXT), HISTFRACTION * sizeof(HISTCOUNTER)) +#define TEXTSIZE (HIGHPC - LOWPC) +#define KCOUNTSIZE (TEXTSIZE / HISTFRACTION) +#define FROMSSIZE (TEXTSIZE / HASHFRACTION) +#define TOLIM (TEXTSIZE * ARCDENSITY / 100) +#define TOLIMIT (TOLIM < MINARCS ? MINARCS : TOLIM > MAXARCS ? MAXARCS : TOLIM) +#define TOSSIZE (TOLIMIT * sizeof(struct tostruct)) -void -kmstartup(void) -{ - char *cp; - struct gmonparam *p = &_gmonparam; - int size; +static char buf[KCOUNTSIZE + FROMSSIZE + TOSSIZE]; - /* -* Round lowpc and highpc to multiples of the density we're using -* so the rest of the scaling (here and in gprof) stays in ints. -*/ - p->lowpc = ROUNDDOWN(KERNBASE, HISTFRACTION * sizeof(HISTCOUNTER)); - p->highpc = ROUNDUP((u_long)etext, HISTFRACTION * sizeof(HISTCOUNTER)); - p->textsize = p->highpc - p->lowpc; - printf("Profiling kernel, textsize=%ld [%lx..%lx]\n", - p->textsize, p->lowpc, p->highpc); - p->kcountsize = p->textsize / HISTFRACTION; - p->hashfraction = HASHFRACTION; - p->fromssize = p->textsize / HASHFRACTION; - p->tolimit = p->textsize * ARCDENSITY / 100; - if (p->tolimit < MINARCS) - p->tolimit = MINARCS; - else if (p->tolimit > MAXARCS) - p->tolimit = MAXARCS; - p->tossize = p->tolimit * sizeof(struct tostruct); - size = p->kcountsize + p->fromssize + p->tossize; - cp = (char *)uvm_km_zalloc(kernel_map, round_page(size)); - if (cp == 0) { - printf("No memory for profiling.\n"); - return; - } - p->tos = (struct tostruct *)cp; - cp += p->tossize; - p->kcount = (u_short *)cp; - cp += p->kcountsize; - p->froms = (u_short *)cp; -} +/* + * Froms is actually a bunch of unsigned shorts indexing tos + */ +struct gmonparam _gmonparam = { + /* state = */ GMON_PROF_ON, + /* kcount = */ (ushort *)(buf + TOSSIZE), + KCOUNTSIZE, + /* froms = */ (ushort *)(buf + TOSSIZE + KCOUNTSIZE), + FROMSSIZE, + /* tos = */ (struct tostruct *)buf, + TOSSIZE, + TOLIMIT, + LOWPC, + HIGHPC, + TEXTSIZE, + HASHFRACTION +}; /* * Return kernel profiling information. Index: usr.sbin/config/mkmakefile.c === RCS file: /cvs/src/usr.sbin/config/mkmakefile.c,v retrieving revision 1.20 diff -u -r1.20 mkmakefile.c --- usr.sbin/config/mkmakefile.c6 May 2006 11:31:46 - 1.20 +++ usr.sbin/config/mkmakefile.c24 Sep 2006 23:24:42 - @@ -42,6 +42,7 @@ */ #include +#in
Re: OpenBSD Order and austin@ encrypted block
On Sun, 24 Sep 2006 20:40:37 -0400 Chris Zakelj <[EMAIL PROTECTED]> wrote: > Got my pre-order entered a couple days ago, but I still haven't been > able to find what keyserver is being used, and thus, I have no idea what > austin's PGP message block says. It says that the information is for ID EA2A0D59 alone. $ cat 1 -BEGIN PGP MESSAGE- hEwDrSNaAuoqDVkBAgCeqJQORcw6my6yFazgGyyTdHWmT7Rk67BW/t2XbTigq2u3 QLsMezjHQJu2C9lOnLtgKp+JNuOfjLtGRDcc+lqppgAAAWrDWEmE4f9LPMVZorkE 5a/72Av7vn0K3d7+bLuP4MhIvxt3AWdYmvXJ8ayNUWbMFczfSiEC/5PRRkVsvRVg ajImub3K01rERV7u5x0KS9eTYE9/eiXqjuFe+napu7rlEjgyCANwCmuM7do6PJ7R LHkRqy+mv++5XSdoBgmVGlaWR8d5wKP5e2/jL+mVcUwVp6KvtWT0uH2eb67opekO OiJWBGhMppaj6B4cQBRjI0MtXstjucVhdNu2YrM4P36o7TiVmcrJtmSqYdlFybaO F4Xs6IhQwC9/vBHzm9fFI6Qj+JmfirTX/tk9WtQ8STbzbgO1FYbxHV56y8ZOEuQd wlSWw9B8UY0Yxx7BEl84awAGXp//+JL/03RptWpRnsbArRlVOC7nenbAIGoKT+VN pjxm+MgBKqP1AJ5gnCDMua2D21LEQoEFxXGLkOuBUtDbmiIehoaxzGtH4V5KCPSK fjpUHwhdVroTaLkurQ== =8kgO -END PGP MESSAGE- $ gpg 1 gpg: encrypted with RSA key, ID EA2A0D59 gpg: decryption failed: secret key not available $
Re: kernel profiling boot startup call graph kgmon gprof
(update of http://marc.theaimsgroup.com/?l=openbsd-misc&m=115914181032738&w=2) Polishing. --- /dev/null Mon Sep 25 16:30:26 2006 +++ sys/conf/gen_addr_etext Mon Sep 25 15:41:13 2006 @@ -0,0 +1,19 @@ +#!/bin/sh +f=addr_etext.h +l='#define ADDR_ETEXT \' +if [ $# = 0 ]; then + echo "$l" > $f + echo '((u_long)KERNBASE + (1<<16))' >> $f + exit 0 +fi +if [ $# = 1 ]; then + a="0x$(nm -gp "$1" | awk '/ etext$/{print $1}')UL" + [ -z "$a" ] && exit 2 + b=$(sed -n 2p < $f) + [ -z "$b" ] && exit 2 + [ x"$a" = x"$b" ] && exit 1 + echo "$l" > $f + echo "$a" >> $f + exit 0 +fi +exit 2 Index: sys/kern/init_main.c === RCS file: /cvs/src/sys/kern/init_main.c,v retrieving revision 1.130 diff -u -r1.130 init_main.c --- sys/kern/init_main.c6 May 2006 23:02:36 - 1.130 +++ sys/kern/init_main.c25 Sep 2006 16:30:30 - @@ -347,6 +347,9 @@ /* Start real time and statistics clocks. */ initclocks(); +#ifdef GPROF + startprofclock(&proc0); +#endif /* Lock the kernel on behalf of proc0. */ KERNEL_PROC_LOCK(p); @@ -385,11 +388,6 @@ domaininit(); if_attachdomain(); splx(s); - -#ifdef GPROF - /* Initialize kernel profiling. */ - kmstartup(); -#endif #if !defined(NO_PROPOLICE) { Index: sys/kern/subr_prof.c === RCS file: /cvs/src/sys/kern/subr_prof.c,v retrieving revision 1.15 diff -u -r1.15 subr_prof.c --- sys/kern/subr_prof.c9 Dec 2005 09:09:52 - 1.15 +++ sys/kern/subr_prof.c25 Sep 2006 16:30:30 - @@ -45,53 +45,40 @@ #ifdef GPROF #include #include -#include +#include "addr_etext.h" /* - * Froms is actually a bunch of unsigned shorts indexing tos + * Round lowpc and highpc to multiples of the density we're using + * so the rest of the scaling (here and in gprof) stays in ints. */ -struct gmonparam _gmonparam = { GMON_PROF_OFF }; - -extern char etext[]; - +#define LOWPC ROUNDDOWN((u_long)KERNBASE, HISTFRACTION * sizeof(HISTCOUNTER)) +#define HIGHPC ROUNDUP(ADDR_ETEXT, HISTFRACTION * sizeof(HISTCOUNTER)) +#define TEXTSIZE (HIGHPC - LOWPC) +#define KCOUNTSIZE (TEXTSIZE / HISTFRACTION) +#define FROMSSIZE (TEXTSIZE / HASHFRACTION) +#define TOLIM (TEXTSIZE * ARCDENSITY / 100) +#define TOLIMIT (TOLIM < MINARCS ? MINARCS : TOLIM > MAXARCS ? MAXARCS : TOLIM) +#define TOSSIZE (TOLIMIT * sizeof(struct tostruct)) -void -kmstartup(void) -{ - char *cp; - struct gmonparam *p = &_gmonparam; - int size; +static char buf[KCOUNTSIZE + FROMSSIZE + TOSSIZE]; - /* -* Round lowpc and highpc to multiples of the density we're using -* so the rest of the scaling (here and in gprof) stays in ints. -*/ - p->lowpc = ROUNDDOWN(KERNBASE, HISTFRACTION * sizeof(HISTCOUNTER)); - p->highpc = ROUNDUP((u_long)etext, HISTFRACTION * sizeof(HISTCOUNTER)); - p->textsize = p->highpc - p->lowpc; - printf("Profiling kernel, textsize=%ld [%lx..%lx]\n", - p->textsize, p->lowpc, p->highpc); - p->kcountsize = p->textsize / HISTFRACTION; - p->hashfraction = HASHFRACTION; - p->fromssize = p->textsize / HASHFRACTION; - p->tolimit = p->textsize * ARCDENSITY / 100; - if (p->tolimit < MINARCS) - p->tolimit = MINARCS; - else if (p->tolimit > MAXARCS) - p->tolimit = MAXARCS; - p->tossize = p->tolimit * sizeof(struct tostruct); - size = p->kcountsize + p->fromssize + p->tossize; - cp = (char *)uvm_km_zalloc(kernel_map, round_page(size)); - if (cp == 0) { - printf("No memory for profiling.\n"); - return; - } - p->tos = (struct tostruct *)cp; - cp += p->tossize; - p->kcount = (u_short *)cp; - cp += p->kcountsize; - p->froms = (u_short *)cp; -} +/* + * Froms is actually a bunch of unsigned shorts indexing tos + */ +struct gmonparam _gmonparam = { + /* state = */ GMON_PROF_ON, + /* kcount = */ (u_short *)(buf + TOSSIZE), + KCOUNTSIZE, + /* froms = */ (u_short *)(buf + TOSSIZE + KCOUNTSIZE), + FROMSSIZE, + /* tos = */ (struct tostruct *)buf, + TOSSIZE, + TOLIMIT, + LOWPC, + HIGHPC, + TEXTSIZE, + HASHFRACTION +}; /* * Return kernel profiling information. Index: sys/sys/systm.h === RCS file: /cvs/src/sys/sys/systm.h,v retrieving revision 1.69 diff -u -r1.69 systm.h --- sys/sys/systm.h 27 Apr 2006 02:17:21 - 1.69 +++ sys/sys/systm.h 25 Sep 2006 16:30:30 - @@ -291,11 +291,6 @@ void cpu_configure(void); extern void (*md_diskconf)(void); - -#ifdef GPROF -void kmstartup(void); -#endif - int nfs_mountroot(void); int dk_mountroot(void); extern int (*
a question about errno
Should a userland program be allowed to depend on errno==0 on entry to main()? (At least one in the tree does.) I see no place in the C library that explicitly ensures this, and it might be false if the user runs the program under LD_PRELOAD tricks.
Re: a question about errno
On Fri, 29 Sep 2006 14:40:04 -0600 Theo de Raadt <[EMAIL PROTECTED]> wrote: > > On 9/28/06, Paul Stoeber <[EMAIL PROTECTED]> wrote: > > > Should a userland program be allowed to depend on errno==0 on entry > > > to main()? (At least one in the tree does.) > > > > checking errno is the wrong way to ascertain whether a function had a > > problem, so this shouldn't be a problem for a well written program. > > > > on the other hand, code running before main is outside the scope of C > > standard, and i think the standard at least implies errno should be 0 > > on entry, so we should fix/verify that too. > > there is an even easier way to look at this: > > errno is only valid if something indicates that you should > be checking it > > some functions are documented & defined so that when they return NULL, > errno is set. > > some functions are documented & defined so that when they return -1, > errno is set. > > if a function has not indicated that errno is now valid, then errno contains > some previous result code which is absolutely irrelevant. > > so fundamentally, the question being asked by the original poster is > "can i check what is in errno whenever i want" has a simple answer: no. > > therefore it is irrelevant what value is currently stored in errno. > > if nothing told you to look at it, don't look at it. I guess that means the answer to my original question is No. I've sent a diff to [EMAIL PROTECTED] Note especially usr.bin/head/head.c
Re: a question about errno
On Fri, 29 Sep 2006 05:30:35 + I wrote: > Should a userland program be allowed to depend on errno==0 on entry > to main()? (At least one in the tree does.) That claim is unfounded, because usr.bin/head/head.c (which I failed to mention; apologies) is not an example. The question remains unsettled and has no immediate importance. Consider this patch, which would have to be done similarly on the other platforms. Index: src/lib/csu/i386/crt0.c === RCS file: /cvs/src/lib/csu/i386/crt0.c,v retrieving revision 1.13 diff -u -r1.13 crt0.c --- src/lib/csu/i386/crt0.c 4 Aug 2005 16:33:05 - 1.13 +++ src/lib/csu/i386/crt0.c 30 Sep 2006 11:08:36 - @@ -35,6 +35,7 @@ #include #include #include +#include static char*_strrchr(char *, char); @@ -96,6 +97,7 @@ __init(); + errno = 0; exit(main(argc, argv, environ)); }
Re: overwritten file recovery - how ?
On Sat, 30 Sep 2006 19:24:43 +0200 Bambero <[EMAIL PROTECTED]> wrote: > Hello > > I need to recovery overwritten txt file. > > Ex. > echo "my data" > testfile.txt > echo "" > testfile.txt > > I have partition image file creted using dd. > Is it possible to dump it and search using grep for example ? > Is it possible to recover overwritten data ? > > Thanks > Bambero I've had luck with tr '\0' '\n' < disk | grep -C1000 KEYWORD > /mnt/safe
the cvs repository doesn't obey the attic criterion
the cvs info manual says: But in case you want to know, the rule is that the RCS file is stored in the attic if and only if the head revision on the trunk has state `dead'. counterexamples: /cvs/src/sbin/swapon/Attic/swapon.8,v /cvs/src/distrib/vax/ramdisk/dot.commonutils,v /cvs/src/sys/arch/mvme88k/stand/wrtvid/Makefile,v,v /cvs/ports/net/rrdtool/patches/patch-config_ltmain_sh,v /cvs/ports/x11/msttcorefonts/pkg/INSTALL,v
blurb blurb
I've been thinking about the legal blurbs in the source files, the most permissive being the one in, for example, src/bin/chio/parse.y I feel it's a bit silly to bother with them, since they have no technical significance. But perhaps it's worthwhile, every once in a while, to ponder the real world and its constraints. The motivation for authors to put blurbs in their work must be some kind of fear. The nature of this fear can be guessed from the wording of the blurb. The authors hope that the blurb affords them protection. I wonder if the following language would provide the same level of protection or better: We, the authors of this work, are giving it away to you, dear reader (and to everyone else), as an opportunity, not as a service. Do with it whatever you want. We welcome your contributions, and we owe you nothing. I imagine that putting this one in place of the orthodox blurb would be an inspiring demonstration of resistance to fear. Surely no judge could misunderstand its intention. Please discuss.
Xorg, i810 - X crashes when switching from wscons to X
This is on -current i386. See dmesg below (the "apg_release_helper" lines seem to be a byproduct of the X crash, since they are not normally in my dmesg). I'm getting this crash very infrequently, and I don't know what to do about it. See compressed Xorg.0.log below the dmesg. I think it's not a memory leak, because on earlier occasions I've had much more repetitions of the "xf86UnbindGARTMemory: unbind key 4" line in the log after crash. I've checked that it is the switching from X to wscons and back that generates these repeated chunks of log. So perhaps my hardware is crumbling or it's a timing problem or both. OpenBSD 4.0-current (GENERIC) #1: Mon Oct 9 18:55:44 UTC 2006 [EMAIL PROTECTED]:/usr/src/sys/arch/i386/compile/GENERIC cpu0: Intel(R) Celeron(R) M processor 1500MHz ("GenuineIntel" 686-class) 1.50 GHz cpu0: FPU,V86,DE,PSE,TSC,MSR,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,TM,SBF real mem = 251162624 (245276K) avail mem = 221401088 (216212K) using 3096 buffers containing 12681216 bytes (12384K) of memory mainbus0 (root) bios0 at mainbus0: AT/286+(d3) BIOS, date 05/21/01, BIOS32 rev. 0 @ 0xe97d0, SMBIOS rev. 2.3 @ 0xeb160 (42 entries) bios0: Acer TravelMate 2350 pcibios0 at bios0: rev 2.1 @ 0xe7000/0x671 pcibios0: PCI IRQ Routing Table rev 1.0 @ 0xfe890/160 (8 entries) pcibios0: PCI Interrupt Router at 000:31:0 ("Intel 82801AA LPC" rev 0x00) pcibios0: PCI bus #2 is the last bus bios0: ROM list: 0xc/0xd000! 0xe/0x1800 0xe6000/0x1000! 0xeb000/0x5000! cpu0 at mainbus0 pci0 at mainbus0 bus 0: configuration mode 1 (no bios) pchb0 at pci0 dev 0 function 0 "Intel 82852GM Hub-PCI" rev 0x02 "Intel 82852GM Memory" rev 0x02 at pci0 dev 0 function 1 not configured "Intel 82852GM Configuration" rev 0x02 at pci0 dev 0 function 3 not configured vga1 at pci0 dev 2 function 0 "Intel 82852GM AGP" rev 0x02: aperture at 0xb000, size 0x800 wsdisplay0 at vga1 mux 1: console (80x25, vt100 emulation) wsdisplay0: screen 1-5 added (80x25, vt100 emulation) "Intel 82852GM AGP" rev 0x02 at pci0 dev 2 function 1 not configured uhci0 at pci0 dev 29 function 0 "Intel 82801DB USB" rev 0x03: irq 11 usb0 at uhci0: USB revision 1.0 uhub0 at usb0 uhub0: Intel UHCI root hub, rev 1.00/1.00, addr 1 uhub0: 2 ports with 2 removable, self powered uhci1 at pci0 dev 29 function 1 "Intel 82801DB USB" rev 0x03: irq 5 usb1 at uhci1: USB revision 1.0 uhub1 at usb1 uhub1: Intel UHCI root hub, rev 1.00/1.00, addr 1 uhub1: 2 ports with 2 removable, self powered uhci2 at pci0 dev 29 function 2 "Intel 82801DB USB" rev 0x03: irq 5 usb2 at uhci2: USB revision 1.0 uhub2 at usb2 uhub2: Intel UHCI root hub, rev 1.00/1.00, addr 1 uhub2: 2 ports with 2 removable, self powered ehci0 at pci0 dev 29 function 7 "Intel 82801DB USB" rev 0x03: irq 10 usb3 at ehci0: USB revision 2.0 uhub3 at usb3 uhub3: Intel EHCI root hub, rev 2.00/1.00, addr 1 uhub3: 6 ports with 6 removable, self powered ppb0 at pci0 dev 30 function 0 "Intel 82801BAM Hub-to-PCI" rev 0x83 pci1 at ppb0 bus 1 rl0 at pci1 dev 1 function 0 "Realtek 8139" rev 0x10: irq 11, address 00:02:3f:0c:3c:9b rlphy0 at rl0 phy 0: RTL internal PHY cbb0 at pci1 dev 4 function 0 "ENE CB-1410 CardBus" rev 0x01: irq 11 cardslot0 at cbb0 slot 0 flags 0 cardbus0 at cardslot0: bus 2 device 0 cacheline 0x8, lattimer 0x20 pcmcia0 at cardslot0 ichpcib0 at pci0 dev 31 function 0 "Intel 82801DBM LPC" rev 0x03: SpeedStep pciide0 at pci0 dev 31 function 1 "Intel 82801DBM IDE" rev 0x03: DMA, channel 0 configured to compatibility, channel 1 configured to compatibility wd0 at pciide0 channel 0 drive 0: wd0: 16-sector PIO, LBA, 38154MB, 78140160 sectors wd0(pciide0:0:0): using PIO mode 4, Ultra-DMA mode 2 atapiscsi0 at pciide0 channel 1 drive 0 scsibus0 at atapiscsi0: 2 targets cd0 at scsibus0 targ 0 lun 0: SCSI0 5/cdrom removable cd0(pciide0:1:0): using PIO mode 4, Ultra-DMA mode 2 ichiic0 at pci0 dev 31 function 3 "Intel 82801DB SMBus" rev 0x03: irq 5 iic0 at ichiic0 auich0 at pci0 dev 31 function 5 "Intel 82801DB AC97" rev 0x03: irq 5, ICH4 AC97 ac97: codec id 0x414c4752 (Avance Logic ALC250A?) ac97: codec features headphone, 20 bit DAC, 18 bit ADC, No 3D Stereo audio0 at auich0 "Intel 82801DB Modem" rev 0x03 at pci0 dev 31 function 6 not configured isa0 at ichpcib0 isadma0 at isa0 pckbc0 at isa0 port 0x60/5 pckbd0 at pckbc0 (kbd slot) pckbc0: using irq 1 for kbd slot wskbd0 at pckbd0: console keyboard, using wsdisplay0 pms0 at pckbc0 (aux slot) pckbc0: using irq 12 for aux slot wsmouse0 at pms0 mux 0 pcppi0 at isa0 port 0x61 midi0 at pcppi0: spkr0 at pcppi0 npx0 at isa0 port 0xf0/16: using exception 16 biomask effd netmask effd ttymask pctr: 686-class user-level performance counters enabled mtrr: Pentium Pro MTRR support aue0 at uhub0 port 1 aue0: ELSA AG MicroLink USB2Ethernet, rev 1.10/1.01, addr 2 aue0: address 00:48:54:21:0a:3c sqphy0 at aue0 phy 1: Seeq 80225 10/100 PHY, rev. 0 dkcsum: wd0 matches BIOS drive 0x80 root on wd0a rootdev=0x0 rrootdev=0x30
getting the source of a snapshot
The FAQ says: It is sometimes asked if there is any way to get a copy of exactly the code used to build a snapshot. The answer is no. For this to change, it would be sufficient if the output of find src XF4 -path '*/CVS/Entries' -exec perl -ne \ 'm:^(/[^/]*/[^/]*): && print substr($ARGV,0,-12),"$1\n"' '{}' ';' (or equivalent information) accompanies the snapshot. Pretty please adopt this practice, for it is inexpensive, and I would recently have loved to have seen a diff between the snapshot source and the checked-out source. Such a diff can be generated using something like cat REVISIONS | while read x; do f=${x%/*}; r=${x##*/}; \ cvs diff -u -r$r $f; done With a local mirror of the cvs repository, this takes 12 minutes on my i386 1.5GHz 256MB. Perhaps it's not nice to do this to a remote anoncvs server. Checking the tree out file by file with cvs co -r$r $f takes an insane amount of time.
Re: How to set proxy authentication when installing?
Jing Peng wrote: > Hello everyone! I am a university student and I can't visit the web > server outside of China. So ,I use proxy to install OpenBSD(the proxy > need for authentication). When I get into the step bellow, I do not > know how to set proxy authentication correctly. I tried for times, but > failed. Proxy authentication is not implemented in ftp(1). You can work around this by creating a custom installation CD. $ find OpenBSD -type f # these files are on the ftp mirrors OpenBSD/4.0/i386/base40.tgz OpenBSD/4.0/i386/bsd OpenBSD/4.0/i386/bsd.mp OpenBSD/4.0/i386/bsd.rd OpenBSD/4.0/i386/cdrom40.fs OpenBSD/4.0/i386/comp40.tgz OpenBSD/4.0/i386/etc40.tgz OpenBSD/4.0/i386/game40.tgz OpenBSD/4.0/i386/man40.tgz OpenBSD/4.0/i386/misc40.tgz OpenBSD/4.0/i386/xbase40.tgz OpenBSD/4.0/i386/xetc40.tgz OpenBSD/4.0/i386/xfont40.tgz OpenBSD/4.0/i386/xserv40.tgz OpenBSD/4.0/i386/xshare40.tgz OpenBSD/4.0/packages/i386/expat-2.0.0.tgz OpenBSD/4.0/packages/i386/gettext-0.14.5p1.tgz OpenBSD/4.0/packages/i386/libiconv-1.9.2p3.tgz OpenBSD/4.0/packages/i386/wget-1.10.2p0.tgz $ mkisofs -l -r -b 4.0/i386/cdrom40.fs -o obsd.iso OpenBSD When you have OpenBSD up and running, try wget's proxy authentication. # mount /dev/cd0a /mnt # replace cd0a with your CD device # pkg_add /mnt/4.0/packages/i386/wget-1.10.2p0.tgz # man wget If you like OpenBSD, you could try to implement proxy authentication in ftp(1).
Re: UTF-8
Matthew Szudzik wrote (2010-08-05 19:50:16): > http://en.wikipedia.org/wiki/IDN_homograph_attack Try this in a default 4.7/i386 wscons console: printf 'set -x\nnslookup www.AAA.com\nnslookup www.AA\300.com\n' > 1 less 1 sh 1 See: sys/dev/ic/pcdisplay_chars.c Remedy: #!/bin/sh # Public domain. wsfontload -N my /usr/share/misc/pcvtfonts/iso8859-1-euro.816 cat > wsfontuse.c << 'Q' #include #include #include #include int main(int argc, char **argv) { struct wsdisplay_font f; int d; d = open(argv[1], O_RDWR, 0); bzero(&f, sizeof f); strlcpy(f.name, argv[2], WSFONT_NAME_SIZE); if (ioctl(d, WSDISPLAYIO_USEFONT, &f) == -1) return 1; return 0; } Q cc -o wsfontuse wsfontuse.c for i in /dev/ttyC*; do ./wsfontuse $i my; done