SOLVED: Re: 6.5 pkg_add "Fatal error: Can't write session into tmp directory"

2019-07-27 Thread Jonathan Thornburg
[[for the archives]]

In message ,
I wrote that pkg_add was failing (on 6.5/i386 running on an alix board):
|   sodium# pkg_add -vv tcsh-6.20.00p1-static.tgz
|   Fatal error: Can't write session into tmp directory
|at /usr/libdata/perl5/OpenBSD/PackageRepository.pm line 1025.
|   sodium#
|
| I've checked that the firewall has adequate free memory & swap space,
| that all the obviously-relevant filesystems are mounted read-write and
| have free inodes and disk space, and that 'touch foo' can create a new
| file in each of /tmp, /var/tmp, and /usr/tmp.

Marc Espie's suggestion in

solved the problem:

> I would look more closely at your /var/tmp
> It's highly likely it has wrong permissions.
> 
> Checking that you can create a file in /var/tmp as root is definitely
> not enough.
> 
> pkg_add is privilege separated, it will run ftp(1)  as _pkgfetch

/var/tmp itself was ok (it's a symlink to ../tmp, and permissions on
symlinks don't matter).  But I had somehow gotten both /tmp and /usr/tmp
to be mode 755, so that non-root users didn't have write permission.
Correcting these directories to both be mode 777, so that non-root users
also had write permission, solved the problem.  (I also set the sticky
bit on both directories, as per sticky(8).)

Marc Espie also noted (private email) that in -current the pkg_* tools
produce a more detailed error message which makes it immediately clear
what's wrong in a situation like this.

For the record, my final (working) directory permissions are:

  sodium# ls -lFgd /tmp /usr/tmp /var/tmp 
  drwxrwxrwt  6 root  wheel  512 Jul 24 03:30 /tmp/
  drwxrwxrwt  2 root  wheel  512 Jul 18 00:31 /usr/tmp/
  lrwxr-xr-x  1 root  wheel6 Jul 24 17:26 /var/tmp@ -> ../tmp
  sodium# 

My thanks to all who replied either on the list or in private email,
and my apologies for the delayed followup (which was due to a hand injury
leaving me badly typing-impaired for several weeks).

ciao,
-- 
-- "Jonathan Thornburg [remove -animal to reply]" 

   Dept of Astronomy & IUCSS, Indiana University, Bloomington, Indiana, USA
   currently on the west coast of Canada
   "There was of course no way of knowing whether you were being watched
at any given moment.  How often, or on what system, the Thought Police
plugged in on any individual wire was guesswork.  It was even conceivable
that they watched everybody all the time."  -- George Orwell, "1984"



Re: 6.5 pkg_add "Fatal error: Can't write session into tmp directory"

2019-07-03 Thread Marc Espie
On Tue, Jul 02, 2019 at 08:58:12AM -, Stuart Henderson wrote:
> On 2019-06-30, Jonathan Thornburg  wrote:
> > I have 6.5/i386 installed on a PC Engines alix board (hostname 'sodium'),
> > acting as a home firewall and router.  I'd like to install some packages
> > the firewall it to make system adminstration easier.  So... I downloaded
> > the appropriate 6./i386 packages from a nearby OpenBSD mirror, ssh-ed them
> > to /tmp on the firewall, and then (logged into the firewall as root) tried
> > to  pkg_add  them.  Alas, pkg_add failed with an error message about being
> > unable to write into a temp directory:
> >
> >   sodium# pkg_add -vv tcsh-6.20.00p1-static.tgz
> >   Fatal error: Can't write session into tmp directory
> >at /usr/libdata/perl5/OpenBSD/PackageRepository.pm line 1025.
> >   sodium#
> >
> > I've checked that the firewall has adequate free memory & swap space,
> > that all the obviously-relevant filesystems are mounted read-write and
> > have free inodes and disk space, and that 'touch foo' can create a new
> > file in each of /tmp, /var/tmp, and /usr/tmp.
> >
> > Is there something obvious I'm overlooked here?  A Fine Man Page I should
> > be rereading before I start hacking debug prints into the pkg_add (perl)
> > source code?


> Chances are you're temporarily out of space in /tmp during the run, but don't
> see it because the files are cleaned up on exit. I think you would be better
> off merging /tmp and /usr/tmp into a single slightly larger fs (or just use
> a partition on wd0 for tmp - alixes don't really have enough RAM to throw
> ~half of it into a ramdisk). 

Nope, I don't think that's the issue.

I would look more closely at your /var/tmp
It's highly likely it has wrong permissions.

Checking that you can create a file in /var/tmp as root is definitely
not enough.

pkg_add is privilege separated, it will run ftp(1)  as _pkgfetch



Re: 6.5 pkg_add "Fatal error: Can't write session into tmp directory"

2019-07-02 Thread Stuart Henderson
On 2019-06-30, Jonathan Thornburg  wrote:
> I have 6.5/i386 installed on a PC Engines alix board (hostname 'sodium'),
> acting as a home firewall and router.  I'd like to install some packages
> the firewall it to make system adminstration easier.  So... I downloaded
> the appropriate 6./i386 packages from a nearby OpenBSD mirror, ssh-ed them
> to /tmp on the firewall, and then (logged into the firewall as root) tried
> to  pkg_add  them.  Alas, pkg_add failed with an error message about being
> unable to write into a temp directory:
>
>   sodium# pkg_add -vv tcsh-6.20.00p1-static.tgz
>   Fatal error: Can't write session into tmp directory
>at /usr/libdata/perl5/OpenBSD/PackageRepository.pm line 1025.
>   sodium#
>
> I've checked that the firewall has adequate free memory & swap space,
> that all the obviously-relevant filesystems are mounted read-write and
> have free inodes and disk space, and that 'touch foo' can create a new
> file in each of /tmp, /var/tmp, and /usr/tmp.
>
> Is there something obvious I'm overlooked here?  A Fine Man Page I should
> be rereading before I start hacking debug prints into the pkg_add (perl)
> source code?

Chances are you're temporarily out of space in /tmp during the run, but don't
see it because the files are cleaned up on exit. I think you would be better
off merging /tmp and /usr/tmp into a single slightly larger fs (or just use
a partition on wd0 for tmp - alixes don't really have enough RAM to throw
~half of it into a ramdisk). 

Running under ktrace may give some clues. Try "ktrace -Bi pkg_add (...)".
The file is likely to be large so maybe cd /usr/obj first, or use ktrace -f.
Use kdump to see the plaintext version, which will be even larger, you might
want to "kdump | gzip -1 > kdump.txt.gz" and copy it to another system to
read it in an editor. Search backwards from the end of the file for part
of the text in the error message, then work backwards.

> Further information (cut-and-pasted from ssh session on the firewall):
>
>   sodium# uname -a
>   OpenBSD sodium.bkis-orchard.net 6.5 GENERIC#1 i386
>   sodium# df -hi
>   Filesystem SizeUsed   Avail Capacity iused   ifree  %iused  Mounted 
> on
>   /dev/wd0a  378M   47.7M311M13%1771   47379 4%   /
>   mfs:54350 62.9M2.0M   57.7M 3%   88182 0%   /tmp
>   /dev/wd0e  677M   15.1M628M 2% 352   87710 0%   /var
>   /dev/wd0f  1.5G698M734M49%   16248  191622 8%   /usr
>   mfs:42325 62.9M2.0K   59.7M 0%   18189 0%   /usr/tmp
>   /dev/wd0g  516M138M352M28%8980   5860213%   
> /usr/X11R6
>   /dev/wd0h  1.7G218K1.6G 0% 110  233744 0%   
> /usr/local
>   /dev/wd0j  5.1G2.0K4.8G 0%   1  701565 0%   /usr/obj
>   /dev/wd0i  1.3G2.0K1.3G 0%   1  181885 0%   /usr/src
>   sodium# cat /etc/fstab
>   5fd63b50b0c6cb1d.a /ffs rw,softdep,noatime  1 1
>   5fd63b50b0c6cb1d.d /tmp mfs rw,async,nodev,nosuid,-s=64m0 0
>   5fd63b50b0c6cb1d.e /var ffs rw,softdep,noatime,nodev,nosuid 1 2
>   5fd63b50b0c6cb1d.f /usr ffs rw,softdep,noatime,nodev1 2
>   5fd63b50b0c6cb1d.d /usr/tmp mfs rw,async,nodev,nosuid,-s=64m0 0
>   5fd63b50b0c6cb1d.g /usr/X11R6   ffs rw,softdep,noatime,nodev1 2
>   5fd63b50b0c6cb1d.h /usr/local   ffs rw,softdep,noatime,wxallowed,nodev  1 2
>   5fd63b50b0c6cb1d.j /usr/obj ffs rw,softdep,noatime,nodev,nosuid 1 2
>   5fd63b50b0c6cb1d.i /usr/src ffs rw,softdep,noatime,nodev,nosuid 1 2
>   sodium# top|head
>   load averages:  0.08,  0.02,  0.01sodium.bkis-orchard.net 13:12:00
>   52 processes: 1 running, 50 idle, 1 on processor  up 14 days,  5:21
>   CPU:  0.1% user,  0.0% nice,  0.3% sys,  0.0% spin,  0.3% intr, 99.3% idle
>   Memory: Real: 35M/110M act/tot Free: 127M Cache: 46M Swap: 0K/548M
>   
> PID USERNAME PRI NICE  SIZE   RES STATE WAIT  TIMECPU COMMAND
>   59735 root  1000K   19M sleep bored44:53  0.44% softnet
>   65312 root -2200K   19M sleep -   339.9H  0.00% idle0
>   57981 root  1000K   19M sleep bored 7:56  0.00% sensors
>   39371 _unbound   20   12M   10M sleep kqread1:33  0.00% unbound
>   sodium# cd /tmp
>   sodium# ls -l
>   total 4144
>   drwxrwxrwt  2 root  wheel  512 Jun 16 07:51 .ICE-unix
>   drwxrwxrwt  2 root  wheel  512 Jun 16 07:51 .X11-unix
>   -rw-r--r--  1 root  wheel  1499861 Jun 30 12:31 lynx-2.8.9rel1.tgz
>   drwxr-xr-x  2 root  wheel  512 Jun 16 07:51 sndio
>   -rw-r--r--  1 root  wheel   564428 Jun 30 12:31 tcsh-6.20.00p1-static.tgz
>   drwxrwxrwt  2 root  wheel  512 Jun 30 12:33 vi.recover
>   sodium#
>   sodium# pkg_info
>   sodium# 
>   sodium# which pkg_add
>   /usr/sbin/pkg_add
>   sodium# pkg_add -vv tcsh-6.20.00p1-static.tgz
>   Fatal error: Can't write 

Re: 6.5 pkg_add "Fatal error: Can't write session into tmp directory"

2019-07-01 Thread Raimo Niskanen
On Sun, Jun 30, 2019 at 01:18:15PM -0700, Jonathan Thornburg wrote:
> I have 6.5/i386 installed on a PC Engines alix board (hostname 'sodium'),
> acting as a home firewall and router.  I'd like to install some packages
> the firewall it to make system adminstration easier.  So... I downloaded
> the appropriate 6./i386 packages from a nearby OpenBSD mirror, ssh-ed them
> to /tmp on the firewall, and then (logged into the firewall as root) tried
> to  pkg_add  them.  Alas, pkg_add failed with an error message about being
> unable to write into a temp directory:
> 
>   sodium# pkg_add -vv tcsh-6.20.00p1-static.tgz
>   Fatal error: Can't write session into tmp directory
>at /usr/libdata/perl5/OpenBSD/PackageRepository.pm line 1025.
>   sodium#
> 
> I've checked that the firewall has adequate free memory & swap space,
> that all the obviously-relevant filesystems are mounted read-write and
> have free inodes and disk space, and that 'touch foo' can create a new
> file in each of /tmp, /var/tmp, and /usr/tmp.
> 
> Is there something obvious I'm overlooked here?  A Fine Man Page I should
> be rereading before I start hacking debug prints into the pkg_add (perl)
> source code?
> 
> Further information (cut-and-pasted from ssh session on the firewall):
> 
>   sodium# uname -a
>   OpenBSD sodium.bkis-orchard.net 6.5 GENERIC#1 i386
>   sodium# df -hi
>   Filesystem SizeUsed   Avail Capacity iused   ifree  %iused  Mounted 
> on
>   /dev/wd0a  378M   47.7M311M13%1771   47379 4%   /
>   mfs:54350 62.9M2.0M   57.7M 3%   88182 0%   /tmp
>   /dev/wd0e  677M   15.1M628M 2% 352   87710 0%   /var
>   /dev/wd0f  1.5G698M734M49%   16248  191622 8%   /usr
>   mfs:42325 62.9M2.0K   59.7M 0%   18189 0%   /usr/tmp

Am I reading the numbers correctly that /tmp and /usr/tmp are two different
memory file systems of maximum size 62.9M?  If so, I wonder what pkg_add is
trying to write into /tmp, it migh be way more than just some metadata...

/ Raimo Niskanen


>   /dev/wd0g  516M138M352M28%8980   5860213%   
> /usr/X11R6
>   /dev/wd0h  1.7G218K1.6G 0% 110  233744 0%   
> /usr/local
>   /dev/wd0j  5.1G2.0K4.8G 0%   1  701565 0%   /usr/obj
>   /dev/wd0i  1.3G2.0K1.3G 0%   1  181885 0%   /usr/src
>   sodium# cat /etc/fstab
>   5fd63b50b0c6cb1d.a /ffs rw,softdep,noatime  1 1
>   5fd63b50b0c6cb1d.d /tmp mfs rw,async,nodev,nosuid,-s=64m0 0
>   5fd63b50b0c6cb1d.e /var ffs rw,softdep,noatime,nodev,nosuid 1 2
>   5fd63b50b0c6cb1d.f /usr ffs rw,softdep,noatime,nodev1 2
>   5fd63b50b0c6cb1d.d /usr/tmp mfs rw,async,nodev,nosuid,-s=64m0 0
>   5fd63b50b0c6cb1d.g /usr/X11R6   ffs rw,softdep,noatime,nodev1 2
>   5fd63b50b0c6cb1d.h /usr/local   ffs rw,softdep,noatime,wxallowed,nodev  1 2
>   5fd63b50b0c6cb1d.j /usr/obj ffs rw,softdep,noatime,nodev,nosuid 1 2
>   5fd63b50b0c6cb1d.i /usr/src ffs rw,softdep,noatime,nodev,nosuid 1 2
>   sodium# top|head
>   load averages:  0.08,  0.02,  0.01sodium.bkis-orchard.net 13:12:00
>   52 processes: 1 running, 50 idle, 1 on processor  up 14 days,  5:21
>   CPU:  0.1% user,  0.0% nice,  0.3% sys,  0.0% spin,  0.3% intr, 99.3% idle
>   Memory: Real: 35M/110M act/tot Free: 127M Cache: 46M Swap: 0K/548M
>   
> PID USERNAME PRI NICE  SIZE   RES STATE WAIT  TIMECPU COMMAND
>   59735 root  1000K   19M sleep bored44:53  0.44% softnet
>   65312 root -2200K   19M sleep -   339.9H  0.00% idle0
>   57981 root  1000K   19M sleep bored 7:56  0.00% sensors
>   39371 _unbound   20   12M   10M sleep kqread1:33  0.00% unbound
>   sodium# cd /tmp
>   sodium# ls -l
>   total 4144
>   drwxrwxrwt  2 root  wheel  512 Jun 16 07:51 .ICE-unix
>   drwxrwxrwt  2 root  wheel  512 Jun 16 07:51 .X11-unix
>   -rw-r--r--  1 root  wheel  1499861 Jun 30 12:31 lynx-2.8.9rel1.tgz
>   drwxr-xr-x  2 root  wheel  512 Jun 16 07:51 sndio
>   -rw-r--r--  1 root  wheel   564428 Jun 30 12:31 tcsh-6.20.00p1-static.tgz
>   drwxrwxrwt  2 root  wheel  512 Jun 30 12:33 vi.recover
>   sodium#
>   sodium# pkg_info
>   sodium# 
>   sodium# which pkg_add
>   /usr/sbin/pkg_add
>   sodium# pkg_add -vv tcsh-6.20.00p1-static.tgz
>   Fatal error: Can't write session into tmp directory
>at /usr/libdata/perl5/OpenBSD/PackageRepository.pm line 1025.
>   sodium# env
>   _=/usr/bin/env
>   LOGNAME=root
>   PWD=/tmp
>   HOME=/root
>   OLDPWD=/tmp
>   SSH_TTY=/dev/ttyp0
>   TOP=-S -i -s1
>   MAIL=/var/mail/root
>   SSH_CLIENT=192.168.105.0 4099 22
>   
> PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/X11R6/bin:/usr/local/sbin:/usr/local/bin
>   TERM=xterm
>   SHELL=/bin/ksh
>   SSH_CONNECTION=192.168.105.0 4099 192.168.105.62 22
>   USER=root
>   

6.5 pkg_add "Fatal error: Can't write session into tmp directory"

2019-06-30 Thread Jonathan Thornburg
I have 6.5/i386 installed on a PC Engines alix board (hostname 'sodium'),
acting as a home firewall and router.  I'd like to install some packages
the firewall it to make system adminstration easier.  So... I downloaded
the appropriate 6./i386 packages from a nearby OpenBSD mirror, ssh-ed them
to /tmp on the firewall, and then (logged into the firewall as root) tried
to  pkg_add  them.  Alas, pkg_add failed with an error message about being
unable to write into a temp directory:

  sodium# pkg_add -vv tcsh-6.20.00p1-static.tgz
  Fatal error: Can't write session into tmp directory
   at /usr/libdata/perl5/OpenBSD/PackageRepository.pm line 1025.
  sodium#

I've checked that the firewall has adequate free memory & swap space,
that all the obviously-relevant filesystems are mounted read-write and
have free inodes and disk space, and that 'touch foo' can create a new
file in each of /tmp, /var/tmp, and /usr/tmp.

Is there something obvious I'm overlooked here?  A Fine Man Page I should
be rereading before I start hacking debug prints into the pkg_add (perl)
source code?

Further information (cut-and-pasted from ssh session on the firewall):

  sodium# uname -a
  OpenBSD sodium.bkis-orchard.net 6.5 GENERIC#1 i386
  sodium# df -hi
  Filesystem SizeUsed   Avail Capacity iused   ifree  %iused  Mounted on
  /dev/wd0a  378M   47.7M311M13%1771   47379 4%   /
  mfs:54350 62.9M2.0M   57.7M 3%   88182 0%   /tmp
  /dev/wd0e  677M   15.1M628M 2% 352   87710 0%   /var
  /dev/wd0f  1.5G698M734M49%   16248  191622 8%   /usr
  mfs:42325 62.9M2.0K   59.7M 0%   18189 0%   /usr/tmp
  /dev/wd0g  516M138M352M28%8980   5860213%   /usr/X11R6
  /dev/wd0h  1.7G218K1.6G 0% 110  233744 0%   /usr/local
  /dev/wd0j  5.1G2.0K4.8G 0%   1  701565 0%   /usr/obj
  /dev/wd0i  1.3G2.0K1.3G 0%   1  181885 0%   /usr/src
  sodium# cat /etc/fstab
  5fd63b50b0c6cb1d.a /ffs rw,softdep,noatime  1 1
  5fd63b50b0c6cb1d.d /tmp mfs rw,async,nodev,nosuid,-s=64m0 0
  5fd63b50b0c6cb1d.e /var ffs rw,softdep,noatime,nodev,nosuid 1 2
  5fd63b50b0c6cb1d.f /usr ffs rw,softdep,noatime,nodev1 2
  5fd63b50b0c6cb1d.d /usr/tmp mfs rw,async,nodev,nosuid,-s=64m0 0
  5fd63b50b0c6cb1d.g /usr/X11R6   ffs rw,softdep,noatime,nodev1 2
  5fd63b50b0c6cb1d.h /usr/local   ffs rw,softdep,noatime,wxallowed,nodev  1 2
  5fd63b50b0c6cb1d.j /usr/obj ffs rw,softdep,noatime,nodev,nosuid 1 2
  5fd63b50b0c6cb1d.i /usr/src ffs rw,softdep,noatime,nodev,nosuid 1 2
  sodium# top|head
  load averages:  0.08,  0.02,  0.01sodium.bkis-orchard.net 13:12:00
  52 processes: 1 running, 50 idle, 1 on processor  up 14 days,  5:21
  CPU:  0.1% user,  0.0% nice,  0.3% sys,  0.0% spin,  0.3% intr, 99.3% idle
  Memory: Real: 35M/110M act/tot Free: 127M Cache: 46M Swap: 0K/548M
  
PID USERNAME PRI NICE  SIZE   RES STATE WAIT  TIMECPU COMMAND
  59735 root  1000K   19M sleep bored44:53  0.44% softnet
  65312 root -2200K   19M sleep -   339.9H  0.00% idle0
  57981 root  1000K   19M sleep bored 7:56  0.00% sensors
  39371 _unbound   20   12M   10M sleep kqread1:33  0.00% unbound
  sodium# cd /tmp
  sodium# ls -l
  total 4144
  drwxrwxrwt  2 root  wheel  512 Jun 16 07:51 .ICE-unix
  drwxrwxrwt  2 root  wheel  512 Jun 16 07:51 .X11-unix
  -rw-r--r--  1 root  wheel  1499861 Jun 30 12:31 lynx-2.8.9rel1.tgz
  drwxr-xr-x  2 root  wheel  512 Jun 16 07:51 sndio
  -rw-r--r--  1 root  wheel   564428 Jun 30 12:31 tcsh-6.20.00p1-static.tgz
  drwxrwxrwt  2 root  wheel  512 Jun 30 12:33 vi.recover
  sodium#
  sodium# pkg_info
  sodium# 
  sodium# which pkg_add
  /usr/sbin/pkg_add
  sodium# pkg_add -vv tcsh-6.20.00p1-static.tgz
  Fatal error: Can't write session into tmp directory
   at /usr/libdata/perl5/OpenBSD/PackageRepository.pm line 1025.
  sodium# env
  _=/usr/bin/env
  LOGNAME=root
  PWD=/tmp
  HOME=/root
  OLDPWD=/tmp
  SSH_TTY=/dev/ttyp0
  TOP=-S -i -s1
  MAIL=/var/mail/root
  SSH_CLIENT=192.168.105.0 4099 22
  
PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/X11R6/bin:/usr/local/sbin:/usr/local/bin
  TERM=xterm
  SHELL=/bin/ksh
  SSH_CONNECTION=192.168.105.0 4099 192.168.105.62 22
  USER=root
  sodium# cd /tmp
  sodium# touch foo
  sodium# ls -l foo
  -rw-r--r--  1 root  wheel  0 Jun 30 13:07 foo
  sodium# /bin/rm foo
  sodium# 
  sodium# cd /var/tmp
  sodium# touch foo
  sodium# ls -l foo
  -rw-r--r--  1 root  wheel  0 Jun 30 13:08 foo
  sodium# /bin/rm foo
  sodium# 
  sodium# cd /usr/tmp
  sodium# touch foo
  sodium# ls -l foo
  -rw-r--r--  1 root  wheel  0 Jun 30 13:13 foo
  sodium# /bin/rm foo
  sodium# 
 
Thanks in advance for any assistance,
-- 
-- "Jonathan Thornburg [remove -animal to