Bug 63561

Summary: [patch] pkg_add fails for mysql-server-4.1.0_1 and mysql-server-4.0.16 package if DB_DIR does not exist
Product: Ports & Packages Reporter: Matthew Fremont <m_fremont>
Component: Individual Port(s)Assignee: Alex Dupre <ale>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: Latest   
Hardware: Any   
OS: Any   

Description Matthew Fremont 2004-03-01 01:40:14 UTC
pkg_add fails for mysql-server-4.1.0_1 and mysql-server-4.0.16 if the directory specified by DB_DIR does not exist, or, if DB_DIR is not set, if the default /var/db/mysql does not exist.

bento# file /var/db/mysql
/var/db/mysql: can't stat `/var/db/mysql' (No such file or directory).
bento# pkg_add ftp://ftp.freebsd.org/pub/FreeBSD/ports/i386/packages-5.2-release/databases/mysql-server-4.1.0_1.tbz

Fetching ftp://ftp.freebsd.org/pub/FreeBSD/ports/i386/packages-5.2-release/databases/mysql-server-4.1.0_1.tbz... Done.
Sorry, the host 'bento' could not be looked up.
Please configure the 'hostname' command to return a correct hostname.
If you want to solve this at a later stage, restart this script with
the --force option
pkg_add: command '/usr/local/bin/mysql_install_db' failed
mysql:*:88:
You already have a group "mysql", so I will use it.
mysql:*:88:88::0:0:MySQL Daemon:/var/db/mysql:/sbin/nologin
You already have a user "mysql", so I will use it.
pw: WARNING: home `/var/db/mysql' does not exist
Changed home directory of "mysql" to "/var/db/mysql"
chown: /var/db/mysql: No such file or directory
pkg_add: install script returned error status


The POST_INSTALL for the package uses pw(8) to set the home directory for the mysql user to DB_DIR. The pw(8) command fails if the directory does not exist, and as a result, pkg_add fails and the package is removed.

Fix: 

add the -m option to the use of the PW command in the +INSTALL script (script is identical in both mysql-server-4.1.0_1 and mysql-server-4.0.16):

28c28
<               if pw usermod ${USER} -d ${DB_DIR}
---
>               if pw usermod ${USER} -m -d ${DB_DIR}
37c37
<                       -d ${DB_DIR} -s /sbin/nologin -c "MySQL Daemon"
---
>                       -m -d ${DB_DIR} -s /sbin/nologin -c "MySQL Daemon"
How-To-Repeat: 1. verify that directory /var/db/mysql does not exist

2. pkg_add ftp://ftp.freebsd.org/pub/FreeBSD/ports/i386/packages-5.2-release/databases/mysql-server-4.1.0_1.tbz
Comment 1 Pav Lucistnik freebsd_committer freebsd_triage 2004-03-01 14:47:12 UTC
Responsible Changed
From-To: freebsd-ports-bugs->ale

Over to local MySQL guru.
Comment 2 Alex Dupre freebsd_committer freebsd_triage 2004-03-01 22:30:43 UTC
State Changed
From-To: open->closed

This behaviour is correct. You should install the port with SKIP_DNS_CHECK knob.