Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lxc
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
lxc
Commits
505af6af
Unverified
Commit
505af6af
authored
Jun 14, 2019
by
Serge Hallyn
Committed by
Christian Brauner
Jun 18, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Switch from gnutls to openssl for sha1
The reason for this is because openssl can be statically linked against, gnutls cannot. Signed-off-by:
Serge Hallyn
<
shallyn@cisco.com
>
parent
5edfbc68
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
53 additions
and
34 deletions
+53
-34
configure.ac
configure.ac
+15
-12
Makefile.am
src/lxc/Makefile.am
+4
-4
lxccontainer.c
src/lxc/lxccontainer.c
+11
-7
utils.c
src/lxc/utils.c
+21
-8
utils.h
src/lxc/utils.h
+2
-3
No files found.
configure.ac
View file @
505af6af
...
...
@@ -257,6 +257,8 @@ fi
AM_CONDITIONAL([ENABLE_API_DOCS], [test "x$HAVE_DOXYGEN" != "x"])
AC_CONFIG_MACRO_DIRS([config])
# Apparmor
AC_ARG_ENABLE([apparmor],
[AC_HELP_STRING([--enable-apparmor], [enable apparmor support [default=auto]])],
...
...
@@ -267,20 +269,21 @@ if test "$enable_apparmor" = "auto" ; then
fi
AM_CONDITIONAL([ENABLE_APPARMOR], [test "x$enable_apparmor" = "xyes"])
# GnuTLS
AC_ARG_ENABLE([gnutls],
[AC_HELP_STRING([--enable-gnutls], [enable GnuTLS support [default=auto]])],
[], [enable_gnutls=auto])
# OpenSSL
# libssl-dev
AC_ARG_ENABLE([openssl],
[AC_HELP_STRING([--enable-openssl], [enable OpenSSL support [default=auto]])],
[], [enable_openssl=auto])
if test "$enable_openssl" = "auto" ; then
AC_CHECK_LIB([ssl], [OPENSSL_init_ssl], [enable_openssl=yes], [enable_openssl=no])
if test "$enable_gnutls" = "auto" ; then
AC_CHECK_LIB([gnutls], [gnutls_hash_fast], [enable_gnutls=yes], [enable_gnutls=no])
fi
AM_CONDITIONAL([ENABLE_
GNUTLS], [test "x$enable_gnutls
" = "xyes"])
AM_CONDITIONAL([ENABLE_
OPENSSL], [test "x$enable_openssl
" = "xyes"])
AM_COND_IF([ENABLE_GNUTLS],
[AC_CHECK_HEADER([gnutls/gnutls.h],[],[AC_MSG_ERROR([You must install the GnuTLS development package in order to compile lxc])])
AC_CHECK_LIB([gnutls], [gnutls_hash_fast],[true],[AC_MSG_ERROR([You must install the GnuTLS development package in order to compile lxc])])
AC_SUBST([GNUTLS_LIBS], [-lgnutls])])
AM_COND_IF([ENABLE_OPENSSL],
[AC_CHECK_HEADER([openssl/engine.h],[],[AC_MSG_ERROR([You must install the OpenSSL development package in order to compile lxc])])
AC_SUBST([OPENSSL_LIBS], '-lssl -lcrypto')])
# SELinux
AC_ARG_ENABLE([selinux],
...
...
@@ -992,7 +995,7 @@ Environment:
- distribution: $with_distro
- init script type(s): $init_script
- rpath: $enable_rpath
-
GnuTLS: $enable_gnutls
-
OpenSSL: $enable_openssl
- Bash integration: $enable_bash
Security features:
...
...
src/lxc/Makefile.am
View file @
505af6af
...
...
@@ -207,8 +207,8 @@ if ENABLE_APPARMOR
AM_CFLAGS
+=
-DHAVE_APPARMOR
endif
if
ENABLE_
GNUTLS
AM_CFLAGS
+=
-DHAVE_
LIBGNUTLS
if
ENABLE_
OPENSSL
AM_CFLAGS
+=
-DHAVE_
OPENSSL
endif
if
ENABLE_SECCOMP
...
...
@@ -240,7 +240,7 @@ liblxc_la_LDFLAGS = -pthread \
-version-info
@LXC_ABI_MAJOR@
liblxc_la_LIBADD
=
$(CAP_LIBS)
\
$(
GNUTLS
_LIBS)
\
$(
OPENSSL
_LIBS)
\
$(SELINUX_LIBS)
\
$(SECCOMP_LIBS)
...
...
@@ -298,7 +298,7 @@ endif
LDADD
=
liblxc.la
\
@CAP_LIBS@
\
@
GNUTLS
_LIBS@
\
@
OPENSSL
_LIBS@
\
@SECCOMP_LIBS@
\
@SELINUX_LIBS@
...
...
src/lxc/lxccontainer.c
View file @
505af6af
...
...
@@ -76,6 +76,10 @@
#include "utils.h"
#include "version.h"
#if HAVE_OPENSSL
#include <openssl/evp.h>
#endif
/* major()/minor() */
#ifdef MAJOR_IN_MKDEV
#include <sys/mkdev.h>
...
...
@@ -1632,9 +1636,9 @@ static bool prepend_lxc_header(char *path, const char *t, char *const argv[])
char
*
contents
;
FILE
*
f
;
int
ret
=
-
1
;
#if HAVE_
LIBGNUTLS
int
i
;
unsigned
char
md_value
[
SHA_DIGEST_LENGTH
];
#if HAVE_
OPENSSL
int
i
,
md_len
=
0
;
unsigned
char
md_value
[
EVP_MAX_MD_SIZE
];
char
*
tpath
;
#endif
...
...
@@ -1675,14 +1679,14 @@ static bool prepend_lxc_header(char *path, const char *t, char *const argv[])
if
(
ret
<
0
)
goto
out_free_contents
;
#if HAVE_
LIBGNUTLS
#if HAVE_
OPENSSL
tpath
=
get_template_path
(
t
);
if
(
!
tpath
)
{
ERROR
(
"Invalid template
\"
%s
\"
specified"
,
t
);
goto
out_free_contents
;
}
ret
=
sha1sum_file
(
tpath
,
md_value
);
ret
=
sha1sum_file
(
tpath
,
md_value
,
&
md_len
);
if
(
ret
<
0
)
{
ERROR
(
"Failed to get sha1sum of %s"
,
tpath
);
free
(
tpath
);
...
...
@@ -1708,9 +1712,9 @@ static bool prepend_lxc_header(char *path, const char *t, char *const argv[])
fprintf
(
f
,
"
\n
"
);
}
#if HAVE_
LIBGNUTLS
#if HAVE_
OPENSSL
fprintf
(
f
,
"# Template script checksum (SHA-1): "
);
for
(
i
=
0
;
i
<
SHA_DIGEST_LENGTH
;
i
++
)
for
(
i
=
0
;
i
<
md_len
;
i
++
)
fprintf
(
f
,
"%02x"
,
md_value
[
i
]);
fprintf
(
f
,
"
\n
"
);
#endif
...
...
src/lxc/utils.c
View file @
505af6af
...
...
@@ -330,17 +330,30 @@ again:
return
status
;
}
#if HAVE_LIBGNUTLS
#include <gnutls/gnutls.h>
#include <gnutls/crypto.h>
#ifdef HAVE_OPENSSL
#include <openssl/evp.h>
__attribute__
((
constructor
))
static
void
gnutls_lxc_init
(
void
)
static
int
do_sha1_hash
(
const
char
*
buf
,
int
buflen
,
unsigned
char
*
md_value
,
int
*
md_len
)
{
gnutls_global_init
();
EVP_MD_CTX
*
mdctx
;
const
EVP_MD
*
md
;
md
=
EVP_get_digestbyname
(
"sha1"
);
if
(
!
md
)
{
printf
(
"Unknown message digest: sha1
\n
"
);
return
-
1
;
}
mdctx
=
EVP_MD_CTX_new
();
EVP_DigestInit_ex
(
mdctx
,
md
,
NULL
);
EVP_DigestUpdate
(
mdctx
,
buf
,
buflen
);
EVP_DigestFinal_ex
(
mdctx
,
md_value
,
md_len
);
EVP_MD_CTX_free
(
mdctx
);
return
0
;
}
int
sha1sum_file
(
char
*
fnam
,
unsigned
char
*
digest
)
int
sha1sum_file
(
char
*
fnam
,
unsigned
char
*
digest
,
int
*
md_len
)
{
char
*
buf
;
int
ret
;
...
...
@@ -394,7 +407,7 @@ int sha1sum_file(char *fnam, unsigned char *digest)
}
buf
[
flen
]
=
'\0'
;
ret
=
gnutls_hash_fast
(
GNUTLS_DIG_SHA1
,
buf
,
flen
,
(
void
*
)
digest
);
ret
=
do_sha1_hash
(
buf
,
flen
,
(
void
*
)
digest
,
md_len
);
free
(
buf
);
return
ret
;
}
...
...
src/lxc/utils.h
View file @
505af6af
...
...
@@ -98,9 +98,8 @@ extern int lxc_pclose(struct lxc_popen_FILE *fp);
extern
int
wait_for_pid
(
pid_t
pid
);
extern
int
lxc_wait_for_pid_status
(
pid_t
pid
);
#if HAVE_LIBGNUTLS
#define SHA_DIGEST_LENGTH 20
extern
int
sha1sum_file
(
char
*
fnam
,
unsigned
char
*
md_value
);
#if HAVE_OPENSSL
extern
int
sha1sum_file
(
char
*
fnam
,
unsigned
char
*
md_value
,
int
*
md_len
);
#endif
/* initialize rand with urandom */
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment