Re: (fwd) [FD] OpenBSD kernel relinking is not transactional and a local exploit exists

2023-06-20 Thread Tomasz Rola
On Mon, Jun 19, 2023 at 05:34:12PM -0600, Theo de Raadt wrote:
> That writeup is bullshit.

Ok, I see.

-- 
Regards,
Tomasz Rola

--
** A C programmer asked whether computer had Buddha's nature.  **
** As the answer, master did "rm -rif" on the programmer's home**
** directory. And then the C programmer became enlightened...  **
**     **
** Tomasz Rola  mailto:tomasz_r...@bigfoot.com **



(fwd) [FD] OpenBSD kernel relinking is not transactional and a local exploit exists

2023-06-19 Thread Tomasz Rola
This happened in my mailbox today. FD means "full disclosure" and is
publicly available mailing list.

I repost onto misc because if this is a real cat, seems it is out of
the bag already. Other than being subscribed to FD, I have no
connection.

- Forwarded message from "Schech, C. W. (\"Connor\")"  
-

Date: Sat, 17 Jun 2023 09:40:16 +
From: "Schech, C. W. (Connor)" 
To: fulldisclos...@seclists.org
Subject: [FD] OpenBSD kernel relinking is not transactional and a local exploit
exists

The automatic and mandatory-by-default reordering of OpenBSD kernels
is NOT transactional and as a result, a local unpatched exploit exists
which allows tampering or replacement of the kernel. Arbitrary build
artifacts are cyclically relinked with no data integrity or provenance
being maintained or verified for the objects being consumed with
respect to the running kernel before and during the execution of the
mandatory kernel_reorder process in the supplied /etc/rc and
/usr/libexec scripts. The reordering occurs at the end of installation
process and also automatically every reboot cycle thereafter unless
manually bypassed by a knowledgable party.

The kernel_reorder routine verifies a SHA256 signature for the linked
kernel from last boot but does not verify the integrity or provenance
of any objects kept in the kernel "link kit" installed in
/usr/share/relink, so arbitrary objects can be injected and
automatically relinked at the next startup. I have verified that it is
indeed the case that both valid kernels with a different uname and
kernels which cause data destruction due to over-tuning of a subset of
the components which were compiled manually and copied into
/usr/share/relink and crash the system after being booted once
relinked but which do not match the build of the running kernel at the
time they were copied into /usr/share/relink as working
proof-of-concept exploits.

Install media are also open to tampering and exploitation as signed
checksum data are not carried with the install sets inside the
installation image and an improperly-encapsulated poorly-documented
tarball of unverifiable (in the sense of SLSA) kernel objects is
embedded in the base distribution and then relinked with a new random
ordering of the objects cyclically between boot cycles.

Sites with a strong security posture are advised that this is a
critical vulnerability and likely deliberate back door into the
system. Additionally, OpenBSD leaks the state of the pseudorandom
number generator to predictable locations on disk and in system memory
at a fixed point during every start up and shutdown procedure. The
lack of build process hardening has been on-going for over three
years. Theo de Raadt is disinterested in improving or reviewing the
design or providing any further clarification, as he has stated on the
mailing list when shortfalls in the relinking process were reported
over the past ~3 years. I hope that this can come to the attention of
a third-party technical expert with standing in the computer security
industry.

Workaround:

As the link kit is embedded in the base distribution and automatically
relinked without an option to disable it in the provided installation
script it requires manual removal at present.

Cf.

https://marc.info/?l=openbsd-bugs=159074964523007=2 (noted lack of
idempotency)
https://marc.info/?l=openbsd-bugs=168688579123005=2 (noted lack of
integrity or provenance verification and the consumption of invalid
objects)

https://slsa.dev/spec/v1.0/levels#build-l2-hosted-build-platform:

"Track/Level Requirements Focus
 Build L3   Hardened build platform  Tampering during the build"
___
Sent through the Full Disclosure mailing list
https://nmap.org/mailman/listinfo/fulldisclosure
Web Archives & RSS: https://seclists.org/fulldisclosure/


- End forwarded message -



Re: tracker-miner-fs-3

2023-02-19 Thread Tomasz Rola
On Sun, Feb 19, 2023 at 06:09:55AM +0100, Daniele B. wrote:
> Feb 19, 2023 03:49:45 Tomasz Rola :
> 
[...]
> 
> I ended up uninstalling it however thanks for this command too, interesting.

Yep. I admit I am unceremonial when dealing with my own systems. And I
am not sure if I would follow my own advices if I was not me.

> (Hint to read the rest of my reply: I'm always in the need to mind, use or 
> project
> myself *effective* gui despite the context. Thats my second job! )
>  
> > Install Midnight Commander, perhaps? Warning: it does not have
[...]
> Thanks for the charm of gem, indeed.. :D
> 
> > 
> > I also like dired-mode in Emacs, but for this to work, one has to like
> > Emacs. Actually, one has to love Emacs. "Like" is not enough in this
> > case.
> 
> Difficult to evaluate and comment on a *big stuff* like Emacs.
[...]
> 
> Summarizing again: I'm not in the need of Emacs (I'm focus on the
> web since years) and I think fortunately is so.

As of MC being a gem, it did not come to my mind until writing of my
previous email, but, yes, it worked for so many years and I do not
recall it failing me even once. Discs, operating systems, unicode in
filenames, it keeps to "just working".

Emacs, while much more complicated, is in different league - it is an
alien artefact standing in the middle of a cornfield. I think most
people simply pretend it is not there. Very few really need Emacs,
which is good, I think.

I sometimes - very rarely - use graphical file managers. They seem too
slow. But if they do the job, fine.

As a side note, since we speak about file management, I also often do
things with files from command line. Not very long ago I did it to
about 17 thousand small files scattered in few dirs. I had to write a
shell script and test quite a bit, because error was not good
idea. But if you plan to do complex procedures with files, writing a
script/program can help a lot. Also, doing not so complex procedures,
but when one is afraid to make a mistake. I am sometimes only
half-awaken, so writing commands in that state of mind is risky. A
script, sometimes a Makefile, run it when I am in hurry, so the
computer (who never gets nervous) takes this off me.

> Indeed, my best advice about gui is that any good stuff should be
> concieved simple enough to result effective to user.
> 
> I want also to thank you for the time of your post. I got the lucky
> chance to read you monitoring the fever of my daughter. And sorry
> for the off-topic commenting style.

Oh. I hope your daughter is going to be ok. Keep smiling.

-- 
Regards,
Tomasz Rola

--
** A C programmer asked whether computer had Buddha's nature.  **
** As the answer, master did "rm -rif" on the programmer's home**
** directory. And then the C programmer became enlightened...  **
** **
** Tomasz Rola  mailto:tomasz_r...@bigfoot.com **



Re: tracker-miner-fs-3

2023-02-18 Thread Tomasz Rola
On Thu, Feb 16, 2023 at 07:13:50PM +0100, Daniele B. wrote:
> Thanks David, thanks Mike.
> 
> In the meanwhile I also investigated a little bit..
> By memory (my case) is the following, I'm with Thunar on XFCE (without gnome 
> services):
> 
> tracker3-miner depends on nautilus
> nautilus depends on file-roller
> file-roller depends on thunar-archive-plugin (omg.. optional)
> 
> Indeed connecting everything something nasty to think about, this tracker..
> 
> What is your best advise?

Am a bit late but in case of doubt:

chmod a-x `which tracker-miner-fs-3` && ls -axl `which tracker-miner-fs-3`

and see if you are good during next few days. Yes -> leave it like
that, chmodded. Sure, some part of your desktop may seem a little bit
unusable. OTOH, maybe it is redundant and one can live without it?

Install Midnight Commander, perhaps? Warning: it does not have
trashcan, so there is no "undo" (unless something changed during last
twenty years). On the plus side: optionally works in vt100 mode (only
one option to choose from), does not display unnecessary icons. Big
plus: I am rather sure it will work with Gnome 15, still like a charm,
always like a charm (if you ask me - a real gem of a software).

I also like dired-mode in Emacs, but for this to work, one has to like
Emacs. Actually, one has to love Emacs. "Like" is not enough in this
case.

-- 
Regards,
Tomasz Rola

--
** A C programmer asked whether computer had Buddha's nature.  **
** As the answer, master did "rm -rif" on the programmer's home**
** directory. And then the C programmer became enlightened...  **
**     **
** Tomasz Rola  mailto:tomasz_r...@bigfoot.com **



Re: Configure OpenBSD for remote server rarely used

2022-11-27 Thread Tomasz Rola
On Sun, Nov 27, 2022 at 09:37:19AM +, James Johnson wrote:
> Hi all,
> 
> OpenBSD is amazing. But I need help in configuring it correctly as a
> remote server, rarely used. 
> 
> 
> The main thing I am trying to do is to make it sleep every now and
> then to protect resources. I am very flexible on how to do this, but
> have been unable to do so.
> Here's what I tried :
[...]

So to sum up your requirements, you want a self driving box which
waits, and once every month or six wakes up, does something, then goes
idle again.

I would avoid power down/up completely - boot takes time, and fsck
takes some more time. Also, AFAIK electronics wears down every time it
goes on-off.

Modern HDD are said to live to 5 on-off cycles, so assume 2
cold boots. But random things can happen, because on-off means power
spike. If you have no problem with eletricity, I would keep it going
all the time. I would however minimise writes. Work on temporary data
in ramdisk, write results to disk. Something like this.

BIOS battery goes down faster when computer is powered down. When it
is up, clock gets power from the wall and saves the battery. I assume
the modern CMOS battery will only keep the clock for about a year
without power and it will not recharge when you power up. After that
time (and before that time, too, but less necessary), every boot
should include query to time server and adjusting the hardware clock.

I would buy a decent PSU. Last time I wanted to know, Seasonic was the
maker of best ones a mortal could buy. Their last unit I bought came
with 10 years warranty. AND, according to description, it was built
with classic electronic art, analog parts, no digital. So if you are
so inclined, you can ask your electronic buddy to inspect it and
perhaps even replace some parts with better ones. Or repair it. If
microcontroller goes bunk, you are out of luck, I assume they somehow
protect their eproms.

If you plan to store some long term data on this box, I would avoid
SSD. They are fast but they also can go bunk and when they do, chance
of recovering data is close to nil (from what I have read).

I would consider putting the box in a plastic bag to protect from dust
and humidity. Dust will clog into radiators, make chips go hotter,
ventillators work harder. I have not tested this, however. I assume
thermal exchange with loose bag over the box should go ok, but you
need to test it very carefully, monitoring temps all the time - all
temps.

HTH

-- 
Regards,
Tomasz Rola

