Skip to content

Commit

Permalink
debian: Move PKI directory to FHS-compliant location.
Browse files Browse the repository at this point in the history
The PKI directory is mutable state, so it should be in /var, not in /usr.
This commit changes its location and, on systems upgraded from earlier
versions, moves the existing PKI and leaves behind a symlink.

CC: [email protected]
Reported-by: Andreas Beckmann <[email protected]>
Signed-off-by: Ben Pfaff <[email protected]>
  • Loading branch information
blp committed Mar 2, 2012
1 parent 748dca8 commit 14bd2d5
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 5 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ Alan Shieh [email protected]
Alban Browaeys [email protected]
Alex Yip [email protected]
Alexey I. Froloff [email protected]
Andreas Beckmann [email protected]
Ben Basler [email protected]
Bob Ball [email protected]
Brad Hall [email protected]
Expand Down
1 change: 1 addition & 0 deletions debian/automake.mk
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ EXTRA_DIST += \
debian/openvswitch-ipsec.dirs \
debian/openvswitch-ipsec.init \
debian/openvswitch-ipsec.install \
debian/openvswitch-pki.dirs \
debian/openvswitch-pki.postinst \
debian/openvswitch-pki.postrm \
debian/openvswitch-switch.README.Debian \
Expand Down
10 changes: 9 additions & 1 deletion debian/openvswitch-controller.postinst
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,16 @@ set -e
case "$1" in
configure)
cd /etc/openvswitch-controller

# If cacert.pem is a symlink to the old location for cacert.pem,
# remove it so that we can symlink it to the new location.
if test -h cacert.pem && \
test X"`readlink cacert.pem`" = X/usr/share/openvswitch/pki/switchca/cacert.pem; then
rm -f cacert.pem
fi

if ! test -e cacert.pem; then
ln -s /usr/share/openvswitch/pki/switchca/cacert.pem cacert.pem
ln -s /var/lib/openvswitch/pki/switchca/cacert.pem cacert.pem
fi
if ! test -e privkey.pem || ! test -e cert.pem; then
oldumask=$(umask)
Expand Down
1 change: 1 addition & 0 deletions debian/openvswitch-pki.dirs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/var/lib/openvswitch
10 changes: 9 additions & 1 deletion debian/openvswitch-pki.postinst
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,16 @@ set -e

case "$1" in
configure)
# Move the pki directory from its previous, non FHS-compliant location,
# to its new location, leaving behind a symlink for compatibility.
if test -d /usr/share/openvswitch/pki && \
test ! -e /var/lib/openvswitch/pki; then
mv /usr/share/openvswitch/pki /var/lib/openvswitch
ln -s /var/lib/openvswitch/pki /usr/share/openvswitch/pki
fi

# Create certificate authorities.
if test ! -d /usr/share/openvswitch/pki; then
if test ! -e /var/lib/openvswitch/pki; then
ovs-pki init
fi
;;
Expand Down
5 changes: 5 additions & 0 deletions debian/openvswitch-pki.postrm
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ set -e
case "$1" in
purge)
rm -f /var/log/openvswitch/ovs-pki.log* || true

# Remove backward compatibility symlink, if present.
if test -h /usr/share/openvswitch/pki; then
rm -f /usr/share/openvswitch/pki
fi
;;

remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
Expand Down
6 changes: 3 additions & 3 deletions m4/openvswitch.m4
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- autoconf -*-

# Copyright (c) 2008, 2009, 2010, 2011 Nicira Networks.
# Copyright (c) 2008, 2009, 2010, 2011, 2012 Nicira Networks.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -106,9 +106,9 @@ AC_DEFUN([OVS_CHECK_PKIDIR],
[AC_ARG_WITH(
[pkidir],
AC_HELP_STRING([--with-pkidir=DIR],
[PKI hierarchy directory [[DATADIR/openvswitch/pki]]]),
[PKI hierarchy directory [[LOCALSTATEDIR/lib/openvswitch/pki]]]),
[PKIDIR=$withval],
[PKIDIR='${pkgdatadir}/pki'])
[PKIDIR='${localstatedir}/lib/openvswitch/pki'])
AC_SUBST([PKIDIR])])

dnl Checks for the directory in which to store pidfiles.
Expand Down

0 comments on commit 14bd2d5

Please sign in to comment.