Monthly Archives: December 2015

MySQL 5.6 on FreeBSD 10.2

# mysql_args="--skip-grant-tables \
--skip-networking" # for resetting the root password
$ ps aux
/usr/local/libexec/mysqld \
--defaults-extra-file=/db/mysql/my.cnf \
--basedir=/usr/local \
mysql> SHOW VARIABLES LIKE '%datadir%';
| Variable_name | Value      |
| datadir       | /db/mysql/ |

How to initialize a new MySQL installation and create new database
Reset/recover MySQL root password in freebsd

sftp chroot on FreeBSD

Filesharing with chrooted SFTP
sftp/scp chroot solution?
How to Set Up an SFTP User on FreeBSD
SFTP chroot jail/access based on wildcard

Match User jon
        ChrootDirectory    /web/
        X11Forwarding      no
        AllowTcpForwarding no
        ForceCommand       internal-sftp
Dec 19 15:25:15 sshd[78707]: Accepted keyboard-interactive/pam for jon from port 62601 ssh2
Dec 19 15:25:15 sshd[78710]: fatal: bad ownership or modes for chroot directory component "/web/"
$ pw user add jon
$ tail /var/log/auth.log
$ chown root /web
$ chown root /web/
$ chown root /web/
$ ssh
Password for
Could not chdir to home directory /web/ No such file or directory
This service allows sftp connections only.
Connection to closed.

Custom Kernel on Fedora 20

Fedora Wiki

Building a custom kernel
Building an upstream kernel
Building Only Kernel Modules

Custom Kernel on Fedora

Custom Kernel for Fedora
‘make prep’ breaks on private branches
Custom Kernel on Fedora 20
Not able to build a fedora kernel

yum install kernel

yum installs kernel-devel different from my kernel version
fedora-20 – VirtualBox – Kernel Sources Missing
how to get kernel source code for — 3.8.6-203.fc18.x86_64


How to Compile Linux Kernel from Source to Build Custom Kernel
Guide to building the Linux kernel


Package maintenance guide

$ fedpkg clone -a kernel
$ cd kernel
$ fedpkg switch-branch f23
$ make depend
$ cd kernel-4.2.fc23/linux-4.2.7-300.fc23.x86_64

Apache 2.4 + PHP 5.6 + PHP-FPM on FreeBSD 10.2

Apache with PHP-FPM, chroots and per-vhost UIDs
Setting up Apache with PHP-FPM

A better way to run PHP-FPM
PHP-FPM Configuration 101 (php-fpm.conf, www.conf)

PHP-FPM not working as PHP handler in Apache
High-performance PHP on apache httpd 2.4.x using mod_proxy_fcgi and php-fpm
Apache 2.4 + PHP-FPM problem
Apache, PHP-FPM, MariaDB and FreeBSD
PHP method #3: PHP-FPM

What is the difference between fastcgi and fpm?
Differences and dis/advanages between: Fast-CGI, CGI, Mod-PHP, SuPHP, PHP-FPM
Showdown: HHVM vs. PHP5-fcgi vs. PHP5-FPM

First try

    DocumentRoot    /web/

    ErrorLog        /web/
    CustomLog       /web/ common
    CustomLog       /web/ referer
    CustomLog       /web/ agent

    ProxyPassMatch  ^/(.*\.php(/.*)?)$ unix:/tmp/fpm_www_example_com.sock|fcgi://localhost/web/
    DirectoryIndex  /index.php index.php

user = www_example_com
group = www_example_com

listen = /tmp/fpm_www_example_com.sock

pm = ondemand
pm.max_children = 5
pm.process_idle_timeout = 120s;
pm.max_requests = 500
[Sat Dec 19 22:13:00.127794 2015] [proxy:error] [pid 82692] (13)Permission denied: AH02454: FCGI: attempt to connect to Unix domain socket /tmp/fpm_www_example_com.sock (localhost) failed
[Sat Dec 19 22:13:00.128004 2015] [proxy:error] [pid 82692] AH00959: ap_proxy_connect_backend disabling worker for (localhost) for 60s
[Sat Dec 19 22:13:00.128038 2015] [proxy_fcgi:error] [pid 82692] [client] AH01079: failed to make connection to backend: httpd-UDS


