Perl in OpenBSD

Andrew Fresh

What is OpenBSD

A complete BSD licenced operating system

Focus on correctness of code

Sane defaults, removal of knobs, things Just Work.

OpenSSH, LibreSSL, tmux, OpenNTPd, OpenBGPd, OpenOSPFd, OpenSMTPd, httpd, cwm

The only OS to have perl integrated into the base

It's awesome knobs are for knobs so many cool things come with it I know at merlyn and tchrist are OpenBSD users already. Only OS AFAIK

My history

Worked at an ISP that needed updates

My friend recommended OpenBSD

For one thing, it came with perl. This was amazing.

Features seemed to show up as I needed them

Worked there starting in 1998, probably got to perl in 99 Some good stories from working there. perl 5.6, although I probably didn't use perl until they had 5.8 I'm now working as a perl developer features like ospfd and bgpd "so i arrived at openbsd. let's go back and look at the history of why perl was there".

Justification to import it

perl still fits the niche between shell and C

easily make changes without upstream approval

The main reasons

It's hard to work with strings safely in the shell

The FreeBSD pkg tools were horribly written in C

Why was it imported? It fit that niche, and still does.

History

5.003 imported by downsj@ in 1996

Taken over by millert@ who imported

2010 he ran out of time, 5.14 was lost

Imported in 1996 by Jason Downs Todd Miller had a pretty impressive run, he's moved on to other things

Notable uses of perl

usr.sbin/adduser

date: 1996/09/28 05:58:34; author: downsj Perl adduser(8) from FreeBSD. in base

usr.bin/vi/build/recover

date: 1999/10/11 20:07:19; author: millert "Rewrite in perl for safety and paranoia."
adduser Script to (safely) recover nvi edit sessions

makewhatis

date: 2000/02/03 18:10:48; author: espie Switch to perl: *much* faster (about ten times), *much* more flexible, simpler to understand (no more sed), and no temporary files.

used for 14 years until it was replaced with C in Ingo's great mandoc rewrite

date: 2014/04/18 10:00:48; author: schwarze Switch to the new makewhatis(8)/apropos(1)/whatis(1) combo.
This is a good example of the development process. Use the best thing available at the time. You should definitely check out his work, he has some good talks online. Interesting feature, you can use the newest `feature`s because you don't need backwards compat, but can't use thigs from the CPAN.

Back to me

Asked how I could help, mentioned I liked perl

It was suggested that I could get a new version ready for import.

I think to try to scare me away, I did not catch on.

I got 5.16.3 cleaned up and ready to go and sthen@ imported it.

Feb of 2014, I got to be afresh1@openbsd.org

Not exactly the perl I meant, but so far it has worked out. I got an account just so I could attempt to break the tree by importing 5.18.2. "are you sure you want the 1?"

What did I do then?

I imported 5.18.2 in March of 2014

Followed by 5.20.1 in November of 2014

5.20.2?

got my account during lock, so although the update was ready, the tree was not I was ahead of the game for 5.20 and timing hit with the lock, so had 5.18.2 for OpenBSD 5.6, but 5.20.1 for OpenBSD 5.7. We'll see in the future, probably .1 releases in November and .2 in March, just after the tree is unlocked

Integration

Installs as /usr/bin/perl

There is a Makefile.bsdwrapper that overrides several targets

Still a few customizations in hints/openbsd.sh

Pre-build unicore files as some architectures don't have memory to build them

Uses symlinks in an obj/ dir to build in a read-only tree

Security features

Uses the system MD5 implementation

Uses the system malloc

Uses arc4random unless you've asked for "reproducable" non-random

MD5, better, assembler, not really security system malloc, slower but much more secure Was some annoyance about the drand48 implementation not being easily overridable. There was worry about getting the change for this upstream

Local patches

I've separated out 47 different patches

mostly for integration with the build system

several have already been shepherded upstream

More annoyances that need patches

I turned the single diff between "stock perl" and "OpenBSD perl" into a set of patch files that makes it much easier to work with. I actually maintain them on github. nearly half of which I know I need to find time to push upstream The only non-core module we add to the distribution is OpenBSD::MkTemp although are others installed this list is not complete

Upstreamed Patches

when I submitted the symlink patch, someone was surprised anyone used it. Tony Cook fixed it for old awk on Solaris 11 And a few module patches that haven't made it in yet. now my name is on perl AUTHORS w00! commit e61ccd964839921b5f9ec9d1e9d648c4b24926a9 Author: Tony Cook <tony@develop-help.com> Date: Wed Jun 11 14:52:26 2014 +1000 Andrew Fresh is now a perl author mostly pushed cleanups for Configure upstream

Maintaining patches

17 architectures, including VAX

Before import:

Most of my issues with getting 5.20 imported ended up being compiler bugs on vax. But, tracking those down made vax more stable for everything. Update any ports that have failures I have a script that I keep tuning to try to avoid screwing it up.

What's it used for

libexec/security

regress/

libtool

pkg_*

pkg-config

dpb

security: The first code my name was actually on in OpenBSD. Actually may still be the only code that has my copyright, need to fix that. regress: (smokers) just haven't been able to convince my lazy brain to be that productive. libtool: AFAIK the only non GNU libtool implementation. Written in perl by espie@ One of the next places I want to look, to try to get the GNU libtool regress test to run pkg_*: Also written by espie@ Where he seems to spend most of his time He has good talks about this, especially making dpb work pkg-config provides paths and things to apps that need them

Installing Packages

pkg_add p5-Mojolicious

That's it, installing packages is recommended

It's then relatively easy to reproduce your setup

    pkg_info -mq > ~/pkg_list
    pkg_add  -z -l ~/pkg_list

OpenBSD 5.7 has (fairly) current Catalyst, Mojolicious, Dancer2 and DBIx::Class

Perl Ports

While you can install from the CPAN, it's much easier to maintain OpenBSD if you make a port

It's easy

I have a tool I use that does most of the heavy lifting

There's a GSOC project to make it better

Creating Ports

I use
https://github.com/afresh1/openbsd-module-ports

Perl port Makefiles are usually 5 lines plus the dependency list.

Sample Makefile

$OpenBSD$
COMMENT =   generate S5 slideshow from POD source
DISTNAME =   Pod-S5-0.09
CATEGORIES =   productivity
# Same as perl and CC BY-SA
PERMIT_PACKAGE_CDROM =  Yes
MODULES =   cpan
RUN_DEPENDS =   devel/p5-Pod-Tree \
      devel/p5-Syntax-Highlight-Engine-Kate

.include <bsd.port.mk>

My Future Plans

Keeping perl up-to-date

lots of patches left for upstreaming

keeping my ports up to date

finishing up my `adduser` rewrite

looking at libtool

My TODO just goes on-and-on

Getting more Information

man pages

mailing lists

openbsd.org

OpenBSD documentation is pretty amazing

Thank you!

@AFresh1 on twitter
afresh1@openbsd.org
andrew@cpan.org
andrew@afresh1.com

BSD Pizza Night
last Thursday of every month,
send me an email and I'll tell you where it is.

http://www.openbsd.org/donations.html
http://www.openbsdfoundation.org/donations.html
http://www.openbsd.org/orders.html