--
** A C programmer asked whether computer had Buddha's nature.  **
** As the answer, master did "rm -rif" on the programmer's home**
** directory. And then the C programmer became enlightened...  **
**         **
** Tomasz Rola  mailto:tomasz_r...@bigfoot.com **



Re: less prints superfluous characters with --no-init

2022-11-21 Thread Tomasz Rola
On Mon, Nov 21, 2022 at 08:51:36AM +0100, Jan Stary wrote:
> On Nov 21 01:38:41, rto...@ceti.pl wrote:
> > I guess it would not be very hard to just add few more *roff hacks
> 
> Stop right here.

My horses froze hanging in the air... :-)

-- 
Regards,
Tomasz Rola

--
** A C programmer asked whether computer had Buddha's nature.  **
** As the answer, master did "rm -rif" on the programmer's home**
** directory. And then the C programmer became enlightened...  **
**     **
** Tomasz Rola  mailto:tomasz_r...@bigfoot.com **



Re: less prints superfluous characters with --no-init

2022-11-20 Thread Tomasz Rola
On Mon, Nov 21, 2022 at 01:38:41AM +0100, Tomasz Rola wrote:
[...]
> I guess it would not be very hard to just add few more *roff hacks
> similar to one above. Or maybe a command (shell script) to retrieve
> relevant subsection from manpage and print just this one. And maybe
> also list names of subsections available on the page. It seems that
> '^[A-Z]( |[A-Z])+$' is the name regexp... So...

Forgot to mention that woman mode in emacs gives exactly this -
jumping to sections and some more.

-- 
Regards,
Tomasz Rola

--
** A C programmer asked whether computer had Buddha's nature.  **
** As the answer, master did "rm -rif" on the programmer's home**
** directory. And then the C programmer became enlightened...  **
**     **
** Tomasz Rola  mailto:tomasz_r...@bigfoot.com **



Re: less prints superfluous characters with --no-init

2022-11-20 Thread Tomasz Rola
On Sun, Nov 20, 2022 at 08:45:01PM +, Jason McIntyre wrote:
> On Sun, Nov 20, 2022 at 08:09:13PM +0100, Tomasz Rola wrote:
[...]
> > I am writing this from ParrotOS (Debian derivative) and since I am
> > avid user of bash, I can do "man bash-builtins" and it prints me a
> > very nice looking summary. Bash package version is 5.1-2+deb11u1,
> > which probably means 5.1 with some Debian-specific addons.
> > 
> 
> the thing is, you have to be aware of a builtins page in order to know
> to type "man builtins" (or whatever). you would need to know that a
> command is a builtin. but if you know it's a builtin, then you can just
> type "man ksh" and get the documentation.

Sure. As a matter of fact, I was for years grumbling about how long
bash manpage is and how long it takes to locate relevant info. Today I
have learned to look for "builtin(|s)" with apropos and here it is.

I have dug a bit deeper and  "zcat /usr/share/man/man7/bash-builtins.7.gz"
shows me that it is just a *roff hack to display subsection of bash
manpage. Worth remembering.

> we could add all these commands to ksh's NAME, but that would look awful.

I guess it would not be very hard to just add few more *roff hacks
similar to one above. Or maybe a command (shell script) to retrieve
relevant subsection from manpage and print just this one. And maybe
also list names of subsections available on the page. It seems that
'^[A-Z]( |[A-Z])+$' is the name regexp... So...

$  man bash | grep -iE '^[A-Z]( |[A-Z])+$'
NAME
SYNOPSIS
COPYRIGHT
DESCRIPTION
...
SHELL BUILTIN COMMANDS
... and so on.

-- 
Regards,
Tomasz Rola

--
** A C programmer asked whether computer had Buddha's nature.  **
** As the answer, master did "rm -rif" on the programmer's home**
** directory. And then the C programmer became enlightened...  **
** **
** Tomasz Rola  mailto:tomasz_r...@bigfoot.com **



Re: less prints superfluous characters with --no-init

2022-11-20 Thread Tomasz Rola
On Sun, Nov 20, 2022 at 01:32:54PM -, Christian Weisgerber wrote:
> On 2022-11-20, Reuben mac Saoidhea  wrote:
> 
> >> It is a builtin, so it is documented inside ksh.
> >
> > i think the 4.3BSD manual allowed for example `man while' for `man sh'?
> 
> FreeBSD has a builtin(1) man page that attempts to list the csh(1)
> and sh(1) builtins and points to the respective man pages:
> 
> https://www.freebsd.org/cgi/man.cgi?query=builtin
> 
> It's an attempt to do something about this problem, but I think the
> result isn't that great.

I am writing this from ParrotOS (Debian derivative) and since I am
avid user of bash, I can do "man bash-builtins" and it prints me a
very nice looking summary. Bash package version is 5.1-2+deb11u1,
which probably means 5.1 with some Debian-specific addons.

-- 
Regards,
Tomasz Rola

--
** A C programmer asked whether computer had Buddha's nature.  **
** As the answer, master did "rm -rif" on the programmer's home**
** directory. And then the C programmer became enlightened...  **
**     **
** Tomasz Rola  mailto:tomasz_r...@bigfoot.com **



Re: A minimal browser in base

2022-09-12 Thread Tomasz Rola
On Sat, Sep 10, 2022 at 09:04:54PM +0300, unix wrote:
> Hello. My reasons for this proposition:
> 1. The user will be able to test basic websites without installing
> anything.
> 2. The user will be able to read an incredibly useful official
> FAQ, with no external devices involved.
> 3. The user will be able to manage mailing list
> membership via the web interface. 
> 4. Using ftp(1) and reading pure HTML is inconvenient.
> 5. The browser (Lynx) was already included. It was removed due to
> concerns about code quality, licensing, and support for insecure
> protocols.
> You could say that you don't need a browser installed by default if you
> have a network connection and can install the package anyway.
> Still, am I the only one who feels like it's pretty much the only thing
> missing in the base for a comfortable day to day desktop usage?
> So, if we include a browser, which one?
[...]
> If you know about any other options, I will be interested in
> discussing them.

I do not want to derail the discussion but I think that if I can have
a pendrive with O*BSD install, then I can also have another pendrive
with some sources and maybe a bash script to compile them. For
browsing on the text console, I like emacs-w3m, which (if I am
correct) is w3m for rendering pages and emacs for showing them, with
tabs and easy way to copy-paste fragments into other emacs buffer, be
it a code or shell.

I would probably also have lynx on this pendrive, because it can open
gopher sites, so I can vent off some steam by looking at obsolete
stuff.

I realize that certain propositions are no-no for base system (and I
totally agree with this), which is why my best option is to be my own
guest and help myself.

In my opinion none of text browsers I use nowadays (links/elinks, lynx
&& emacs-w3m) will work on every website (some are polite enough to
tell me I need to turn js on). There is good chance with pages written
for programmers, however.

-- 
Regards,
Tomasz Rola

--
** A C programmer asked whether computer had Buddha's nature.  **
** As the answer, master did "rm -rif" on the programmer's home**
** directory. And then the C programmer became enlightened...  **
**     **
** Tomasz Rola  mailto:tomasz_r...@bigfoot.com **



Re: dump(8) is slow

2022-08-10 Thread Tomasz Rola
On Tue, Aug 09, 2022 at 07:06:04PM -0600, Theo de Raadt wrote:
> Tomasz Rola  wrote:
> 
> > Ok. But what is a theoretic speed limit for this device?
> > 
[...]
> 
> Bravo, you tested the speed at 1024 bytes of data per system call.

The OP complained his dump was slow. I was wondering if it was slow
because of problem with dump, or if the device from which he was
dumping was slow by itself.

If he did dd from device->null and measured time, he would have basis
to claim that slowness was a fault of dump - if dd was, say twice as
fast.

-- 
Regards,
Tomasz Rola

--
** A C programmer asked whether computer had Buddha's nature.  **
** As the answer, master did "rm -rif" on the programmer's home**
** directory. And then the C programmer became enlightened...  **
**     **
** Tomasz Rola  mailto:tomasz_r...@bigfoot.com **



Re: dump(8) is slow

2022-08-09 Thread Tomasz Rola
On Tue, Aug 09, 2022 at 02:21:21PM +0200, Christian Weisgerber wrote:
> Moving 9TB with dump|restore from an old hard disk to a bigger one
> reminded me again that dump(8) is, well, slow:
> 
>   DUMP: 9104433830 tape blocks
>   DUMP: Date of this level 0 dump: Sat Aug  6 16:36:52 2022
>   ...
>   DUMP: Date this dump completed:  Tue Aug  9 13:51:01 2022
>   DUMP: Average transfer rate: 36530 KB/s
> 
> That is far below the read-write speed of a modern SATA drive.
> systat(1) clearly showed that the source disk and dump(8) was the
> bottleneck, not the target disk and restore(8).  Too much seeking?

Ok. But what is a theoretic speed limit for this device?

If I do something like this on my laptop w/ssd:

 #  date +'%s'; dd if=/dev/sda2 of=/dev/null bs=1024 count=$((512*1024)); date 
+'%s'
1660089697
521565184 bytes (522 MB, 497 MiB) copied, 2 s, 261 MB/s
524288+0 records in
524288+0 records out
536870912 bytes (537 MB, 512 MiB) copied, 2,06702 s, 260 MB/s
1660089699

I tried it with reading first 512 megs, for you, since you want to
deal with terabytes, count= would need to be adjusted, say, 100 gigs?

Reasoning: the specification for sata says one thing, but it says
theoretical upper speed, if I am correct. So you want to know about
real speed limit of _this_ device.

-- 
Regards,
Tomasz Rola

--
** A C programmer asked whether computer had Buddha's nature.  **
** As the answer, master did "rm -rif" on the programmer's home**
** directory. And then the C programmer became enlightened...  **
**     **
** Tomasz Rola  mailto:tomasz_r...@bigfoot.com **



Re: Freeze on OpenBSD 7.1

2022-07-17 Thread Tomasz Rola
On Mon, Jul 18, 2022 at 12:14:20AM +0200, Tobias Fiebig wrote:
> Heho,
> If the machine just hardlocks (no panic), and the memory seems fine
> (did you run memtest?), and there are no blown elcos on the
> motherboard, my first guess would be testing another PSU; The
> pattern sounds familiar. 
> 
> Also, the voltages do not necessarily look overly healthy... but
> that might just be a fluke. 
[...]
> Could you help me please ? Thank you very much !
> 
> Nicolas, Paris.
> 
[...]
> hw.sensors.it0.volt0=4.08 VDC (VCORE_A)
> hw.sensors.it0.volt1=4.08 VDC (VCORE_B)
> hw.sensors.it0.volt2=4.08 VDC (+3.3V)
> hw.sensors.it0.volt3=6.85 VDC (+5V)
> hw.sensors.it0.volt4=16.32 VDC (+12V)
> hw.sensors.it0.volt5=4.01 VDC (-12V)
> hw.sensors.it0.volt6=4.05 VDC (-5V)
> hw.sensors.it0.volt7=6.85 VDC (+5VSB)
> hw.sensors.it0.volt8=4.08 VDC (VBAT)
> 

