~ubuntu-branches/ubuntu/wily/psi/wily-proposed

« back to all changes in this revision

Viewing changes to qcm/openssl.qcm

  • Committer: Package Import Robot
  • Author(s): Jan Niehusmann
  • Date: 2014-07-01 21:49:34 UTC
  • mfrom: (6.1.7 sid)
  • Revision ID: package-import@ubuntu.com-20140701214934-gt4dkgm94byi4vnn
Tags: 0.15-1
* New upstream version
* set debhelper compat level to 9
* set Standards-Version to 3.9.5 (no further changes)
* add lintian override regarding license-problem-non-free-RFC
* use qconf to regenerate configure script
* implement hardening using buildflags instead of hardening-wrapper

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
-----BEGIN QCMOD-----
3
 
name: OpenSSL (bundled QCA only)
4
 
arg: with-openssl-inc=[path],Path to OpenSSL include files (bundled QCA only)
5
 
arg: with-openssl-lib=[path],Path to OpenSSL library files (bundled QCA only)
6
 
-----END QCMOD-----
7
 
*/
8
 
class qc_openssl : public ConfObj
9
 
{
10
 
public:
11
 
        qc_openssl(Conf *c) : ConfObj(c) {}
12
 
        QString name() const { return "OpenSSL"; }
13
 
        QString shortname() const { return "openssl"; }
14
 
 
15
 
        QString checkString() const {
16
 
                if (!QFile::exists("third-party/qca/qca") || !conf->getenv("QC_DISABLE_bundled_qca").isEmpty())
17
 
                        return "";
18
 
                else
19
 
                        return ConfObj::checkString();
20
 
        }
21
 
 
22
 
        bool exec()
23
 
        {
24
 
                if (!QFile::exists("third-party/qca/qca") || !conf->getenv("QC_DISABLE_bundled_qca").isEmpty() || !QFile::exists("third-party/qca/qca-ossl"))
25
 
                        return false;
26
 
 
27
 
#ifdef Q_OS_WIN
28
 
                QString ossl_inc = conf->getenv("QC_WITH_OPENSSL_INC");
29
 
                if(ossl_inc.isEmpty())
30
 
                        return false;
31
 
 
32
 
                QString ossl_lib = conf->getenv("QC_WITH_OPENSSL_LIB");
33
 
                if(ossl_lib.isEmpty())
34
 
                        return false;
35
 
 
36
 
                QStringList libnames;
37
 
                libnames += "-llibeay32 -lssleay32";
38
 
                libnames += "-leay32 -lssl32";
39
 
                libnames += "-leay32 " + ossl_lib + "/ssleay32.a";
40
 
 
41
 
                bool success = false;
42
 
                QString libname_success;
43
 
                foreach(const QString &libname, libnames)
44
 
                {
45
 
                        QString str =
46
 
                                "#include<openssl/opensslv.h>\n"
47
 
                                "int main()\n"
48
 
                                "{\n"
49
 
                                "  unsigned long x = OPENSSL_VERSION_NUMBER;\n"
50
 
                                "  if(x >= 0x00907000) return 0; else return 1;\n"
51
 
                                "}\n";
52
 
                        QString ext;
53
 
                        QStringList incs;
54
 
                        incs += ossl_inc;
55
 
                        ext += QString("-L") + ossl_lib + " " + libname;
56
 
                        int ret;
57
 
                        if(conf->doCompileAndLink(str, incs, ext, QString(), &ret))
58
 
                        {
59
 
                                success = true;
60
 
                                libname_success = libname;
61
 
                                if(ret == 0)
62
 
                                        conf->addDefine("OSSL_097");
63
 
                                break;
64
 
                        }
65
 
                }
66
 
 
67
 
                if(!success)
68
 
                        return false;
69
 
 
70
 
                conf->addIncludePath(ossl_inc);
71
 
                conf->addLib(QString("-L") + ossl_lib);
72
 
                conf->addLib(libname_success);
73
 
 
74
 
                conf->addDefine("HAVE_OPENSSL");
75
 
 
76
 
                return true;
77
 
#else
78
 
                QString inc, lib;
79
 
                QString s;
80
 
                bool kb = false;
81
 
                QString kbdir = "/usr/kerberos/include";
82
 
 
83
 
                // Redhat 9?
84
 
                if(QFileInfo(kbdir).exists())
85
 
                        kb = true;
86
 
 
87
 
                s = conf->getenv("QC_WITH_OPENSSL_INC");
88
 
                if(!s.isEmpty()) {
89
 
                        if(!conf->checkHeader(s, "openssl/ssl.h"))
90
 
                                return false;
91
 
                        inc = s;
92
 
                }
93
 
                else {
94
 
                        if(!conf->findHeader("openssl/ssl.h", QStringList(), &s))
95
 
                                return false;
96
 
                        inc = s;
97
 
                }
98
 
 
99
 
                s = conf->getenv("QC_WITH_OPENSSL_LIB");
100
 
                if(!s.isEmpty()) {
101
 
                        if(!conf->checkLibrary(s, "ssl"))
102
 
                                return false;
103
 
                        lib = s;
104
 
                }
105
 
                else {
106
 
                        if(!conf->findLibrary("ssl", &s))
107
 
                                return false;
108
 
                        lib = s;
109
 
                }
110
 
 
111
 
                // is it at least openssl 0.9.7?
112
 
                QString str =
113
 
                        "#include<openssl/opensslv.h>\n"
114
 
                        "int main()\n"
115
 
                        "{\n"
116
 
                        "  unsigned long x = OPENSSL_VERSION_NUMBER;\n"
117
 
                        "  if(x >= 0x00907000) return 0; else return 1;\n"
118
 
                        "}\n";
119
 
                QString ext;
120
 
                QStringList incs;
121
 
                if(!inc.isEmpty())
122
 
                        incs += inc;
123
 
                if(kb)
124
 
                        incs += kbdir;
125
 
                if(!lib.isEmpty())
126
 
                        ext += QString("-L") + lib + " -lssl -lcrypto ";
127
 
                int ret;
128
 
                if(!conf->doCompileAndLink(str, incs, ext, QString(), &ret))
129
 
                        return false;
130
 
                if(ret == 0)
131
 
                        conf->addDefine("OSSL_097");
132
 
 
133
 
                if(!inc.isEmpty())
134
 
                        conf->addIncludePath(inc);
135
 
                if(kb)
136
 
                        conf->addIncludePath(kbdir);
137
 
                if(!lib.isEmpty())
138
 
                        conf->addLib(QString("-L") + s);
139
 
                conf->addLib("-lssl -lcrypto");
140
 
 
141
 
                conf->addDefine("HAVE_OPENSSL");
142
 
 
143
 
                return true;
144
 
#endif
145
 
        }
146
 
};