perl -p -i -e 's/\ +$//' $(find . -name "*.[ch]" -print)
[freeradius.git] / src / main / version.c
1 /*
2  * version.c    Print version number and exit.
3  *
4  * Version:     $Id$
5  *
6  *   This program is free software; you can redistribute it and/or modify
7  *   it under the terms of the GNU General Public License as published by
8  *   the Free Software Foundation; either version 2 of the License, or
9  *   (at your option) any later version.
10  *
11  *   This program is distributed in the hope that it will be useful,
12  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *   GNU General Public License for more details.
15  *
16  *   You should have received a copy of the GNU General Public License
17  *   along with this program; if not, write to the Free Software
18  *   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19  *
20  * Copyright 1999-2012  The FreeRADIUS server project
21  * Copyright 2012  Alan DeKok <aland@ox.org>
22  * Copyright 2000  Chris Parker <cparker@starnetusa.com>
23  */
24
25 #include <freeradius-devel/ident.h>
26 RCSID("$Id$")
27
28 #include <freeradius-devel/radiusd.h>
29
30
31 #ifdef HAVE_OPENSSL_CRYPTO_H
32 #include <openssl/crypto.h>
33 #include <openssl/opensslv.h>
34
35 static long ssl_built = OPENSSL_VERSION_NUMBER;
36
37 /** Check build and linked versions of OpenSSL match
38  *
39  * Startup check for whether the linked version of OpenSSL matches the
40  * version the server was built against.
41  *
42  * @return 0 if ok, else -1
43  */
44 int ssl_check_version(void)
45 {
46         long ssl_linked;
47         
48         ssl_linked = SSLeay();
49         
50         if (ssl_linked != ssl_built) {
51                 radlog(L_ERR, "libssl version mismatch."
52                        "  Built with: %lx\n  Linked: %lx",
53                        (unsigned long) ssl_built,
54                        (unsigned long) ssl_linked);
55         
56                 return -1;
57         };
58         
59         return 0;
60 }
61
62 /** Print the current linked version of Openssl
63  *
64  * Print the currently linked version of the OpenSSL library.
65  */
66 const char *ssl_version(void)
67 {
68         return SSLeay_version(SSLEAY_VERSION);
69 }
70 #else
71 int ssl_check_Version(void) {
72         return 0;
73 }
74
75 const char *ssl_version()
76 {
77         return "not linked";
78 }
79 #endif
80
81 /*
82  *      Display the revision number for this program
83  */
84 void version(void)
85 {
86         radlog(L_INFO, "%s: %s", progname, radiusd_version);
87         
88         DEBUG3("Server was built with: ");
89                 
90 #ifdef WITH_ACCOUNTING
91         DEBUG3("  accounting");
92 #endif
93         DEBUG3("  authentication"); /* always enabled */
94
95 #ifdef WITH_ASCEND_BINARY
96         DEBUG3("  ascend binary attributes");
97 #endif
98 #ifdef WITH_COA
99         DEBUG3("  coa");
100 #endif
101 #ifdef WITH_COMMAND_SOCKET
102         DEBUG3("  control-socket");
103 #endif
104 #ifdef WITH_DETAIL
105         DEBUG3("  detail");
106 #endif
107 #ifdef WITH_DHCP
108         DEBUG3("  dhcp");
109 #endif
110 #ifdef WITH_DYNAMIC_CLIENTS
111         DEBUG3("  dynamic clients");
112 #endif
113 #ifdef OSFC2
114         DEBUG3("  OSFC2");
115 #endif
116 #ifdef WITH_PROXY
117         DEBUG3("  proxy");
118 #endif
119 #ifdef HAVE_PCREPOSIX_H
120         DEBUG3("  regex-pcre");
121 #else
122 #ifdef HAVE_REGEX_H
123         DEBUG3("  regex-posix");
124 #endif
125 #endif
126
127 #ifdef WITH_SESSION_MGMT
128         DEBUG3("  session-management");
129 #endif
130 #ifdef WITH_STATS
131         DEBUG3("  stats");
132 #endif
133 #ifdef WITH_TCP
134         DEBUG3("  tcp");
135 #endif
136 #ifdef WITH_THREADS
137         DEBUG3("  threads");
138 #endif
139 #ifdef WITH_TLS
140         DEBUG3("  tls");
141 #endif
142 #ifdef WITH_UNLANG
143         DEBUG3("  unlang");
144 #endif
145 #ifdef WITH_VMPS
146         DEBUG3("  vmps");
147 #endif
148
149         DEBUG3("Server core libs:");
150         DEBUG3("  talloc : %i.%i.*", talloc_version_major(),
151                talloc_version_minor());
152         DEBUG3("  ssl    : %s", ssl_version());
153
154
155         radlog(L_INFO, "Copyright (C) 1999-2013 The FreeRADIUS server project and contributors.");
156         radlog(L_INFO, "There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A");
157         radlog(L_INFO, "PARTICULAR PURPOSE.");
158         radlog(L_INFO, "You may redistribute copies of FreeRADIUS under the terms of the");
159         radlog(L_INFO, "GNU General Public License.");
160         radlog(L_INFO, "For more information about these matters, see the file named COPYRIGHT.");
161         
162         fflush(NULL);
163 }
164