What Tobias wrote - voltages look way too much off. Onboard sensors
are not always trusty, so I would go with real voltmeter. If you do
not feel comfortable with electrical stuff, ask somebody for help.

I would:

1. turn computer off, open the case
2. find molex connector

 https://en.wikipedia.org/wiki/Molex_connector#Disk_drive

3. pull it out of the case so I could reach it without touching
insides of the case

4. turn computer on and start memtest

5. put black probe of voltmeter into black hole of molex
6. put red probe into another hole of molex (yellow or red) and see
what voltages it measures

Do not touch or move any cables beyound molex while the hw is powered
on. This means if you move molex cable, it should not push on other
cables - because some cables are very touchy touchy, like hdd data
connectors. 

>From what I recall, PSU voltages are good when within +- 5% of what
they should be. Yours look bad, because ~30% too big.

Bear in mind, I am not electrical engineer. If you do not own
voltmeter, this probably means you should ask for help of someone who
does.

-- 
Regards,
Tomasz Rola

--
** A C programmer asked whether computer had Buddha's nature.  **
** As the answer, master did "rm -rif" on the programmer's home**
** directory. And then the C programmer became enlightened...      **
**     **
** Tomasz Rola  mailto:tomasz_r...@bigfoot.com **



Re: www.openbsd.org unreachable for a few days

2020-12-15 Thread Tomasz Rola
On Tue, Dec 15, 2020 at 10:55:27AM -0700, Theo de Raadt wrote:
> Janne Johansson  wrote:
> 
> > Den tis 15 dec. 2020 kl 13:00 skrev Ottavio Caruso <
> > ottavio2006-usenet2...@yahoo.com>:
> > 
> > > Hi,
> > > I asked on Freenode#OpenBSD and apparently it's only me, but I haven't
> > > been able to access www.openbsd.org for a few days.
> > >
> > > $ traceroute 129.128.5.194
> > > traceroute to 129.128.5.194 (129.128.5.194), 30 hops max, 60 byte packets
> > >
> > >
> > ...
> > 
> > 
> > > 11  40ge1-3.core1.lon2.he.net (195.66.224.21)  35.068 ms
> > > 100ge4-1.core1.nyc4.he.net (72.52.92.166)  101.075 ms  86.105 ms
> > 
> > 
> > I heard a similar complaint elsewhere and that was going over he.net also,
> > whereas I could reach it in the mean time, going over shawn to ualbert.ca
> > and onwards, so I guess he.net is presently bad at routing to the correct
> > places.
> 
> Sorry, you'd be incorrect blaming he.net.
> 
> UofA border is doing some kind of broken filtering, or perhaps it is
> incorrect routing of replies into EDU network (cybera/canarie).
> 
> It is up to them to fix it, but there have been no replies yet.

I have just traced www.openbsd.org from Poland:

[... skip irrelevant part ...]
4  pl-waw02a-ri1-ae-0-0.aorta.net (84.116.138.94)  12.570 ms  13.431 ms  15.473 
ms
5  213.46.178.30 (213.46.178.30)  14.047 ms  15.825 ms  13.434 ms
6  100ge16-2.core1.par2.he.net (184.105.213.121)  39.736 ms  53.853 ms  41.229 
ms
7  100ge11-2.core1.nyc4.he.net (72.52.92.113)  107.904 ms  116.301 ms  109.851 
ms
8  100ge14-1.core1.tor1.he.net (184.105.80.10)  119.988 ms  124.484 ms  119.546 
ms
9  100ge6-1.core1.ywg1.he.net (184.105.64.102)  138.756 ms  140.801 ms  139.474 
ms
10  100ge5-2.core1.yxe1.he.net (184.104.192.70)  157.590 ms  153.117 ms  
155.520 ms
11  100ge11-2.core1.yeg1.he.net (72.52.92.61)  154.828 ms  154.963 ms  156.100 
ms
12  university-of-alberta-sms.10gigabitethernet2-2.core1.yeg1.he.net 
(184.105.18.50)  156.854 ms  157.227 ms  160.990 ms
13  cabcore-esqgw.corenet.ualberta.ca (129.128.255.35)  158.464 ms  163.029 ms 
katzcore-esqgw.corenet.ualberta.ca (129.128.255.41)  157.714 ms
14  * * *
15  gateway-5.ucs.ualberta.ca (129.128.5.1)  166.056 ms  155.914 ms  160.884 ms
16  obsd3.srv.ualberta.ca (129.128.5.194)  154.972 ms  160.039 ms  156.403 ms
2020-12-15 18:54:31  www.openbsd.org reachable

HTH,
-- 
Regards,
Tomasz Rola

--
** A C programmer asked whether computer had Buddha's nature.  **
** As the answer, master did "rm -rif" on the programmer's home**
** directory. And then the C programmer became enlightened...  **
** **
** Tomasz Rola  mailto:tomasz_r...@bigfoot.com **



Emulating ps/2 for usb keyboard [was Re: Mouse hotplug in X?]

2020-11-01 Thread Tomasz Rola
On Sun, Nov 01, 2020 at 01:12:30PM -0800, obs...@loopw.com wrote:
> note that ps/2 is not actually designed for hotplug (I fried a
> keyboard controller to bring you this knowledge)

Thanks. I kind of know about ps/2. Albeit it happened once or twice
that I hotplugged ps/2 keyboard. I later vowed to avoid it. Right now
it is unplugged - my old ps/2 kbs are running issues and I am not very
happy about it. I notice some lagging with my current usb kb, which is
the cheapest mech [1] I was able to find, so maybe this is because of the
"cheap". Or, the usb part of system (still Linux) is not so fast.

If gaming guys can give some clues, they seem to prefer ps/2 kbds,
which probably means the lag of usb is too big to suffer.

I would be happy to connect my kbd into ps/2 port one day, but a quick
test (usb kbd -> usb-to-ps2 converter -> ps2-to-usb converter -> usb
plughole) showed me that this one kbd cannot speak ps/2 protocol. I
also tested same procedure on rubber dome usb kbd from same maker and this one
connected without problem.

So, now I have a problem. I would like to keep plugging my new
keyboards into ps/2 hole. I really would. But for plugging the mech
which I have now, I would need some special kind of usb-to-ps/2
converter. The dumb one does not work and I could not find anything
better.

It is obvious I will be able to buy "some" ps/2 kbd for a while. But
they will be of deteriorating quality, post-office after-use
sell-outs. I will probably eke out for better mech, which will last me
good ten years. But, stuff breaks. And in the future there might be
usb-only kbds which will not understand how to talk "ps/2-ish". So,
obviously, to connect such keyboard into ps/2 hole, one would need a
translator. So far, the only DIY thing I _maybe_ could pull out is RPi
- it would take usb kbd into its usb port and translate characters (by
C program) into five gpio ports connected to ps/2 male plug. However,
using whole big RPi sounds a bit like overkill. And I am yet to learn
the stuff.

So, is there something I could hunt down, some kind of smarter
usb-to-ps/2 converter? For now, I am just curious and try to be
proactive with my hardware choices. But I will gladly learn if anybody
has a clue or hint for me (oh, not just for me, there are going to be
many more people like me, they just do not know yet).


[1] If anybody is curious, it was supposed to be my inroad into the
land of mechs. On the plus side, I love "ten key less" layout. I want
more of this. On the 50-50 side, it has Outemu Blue switches. They
work, but sometimes I have to press the key more than once (after
about year of not very heavy typing). I have it plugged into usb hub
with micro on-off switches for individual devices, so when I get
annoyed, I "hard reset" the keyboard and after that it somehow comes
back to the order. There is nothing on minus side yet. I expected it
would not be perfect for this price but it is better than I expected.

-- 
Regards,
Tomasz Rola

--
** A C programmer asked whether computer had Buddha's nature.  **
** As the answer, master did "rm -rif" on the programmer's home**
** directory. And then the C programmer became enlightened...  **
**     **
** Tomasz Rola  mailto:tomasz_r...@bigfoot.com **



Re: Mouse hotplug in X?

2020-11-01 Thread Tomasz Rola
On Sun, Nov 01, 2020 at 01:51:45PM -0500, Brennan Vincent wrote:
> Is it possible to get hot-plugging of USB mice to work? Can't find
> it in Google or man pages.

My X is hardly the newest one and I can testplug usb mice at
will. They work along ps/2 mouse (but just one mouse cursor/arrow, if
I recall - it was a bit of time since I did it last).

Same for keyboards.

-- 
Regards,
Tomasz Rola

--
** A C programmer asked whether computer had Buddha's nature.  **
** As the answer, master did "rm -rif" on the programmer's home**
** directory. And then the C programmer became enlightened...  **
**         **
** Tomasz Rola  mailto:tomasz_r...@bigfoot.com **



Re: How many IPs can I block before taking a performance hit?

2020-08-12 Thread Tomasz Rola
On Wed, Aug 12, 2020 at 03:00:03PM +0200, Martin Sukany wrote:
> Hi,
> 
> as the tables are stored in RAM anyway during thee processing it’s
> moreless matter of how fast are your DIMMs / CPU. I’m usually work
> with several tables with cca 30 K records - no impact on the
> performance so far.

So, for as long as the table(s) do not spill out of cpu's cache, it is
going to be a not so huge problem. If you run memtest, the difference
between various caches is big, but cache vs ram is huge.

Is there a way to have listing of offending IPs and perhaps grouping
them into /nn subnets - other than writing oneself the script?
Something as easy as awk might suffice, I guess - and then instead of
five rules, just one rule for a subnet. If IPs are close enough to
form a subnet (now, what is "close enough", there might be interesting
problem). Of course, this way, some IPs will be excluded even if
they did nothing wrong (yet).

Another nice thing to have might be a utility which looks for rules
and disables those which did not fired up during last x seconds (by
looking up through firewall logs, perhaps). I have no idea if there is
such utility and am not sure how to look it up.

-- 
Regards,
Tomasz Rola

--
** A C programmer asked whether computer had Buddha's nature.  **
** As the answer, master did "rm -rif" on the programmer's home**
** directory. And then the C programmer became enlightened...  **
**     **
** Tomasz Rola  mailto:tomasz_r...@bigfoot.com **



Re: Hardening browser