[Sun Dec 20 11:39:18.535056 2015] [core:error] [pid 82705] (13)Permission denied: [client] AH00035: access to /index.html denied (filesystem path '/web/') because search permissions are missing on a component of the path


UBIFS / nandsim on Fedora 20

Memory Technology Devices – UBI
Memory Technology Devices – UBIFS
Memory Technology Devices – NAND


NAND Flash Framework Introduction, experimental

Own try…

# file /tmp/nandimg_.JeCb7JOv/common.fs
/tmp/nandimg_.JeCb7JOv/common.fs: UBIfs image, sequence number 8, length 4096, CRC 0x151054e7

# mount -t ubifs /tmp/nandimg_.JeCb7JOv/common.fs /mnt/common
mount: unknown filesystem type 'ubifs'

Should work, but…

Where are the sources for mtd/nand/nandsim kernel module?
UBI / UBIFS on NANDSIM simulator
Simulate NAND MTD Device
Extract and rebuild a UBI image (on Ubuntu)

$ mkdir /mnt/ubi
$ modprobe mtdblock
$ modprobe ubi
$ modprobe nandsim \
first_id_byte=0x20 \
second_id_byte=0xaa \
third_id_byte=0x00 \
$ cat /proc/mtddev
$ ls -l /dev/mtd*
$ dd if=ubi.img of=/dev/mtdblock[COLOR=red]0[/COLOR] bs=2048
$ ubiattach /dev/ubi_ctrl -m 0
$ ls -l /dev/ubi*
$ mount -t ubifs ubi0_0 /mnt/ubi
$ mkfs.ubifs -m 2048 -e 129024 -c 2047 -r /mnt/ubi ubifs.img
$ nano ubi.ini
$ ubinize -o ubi.img -p 131072 -m 2048 -s 512 ubi.ini

Compile kernel module

Fedore – Building Only Kernel Modules
How to: Compile Linux kernel modules
“FATAL: Module not found error” using modprobe
Building nandsim for Fedora

$ yum install mtd-utils
$ yum install kernel-devel
$ mkdir -p ~/src/nand
$ cd ~/src/nand
$ fetch <URL>/nandsim.c
$ vi Makefile <= (as in Fedora: Building Only Kernel Modules)
$ make
make -C /lib/modules/3.11.10-301.fc20.x86_64/build M=/home/andreas/src/nand modules
make[1]: Entering directory `/usr/src/kernels/3.11.10-301.fc20.x86_64'
  CC [M]  /home/andreas/src/nand/nandsim.o
/home/andreas/src/nand/nandsim.c: In function ‘alloc_device’:
/home/andreas/src/nand/nandsim.c:581:25: error: ‘FMODE_CAN_READ’ undeclared (first use in this function)
   if (!(cfile->f_mode & FMODE_CAN_READ)) {
/home/andreas/src/nand/nandsim.c:581:25: note: each undeclared identifier is reported only once for each function it appears in
/home/andreas/src/nand/nandsim.c:586:25: error: ‘FMODE_CAN_WRITE’ undeclared (first use in this function)
   if (!(cfile->f_mode & FMODE_CAN_WRITE)) {
make[2]: *** [/home/andreas/src/nand/nandsim.o] Error 1
make[1]: *** [_module_/home/andreas/src/nand] Error 2
make[1]: Leaving directory `/usr/src/kernels/3.11.10-301.fc20.x86_64'
make: *** [default] Error 2

$ uname -a
Linux 3.11.10-301.fc20.x86_64 [...]

$ grep -r FMODE_CAN_READ /usr/src/kernels/3.11.10-301.fc20.x86_64/

