Question

I have been scratching my head for a while now and cannot find a way to make it work...

I want to run some cgi scripts (written in Python) on my OpenBSD server. Since the web-server on OpenBSD runs in a jail I recreated the whole folder structure (/bin /dev /usr /usr/local/lib etc. etc.) but I'm still getting '500 Server Internal Error' when I'm trying to import some Python modules that require access to /dev/urandom device.

I have created the device special files using mknod.

ls -la /dev/*random
ls -la /dev/{null,zero}

I got the following output

crw-r--r--  1 root  wheel   45,   3 Sep 13 11:09 /dev/arandom
crw-r--r--  1 root  wheel   45,   0 Jul 15 19:02 /dev/random
crw-r--r--  1 root  wheel   45,   1 Jul 15 19:02 /dev/srandom
crw-r--r--  1 root  wheel   45,   2 Jul 15 19:02 /dev/urandom

and

crw-rw-rw-  1 root  wheel    2,   2 Sep 16 01:30 /dev/null
crw-rw-rw-  1 root  wheel    2,  12 Jul 15 19:02 /dev/zero

So I executed the following commands in the /var/www/dev folder (OpenBSD web-server runs in chroot -u www /var/www)

mknod -m 666 null c 2 2
mknod -m 666 zero c 2 12
mknod -m 644 random 45 0
mknod -m 644 srandom 45 1
mknod -m 644 urandom 45 2
mknod -m 644 arandom 45 3

However, Python still reports that the

OSError: [Errno 6] Device not configured '/dev/urandom'

The same code works fine in a non-chroot-ed environment.

import os
import cgitb
cgitb.enable()

Any help would be truly appreciated!

Was it helpful?

Solution

On OpenBSD non-root (/) partitions are mounted with nodev option. Look at your /etc/fstab. For example:

$ mount | grep -F /var
/dev/wd0g on /var type ffs (local, nodev, nosuid)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top