2020-03-08 Thread Tomasz Rola
On Sat, Mar 07, 2020 at 11:55:59AM -0700, Luke A. Call wrote:
> On 03-07 19:19, whistlez...@riseup.net wrote:
[...]
> > As I know many sites without js doesn't work. Anyway I don't understand
> > how switching off js defend you from 0day browser bug.
> > Maybe you mean that because many 0day concern javascript ?
> 
> Yes, as well as the general category of speculative execution CPU
> attacks, rowhammer-type attacks, evercookies that use javascript, 
> and/or whatever else I don't know about that is enabled by javascript.
> It just seems to be required for many attacks that one reads about, over
> time, and given that trend, probably some future ones, all from
> downloading unknown code to run locally.  For those fewer times when I do
> enable it, I'm glad for OBSD's various protections, to further lower
> risk.


I think switching js off is one (very important) thing. But, there is
more of it. Which is why I try to not load page-provided fonts and css
at all. In css (or in certain browser-specific variation), one can
embed js code, and same with svg file. I wonder if switching js off in
browser would then result in not executing embedded js as well?

Another fun read: Krebbs describes how browser extension has been sold
by original author and then used by new owner to detect if user works
on Wordpress or Joomla. If so, the "Page Ruler" injected small js
snippet into edited webpage.

   
https://krebsonsecurity.com/2020/03/the-case-for-limiting-your-browser-extensions/

I guess extensions work even with js switched off...

Etc etc

-- 
Regards,
Tomasz Rola

--
** A C programmer asked whether computer had Buddha's nature.  **
** As the answer, master did "rm -rif" on the programmer's home**
** directory. And then the C programmer became enlightened...  **
**         **
** Tomasz Rola  mailto:tomasz_r...@bigfoot.com **



Re: Hardening browser

2020-03-08 Thread Tomasz Rola
On Thu, Mar 05, 2020 at 12:25:56PM +0100, zeurk...@volny.cz wrote:
> Me's been following this discussion w/ some interest.
> 
> Personally, meuses lynx(1) (w/o the ports patches, as they interfere w/
> text field editing among other things), in image_links mode w/ feh(1).
> Works like a charm :)

I use lynx a lot, very nice tool. It also helped me to restart my
browsing of gopher sites. There was plenty of them 20+ years ago, now
it is just a handful of servers. But still, better than nothing.

[...]
> Occasionally, when really pressed, meruns 'tails', a specialized Lunix
> distro, from a DVD on a spare craptop; at least that way, mecan get rid
> of the bloated, buggy shit by simply turning off the machine.

I do not know tails, only read about it.

Using separate computers for different roles might be a way of the
future. A very convoluted way. But one cannot count too much on
security offered by modern popular cpus and there is always a chance
to be struck by something unexpected: I have just read that bmp file
from game server might make buffer overflow on client side. So, one
machine for gaming, one for reading, one for shopping and one for
work. And one for listing the music.

I will never propose this kind of solution to normal people. :-)

[...]
>  --zeurkous.
> 
> -- 
> Friggin' Machines!

Oh no, it is not the machines. It is their masters.

-- 
Regards,
Tomasz Rola

--
** A C programmer asked whether computer had Buddha's nature.  **
** As the answer, master did "rm -rif" on the programmer's home**
** directory. And then the C programmer became enlightened...  **
**     **
** Tomasz Rola  mailto:tomasz_r...@bigfoot.com **



Re: Hardening browser

2020-03-04 Thread Tomasz Rola
On Thu, Mar 05, 2020 at 04:18:00AM +0100, Tomasz Rola wrote:
[...]
> As a side note, I sometimes get a bit obsessed upon seeing a program
> which "sits idle" but scratches my disk every n seconds (and/or loads
> my cpu with empty loops). A daemon can be hunted down and nailed. No
> big deal. But a browser, it its grandiose form (say, ff) cannot be
> nailed and used at the same time. I (partially) solved the problem by
> putting ~/.cache-mozilla and ~/.mozilla on the ram disk. Now scratch
> me if you can, browser. Actually, ~/.cache-mozilla and ~/.mozilla are

I meant, ~/.cache/mozilla  is a dead symlink.

-- 
Regards,
Tomasz Rola

--
** A C programmer asked whether computer had Buddha's nature.  **
** As the answer, master did "rm -rif" on the programmer's home**
** directory. And then the C programmer became enlightened...  **
**     **
** Tomasz Rola  mailto:tomasz_r...@bigfoot.com **



Re: Hardening browser

2020-03-04 Thread Tomasz Rola
lways
the same, same session, same settings, same everything as was saved to
tar-files. The script is written with Elisp and duct tape, survived
more years than I intended for it (planned to rewrite it in civilised
Scheme dialect, but time too scarce to learn).

Performance is better when the said dirs are saved in tar. No more
zzz-zzz-zzz-ziping through multistaged directory structures. I
measured the times, so I know. Compressing does not help in this
case.

Of course, that way I cannot use bookmarks in ff, but that is not a
problem. I have already moved with bookmarking to org-mode. And good,
because I doubt any browser would deal with ca. 100k bookmarks (once I
was off the limits imposed by a browser, I kept adding and see where I
ended).

On the darker side of things, I am to introduce older family member to
the World of Widely screW-W-Wed Web. The plan is to configure her
browser like I do for myself (minus ramdisk, settings will be saved),
but I am very much afraid the experience will be shocking and
grievious for one of us. Either she will have to deal with noscript
all the time, which is only so-so experience, but the alternative is
that I keep imagining how she gets undead shit loaded from all over
the WWW-world. I swallow noscript because I know what is the deal. Not
sure if I can properly translate it to beginner user. I tried
translating to medium-advanced younger user and failed miserably - she
does not remember what I told her, not even the name "noscript" stays
in memory, so after repeating ten+ times (over many months) I
acknowledged my pitiful failure (fortunately, only I remember it) and
reiteraited to the lair.

Any ideas? The host is going to be laptop with Mint Xfce (yes, I have
strong obsession against Unity), but I might move it to obsd one day
(thanks to chronic lack of time I myself still had not moved out of
Linux yet). TIA :-)

-- 
Regards,
Tomasz Rola

--
** A C programmer asked whether computer had Buddha's nature.  **
** As the answer, master did "rm -rif" on the programmer's home**
** directory. And then the C programmer became enlightened...  **
**     **
** Tomasz Rola  mailto:tomasz_r...@bigfoot.com **



Re: Softdep and noatime

2019-11-30 Thread Tomasz Rola
On Sat, Nov 30, 2019 at 09:20:37PM +0100, Xianwen Chen (陈贤文) wrote:
> Dear Mr. Rola,
> 
> > I wonder what other will say about this, but I mount everything as
> > noatime, since more than a decade, spinning or not. I assume this may
> 
> Do you mount swap as noatime too, I'm curious?
> 
> Yours sincerely,
> Xianwen

Hello,

Frankly, I have never considered atime or noatime option for swap. I
think there is not much use for atime in swap anyway. Access time for
memory pages, this is another story. I guess some optimisation
algorithms make use of this information.

Ok, so not "everything", I only mount filesystems as noatime. :-)

-- 
Regards,
Tomasz Rola

--
** A C programmer asked whether computer had Buddha's nature.  **
** As the answer, master did "rm -rif" on the programmer's home**
** directory. And then the C programmer became enlightened...  **
**     **
** Tomasz Rola  mailto:tomasz_r...@bigfoot.com **



Re: Softdep and noatime

2019-11-30 Thread Tomasz Rola
On Sat, Nov 30, 2019 at 06:12:42AM -0700, Raymond, David wrote:
[...]
> On SSDs in particular, is it worth setting noatime to reduce the
> number of disk writes?
[...]

I wonder what other will say about this, but I mount everything as
noatime, since more than a decade, spinning or not. I assume this may
make lifetime a bit longer and decided it is better to be on safe(r)
side.

-- 
Regards,
Tomasz Rola

--
** A C programmer asked whether computer had Buddha's nature.  **
** As the answer, master did "rm -rif" on the programmer's home**
** directory. And then the C programmer became enlightened...  **
**         **
** Tomasz Rola  mailto:tomasz_r...@bigfoot.com **



Re: Tools for writers

2019-11-02 Thread Tomasz Rola
On Sat, Nov 02, 2019 at 03:00:28PM +, Oliver Leaver-Smith wrote:
> Hello,
> 
> What tools do people find useful for writing on OpenBSD? By writing
> I mean long form such as novels and technical books, including plot
> and character development, outlining, and formatting for publishing
> (not all the same application necessarily)
> 
> I have found a number which boast Linux support, but not really
> anything that stands out which supports OpenBSD (aside from the
> obvious LaTeX et al.)
> 
> Mich appreciated
> 
>  ~ols

I am not sure what is your ability to learn tools - no offence, but
some people want to have it as WYSIWIG, period, and I am mostly ok
about it (as long as they also do their cleaning). However, my unholy
opinion is, if you plan for your words to be readable with the least
problem say, twenty years from now, then you should stick with text
based formats for, er, text and learn few tools that can process such
format.

So,

 - LaTeX for writing a book

It is possible to have parts of a text in various files, which can be
included into main file - various ways of developing plot, etc. It is
possible to have many versions of same book, including chapters into
them as separate files. And so on. I am not sure if a writer actually
needs this much flexibility, but a lot is possible if you would like
to mess with different ways to organize a book.

 - Emacs for editor

This part is tricky, but I definitely prefer Emacs. Some prefer Vim
and I agree it is very fine editor, but myself, I go with Emacs. I
stay away from anything web based, browser based and Javascript
based. All of those look like ticking bombs to me. When they go (not
an unlikely event, IMHO) those depending on them are left to
freeze. Or they will be dying a death of thousand worms loaded from
some far away countries in their just-updated JS library.

 - Org mode for plot/characters and stuff

Org mode is kind of program running inside Emacs (not really, but do I
want to delve into talking about Lisp, loadable code and programmable
editors). Or, it is a way to have one's own personal wiki in a file,
without the need for web server and whatnot. Very handy, if you ask
me.

All those are tools and require some learning. In my case, I read a
tutorial built into Emacs (say, an hour of reading + learning to press
right keys), I read some chapters from Leslie Lamport book on LaTeX
(say, maybe few hours of trying stuff inside Emacs and producing
documents with it). As of Org-mode, I caught some basics and started
going, then caught some more and there is still 98% or more to learn,
but as I do not have to, I just use what I know and keep going.

