Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
Education
xephem
xephem-3.7.7_openssl.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File xephem-3.7.7_openssl.patch of Package xephem
diff -burNE xephem-3.7.7_orig/GUI/xephem/Makefile xephem-3.7.7/GUI/xephem/Makefile --- xephem-3.7.7_orig/GUI/xephem/Makefile 2017-01-03 11:24:14.691545416 +0100 +++ xephem-3.7.7/GUI/xephem/Makefile 2017-01-03 11:24:27.699598880 +0100 @@ -35,7 +35,7 @@ CFLAGS = $(LIBINC) $(CLDFLAGS) -O2 -Wall -I$(MOTIFI) -I/usr/X11R6/include $(RPM_OPT_FLAGS) LDFLAGS = $(LIBLNK) $(CLDFLAGS) -L$(MOTIFL) -L/usr/X11R6/lib64 XLIBS = -lXm -lXp -lXt -lXext -lXmu -lX11 -LIBS = $(XLIBS) $(LIBLIB) -lm +LIBS = $(XLIBS) $(LIBLIB) -lm -lssl # static linking on Apple using X11 libs from ports # CC = gcc diff -burNE xephem-3.7.7_orig/GUI/xephem/net.h xephem-3.7.7/GUI/xephem/net.h --- xephem-3.7.7_orig/GUI/xephem/net.h 2017-01-03 11:24:14.687545399 +0100 +++ xephem-3.7.7/GUI/xephem/net.h 2017-01-03 11:24:27.699598880 +0100 @@ -20,6 +20,13 @@ #include <sys/select.h> #endif +#include <openssl/ssl.h> + +typedef struct { + int fd; //file desciptor for the underlying connection socket + SSL *ssl; //ssl connection for use with SSL_read( )and SSL_write() +} XE_SSL_FD; + /* support functions */ extern int httpGET (char *host, char *GETcmd, char msg[]); @@ -29,6 +36,8 @@ extern int recvline (int fd, char buf[], int max); extern int recvlineb (int sock, char *buf, int size); extern int sendbytes (int fd, unsigned char buf[], int n); +extern int httpsGET (char *host, char *GETcmd, char msg[], XE_SSL_FD *ssl_fd); +extern int ssl_recvline (SSL *ssl, char buf[], int max); diff -burNE xephem-3.7.7_orig/GUI/xephem/netmenu.c xephem-3.7.7/GUI/xephem/netmenu.c --- xephem-3.7.7_orig/GUI/xephem/netmenu.c 2017-01-03 11:24:14.687545399 +0100 +++ xephem-3.7.7/GUI/xephem/netmenu.c 2017-01-03 11:24:27.699598880 +0100 @@ -9,6 +9,8 @@ #include <string.h> #include <unistd.h> +#include <openssl/ssl.h> + #include <Xm/Form.h> #include <Xm/Label.h> #include <Xm/PushB.h> @@ -70,12 +72,24 @@ static char netcategory[] = "Network"; /* Save category */ +static SSL_METHOD *ssl_method; /* global ssl dispatch structure for creating a ssl context */ +static SSL_CTX *ssl_ctx; /* global ssl context structure for creating ssl connections */ + /* call to set up without actually bringing up the menus. */ void net_create() { if (!netshell_w) { + if(SSL_library_init() < 0){ + fprintf(stderr, "Could not initialize the OpenSSL library !\n"); + } else { + ssl_method = SSLv23_client_method(); /* deprecated since openssl 1.1.x */ +// ssl_method = TLS_client_method(); /* since openssl 1.1.x */ + ssl_ctx = SSL_CTX_new(ssl_method); + SSL_CTX_set_options(ssl_ctx, SSL_OP_NO_SSLv2); + }; + net_create_form(); (void) net_save(); /* confirming here is just annoying */ } @@ -251,8 +265,8 @@ struct { unsigned char VN; /* version number */ unsigned char CD; /* command code */ - unsigned short DSTPORT; /* destination port */ - unsigned long DSTIP; /* destination IP addres */ + uint16_t DSTPORT; /* destination port */ + uint32_t DSTIP; /* destination IP addres */ } SocksPacket; struct hostent *hs = gethostbyname (socks_host); @@ -390,7 +404,7 @@ /* read up to and including the next '\n' from socket fd into buf[max]. * we silently ignore all '\r'. we add a trailing '\0'. - * return line lenth (not counting \0) if all ok, else -1. + * return line length (not counting \0) if all ok, else -1. * N.B. this never reads ahead -- if that's ok, recvlineb() is better */ int @@ -466,6 +480,118 @@ return (ok); } +/* open the host, do the given GET cmd, and return a socket fd for the result. + * on success it fills the XE_SSL_FD structure for later use by SSL_read() and necessary cleanup. + * return -1 and with excuse in msg[], else 0 if ok. + * N.B. can be called before we are created if net set in app defaults. + */ +int +httpsGET (char *host, char *GETcmd, char msg[], XE_SSL_FD *ssl_fd) +{ + char buf[2048]; + int fd; + int connected; + SSL *ssl; + int n; + int ret; + int httpsport = 443; + + /* open connection */ + if (proxy_on) { + fd = mkconnection (proxy_host, proxy_port, msg); + if (fd < 0) + return (-1); + + /* fill buf with CONNECT */ + (void) sprintf (buf, "CONNECT %1$s:%2$d HTTP/1.0\r\nUser-Agent: xephem/%3$s\r\nHost: %1$s:%2$d\r\n\r\n", host, httpsport, PATCHLEVEL); + + /* add proxy auth if enabled */ + if (!auth_w) + net_create_form(); + if (XmToggleButtonGetState (auth_w)) + addAuth(buf); + + /* log it */ + xe_msg (0, "https proxy connect: %s", buf); + + /* send it */ + n = strlen (buf); + if (sendbytes(fd, (unsigned char *)buf, n) < 0) { + (void) sprintf (msg, "%s: send error: %s", proxy_host, syserrstr()); + (void) close (fd); + return (-1); + } + + connected = 0; + while (recvline (fd, buf, sizeof(buf)) > 1) { + xe_msg (0, "Rcv: %s", buf); + if (strstr (buf, "200 ")) + connected = 1; + } + if (!connected) { + (void) sprintf (msg, "%s: connect error: %s", proxy_host, syserrstr()); + (void) close (fd); + return (-1); + } + } else { + /* SOCKS or direct are both handled by mkconnection() */ + fd = mkconnection (host, httpsport, msg); + if (fd < 0) + return (-1); + } + + /* fill buf with GETcmd */ + (void) sprintf (buf, "%s", GETcmd); + + /* start ssl connection */ + ssl = SSL_new(ssl_ctx); + SSL_set_fd(ssl, fd); + SSL_connect(ssl); + + /* log it */ + xe_msg (0, "https: %s", buf); + + /* send it */ + n = strlen (buf); + ret = SSL_write(ssl, (unsigned char *)buf, n); + if (ret <= 0) { + (void) sprintf (msg, "%s: ssl send error code: %d", host, SSL_get_error(ssl, ret)); + (void) SSL_free(ssl); + (void) close (fd); + return (-1); + } + + /* caller can read response */ + ssl_fd->fd = fd; + ssl_fd->ssl = ssl; + return (fd); +} + +/* read up to and including the next '\n' from ssl into buf[max]. + * we silently ignore all '\r'. we add a trailing '\0'. + * return line length (not counting \0) if all ok, else -1. + */ +int +ssl_recvline (SSL *ssl, char buf[], int max) +{ + unsigned char c; + int n; + + max--; /* leave room for trailing \0 */ + + for (n = 0; n < max && SSL_read(ssl, &c, 1) == 1; ) { + if (c != '\r') { + buf[n++] = c; + if (c == '\n') { + buf[n] = '\0'; + return (n); + } + } + } + + return (-1); +} + static void net_create_form() { diff -burNE xephem-3.7.7_orig/GUI/xephem/sunmenu.c xephem-3.7.7/GUI/xephem/sunmenu.c --- xephem-3.7.7_orig/GUI/xephem/sunmenu.c 2017-01-03 11:24:14.691545416 +0100 +++ xephem-3.7.7/GUI/xephem/sunmenu.c 2017-01-03 11:24:27.699598880 +0100 @@ -884,9 +884,11 @@ int isjpeg, jpegl; int njpeg; unsigned char *jpeg; + XE_SSL_FD ssl_fd; int fd, nr; struct tm tm; + memset(&ssl_fd, 0, sizeof(ssl_fd)); memset(&tm, 0, sizeof(struct tm)); /* get desired type and size */ @@ -901,16 +903,16 @@ sprintf (get, "GET http://%s%s HTTP/1.0\r\nUser-Agent: xephem/%s\r\n\r\n", sohohost, fn, PATCHLEVEL); /* query server */ - fd = httpGET (sohohost, get, buf); + fd = httpsGET (sohohost, get, buf, &ssl_fd); if (fd < 0) { - xe_msg (1, "http get: %s", buf); + xe_msg (1, "https get: %s", buf); return (-1); } /* read header (everything to first blank line), looking for jpeg */ isjpeg = 0; jpegl = 0; - while (recvline (fd, buf, sizeof(buf)) > 1) { + while (ssl_recvline (ssl_fd.ssl, buf, sizeof(buf)) > 1) { xe_msg (0, "Rcv: %s", buf); if (strstr (buf, "Content-Type:") && strstr (buf, "image/jpeg")) isjpeg = 1; @@ -923,15 +925,17 @@ } } if (!isjpeg) { - while (recvline (fd, buf, sizeof(buf)) > 0) + while (ssl_recvline (ssl_fd.ssl, buf, sizeof(buf)) > 0) xe_msg (0, "Rcv: %s", buf); xe_msg (1, "Error talking to SOHO .. see File->System log\n"); - close (fd); + SSL_free(ssl_fd.ssl); + close(ssl_fd.fd); return (-1); } if (jpegl == 0) { xe_msg (1, "No Content-Length in header"); - close (fd); + SSL_free(ssl_fd.ssl); + close(ssl_fd.fd); return (-1); } @@ -941,18 +945,20 @@ for (njpeg = 0; njpeg < jpegl; njpeg += nr) { pm_set (100*njpeg/jpegl); jpeg = (unsigned char *) XtRealloc ((char*)jpeg, njpeg+NSREAD); - nr = readbytes (fd, jpeg+njpeg, NSREAD); - if (nr < 0) { - xe_msg (1, "%s:\n%s", sohohost, syserrstr()); + nr = SSL_read (ssl_fd.ssl, jpeg+njpeg, NSREAD); + if (nr <= 0) { + xe_msg (1, "%s: ssl read error code: %d", sohohost, SSL_get_error(ssl_fd.ssl, nr)); pm_down(); - close (fd); + SSL_free(ssl_fd.ssl); + close(ssl_fd.fd); return (-1); } if (nr == 0) break; } pm_down(); - close (fd); + SSL_free(ssl_fd.ssl); + close(ssl_fd.fd); sprintf (fn, "/%s_%s.jpg", filetime, filetype); /* display jpeg */ diff -burNE xephem-3.7.7_orig/GUI/xephem/ucac.c xephem-3.7.7/GUI/xephem/ucac.c --- xephem-3.7.7_orig/GUI/xephem/ucac.c 2017-01-03 11:24:14.691545416 +0100 +++ xephem-3.7.7/GUI/xephem/ucac.c 2017-01-03 11:24:27.699598880 +0100 @@ -18,15 +18,15 @@ #define MAXFOV 15.0 /* max fov, degs */ -typedef unsigned char UC; /* byte */ -typedef unsigned int UI; /* unsigned integer */ +typedef unsigned char XE_UC; /* byte */ +typedef unsigned int XE_UI; /* unsigned integer */ /* access an I*2 or I*4 at offset i in UC array a in little-endian byte order. * a bit slow but ultra portable. */ -#define I2(a,i) ((int)(short)((((UI)(a)[i]) | (((UI)(a)[i+1])<<8)))) -#define I4(a,i) ((int)((((UI)(a)[i]) | (((UI)(a)[i+1])<<8) | \ - (((UI)(a)[i+2])<<16) | (((UI)(a)[i+3])<<24)))) +#define I2(a,i) ((int)(short)((((XE_UI)(a)[i]) | (((XE_UI)(a)[i+1])<<8)))) +#define I4(a,i) ((int)((((XE_UI)(a)[i]) | (((XE_UI)(a)[i+1])<<8) | \ + (((XE_UI)(a)[i+2])<<16) | (((XE_UI)(a)[i+3])<<24)))) /* keep track of an array of ObjF */ typedef struct { @@ -48,9 +48,9 @@ #define DPMAS (1.0/3600000.0) /* degrees per milliarcsecond */ -typedef UC U2Star[44]; /* UCAC2 record */ -typedef UC U3Star[84]; /* UCAC3 record */ -typedef UC U4Star[78]; /* UCAC4 record */ +typedef XE_UC U2Star[44]; /* UCAC2 record */ +typedef XE_UC U3Star[84]; /* UCAC3 record */ +typedef XE_UC U4Star[78]; /* UCAC4 record */ static char *basedir; /* full dir with zone files and index */ static FILE *indexfp; /* index file handle */ @@ -293,7 +293,7 @@ read4Index (int rz, int dz, int *nskip, int *nnew) { off_t offset; - UC i4[4]; + XE_UC i4[4]; offset = (rz*NZH4 + dz)*sizeof(i4); if (fseek (indexfp, offset, SEEK_SET) < 0) { @@ -508,7 +508,7 @@ read3Index (int rz, int dz, int *nskip, int *nnew) { off_t offset; - UC i4[4]; + XE_UC i4[4]; offset = (rz*NZH + dz)*sizeof(i4); if (fseek (indexfp, offset, SEEK_SET) < 0) { @@ -663,7 +663,7 @@ get2N (int rz, int dz, int *idp) { off_t offset; - UC nat[4]; + XE_UC nat[4]; offset = (dz*NZW + rz)*sizeof(nat); if (fseek (indexfp, offset, SEEK_SET) < 0) diff -burNE xephem-3.7.7_orig/GUI/xephem/usno.c xephem-3.7.7/GUI/xephem/usno.c --- xephem-3.7.7_orig/GUI/xephem/usno.c 2017-01-03 11:24:14.691545416 +0100 +++ xephem-3.7.7/GUI/xephem/usno.c 2017-01-03 11:24:27.699598880 +0100 @@ -14,8 +14,8 @@ #define CATBPR 12 /* bytes per star record in .cat file */ #define ACCBPR 30 /* bytes per record in .acc file */ -typedef unsigned int UI; -typedef unsigned char UC; +typedef unsigned int XE_UI; +typedef unsigned char XE_UC; /* One Field star */ typedef struct { @@ -36,7 +36,7 @@ double lr[2], int *nd, double fd[2], double ld[2], int zone[2], char msg[]); static int fetchSwath (int zone, double maxmag, double fr, double lr, double fd, double ld, StarArray *sap, char msg[]); -static int crackCatBuf (UC buf[CATBPR], FieldStar *fsp); +static int crackCatBuf (XE_UC buf[CATBPR], FieldStar *fsp); static int addGS (StarArray *sap, FieldStar *fsp); static char *cdpath; /* where CD rom is mounted */ @@ -236,7 +236,7 @@ { char fn[1024]; char buf[ACCBPR]; - UC catbuf[CATBPR]; + XE_UC catbuf[CATBPR]; FieldStar fs; long frec; long os; @@ -314,13 +314,13 @@ * return 0 if ok, else -1. */ static int -crackCatBuf (UC buf[CATBPR], FieldStar *fsp) +crackCatBuf (XE_UC buf[CATBPR], FieldStar *fsp) { -#define BEUPACK(b) (((UI)((b)[0])<<24) | ((UI)((b)[1])<<16) | ((UI)((b)[2])<<8)\ - | ((UI)((b)[3]))) +#define BEUPACK(b) (((XE_UI)((b)[0])<<24) | ((XE_UI)((b)[1])<<16) | ((XE_UI)((b)[2])<<8)\ + | ((XE_UI)((b)[3]))) double ra, dec; int red, blu; - UI mag; + XE_UI mag; /* first 4 bytes are packed RA, big-endian */ ra = BEUPACK(buf)/(100.0*3600.0*15.0); diff -burNE xephem-3.7.7_orig/GUI/xephem/xephem.h xephem-3.7.7/GUI/xephem/xephem.h --- xephem-3.7.7_orig/GUI/xephem/xephem.h 2017-01-03 11:24:14.691545416 +0100 +++ xephem-3.7.7/GUI/xephem/xephem.h 2017-01-03 11:24:27.699598880 +0100 @@ -12,12 +12,12 @@ #include <stdarg.h> /* be kind to those who don't use xe_msg() */ +#include "net.h" /* has to be included before astro.h because of openssl */ #include "astro.h" #include "ip.h" /* local glue files */ #include "map.h" -#include "net.h" #include "patchlevel.h" #include "preferences.h" #include "db.h"
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor