1 |
ulm 07/12/07 22:41:04 |
2 |
|
3 |
Modified: ssl-cert.eclass |
4 |
Log: |
5 |
New function install_cert, replaces docert. Bug #174759. |
6 |
|
7 |
Revision Changes Path |
8 |
1.10 eclass/ssl-cert.eclass |
9 |
|
10 |
file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/ssl-cert.eclass?rev=1.10&view=markup |
11 |
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/ssl-cert.eclass?rev=1.10&content-type=text/plain |
12 |
diff : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/ssl-cert.eclass?r1=1.9&r2=1.10 |
13 |
|
14 |
Index: ssl-cert.eclass |
15 |
=================================================================== |
16 |
RCS file: /var/cvsroot/gentoo-x86/eclass/ssl-cert.eclass,v |
17 |
retrieving revision 1.9 |
18 |
retrieving revision 1.10 |
19 |
diff -u -r1.9 -r1.10 |
20 |
--- ssl-cert.eclass 11 Jul 2005 15:08:06 -0000 1.9 |
21 |
+++ ssl-cert.eclass 7 Dec 2007 22:41:04 -0000 1.10 |
22 |
@@ -1,6 +1,6 @@ |
23 |
# Copyright 1999-2004 Gentoo Foundation |
24 |
# Distributed under the terms of the GNU General Public License v2 |
25 |
-# $Header: /var/cvsroot/gentoo-x86/eclass/ssl-cert.eclass,v 1.9 2005/07/11 15:08:06 swegener Exp $ |
26 |
+# $Header: /var/cvsroot/gentoo-x86/eclass/ssl-cert.eclass,v 1.10 2007/12/07 22:41:04 ulm Exp $ |
27 |
# |
28 |
# Author: Max Kalika <max@g.o> |
29 |
# |
30 |
@@ -140,6 +140,7 @@ |
31 |
|
32 |
# Uses all the private functions above to generate |
33 |
# and install the requested certificates |
34 |
+# Note: This function is deprecated, use install_cert instead |
35 |
# |
36 |
# Access: public |
37 |
docert() { |
38 |
@@ -203,3 +204,71 @@ |
39 |
ewarn "Some requested certificates were not generated" |
40 |
fi |
41 |
} |
42 |
+ |
43 |
+# Uses all the private functions above to generate |
44 |
+# and install the requested certificates |
45 |
+# |
46 |
+# Access: public |
47 |
+install_cert() { |
48 |
+ if [ $# -lt 1 ] ; then |
49 |
+ eerror "At least one argument needed" |
50 |
+ return 1; |
51 |
+ fi |
52 |
+ |
53 |
+ case ${EBUILD_PHASE} in |
54 |
+ unpack|compile|test|install) |
55 |
+ eerror "install_cert cannot be called in ${EBUILD_PHASE}" |
56 |
+ return 1 ;; |
57 |
+ esac |
58 |
+ |
59 |
+ # Initialize configuration |
60 |
+ gen_cnf || return 1 |
61 |
+ echo |
62 |
+ |
63 |
+ # Generate a CA environment |
64 |
+ gen_key 1 || return 1 |
65 |
+ gen_csr 1 || return 1 |
66 |
+ gen_crt 1 || return 1 |
67 |
+ echo |
68 |
+ |
69 |
+ local count=0 |
70 |
+ for cert in "$@" ; do |
71 |
+ # Check the requested certificate |
72 |
+ if [ -z "${cert##*/}" ] ; then |
73 |
+ ewarn "Invalid certification requested, skipping" |
74 |
+ continue |
75 |
+ fi |
76 |
+ |
77 |
+ # Check for previous existence of generated files |
78 |
+ for type in key csr crt pem ; do |
79 |
+ if [ -e "${ROOT}${cert}.${type}" ] ; then |
80 |
+ ewarn "${ROOT}${cert}.${type}: exists, skipping" |
81 |
+ continue 2 |
82 |
+ fi |
83 |
+ done |
84 |
+ |
85 |
+ # Generate the requested files |
86 |
+ gen_key || continue |
87 |
+ gen_csr || continue |
88 |
+ gen_crt || continue |
89 |
+ gen_pem || continue |
90 |
+ echo |
91 |
+ |
92 |
+ # Install the generated files and set sane permissions |
93 |
+ local base=$(get_base) |
94 |
+ install -d "${ROOT}${cert%/*}" |
95 |
+ install -m0400 "${base}.key" "${ROOT}${cert}.key" |
96 |
+ install -m0444 "${base}.csr" "${ROOT}${cert}.csr" |
97 |
+ install -m0444 "${base}.crt" "${ROOT}${cert}.crt" |
98 |
+ install -m0400 "${base}.pem" "${ROOT}${cert}.pem" |
99 |
+ count=$((${count}+1)) |
100 |
+ done |
101 |
+ |
102 |
+ # Resulting status |
103 |
+ if [ ! ${count} ] ; then |
104 |
+ eerror "No certificates were generated" |
105 |
+ return 1 |
106 |
+ elif [ ${count} != ${#} ] ; then |
107 |
+ ewarn "Some requested certificates were not generated" |
108 |
+ fi |
109 |
+} |
110 |
|
111 |
|
112 |
|
113 |
-- |
114 |
gentoo-commits@g.o mailing list |