There are few more tools which might be useful for above case.

 - pandoc for converting from LaTeX to ODT (i.e. Open Office) - I have
   not used it but some people say it works

 - version control - whatever is easier, I have just set my own
   org-mode based "wiki" into RCS. RCS is amongst the oldest such
   system still in use, but I did not wanted to mess with other
   things, for a while. Now, if I make a mistake, press wrong key
   combo and delete half of my wiki, I might have better chance to
   recover from this error. There are many version control systems to
   choose from, I think most will work locally on your computer
   without prematurely exposing the book to the outside world.

This email was written in Emacs, BTW. I get easy formatting for free.

Of course, tools have quirks. I think so. I got used to them and
forgot, so I am unable to say more about this. So maybe the learning
experience will not be peachy rosy for you at first, but I would say
positives prevail over time.

HTH

-- 
Regards,
Tomasz Rola

--
** A C programmer asked whether computer had Buddha's nature.  **
** As the answer, master did "rm -rif" on the programmer's home**
** directory. And then the C programmer became enlightened...  **
**     **
** Tomasz Rola  mailto:tomasz_r...@bigfoot.com **



Re: BACK TO BASICS

2019-10-11 Thread Tomasz Rola
On Fri, Oct 11, 2019 at 06:34:10PM +0200, Sylvain wrote:
> Le 11 octobre 2019 18:08:22 GMT+02:00, "Theo de Raadt - dera...@openbsd.org" 
>  a écrit :

Holy fork, now this is a long email address...

> >openbsd.s...@0sg.net wrote:
[...]
> >
> >That's right, because monopolies always serve the public better!
> 
> Rhetorically this answer sounds actually right... 

But I suspect it is given with a really long tongue in a cheek. Or
maybe not?

-- 
Regards,
Tomasz Rola

--
** A C programmer asked whether computer had Buddha's nature.  **
** As the answer, master did "rm -rif" on the programmer's home**
** directory. And then the C programmer became enlightened...  **
**     **
** Tomasz Rola  mailto:tomasz_r...@bigfoot.com **



Re: Postscript printer recommendations

2019-07-14 Thread Tomasz Rola
On Sun, Jul 14, 2019 at 12:09:20AM -0600, Jonathan Drews wrote:
> On Sun, Jul 14, 2019 at 06:03:05AM +0200, Tomasz Rola wrote:
> > On Sat, Jul 13, 2019 at 08:06:07AM +0200, Jonathan Drews wrote:
> > > Hi Folks:  I need some recommendations on what brand of printers will
> > > work
> > > with Ghostscript (Postscript). The cartridges for my 15 year old HP
[...]
> > 
> > I am not sure why you want to avoid CUPS.
>  
> I have had difficulty getting cups to work in the past. I am just a simple
> desktop user, so I really don't have a great grasp of computer
> fundamentals. That begs the question as to why a desktop user would
> use a complicated system like OpenBSD. Short answer:
[...]

Overally, I agree with your opinions except with that saying that
OpenBSD is complicated. But it may be subjective. Try to imagine
someone who wants to change wheels in a big truck, in a middle of a
desert, with his bare hands (because the lousy car maker gave no
tools). This is how my experiences with Windows were so far and *this*
was complicated.

> I never could get CUPS working in previous versions of OpenBSD.
> Also, IIRC CUPS requires chown and chmod to certain /dev files. I am
> loathe to do that. I really don't want to mess with root file
> permissions. IMHO, if you need a service, then add your account to
> the appropriate group in /etc/groups.
> 
[...]
> > 
> According to Xerox's web page on Postscript, they claim that
> Postscript gives higher quality renderings:
> 
> "Unlike PCL, PostScript is device independent. This means that the
[...]
> device. Specifically, the graphic objects will be consistent and in
> some cases of higher quality than PCL."

I smell marketing, unless they can show some examples which do not
look like being specially crafted to prove their case. Of course,
there might be differences - each time one wants to simulate a
continuous line from square/round dots, there was plenty of research
that went into achieving this illusion to satisfy the eye and I expect
each of the great printer companies to have some patented algorithms of
achieving the goal. But, since they are in the game for many decades,
I expect the results to be comparable.

Ok, so to sum up, so far you are ok with quality of your printer, just
not so happy with Windows side?

My own experience with CUPS was only so-so. About 7-10 years ago I
connected my old (by then) HPDJ 840C and things did not work. So I
mangled system a bit: I assumed one of the previous HPDJs was close
relative to mine, copy-pasted description of either 630 or 620c
(sumthing like this) and changed names to 840c (and maybe I changed
some more, I really do not remember, it should be in old config
files). From what I remember, CUPS caught up even though I was never
sure why. Perhaps I had to resign from using the highest dot density
supported by 840, but this was not a big deal since I wanted economic
print, so I used 300 and 150dpi and dithering, rather than more dpis
and full ink.

So, CUPS worked for me, after a while. However, I am not sure if I
would be able to help with setting it up - a year ago my twenty years
old dj went into cartoon box (inks and printing heads - they were
mostly ok but ink replacement dried up and I only printed once or
twice a month, each time having to unmount the cartridge and wash
heads in sumthin (sometimes isopropanol, sometimes lcd cleaner, which
ever was at hand). The CUPS side, however, once it was up, it stood
up, so I cannot complain. And it has got nice www interface, allowing
me to set up few virtual printers (say, one for color print, one for
300dpi, and so on). But, it could probably be set up without CUPS.

Perhaps you can arrange things so that you can try whichever printer
works for you and is supported on OBSD, and compare same printed pages
with whatever the bestest print thing there is in a nearby print shop?
>From my experience (in my city and country) such shops are located
near universities and cater to students, so they must be
affordable. Chances are, the personnel will happily voice their
opinions on the subject (just like any other opinion, incl mine, apply
salt, especially that they may sell printers, too).

-- 
Regards,
Tomasz Rola

--
** A C programmer asked whether computer had Buddha's nature.  **
** As the answer, master did "rm -rif" on the programmer's home**
** directory. And then the C programmer became enlightened...  **
** **
** Tomasz Rola  mailto:tomasz_r...@bigfoot.com **



Re: Postscript printer recommendations

2019-07-13 Thread Tomasz Rola
On Sat, Jul 13, 2019 at 08:06:07AM +0200, Jonathan Drews wrote:
> Hi Folks:  I need some recommendations on what brand of printers will
> work
> with Ghostscript (Postscript). The cartridges for my 15 year old HP
> Deskjet have gotten too expensive. I know Xerox makes some
> Postscript printers. Are there any other manufactureres of Postscript
> printers? I am running OpenBSD 6.5 as a desktop. Any advice would be
> appreciated. Also, I just want to use printcap and lpd. I would like to
> avoid CUPS. Kind Regards,
> Jonathan

I am not sure why you want to avoid CUPS.

In case it is not clear, Postscript is just a programming language
(stack based, somewhat like contorted Forth with graphics
instructions, go have a /usr/bin/less on your favourite *.ps file and
see). The printer "supporting Postscript" is just the one with CPU and
enough memory to run interpreter inside the box.

Thus, just like one feeds txt file to raw printer and gets raw txt
display, so - I think - one feeds ps file and printer runs it,
resulting in printing page (consecutive pages). I believe no special
filter is necesary, because ps files start with magic line (well, some
do not, possibly those produced by some proprietary programs, but I
cannot recall right now) and chances are, PS-printer will recognize
such line and act accordingly.

However, I have seen documents, even single pages, with so many
details that Ghostview running on relatively recent computer choked on
it. I have no idea how much memory PS-printer can have, but I would
not count on it having enough. My current desktop has 12gigs and four
cores (not very fast), but obviously only one is tired by GV.

I would try going with CUPS and printer with good resolution. Unless
you have very specific needs requiring exactly such device (hard to
tell, specific people have specific needs). But why running an
interpreter and producing a bitmap onboard a printer would be better
than running an interpreter (possibly up-to-dated) and sending a
bitmap to the printer? Would one be able to spot a difference? Just
curious.

-- 
Regards,
Tomasz Rola

--
** A C programmer asked whether computer had Buddha's nature.  **
** As the answer, master did "rm -rif" on the programmer's home**
** directory. And then the C programmer became enlightened...  **
**     **
** Tomasz Rola  mailto:tomasz_r...@bigfoot.com **



Re: Future of X.org?

2019-07-08 Thread Tomasz Rola
On Mon, Jul 08, 2019 at 06:01:52PM -0400, Steve Litt wrote:
[...]
> I use Openbox with program instantiation via dmenu. Now here's the
> thing: dmenu is written in pure X: No qt, no gtk, no xforms. Dmenu
> does its job perfectly, so quickly that instantiation from hotkey is
> imperceptable, as is menu changes in response to keystrokes.

I did not know about dmenu, will have a look when spare time comes,
thank you for a hint.

[...]
> If Wayland is now reliable and safe enough to use in OpenBSD, fine,
> include it. But those who call for X11's removal are just asking for
> trouble like the 2012-2015 systemd wars that plagued Linux and which
> OpenBSD avoided.

This new daemon was exactly the reason I subscribed to this list (and
few others, to sniff on alternatives), even though various events kept me
from installing OBSD (or anything else) so far.

-- 
Regards,
Tomasz Rola

--
** A C programmer asked whether computer had Buddha's nature.  **
** As the answer, master did "rm -rif" on the programmer's home**
** directory. And then the C programmer became enlightened...  **
**     **
** Tomasz Rola  mailto:tomasz_r...@bigfoot.com **



Re: Future of X.org?

2019-07-08 Thread Tomasz Rola
On Mon, Jul 01, 2019 at 07:18:18PM +0200, Ingo Schwarze wrote:
[...]
> 
> Frankly, there is not much point in non-developers discussing
> whether additions to base are acceptable.  Feel free to suggest

Well, whatever developers come up to, I hope I will be able to
continue using FVWM, on top or inside the thing. I only post in this
thread because I sense there are many people out there (I do not mean
you) who equal graphical environment with the lookalikes of Windows
and Mac (KDE, Gnome2 or 3). For me, that is too bloated and sometimes
too inefficient. I had been using both KDE and Gnome for few years in
total (and quite a few years ago, so my experiences are probably
outdated), but after one upgrade KDE just stopped responding (possibly
went into some O(n^2) loop while updating some internal database) and
Unity just could not deliver for me (to say it politely). Also,
cluttering display with permament menubars and this trash in the
bottom had just lost its novelty after a while and became tiring to
me.

I make use of relatively huge virtual desktop (few-by-few screens) and
open many windows. I would like to experiment with making some scripts
for FVWM, to help me with juggling the mess around.

As long as I can keep doing this, I will be happy (I guess). Thank you.

Oh, and BTW I am huge fan of starting in text mode, so I turn off
graphical logins whenever I can.

-- 
Regards,
Tomasz Rola

--
** A C programmer asked whether computer had Buddha's nature.  **
** As the answer, master did "rm -rif" on the programmer's home**
** directory. And then the C programmer became enlightened...  **
**     **
** Tomasz Rola  mailto:tomasz_r...@bigfoot.com **



Re: OT: hardware war with manufacturers (espionage claims)

2019-07-06 Thread Tomasz Rola
On Sat, Jul 06, 2019 at 07:56:10PM +0200, Tomasz Rola wrote:
[...]
> machine, two of which killed more than six hundred people, before
> someone turned the switch. As for now, there was a way to stop it.

I have rechecked and the number of fatalities was 189 and 157,
totaling 346 people. Please excuse my error.

-- 
Regards,
Tomasz Rola

--
** A C programmer asked whether computer had Buddha's nature.  **
** As the answer, master did "rm -rif" on the programmer's home**
** directory. And then the C programmer became enlightened...  **
**         **
** Tomasz Rola  mailto:tomasz_r...@bigfoot.com **



Re: OT: hardware war with manufacturers (espionage claims)

2019-07-06 Thread Tomasz Rola
On Fri, Jul 05, 2019 at 09:49:02PM -0600, Theo de Raadt wrote:
> Stuart Longland  wrote:
[...]
> 
> > Basically your best bet: don't rely on a single vendor.  It's harder for
> > them to hide their espionage then as one vendor won't know how to hide
> > another vendor's dirty deeds.
> 
> Precisely.  Most of the risks are in the bugs, and if you hit a problem
> you'll be Dennis Muilenburg saying you didn't know (that phrase works
> one way today, but if in the next few days he leaves his position, it
> will work a different way).  The unknown risk factors are first unknown
> and potentially accidental, and secondly unknown and now we are supposed
> to guess it wasn't accidental.  Vendors are wired to increase
> performance and noone judges security aspects, that the process where
> the "accident" arises.  Maybe we should suddenly accuse absolutely
> everyone of malpractice!  As if that will change anything...

While the problems of spying on individuals are important and have an
ugly side [1], I think nowadays [2][3] that long term, the real problem
will be autonomous hardware. Just like two recent catastrophes
involving Boeing. On the one side, it may be seen as unfortunate
sequence of human errors, fueled by greed (fueled by procreation
drive). On the other side, the very same decisions led to making a
machine, two of which killed more than six hundred people, before
someone turned the switch. As for now, there was a way to stop it.

I wait in terror for "our devices never stop".

[1] I am not sure, do they have a nice side? perhaps if certain
kind of crimes could be fought with it?

[2] This can change in the future - GIGO, FIFO, you all know it

[3] Oh, I did not come to it all by myself. If some of you have a
chance, try reading Stanislaw Lem. Some of his works have even been
translated to English (but I cannot say how well, opinions say very
well, but then again US editors like changing what they print from
original versions (anecdotic evidence, surprisingly too many to
ignore)). Do not be misled by his joking tone. The man survived in the
heart of WW2 and witnessed both post-war and Cold War. People mostly
take things at the face value. He told them jokes about humanity and
readers had a good time. Some, not so good.[4]

[4] For shortified super-short version, try Henry Kuttner's "Twonky".

> So this is misc, which is full of lots of talk about nothing, by people
> who can't change the ecosystem.  Having worried vocally about this
> before, I know I can't change it.  Pretty sad to see people who are even
> less capable find the energy to moan about it.  Especially americans.
> Know what I mean?

Humans, when faced with inevitable, do:
1. forget it is inevitable
2. phantasise about something nice, to kill time while waiting for it

Do not expect too much from a jello between the ears. For our
limitations, we came surprisingly far and long, albeit some are saying
there will be cost and paying the bills and dies irae et calamitatis.

Who knows. Nothing in nature is free, eh? I guess there is a lot of
shifting stuff around, so those who pay the bills are not those who
got the credit.

Sorry for being so much offtopic. On the other hand, we are living in
a future, so maybe this is more on topic than one would expect. People
here are involved in creating significant portion of our lifes. Not
that I see any way to make use of it, I am too apathetic for this.

-- 
Regards,
Tomasz Rola

--
** A C programmer asked whether computer had Buddha's nature.  **
** As the answer, master did "rm -rif" on the programmer's home**
** directory. And then the C programmer became enlightened...  **
** **
** Tomasz Rola  mailto:tomasz_r...@bigfoot.com **



Re: Cheaper alternatives for APC UPS

2018-12-17 Thread Tomasz Rola
On Mon, Dec 17, 2018 at 09:47:25PM +0100, Radek wrote:
> Hello,
> 
> could you recommend me any UPS brands *cheaper* than APC that are
> fully supported in OpenBSD?
> I always use APC, managing them via USB and apcupsd(both servers and
> clients) and PowerChute(windows clients). It works like a charm.
> APC is quite expensive brand so I am looking for any cheaper
> alternatives.

I am not sure about "supported", but for a while I used Fideltronik
and was satisfied (battery failed after some years of good job). Alas,
it gave approximated sinus, and I want true one nowadays. The only
choice available in the limits of my budget is either used APC or
another brand, new European-by-the-name-seemingly. I used a second
hand APC (1000-something, blinking leds model), after some years
batteries died and I decided to try this other option. It worked fine
for two years, then died. Upon inspection I found that certain part
inside looked like burned, with ash on it (possibly burned
plastic). Also, I cannot bet on it because I stuffed the battery
somewhere ("hey I can reuse that for a hobby!") and am not sure where
it is, but I would say there was single 6v unit inside. As far as I
can tell, the ups never reported more than 50% load, so I do not think I
overworked it.

Anyway, I could easily lift its battery on two fingers, maybe
three. In both APCs (I am on another second hand now, again
1000-something but now with lcd display) there are two 12v batts (I
think) and I would rather not want to lift any of them other than on
full arm. The first second-hand will probably be inspected and turned
into spare unit, because the current one will finish itself too, one
day. But the batts can be replaced in both models.

HTH

-- 
Regards,
Tomasz Rola

--
** A C programmer asked whether computer had Buddha's nature.  **
** As the answer, master did "rm -rif" on the programmer's home**
** directory. And then the C programmer became enlightened...  **
**     **
** Tomasz Rola  mailto:tomasz_r...@bigfoot.com **



Re: Common Lisp and OpenBSD

2018-11-25 Thread Tomasz Rola
On Sun, Nov 25, 2018 at 05:17:20AM -0500, Programmer wrote:
> There don't seem to be any Common Lisp libraries available as
> packages.  I'd be interested in packaging the most common and mature
> Common Lisp libraries, but I'm not certain who I'd discuss this with.
> 
> I'd appreciate any help with getting started contributing to OpenBSD.

Dear Programmer,

I am not going to tell you what to do, but if I had enough free time
to consider such projects, I would go and ask if Quicklisp project
needs some help from me (in case you do not know, it is a package
installer for Common Lisp).

https://www.quicklisp.org/beta/

http://blog.quicklisp.org/2018/10/october-2018-quicklisp-dist-update-now.html

Zach Beane is the author (it seems) and is doing enormous job. It
looks like in best case you would be replicating his work, which, with
all due respect to OpenBSD, might get ignored if you cannot keep up
with updating ports at his speed. I, for one example, would rather
stick with quicklisp, because it is going to work everywhere when CL
is installed (well, mostly).

While I have never done it, I guess making one system wide quicklisp
install is easy to do, probably just add user and have his quicklisp
files word- or group readable. And have users read this guy's
setup.lisp from quicklisp install.

And quicklisp allows me to keep using old versions of installed libs,
which ports cannot give me, AFAICT. This one feature is worth going QL
way. At least to me.

HTH

-- 
Regards,
Tomasz Rola

--
** A C programmer asked whether computer had Buddha's nature.  **
** As the answer, master did "rm -rif" on the programmer's home**
** directory. And then the C programmer became enlightened...  **
**     **
** Tomasz Rola  mailto:tomasz_r...@bigfoot.com **



Re: find the process that heavily uses a disc

2018-10-27 Thread Tomasz Rola
On Tue, Oct 16, 2018 at 02:22:16PM +0200, Rudolf Sykora wrote:
> Hello,
> 
> please, how can I monitor disk usage and tell
> what process is using it heavily?
> 
> (I hear [and see] that the disk is being used,
> but cannot think of a process that would cause
> it.)

I would start with atop, it has a column for RDISK and WDISK.

If you cannot atop, there is about 78% chance that killing a browser
will solve the problem.

HTH

-- 
Regards,
Tomasz Rola

--
** A C programmer asked whether computer had Buddha's nature.  **
** As the answer, master did "rm -rif" on the programmer's home**
** directory. And then the C programmer became enlightened...  **
**     **
** Tomasz Rola  mailto:tomasz_r...@bigfoot.com **



Re: ksh equivalent to shell-expand-line

2018-10-07 Thread Tomasz Rola
On Sun, Oct 07, 2018 at 11:17:37PM +0200, John Ankarström wrote:
[...]
> 
> To which message is this a response?  It seems I haven't received
> it, but I'd like to read it.  Tomasz?

I have sent you a message offlist, see if you have it.

-- 
Regards,
Tomasz Rola

--
** A C programmer asked whether computer had Buddha's nature.  **
** As the answer, master did "rm -rif" on the programmer's home**
** directory. And then the C programmer became enlightened...  **
**     **
** Tomasz Rola  mailto:tomasz_r...@bigfoot.com **



Re: ksh equivalent to shell-expand-line

2018-10-07 Thread Tomasz Rola
On Sun, Oct 07, 2018 at 07:47:46PM +0200, Klemens Nanni wrote:
> On Sun, Oct 07, 2018 at 07:30:15PM +0200, Tomasz Rola wrote:
> > Another trick may be executing the line with echo prepended - should
> > do all expansions and write what will be executed. I think it is not
> > going to work too well if for loop is being echoed, and other such
> > things, so perhaps quoting a command and echoing would do the job.
> This will break any non-trivial construct including pipes, command lists,
> loops, (nested) quoting, et al.

And let's not forget about redirections - any writing/appending inside
expansion will make echoing it even more non-trivial.

However, the same can be said about M-C-e in command prompt - how is
the shell going to know it should not expand this particular part,
because it calls a script which appends to / deletes from database?
And lets say it deletes not quite what we want? Because we are
prototyping on live command.

Which makes me say again, if this is such nontrivial, then I choose
writing a script.

-- 
Regards,
Tomasz Rola

--
** A C programmer asked whether computer had Buddha's nature.  **
** As the answer, master did "rm -rif" on the programmer's home**
** directory. And then the C programmer became enlightened...  **
**     **
** Tomasz Rola  mailto:tomasz_r...@bigfoot.com **



Re: ksh equivalent to shell-expand-line

2018-10-07 Thread Tomasz Rola
On Sun, Oct 07, 2018 at 10:13:16AM +0200, Otto Moerbeek wrote:
> On Sun, Oct 07, 2018 at 08:48:52AM +0200, Tomasz Rola wrote:
> 
> > On Sun, Oct 07, 2018 at 12:03:31AM +0200, Klemens Nanni wrote:
> > > On Sat, Oct 06, 2018 at 09:38:42PM +0200, John Ankarström wrote:
> > [...]
> > > And yet, it disregards quoting and will errornously expand the following
> > > example into multiple words instead of one:
> > > 
> > >   bash-4.4$ echo "$(echo a b)"
> > >   bash-4.4$ echo a b
> > 
> > Just in case it matters to anybody:
> > 
> >   $ echo "$(echo a b)"
> > a b
> >   $   bash --version
> > GNU bash, version 4.2.25(1)-release (x86_64-pc-linux-gnu)
> > 
> > Looks like something changed in between?
> 
> This is not about executing the line, it's abouty expanding using Ctrl-Alt-e

I can see now (side note to myself: do not ever never again reply to
emails before going to sleep at morning, sorry).

So, can this problem be described as that OP cannot expand this stuff
in his memory (this jello ram between the ears), because it has got
too complicated? Perhaps this can be helped by writing things into a
proper script? I performed a lot of $() things in cli but never
learned about M-C-e, so I assume I never did things that required this
trick. Hence a script suggestion.

Another trick may be executing the line with echo prepended - should
do all expansions and write what will be executed. I think it is not
going to work too well if for loop is being echoed, and other such
things, so perhaps quoting a command and echoing would do the job.

Seems like it works in bash as I hoped:

==>$ echo "for i in $(seq 3); do circle ${i}; done"
for i in 1
2
3; do circle ; done

HTH
-- 
Regards,
Tomasz Rola

--
** A C programmer asked whether computer had Buddha's nature.  **
** As the answer, master did "rm -rif" on the programmer's home**
** directory. And then the C programmer became enlightened...  **
** **
** Tomasz Rola  mailto:tomasz_r...@bigfoot.com **



Re: ksh equivalent to shell-expand-line

2018-10-07 Thread Tomasz Rola
On Sun, Oct 07, 2018 at 12:03:31AM +0200, Klemens Nanni wrote:
> On Sat, Oct 06, 2018 at 09:38:42PM +0200, John Ankarström wrote:
[...]
> And yet, it disregards quoting and will errornously expand the following
> example into multiple words instead of one:
> 
>   bash-4.4$ echo "$(echo a b)"
>   bash-4.4$ echo a b

Just in case it matters to anybody:

  $ echo "$(echo a b)"
a b
  $   bash --version
GNU bash, version 4.2.25(1)-release (x86_64-pc-linux-gnu)

Looks like something changed in between?

-- 
Regards,
Tomasz Rola

--
** A C programmer asked whether computer had Buddha's nature.  **
** As the answer, master did "rm -rif" on the programmer's home**
** directory. And then the C programmer became enlightened...  **
**         **
** Tomasz Rola  mailto:tomasz_r...@bigfoot.com **



Re: Some highlights: Emacs 21.4 and 25.3

2018-10-02 Thread Tomasz Rola
On Tue, Oct 02, 2018 at 04:40:53PM -0400, John M wrote:
> Personally I use Emacs 25.x on OpenBSD 6.3, with the caveat being that
> I rely on a number of customizations to normalize behavior to be what I
> expect. I would suggest using whichever version annoys you the least.

Yeah. After learning that 25 has Webkit support and 26 has threads, I
have made resolution to manually compile Emacs for myself. Since I am
yet to install OpenBSD, I have no idea what are defaults there and
whether I would like them, but it looks like I have to check for such
things nowadays. Which makes inclusion of 21 even more understandable
and plausible safe choice.

> >> And I am tired that in some modes I cannot get emacs to stop
> >> writing things (like indentation) that I do not type.
> >
> > I believe there is a variable to customize for this behaviour. I will
> > know the variable name when I find it in Elisp code down there in
> > sources. After that, googling for this name will be very easy.
[...]
> 
> This may be a bit off-topic but the feature responsible for this is
> 'electric-indent-mode', which is enabled by default in 24.4 or later.
> 
> http://www.gnu.org/software/emacs/manual/html_node/emacs/Indent-Convenience.html#index-Electric-Indent-mode
> 
> Put (electric-indent-mode -1) somewhere in your Emacs configuration
> when using 24.4 or later.

Ah so this is the name. Thank you!

-- 
Regards,
Tomasz Rola

--
** A C programmer asked whether computer had Buddha's nature.  **
** As the answer, master did "rm -rif" on the programmer's home**
** directory. And then the C programmer became enlightened...      **
** **
** Tomasz Rola  mailto:tomasz_r...@bigfoot.com **



Re: Some highlights: Emacs 21.4 and 25.3

2018-10-02 Thread Tomasz Rola
On Tue, Oct 02, 2018 at 03:55:31PM +, Roderick wrote:
> 
> On Tue, 2 Oct 2018, Solene Rapenne wrote:
> 
> >emacs 25 has a X11 flavour -athena which do not use gtk, but you need
> >to build it from ports, there is no package for it.
> 
> And indeed I do that.
> 
> I thought that perhaps 21.4 is more stable, or less bloated ...
> 
> Interessting remains to know, what the reson was.

Your remarks prompted me to have a look myself - so those are just my
wild guesses, but:

 - a comparison between announcements for 21.1 and 22.1

http://lists.gnu.org/archive/html/info-gnu-emacs/2001-10/msg9.html

http://lists.gnu.org/archive/html/info-gnu-emacs/2007-06/msg0.html

   tells me that support for GTK started with 22.1 - and if so then 21.4
   is the latest bugfixed version without it, while still enabling
   color themes (and custom fonts?), which are very nice to have (me
   being color abuser).

 - myself, I am using 23 and 24, and comparison of their "concept
   index" info nodes shows there are 1582 and 1863 items,
   respectively. Some of those new concepts were introduced earlier
   and only documented in 24 but this gives a glimpse into amount of
   ongoing changes. There are some new Elisp functions in 24 and
   various sets of installed Elisp files for each, which makes
   supporting them both in my dot-emacs an interesting puzzle (not
   always succesfull).

> And I am tired that in some modes I cannot get emacs to stop
> writing things (like indentation) that I do not type.

I believe there is a variable to customize for this behaviour. I will
know the variable name when I find it in Elisp code down there in
sources. After that, googling for this name will be very easy.

Before this happens, I will continue to use 23 and 24 (23 does not
show me indent problem), but I feel prompted to have a look at 21 as
well (but then even more puzzles for dot-emacs).

My guess is, all those inconveniences are introduced to make more
users into looking under the hood. I have not really cared much about
such detail until I played with elpa too much and had to manually
unkcuf it.

-- 
Regards,
Tomasz Rola

--
** A C programmer asked whether computer had Buddha's nature.  **
** As the answer, master did "rm -rif" on the programmer's home**
** directory. And then the C programmer became enlightened...  **
**     **
** Tomasz Rola  mailto:tomasz_r...@bigfoot.com **



Re: Remiss on my personal and server security practices, offering server usage to outsiders

2018-09-23 Thread Tomasz Rola
On Wed, Sep 19, 2018 at 11:09:20AM -0700, Chris Bennett wrote:
[...]
> I still would like to know about httpd's owner:group and permissions on files
> not served to the public.

I am not sure if somebody answered you offline, but my reasoning goes
like this:

1. httpd runs and has said files writeable to itself (due to same
owner:group) (if Perl is a no-no, how about PHP, a popular choice with
problems of its own [judging from bug reports from time to time])
2. someone finds a security hole 
3. your scripts in Perl/PHP/C++ or whatever become overwritten by httpd
4. from now on the scripts will be not only doing what they were doing
upto now, but also whatever additional code someone appended to them
5. ... something nasty

HTH

-- 
Regards,
Tomasz Rola

--
** A C programmer asked whether computer had Buddha's nature.  **
** As the answer, master did "rm -rif" on the programmer's home**
** directory. And then the C programmer became enlightened...  **
**         **
** Tomasz Rola  mailto:tomasz_r...@bigfoot.com **



Re: wifi gui manager

2018-08-22 Thread Tomasz Rola
On Wed, Aug 22, 2018 at 08:49:57AM +0300, Consus wrote:
> On 18:07 Tue 21 Aug, Stuart Henderson wrote:
[...]
> > They're even slower and uglier if you have to run the m4 stuff to
> > *generate* them before you can even run them, and may not work as
> > intended if they're run through a version of autoconf which they
> > weren't designed for.
> 
> That's why we should nuke autloluz in favor of something else. Just
> plain Makefiles for example. Or meson, I heard it's okay.

I always thought that autoconf had been written exactly because
"plain Makefile" was unable to make it. It is not really that slow,
unless one insists on recreating config and Make* files every time
they want to compile a project - like, they would expect their system
changed and installed some new stuff during five minutes between
compiles.

BTW, I sometimes compile from sources (not ports, just source*tgz from
the respective websites) and I usually find that config script
provided is ok, so I had to regenerate one such file maybe two years
ago (via autoconf).

HTH

-- 
Regards,
Tomasz Rola

--
** A C programmer asked whether computer had Buddha's nature.  **
** As the answer, master did "rm -rif" on the programmer's home**
** directory. And then the C programmer became enlightened...  **
**         **
** Tomasz Rola  mailto:tomasz_r...@bigfoot.com **



Re: Lumina-Terminal on OpenBSD

2018-07-10 Thread Tomasz Rola
On Sun, Jul 08, 2018 at 01:45:09PM -0400, rehcla wrote:
> I am pretty sure there is absolutely nothing wrong with me!
> 
> But thanks for the explanations, which provided a working solution
> for me...  Last but not least it inspired me to set a second desktop
> with FVWM to learn more about terminals...

FVWM makes great minimal environment, IMHO. If you need multitabbed
terminal, I have had (so far) good experience with roxterm, and I also
use uxterm a lot - it is a Unicode-enabling wrapper around xterm.

-- 
Regards,
Tomasz Rola

--
** A C programmer asked whether computer had Buddha's nature.  **
** As the answer, master did "rm -rif" on the programmer's home**
** directory. And then the C programmer became enlightened...  **
**     **
** Tomasz Rola  mailto:tomasz_r...@bigfoot.com **



Re: How to copy n bytes from stdin to stdout?

2018-06-25 Thread Tomasz Rola
On Sun, Jun 24, 2018 at 10:53:37PM -0400, Steve Litt wrote:
> On Thu, 21 Jun 2018 00:56:04 +0200
> Tomasz Rola  wrote:
> 
[...]
> > Craps. I have consulted OpenBSD's manpage for dd and there is no
> > mention of iflag. So this will not work on OpenBSD. I will have to
> > rethink this, sorry.
> > 
> 
> Untested...
> 
> int main(int argc, char* argv[]){
>   long l = atod(argv[1]);
>   while(l--){
> if (c = getc(STDIN) != EOF)
> putc(c, STDOUT);
> else
> break;
>   }
> return 0;
> }
> 
> I haven't tested it so it might not be exactly right, and of course
> error handling would need to be added, but you know what I mean. IIRC
> getc() and putc() are very well buffered so it will be fast. In my
> youth I wrote similar functions using low level read() and write() and
> doing my own buffering, and those things were *really* fast, but I
> think that's overkill in this century.
> 
> As far as finding command line tools that do it, if that's becoming
> hard to do, why not just write a 10 line program?

Actually, I have written few such programs to satiate my own curiosity
- I was dragged away from computer and in the meantime, others joined
thread and even wrote nice buffered version of solution in C. I pitted
this solution against my programs (in C, with fgetc/fputc and Common
Lisp, with read-sequence/write-sequence) and head-c.c was many times
faster (about hundred or more times) than my programs.

I am not sure if there is performance difference between fgetc/fputc
and getc/putc. Man says getc are macros around fgetc. Might be worth
checking, but I guess no difference.

My curiosity also "wanted" to know how much of performance hit was to
be expected when writing best to my knowledge optimised Common Lisp vs
simplistic C - they were similar in performance, with CL compiled by
SBCL and few times slower, and head-c.c had beaten them both by many
lengths. I am a bit surprised that in CL, performance was about the
same, whether reading one byte or many at once. Perhaps I will find a
way to speed it up some more.

As of finding command line tools, I had working script in about an
hour (and buggy one in few minutes). Buggy, because "dd | dd" is bad
idea, and after finding better options for using dd in my script -
which worked, but under Linux - I had also found out they would not
work in OpenBSD.

So, I consider it a worthy lesson for myself. Next time, I might just
fire up Emacs and write a script in CL (mostly, because this is what
is comfy for me nowadays, and I will not object against having compiled
script for free). Or something similar, or maybe even do it in C, why
not.

BTW, the version of nread.sh (improved options) was on par with
head-c.c, so writing a script with right things inside is very good
choice, too. If the script actually works :-) .

While the speed is not big problem for input of about 1 megabyte, it
becomes a problem when gigabytes are copied.

-- 
Regards,
Tomasz Rola

--
** A C programmer asked whether computer had Buddha's nature.  **
** As the answer, master did "rm -rif" on the programmer's home**
** directory. And then the C programmer became enlightened...  **
** **
** Tomasz Rola  mailto:tomasz_r...@bigfoot.com **



Re: How to copy n bytes from stdin to stdout?

2018-06-20 Thread Tomasz Rola
On Thu, Jun 21, 2018 at 12:44:14AM +0200, Tomasz Rola wrote:
[...]
> =>  (591 60):   cat nread
> #!/bin/sh
> 
> # nread n - read up to n bytes from stdio, put them on to stdout
> 
> N=$1
> 
> dd bs=512 count=$((N / 512)) iflag=fullblock 2>/dev/null
> dd bs=1 count=$((N % 512)) iflag=fullblock 2>/dev/null

Craps. I have consulted OpenBSD's manpage for dd and there is no
mention of iflag. So this will not work on OpenBSD. I will have to
rethink this, sorry.

-- 
Regards,
Tomasz Rola

--
** A C programmer asked whether computer had Buddha's nature.  **
** As the answer, master did "rm -rif" on the programmer's home**
** directory. And then the C programmer became enlightened...  **
**     **
** Tomasz Rola  mailto:tomasz_r...@bigfoot.com **