$ grep -r FMODE_CAN_READ /usr/src/kernels/3.19.8-100.fc20.x86_64
/usr/src/kernels/3.19.8-100.fc20.x86_64/include/linux/fs.h:#define FMODE_CAN_READ          ((__force fmode_t)0x20000)

$ rpm -qa kernel

$ grub2-mkconfig -o /boot/grub2/grub.cfg
$ grub2-install /dev/sda


$ yum remove kernel-3.11.10-301.fc20.x86_64
$ yum remove kernel-devel-3.11.10-301.fc20.x86_64

FreeBSD bash Key Bindings

FreeBSD: Customize Home, Del, Insert keys for BASH shell

# vi /etc/profile
export INPUTRC=/usr/local/etc/inputrc

# vi /usr/local/etc/inputrc
set meta-flag on
set input-meta on
set convert-meta off
set output-meta on
"\e[1~": beginning-of-line
"\e[4~": end-of-line
"\e[5~": beginning-of-history
"\e[6~": end-of-history
"\e[3~": delete-char
"\e[2~": quoted-insert
"\e[5C": forward-word
"\e[5D": backward-word

FreeBSD 10.2 Server

GeoIP-1.6.4                    Find the country that any IP address or hostname originates from
adns-1.5.0                     Easy to use asynchronous-capable DNS client library and utilities
bash-4.3.33                    The GNU Project's Bourne Again SHell
bind99-9.9.7                   BIND DNS suite with updated DNSSEC and DNS64
ca_root_nss-3.19.1_1           Root certificate bundle from the Mozilla Project
cairo-1.12.18_1,2              Vector graphics library with cross-device output support
cups-client-2.0.3_2            Common UNIX Printing System: Library cups
cups-image-2.0.3_2             Common UNIX Printing System: Library cupsimage
curl-7.42.1                    Non-interactive tool to get files from FTP, GOPHER, HTTP(S) servers
cvsps-2.1_1                    Create patchset information from CVS
db5-5.3.28_2                   The Oracle Berkeley DB, revision 5.3
dejavu-2.35                    Bitstream Vera Fonts clone with a wider range of characters
dialog4ports-0.1.5_2           Console Interface to configure ports
encodings-1.0.4_3,1            X.Org Encoding fonts
expat-2.1.0_2                  XML 1.0 parser written in C
font-bh-ttf-1.0.3_3            X.Org Bigelow & Holmes TTF font
font-misc-ethiopic-1.0.3_3     X.Org miscellaneous Ethiopic font
font-misc-meltho-1.0.3_3       X.Org miscellaneous Meltho font
font-util-1.3.1                Create an index of X font files in a directory
fontconfig-2.11.1,1            XML-based font configuration API for X Windows
freetype2-2.5.5                Free and portable TrueType font rendering engine
gdbm-1.11_2                    GNU database manager
gettext-runtime-0.19.4         GNU gettext runtime libraries and programs
gettext-tools-0.19.4           GNU gettext development and translation tools
ghostscript9-9.06_10           Ghostscript 9.x PostScript interpreter
git-2.4.2                      Distributed source code management tool
glib-2.42.1                    Some useful routines of C programming (current stable version)
gmake-4.1_1                    GNU version of 'make' utility
gmp-5.1.3_2                    Free library for arbitrary precision arithmetic
gnutls-3.3.15                  GNU Transport Layer Security library
graphite2-1.2.4                Rendering capabilities for complex non-Roman writing systems
graphviz-2.38.0_6              Graph Visualization Software from AT&T and Bell Labs
gsfonts-8.11_6                 Standard Fonts for Ghostscript
harfbuzz-0.9.40_1              OpenType text shaping engine
icu-55.1                       International Components for Unicode (from IBM)
idnkit-1.0_5                   Library to handle internationalized domain names
indexinfo-0.2.2                Utility to regenerate the GNU info page index
jbig2dec-0.11_4                Decoder implementation of the JBIG2 image compression format
jbigkit-2.1_1                  Lossless compression for bi-level images such as scanned pages, faxes
jpeg-8_6                       IJG's jpeg compression utilities
kbproto-1.0.6                  KB extension headers
lcms-1.19_5,1                  Light Color Management System -- a color management library
lcms2-2.7                      Accurate, fast, and small-footprint color management engine
libICE-1.0.9_1,1               Inter Client Exchange library for X11
libSM-1.2.2_3,1                Session Management library for X11
libX11-1.6.2_3,1               X11 library
libXScrnSaver-1.2.2_3          The XScrnSaver library
libXau-1.0.8_3                 Authentication Protocol library for X11
libXaw-1.0.12_3,2              X Athena Widgets library
libXdmcp-1.1.2                 X Display Manager Control Protocol library
libXext-1.3.3_1,1              X11 Extension library
libXft-2.3.2_1                 Client-sided font API for X applications
libXmu-1.1.2_3,1               X Miscellaneous Utilities libraries
libXp-1.0.3,1                  X print library
libXpm-3.5.11_3                X Pixmap library
libXrender-0.9.8_3             X Render extension library
libXt-1.1.4_3,1                X Toolkit library
libevent2-2.0.22_1             API for executing callback functions on events or timeouts
libffi-3.2.1                   Foreign Function Interface
libfontenc-1.1.2_3             The fontenc Library
libgcrypt-1.6.3                General purpose crypto library based on code used in GnuPG
libgd-2.1.0_6,1                Graphics library for fast creation of images
libgpg-error-1.19_1            Common error values for all GnuPG components
libiconv-1.14_6                Character set conversion library
libidn-1.29                    Internationalized Domain Names command line tool
libltdl-2.4.6                  System independent dlopen wrapper
libpaper-              Library providing routines for paper size management
libpthread-stubs-0.3_6         This library provides weak aliases for pthread functions
libsmi-0.4.8_1                 Library to access SMI MIB information
libtasn1-4.5_1                 ASN.1 structure parser library
libxcb-1.11_1                  The X protocol C-language Binding (XCB) library
libxml2-2.9.2_2                XML parser library for GNOME
libxslt-1.1.28_6               The XSLT C library for GNOME
mDNSResponder-567              Bonjour (zero-configuration networking) by Apple
mkfontdir-1.0.7                Create an index of X font files in a directory
mkfontscale-1.1.2              Creates an index of scalable font files for X
nettle-2.7.1                   Low-level cryptographic library
node-0.12.4                    V8 JavaScript for client and server
npm-2.11.1                     Node package manager
openldap-client-2.4.40_1       Open source LDAP client implementation
p11-kit-0.23.1                 Library for loading and enumerating of PKCS#11 modules
p5-Authen-SASL-2.16_1          Perl5 module for SASL authentication
p5-Digest-HMAC-1.03_1          Perl5 interface to HMAC Message-Digest Algorithms
p5-Error-0.17024               Error/exception handling in object-oriented programming style
p5-GSSAPI-0.28_1               Perl extension providing access to the GSSAPIv2 library
p5-IO-Socket-IP-0.37           Drop-in replacement for IO::Socket::INET supporting IPv4 and IPv6
p5-IO-Socket-SSL-2.016         Perl5 interface to SSL sockets
p5-Mozilla-CA-20141217         Perl extension for Mozilla CA cert bundle in PEM format
p5-Net-SMTP-SSL-1.02           SSL support for Net::SMTP
p5-Net-SSLeay-1.69             Perl5 interface to SSL
p5-Socket-2.019                Networking constants and support functions
pango-1.36.8_1                 Open-source framework for the layout and rendering of i18n text
pcre-8.35_2                    Perl Compatible Regular Expressions library
perl5-5.20.2_4                 Practical Extraction and Report Language
pixman-0.32.6_1                Low-level pixel manipulation library
pkg-1.6.2                      Package manager
pkgconf-0.9.7_1                Utility to help to configure compiler and linker flags
png-1.6.17                     Library for manipulating PNG images
postgresql93-client-9.3.9      PostgreSQL database (client)
postgresql93-server-9.3.9      The most advanced open-source database available anywhere
printproto-1.0.5               Print extension headers
py27-Babel-1.3_2               Collection of tools for internationalizing Python applications
py27-MarkupSafe-0.23           Implements a XML/HTML/XHTML Markup safe string for Python
py27-asn1-0.1.7,1              ASN.1 toolkit for Python
py27-asn1-modules-0.0.5_1      Collection of ASN.1 data structures for py-asn1
py27-beaker-1.6.4_1            Session and Caching library with WSGI Middleware
py27-bsddb-2.7.9_5             Standard Python bindings to the Berkeley DB library
py27-chart-1.39_5              Create high quality Encapsulated Postscript, PDF, or PNG charts
py27-dateutil-2.3              Extensions to the standard Python datetime module
py27-gdbm-2.7.9_3              Python bindings to the GNU dbm library
py27-ldap2-2.4.19              LDAP module for python, for OpenLDAP2
py27-libxml2-2.9.2             Python interface for XML parser library for GNOME
py27-libxslt-1.1.28_6          Python interface for XSLT C library for GNOME
py27-lxml-3.4.1_1              Pythonic binding for the libxml2 and libxslt libraries
py27-mako-1.0.0                Super-fast templating language in Python
py27-mx-base-3.2.8             eGenix mx-Extension Series for Python
py27-parsing-2.0.3             General parsing module for Python
py27-pillow-2.6.0_1            Fork of the Python Imaging Library (PIL)
py27-pip-6.1.1                 Tool for installing and managing Python packages
py27-psycopg2-2.5.5            High performance Python adapter for PostgreSQL
py27-pydot-1.0.28              Python interface to the Graphviz Dot language
py27-pytz-2014.10,1            World Timezone Definitions for Python
py27-reportlab2-2.7_1          Library to create PDF documents using the Python language
py27-setuptools27-5.5.1_1      Python packages installer
py27-six-1.8.0                 Python 2 and 3 compatibility utilities
py27-sqlite3-2.7.9_6           Standard Python binding to the SQLite3 library
py27-tkinter-2.7.9_5           Python bindings to the Tk widget set
py27-xml-0.8.4_4               Python XML library enhancements
py27-yaml-3.11                 Python YAML parser
python2-2_3                    The "meta-port" for version 2 of the Python interpreter
python27-2.7.9                 Interpreted object-oriented programming language
renderproto-0.11.1             RenderProto protocol headers
rsync-3.1.1_4                  Network file distribution/synchronization utility
screen-4.2.1_5                 Multi-screen window manager
scrnsaverproto-1.2.2           ScrnSaver extension headers
sqlite3-                SQL database engine in a C library
svgalib-1.4.3_7                Low level console graphics library
tcl86-8.6.4                    Tool Command Language
tiff-4.0.4.b_1                 Tools and library routines for working with TIFF images
tk86-8.6.4                     Graphical toolkit for Tcl
trousers-tddl-0.3.10_7         The open-source TCG Software Stack
tshark-1.12.3_1                Powerful network analyzer/capture tool
urwfonts-1.0_7                 Another font package for X
vim-lite-7.4.884               Improved version of the vi editor (lite package)
wget-1.16.2_1                  Retrieve files from the Net via HTTP(S) and FTP
xcb-util-0.4.0_1,1             Module with libxcb/libX11 extension/replacement libraries
xcb-util-renderutil-0.3.9_1    Convenience functions for the Render extension
xextproto-7.3.0                XExt extension headers
xorg-fonts-truetype-7.7_1      X.Org TrueType fonts
xproto-7.0.27                  X11 protocol headers