Check-in [fc49ac54cf]
Overview
SHA1:fc49ac54cfc18ef98c37a180b6f1b7351d37329d
Date: 2016-02-03 05:26:20
User: rkeene
Comment:Added start of a Google Chrome extension
Timelines: family | ancestors | descendants | both | trunk
Downloads: Tarball | ZIP archive
Other Links: files | file ages | folders | manifest
Tags And Properties
Context
2016-02-03
07:08
[b4f1d32aff] Add header files for pcsclite (user: rkeene, tags: trunk)
05:26
[fc49ac54cf] Added start of a Google Chrome extension (user: rkeene, tags: trunk)
2015-09-30
15:16
[bb7be6db49] CACKey 0.7.5 (user: rkeene, tags: trunk, 0.7.5)
Changes

Modified .fossil-settings/ignore-glob from [9166d2ec0f] to [e1c6eee148].

    13     13   libcackey_g.so
    14     14   libcackey.so
    15     15   libcackey.syms
    16     16   build/certs
    17     17   test
    18     18   test-afl
    19     19   test-afl.data
           20  +build/chrome/archive
           21  +build/chrome/workdir-*

Added build/chrome/build-deps version [7f9ef1ab4d].

            1  +#! /usr/bin/env bash
            2  +
            3  +# f24353d02d90f97c72b6977f3a8a05006ad06120
            4  +
            5  +ourScript="$(which "$0")"
            6  +if ! head -3 "${ourScript}" 2>/dev/null | grep f24353d02d90f97c72b6977f3a8a05006ad06120 >/dev/null; then
            7  +	echo "error: Unable to find ourselves" >&2
            8  +
            9  +	exit 1
           10  +fi
           11  +
           12  +cd "$(dirname "${ourScript}")" || exit 1
           13  +
           14  +patchDir="$(pwd)/patches"
           15  +
           16  +function download() {
           17  +	local url file hash
           18  +	local hashMethod
           19  +	local chkHash
           20  +
           21  +	url="$1"
           22  +	file="$2"
           23  +	hash="$3"
           24  +
           25  +	if [ -f "${file}" ]; then
           26  +		return 0
           27  +	fi
           28  +
           29  +	mkdir -p "$(dirname "${file}")"
           30  +
           31  +	hashMethod='sha256'
           32  +
           33  +	rm -f "${file}.new"
           34  +	wget --header "X-Cache-URL: ${url}" -O "${file}.new" "http://hashcache.rkeene.org/${hashMethod}/${hash}" || \
           35  +		wget -O "${file}.new" "${url}" || \
           36  +		return 1
           37  +
           38  +	chkHash="$(openssl "${hashMethod}" "${file}.new" | sed 's@.*= *@@')"
           39  +
           40  +	if [ "${chkHash}" != "${hash}" ]; then
           41  +		echo "error: Checksum mismatch: Got: ${chkHash}; Expected: ${hash}" >&2
           42  +
           43  +		return 1
           44  +	fi
           45  +
           46  +	mv "${file}.new" "${file}"
           47  +
           48  +	return 0
           49  +}
           50  +
           51  +function extract() {
           52  +	local file directory
           53  +
           54  +	file="$1"
           55  +	directory="$2"
           56  +
           57  +	if [ ! -f "${file}" ]; then
           58  +		echo "error: Unable to extract \"${file}\"" >&2
           59  +
           60  +		return 1
           61  +	fi
           62  +
           63  +	rm -rf "${directory}"
           64  +
           65  +	mkdir -p "${directory}" || return 1
           66  +	(
           67  +		cd "${directory}" || exit 1
           68  +
           69  +		case "${file}" in
           70  +			*.tar.bz2|*.bz2)
           71  +				bzip2 -dc | tar -xf - || exit 1
           72  +				;;
           73  +			*.tar.gz|*.tgz)
           74  +				gzip -dc | tar -xf - || exit 1
           75  +				;;
           76  +			*.tar.xz|*.txz)
           77  +				xz -dc | tar -xf - || exit 1
           78  +				;;
           79  +			*)
           80  +				echo "error: Don't know what to do with \"${file}\"" >&2
           81  +
           82  +				exit 1
           83  +				;;
           84  +		esac
           85  +
           86  +		if [ -d "$(echo *)" ]; then
           87  +			mv */* . >/dev/null 2>/dev/null
           88  +		fi
           89  +	) < "${file}" || return 1
           90  +
           91  +	return 0
           92  +}
           93  +
           94  +function make() {
           95  +	"${MAKE:-$(which make)}" "$@"
           96  +}
           97  +
           98  +function buildLibUSB() {
           99  +	local version url pkg sha256 configure_extra
          100  +	local archive workdir instdir
          101  +
          102  +	pkg='libusb'
          103  +	version='1.0.9'
          104  +	url="http://sourceforge.net/projects/libusb/files/libusb-1.0/libusb-${version}/libusb-${version}.tar.bz2"
          105  +	sha256='e920eedc2d06b09606611c99ec7304413c6784cba6e33928e78243d323195f9b'
          106  +	configure_extra=(--disable-shared --enable-static --with-pic "${global_configure_extra[@]}")
          107  +
          108  +	archive="archive/${pkg}-${version}.tar.bz2"
          109  +	workdir="workdir-${RANDOM}${RANDOM}${RANDOM}${RANDOM}.build"
          110  +	instdir="workdir-${RANDOM}${RANDOM}${RANDOM}${RANDOM}.inst"
          111  +
          112  +	download "${url}" "${archive}" "${sha256}" || return 1
          113  +	extract "${archive}" "${workdir}" || return 1
          114  +
          115  +	(
          116  +		mkdir "${instdir}"
          117  +
          118  +		instdir="$(cd "${instdir}" && pwd)" || exit 1
          119  +
          120  +		cd "${workdir}" || exit 1
          121  +
          122  +		./configure --prefix='' "${configure_extra[@]}" || exit 1
          123  +		make V=1 || exit 1
          124  +		make V=1 DESTDIR="${instdir}" install || exit 1
          125  +	) || return 1
          126  +
          127  +	rm -rf "${workdir}"
          128  +
          129  +	cackeyChromeExtLibUSBDir="$(cd "${instdir}" && pwd)" || return 1
          130  +	export LIBUSB_LIBS="-L${cackeyChromeExtLibUSBDir}/lib -lusb-1.0 -lrt -pthread"
          131  +	export LIBUSB_CFLAGS="-I${cackeyChromeExtLibUSBDir}/include/libusb-1.0"
          132  +
          133  +	return 0
          134  +}
          135  +
          136  +function buildCCID() {
          137  +	local version url pkg sha256 configure_extra
          138  +	local archive workdir instdir
          139  +
          140  +	pkg='ccid'
          141  +	version='1.4.22'
          142  +	url="https://alioth.debian.org/frs/download.php/file/4162/ccid-${version}.tar.bz2"
          143  +	sha256='9c5c8be465b6d33316be7a7ea720c24a776e2d76be9072116d28fc9adf58c106'
          144  +	configure_extra=(
          145  +		--with-pic
          146  +		--disable-shared --enable-static --enable-usb
          147  +		--enable-usbdropdir=/drivers
          148  +		"${global_configure_extra[@]}"
          149  +	)
          150  +
          151  +	archive="archive/${pkg}-${version}.tar.bz2"
          152  +	workdir="workdir-${RANDOM}${RANDOM}${RANDOM}${RANDOM}.build"
          153  +	instdir="workdir-${RANDOM}${RANDOM}${RANDOM}${RANDOM}.inst"
          154  +
          155  +	download "${url}" "${archive}" "${sha256}" || return 1
          156  +	extract "${archive}" "${workdir}" || return 1
          157  +
          158  +	(
          159  +		mkdir "${instdir}"
          160  +
          161  +		instdir="$(cd "${instdir}" && pwd)" || exit 1
          162  +
          163  +		cd "${workdir}" || exit 1
          164  +
          165  +		./configure --prefix='' "${configure_extra[@]}" || exit 1
          166  +
          167  +		make V=1 || exit 1
          168  +
          169  +		mkdir "${instdir}/lib"
          170  +		cp src/.libs/libccid.a "${instdir}/lib"
          171  +
          172  +		mkdir "${instdir}/include"
          173  +		./src/create_Info_plist.pl ./readers/supported_readers.txt src/Info.plist.src --target=libccid.so --version=1.0.0 | \
          174  +			sed '/<key>ifdDriverOptions/ {n;c \'$'\n''<string>0x0004</string>'$'\n''p}' | \
          175  +			od -t x1 -v | sed 's@^[^ ]* @@;s@ @@g;s@..@\\x&@g;$ d;s@^@"@;s@$@"@' > "${instdir}/include/Info.plist.h"
          176  +	) || return 1
          177  +
          178  +	rm -rf "${workdir}"
          179  +
          180  +	cackeyChromeExtCCIDDir="$(cd "${instdir}" && pwd)" || return 1
          181  +
          182  +	return 0
          183  +}
          184  +
          185  +function buildPCSCLite() {
          186  +	local version url pkg sha256 configure_extra
          187  +	local archive workdir instdir
          188  +
          189  +	buildLibUSB || return 1
          190  +
          191  +	pkg='pcsc-lite'
          192  +	version='1.8.15'
          193  +	url="https://alioth.debian.org/frs/download.php/file/4157/pcsc-lite-${version}.tar.bz2"
          194  +	sha256='ad8b1f3d2c59d3a966cb203fc74588629c4a5fa30f8ad9005e06ef7aa445d341'
          195  +	configure_extra=(
          196  +		--disable-shared --enable-static --enable-usb --disable-libudev --disable-polkit --with-pic
          197  +		"${global_configure_extra[@]}"
          198  +	)
          199  +
          200  +	archive="archive/${pkg}-${version}.tar.bz2"
          201  +	workdir="workdir-${RANDOM}${RANDOM}${RANDOM}${RANDOM}.build"
          202  +	instdir="workdir-${RANDOM}${RANDOM}${RANDOM}${RANDOM}.inst"
          203  +
          204  +	download "${url}" "${archive}" "${sha256}" || return 1
          205  +	extract "${archive}" "${workdir}" || return 1
          206  +
          207  +	(
          208  +		mkdir "${instdir}"
          209  +
          210  +		instdir="$(cd "${instdir}" && pwd)" || exit 1
          211  +
          212  +		cd "${workdir}" || exit 1
          213  +
          214  +		./configure --prefix='' --sbindir="/bin" "${configure_extra[@]}" || exit 1
          215  +		make V=1 || exit 1
          216  +		make V=1 DESTDIR="${instdir}" install || exit 1
          217  +	) || return 1
          218  +
          219  +	cackeyChromeExtPCSCLiteDir="$(cd "${instdir}" && pwd)"
          220  +	export PCSC_CFLAGS="-I${cackeyChromeExtPCSCLiteDir}/include/PCSC"
          221  +	export PCSC_LIBS="-L${cackeyChromeExtPCSCLiteDir}/lib -lpcsclite -pthread"
          222  +
          223  +	buildCCID || return 1
          224  +
          225  +	rm -rf "${instdir}"
          226  +	unset PCSC_CFLAGS PCSC_LIBS cackeyChromeExtPCSCLiteDir
          227  +
          228  +	rm -rf "${workdir}"
          229  +	extract "${archive}" "${workdir}" || return 1
          230  +
          231  +	(
          232  +		mkdir "${instdir}"
          233  +
          234  +		instdir="$(cd "${instdir}" && pwd)" || exit 1
          235  +
          236  +		cd "${workdir}" || exit 1
          237  +
          238  +		sed -i 's@^pcscd_LDFLAGS[[:space:]]*=@& -all-static @' src/Makefile.in
          239  +
          240  +		for patchFile in "${patchDir}"/pcsc-lite-*.diff; do
          241  +			if [ ! -f "${patchFile}" ]; then
          242  +				continue
          243  +			fi
          244  +
          245  +			patch -p1 < "${patchFile}" || exit 1
          246  +		done
          247  +
          248  +		cp "${cackeyChromeExtCCIDDir}/include/Info.plist.h" src/ || exit 1
          249  +
          250  +		extraDefines='-DPCSCLITE_STATIC_DRIVER -DIFDHANDLERv3'
          251  +
          252  +		./configure --prefix='' --sbindir="/bin" "${configure_extra[@]}" CFLAGS="-g3 -ggdb3 ${CFLAGS} ${extraDefines}" CPPFLAGS="${CPPFLAGS} ${extraDefines}" LIBS="${LIBS} -L${cackeyChromeExtCCIDDir}/lib -lccid" || exit 1
          253  +		make V=1 || exit 1
          254  +		make V=1 DESTDIR="${instdir}" install || exit 1
          255  +	) || return 1
          256  +
          257  +	rm -rf "${cackeyChromeExtLibUSBDir}"
          258  +	unset LIBUSB_LIBS LIBUSB_CFLAGS
          259  +
          260  +	rm -rf "${cackeyChromeExtCCIDDir}"
          261  +	rm -rf "${workdir}"
          262  +
          263  +	cackeyChromeExtPCSCLiteDir="$(cd "${instdir}" && pwd)"
          264  +	export PCSC_CFLAGS="-I${cackeyChromeExtPCSCLiteDir}/include/PCSC"
          265  +	export PCSC_LIBS="-L${cackeyChromeExtPCSCLiteDir}/lib -lpcsclite -pthread"
          266  +
          267  +	cp "${cackeyChromeExtPCSCLiteDir}/bin/pcscd" "${outdir}" || return 1
          268  +
          269  +	return 0
          270  +}
          271  +
          272  +function buildCACKey() {
          273  +	local file copied
          274  +
          275  +	(
          276  +		cd ../.. || exit 1
          277  +
          278  +		make distclean
          279  +
          280  +		./configure --with-pcsc-headers="${cackeyChromeExtPCSCLiteDir}/include/PCSC" --with-pcsc-libs="${PCSC_LIBS}" || exit 1
          281  +		make || exit 1
          282  +	) || return 1
          283  +
          284  +	copied='0'
          285  +	for file in ../../libcackey{,_g}.{so,dll,dylib}; do
          286  +		if [ -f "${file}" ]; then
          287  +			cp "${file}" "${outdir}"
          288  +			copied='1'
          289  +		fi
          290  +	done
          291  +
          292  +	if [ "${copied}" = '0' ]; then
          293  +		echo "error: Unable to copy built libcackey to local directory" >&2
          294  +
          295  +		return 1
          296  +	fi
          297  +
          298  +	rm -rf "${cackeyChromeExtPCSCLiteDir}"
          299  +	unset PCSC_CFLAGS PCSC_LIBS
          300  +
          301  +	return 0
          302  +}
          303  +
          304  +outdir="workdir-${RANDOM}${RANDOM}${RANDOM}${RANDOM}.out"
          305  +rm -rf "${outdir}"
          306  +mkdir "${outdir}" || exit 1
          307  +
          308  +buildPCSCLite || exit 1
          309  +
          310  +buildCACKey || exit 1
          311  +
          312  +exit 0

Added build/chrome/patches/pcsc-lite-1.8.15-hotplugstaticccid.diff version [856f9b4aaa].

            1  +diff --no-dereference -uNr pcsc-lite-1.8.15.orig/src/hotplug_libusb.c pcsc-lite-1.8.15-hotplugstaticccid/src/hotplug_libusb.c
            2  +--- pcsc-lite-1.8.15.orig/src/hotplug_libusb.c	2015-11-06 02:39:51.000000000 -0600
            3  ++++ pcsc-lite-1.8.15-hotplugstaticccid/src/hotplug_libusb.c	2016-02-02 23:05:02.738140506 -0600
            4  +@@ -128,21 +128,10 @@
            5  + static LONG HPReadBundleValues(void)
            6  + {
            7  + 	LONG rv;
            8  +-	DIR *hpDir;
            9  +-	struct dirent *currFP = NULL;
           10  + 	char fullPath[FILENAME_MAX];
           11  + 	char fullLibPath[FILENAME_MAX];
           12  + 	int listCount = 0;
           13  + 
           14  +-	hpDir = opendir(PCSCLITE_HP_DROPDIR);
           15  +-
           16  +-	if (hpDir == NULL)
           17  +-	{
           18  +-		Log1(PCSC_LOG_ERROR, "Cannot open PC/SC drivers directory: " PCSCLITE_HP_DROPDIR);
           19  +-		Log1(PCSC_LOG_ERROR, "Disabling USB support for pcscd.");
           20  +-		return -1;
           21  +-	}
           22  +-
           23  + 	/* allocate a first array */
           24  + 	driverTracker = calloc(DRIVER_TRACKER_SIZE_STEP, sizeof(*driverTracker));
           25  + 	if (NULL == driverTracker)
           26  +@@ -158,12 +147,8 @@
           27  + 	{ \
           28  + 		Log2(PCSC_LOG_ERROR, "Value/Key not defined for " key " in %s", \
           29  + 			fullPath); \
           30  +-		continue; \
           31  + 	}
           32  + 
           33  +-	while ((currFP = readdir(hpDir)) != 0)
           34  +-	{
           35  +-		if (strstr(currFP->d_name, ".bundle") != 0)
           36  + 		{
           37  + 			unsigned int alias;
           38  + 			list_t plist, *values;
           39  +@@ -171,24 +156,16 @@
           40  + 			char *libraryPath;
           41  + 			int ifdCapabilities;
           42  + 
           43  +-			/*
           44  +-			 * The bundle exists - let's form a full path name and get the
           45  +-			 * vendor and product ID's for this particular bundle
           46  +-			 */
           47  +-			snprintf(fullPath, sizeof(fullPath), "%s/%s/Contents/Info.plist",
           48  +-				PCSCLITE_HP_DROPDIR, currFP->d_name);
           49  +-			fullPath[sizeof(fullPath) - 1] = '\0';
           50  +-
           51  +-			rv = bundleParse(fullPath, &plist);
           52  ++			rv = bundleParse("", &plist);
           53  + 			if (rv)
           54  +-				continue;
           55  ++				return -1;
           56  + 
           57  + 			/* get CFBundleExecutable */
           58  + 			GET_KEY(PCSCLITE_HP_LIBRKEY_NAME, &values)
           59  + 			libraryPath = list_get_at(values, 0);
           60  + 			(void)snprintf(fullLibPath, sizeof(fullLibPath),
           61  + 				"%s/%s/Contents/%s/%s",
           62  +-				PCSCLITE_HP_DROPDIR, currFP->d_name, PCSC_ARCH,
           63  ++				PCSCLITE_HP_DROPDIR, "", PCSC_ARCH,
           64  + 				libraryPath);
           65  + 			fullLibPath[sizeof(fullLibPath) - 1] = '\0';
           66  + 
           67  +@@ -215,7 +192,7 @@
           68  + 				driverTracker[listCount].readerName = strdup(list_get_at(readerNames, alias));
           69  + 
           70  + 				/* constant entries for a same driver */
           71  +-				driverTracker[listCount].bundleName = strdup(currFP->d_name);
           72  ++				driverTracker[listCount].bundleName = strdup("");
           73  + 				driverTracker[listCount].libraryPath = strdup(fullLibPath);
           74  + 				driverTracker[listCount].ifdCapabilities = ifdCapabilities;
           75  + 
           76  +@@ -240,7 +217,6 @@
           77  + 					{
           78  + 						Log1(PCSC_LOG_CRITICAL, "Not enough memory");
           79  + 						driverSize = -1;
           80  +-						closedir(hpDir);
           81  + 						return -1;
           82  + 					}
           83  + 
           84  +@@ -258,10 +234,8 @@
           85  + 			}
           86  + 			bundleRelease(&plist);
           87  + 		}
           88  +-	}
           89  + 
           90  + 	driverSize = listCount;
           91  +-	closedir(hpDir);
           92  + 
           93  + 	rv = TRUE;
           94  + 	if (driverSize == 0)
           95  +diff --no-dereference -uNr pcsc-lite-1.8.15.orig/src/parser.h pcsc-lite-1.8.15-hotplugstaticccid/src/parser.h
           96  +--- pcsc-lite-1.8.15.orig/src/parser.h	2015-11-06 02:39:51.000000000 -0600
           97  ++++ pcsc-lite-1.8.15-hotplugstaticccid/src/parser.h	2016-02-02 14:04:35.619279091 -0600
           98  +@@ -48,6 +48,7 @@
           99  + 
          100  + int LTPBundleFindValueWithKey(list_t *l, const char *key, list_t **values);
          101  + int bundleParse(const char *fileName, list_t *l);
          102  ++int bundleParseContents(const char *plistContents, list_t *l);
          103  + void bundleRelease(list_t *l);
          104  + 
          105  + #endif
          106  +diff --no-dereference -uNr pcsc-lite-1.8.15.orig/src/pcscdaemon.c pcsc-lite-1.8.15-hotplugstaticccid/src/pcscdaemon.c
          107  +--- pcsc-lite-1.8.15.orig/src/pcscdaemon.c	2015-11-06 02:39:51.000000000 -0600
          108  ++++ pcsc-lite-1.8.15-hotplugstaticccid/src/pcscdaemon.c	2016-02-02 13:45:36.214210985 -0600
          109  +@@ -641,7 +641,7 @@
          110  + 	(void)signal(SIGHUP, SIG_IGN);	/* needed for Solaris. The signal is sent
          111  + 				 * when the shell is existed */
          112  + 
          113  +-#if !defined(PCSCLITE_STATIC_DRIVER) && defined(USE_USB)
          114  ++#if defined(USE_USB)
          115  + 	/*
          116  + 	 * Set up the search for USB/PCMCIA devices
          117  + 	 */
          118  +diff --no-dereference -uNr pcsc-lite-1.8.15.orig/src/tokenparser.l pcsc-lite-1.8.15-hotplugstaticccid/src/tokenparser.l
          119  +--- pcsc-lite-1.8.15.orig/src/tokenparser.l	2015-11-06 02:39:51.000000000 -0600
          120  ++++ pcsc-lite-1.8.15-hotplugstaticccid/src/tokenparser.l	2016-02-02 23:05:44.680142552 -0600
          121  +@@ -200,36 +200,51 @@
          122  +  */
          123  + int bundleParse(const char *fileName, list_t *l)
          124  + {
          125  +-	FILE *file = NULL;
          126  ++	return(bundleParseContents(
          127  ++#include "Info.plist.h"
          128  ++		, l));
          129  ++}
          130  ++
          131  ++/**
          132  ++ * Parse a Info.plist file's contents as a string and return a list
          133  ++ *
          134  ++ * @param plistContents plist contents
          135  ++ * @param l list containing the results
          136  ++ * @retval -1 configuration file not found
          137  ++ * @retval 0 OK
          138  ++ */
          139  ++int bundleParseContents(const char *plistContents, list_t *l)
          140  ++{
          141  + 	int r;
          142  +-#ifndef NDEBUG
          143  +-	int i;
          144  +-#endif
          145  ++	char *tmpBuffer;
          146  ++	size_t plistContentsLen;
          147  + 
          148  +-	file = fopen(fileName, "r");
          149  +-	if (!file)
          150  +-	{
          151  +-		Log3(PCSC_LOG_CRITICAL, "Could not open bundle file %s: %s",
          152  +-			fileName, strerror(errno));
          153  +-		return 1;
          154  ++	plistContentsLen = strlen(plistContents);
          155  ++
          156  ++	if (plistContentsLen == 0) {
          157  ++		return(-1);
          158  ++	}
          159  ++
          160  ++	tmpBuffer = strdup(plistContents);
          161  ++	if (tmpBuffer == NULL) {
          162  ++		return(-1);
          163  + 	}
          164  + 
          165  + 	r = list_init(l);
          166  + 	assert(r >= 0);
          167  +-	(void)r;
          168  + 
          169  + 	ListKeys = l;
          170  +-	yyin = file;
          171  + 
          172  +-	do
          173  +-	{
          174  +-		(void)yylex();
          175  +-	} while (!feof(file));
          176  +-	yylex_destroy();
          177  ++	YY_BUFFER_STATE yyTmpBuffer = yy_scan_string(tmpBuffer); 
          178  ++	while (yylex() != 0) {
          179  ++		/**/
          180  ++	}
          181  ++	yy_delete_buffer(yyTmpBuffer);
          182  + 
          183  +-	(void)fclose(file);
          184  ++	yylex_destroy();
          185  + 
          186  + #ifndef NDEBUG
          187  ++	int i;
          188  + 	printf("size: %d\n", list_size(l));
          189  + 	for (i=0; i < list_size(l); i++)
          190  + 	{