Re: How to copy n bytes from stdin to stdout?

2018-06-20 Thread Tomasz Rola
On Thu, Jun 21, 2018 at 12:02:14AM +0200, Maximilian Pichler wrote:
> Your script is incorrect.
> 
> $ dd if=/dev/zero bs=1 | ./nread 1234567 | wc -c
> 0+2411 records in
> 0+2411 records out
> 2411 bytes transferred in 0.038 secs (62579 bytes/sec)
> 135+0 records in
> 135+0 records out
> 135 bytes transferred in 0.001 secs (126148 bytes/sec)
> 2546
> 

I have slightly modified the script to ease debugging. Also, slight
mod to read full blocks - I was not aware that strange things can
happen when two dd's feed one another in a pipe.

=>  (591 60):   cat nread
#!/bin/sh

# nread n - read up to n bytes from stdio, put them on to stdout

N=$1

dd bs=512 count=$((N / 512)) iflag=fullblock 2>/dev/null
dd bs=1 count=$((N % 512)) iflag=fullblock 2>/dev/null

=>  (591 61):   md5sum   (591 65):   dd if=/dev/zero bs=1  2>/dev/null | /usr/bin/time nread 1234567 
| wc -c
0.14user 3.00system 0:03.55elapsed 88%CPU (0avgtext+0avgdata
768maxresident)k
0inputs+0outputs (0major+737minor)pagefaults 0swaps
1234567

=>  (591 66):  cat HUGE  | /usr/bin/time nread 1234567 | wc -c
0.00user 0.01system 0:00.02elapsed 54%CPU (0avgtext+0avgdata
768maxresident)k
0inputs+0outputs (0major+734minor)pagefaults 0swaps
1234567

-- 
Regards,
Tomasz Rola

--
** A C programmer asked whether computer had Buddha's nature.  **
** As the answer, master did "rm -rif" on the programmer's home**
** directory. And then the C programmer became enlightened...  **
**     **
** Tomasz Rola  mailto:tomasz_r...@bigfoot.com **



Re: How to copy n bytes from stdin to stdout?

2018-06-20 Thread Tomasz Rola
On Wed, Jun 20, 2018 at 08:20:16PM +0200, Maximilian Pichler wrote:
> On Wed, Jun 20, 2018 at 7:17 PM, Tomasz Rola  wrote:
> > But seriously: man sh.
> 
> Are you saying there is a shell built-in that does this? If so, which one?

=>  (591 13):cat nread
#!/bin/sh

# nread n - read up to n bytes from stdio, put them on to stdout

N=$1

dd bs=512 count=$((N / 512))
dd bs=1 count=$((N % 512))

=>  (591 14):   md5sum   (591 15):  chmod a+x nread

=>  (591 16):   cat HUGE | /usr/bin/time ./nread 1234567 | wc -c
2411+0 records in
2411+0 records out
1234432 bytes (1.2 MB) copied, 0.0122527 s, 101 MB/s
135+0 records in
135+0 records out
135 bytes (135 B) copied, 0.000620305 s, 218 kB/s
0.00user 0.01system 0:00.02elapsed 57%CPU (0avgtext+0avgdata 768maxresident)k
0inputs+0outputs (0major+731minor)pagefaults 0swaps
1234567

Total time is well below 1s. If you want faster, then you have to
write it in C or assembly.

-- 
Regards,
Tomasz Rola

--
** A C programmer asked whether computer had Buddha's nature.  **
** As the answer, master did "rm -rif" on the programmer's home**
** directory. And then the C programmer became enlightened...  **
**     **
** Tomasz Rola  mailto:tomasz_r...@bigfoot.com **



Re: How to copy n bytes from stdin to stdout?

2018-06-20 Thread Tomasz Rola
On Wed, Jun 20, 2018 at 06:50:06PM +0200, Tomasz Rola wrote:
[...]
> 
> Maybe suggest to the teacher that she sticks to numbers divisible by
> 512? That is what haxorz do.

But seriously: man sh.

-- 
Regards,
Tomasz Rola

--
** A C programmer asked whether computer had Buddha's nature.  **
** As the answer, master did "rm -rif" on the programmer's home**
** directory. And then the C programmer became enlightened...  **
**     **
** Tomasz Rola  mailto:tomasz_r...@bigfoot.com **



Re: How to copy n bytes from stdin to stdout?

2018-06-20 Thread Tomasz Rola
On Wed, Jun 20, 2018 at 06:35:49PM +0200, Maximilian Pichler wrote:
> On Wed, Jun 20, 2018 at 6:27 PM, Tomasz Rola  wrote:
> > On my Linux box:
> 
> ?
> 
> > cat HUGE | /usr/bin/time dd bs=1 count=1234944 | wc -c
> 
> stdin might be something much faster than your disk, in which case the
> relative cost of bs=1 increases.

So is this the problem with slow disk?

> > cat HUGE | /usr/bin/time dd bs=1024 count=1206 | wc -c
> 
> Doesn't work for prime numbers. ;)

Maybe suggest to the teacher that she sticks to numbers divisible by
512? That is what haxorz do.

-- 
Regards,
Tomasz Rola

--
** A C programmer asked whether computer had Buddha's nature.  **
** As the answer, master did "rm -rif" on the programmer's home**
** directory. And then the C programmer became enlightened...  **
**     **
** Tomasz Rola  mailto:tomasz_r...@bigfoot.com **



Re: How to copy n bytes from stdin to stdout?

2018-06-20 Thread Tomasz Rola
On Wed, Jun 20, 2018 at 06:01:21PM +0200, Maximilian Pichler wrote:
> On Wed, Jun 20, 2018 at 5:50 PM, Solene Rapenne  wrote:
> > it's slow because it flushes the output every byte, what would you
> > expect? Maybe you should do in a different manner.
> 
> I know, my question is what such a different manner might look like. :)

On my Linux box:

cat HUGE | /usr/bin/time dd bs=1 count=1234944 | wc -c
1234944+0 records in
1234944+0 records out
1234944 bytes (1.2 MB) copied, 4.33782 s, 285 kB/s
0.33user 4.00system 0:04.34elapsed 99%CPU (0avgtext+0avgdata
772maxresident)k
0inputs+0outputs (0major+249minor)pagefaults 0swaps
1234944

cat HUGE | /usr/bin/time dd bs=1024 count=1206 | wc -c
1206+0 records in
1206+0 records out
1234944 bytes (1.2 MB) copied, 0.00895034 s, 138 MB/s
0.00user 0.00system 0:00.01elapsed 66%CPU (0avgtext+0avgdata
768maxresident)k
0inputs+0outputs (0major+248minor)pagefaults 0swaps
1234944

-- 
Regards,
Tomasz Rola

--
** A C programmer asked whether computer had Buddha's nature.  **
** As the answer, master did "rm -rif" on the programmer's home**
** directory. And then the C programmer became enlightened...  **
**     **
** Tomasz Rola  mailto:tomasz_r...@bigfoot.com **