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

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

13
14
15
16
17
18
19


13
14
15
16
17
18
19
20
21







+
+
libcackey_g.so
libcackey.so
libcackey.syms
build/certs
test
test-afl
test-afl.data
build/chrome/archive
build/chrome/workdir-*

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

























































































































































































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /usr/bin/env bash

# f24353d02d90f97c72b6977f3a8a05006ad06120

ourScript="$(which "$0")"
if ! head -3 "${ourScript}" 2>/dev/null | grep f24353d02d90f97c72b6977f3a8a05006ad06120 >/dev/null; then
	echo "error: Unable to find ourselves" >&2

	exit 1
fi

cd "$(dirname "${ourScript}")" || exit 1

patchDir="$(pwd)/patches"

function download() {
	local url file hash
	local hashMethod
	local chkHash

	url="$1"
	file="$2"
	hash="$3"

	if [ -f "${file}" ]; then
		return 0
	fi

	mkdir -p "$(dirname "${file}")"

	hashMethod='sha256'

	rm -f "${file}.new"
	wget --header "X-Cache-URL: ${url}" -O "${file}.new" "http://hashcache.rkeene.org/${hashMethod}/${hash}" || \
		wget -O "${file}.new" "${url}" || \
		return 1

	chkHash="$(openssl "${hashMethod}" "${file}.new" | sed 's@.*= *@@')"

	if [ "${chkHash}" != "${hash}" ]; then
		echo "error: Checksum mismatch: Got: ${chkHash}; Expected: ${hash}" >&2

		return 1
	fi

	mv "${file}.new" "${file}"

	return 0
}

function extract() {
	local file directory

	file="$1"
	directory="$2"

	if [ ! -f "${file}" ]; then
		echo "error: Unable to extract \"${file}\"" >&2

		return 1
	fi

	rm -rf "${directory}"

	mkdir -p "${directory}" || return 1
	(
		cd "${directory}" || exit 1

		case "${file}" in
			*.tar.bz2|*.bz2)
				bzip2 -dc | tar -xf - || exit 1
				;;
			*.tar.gz|*.tgz)
				gzip -dc | tar -xf - || exit 1
				;;
			*.tar.xz|*.txz)
				xz -dc | tar -xf - || exit 1
				;;
			*)
				echo "error: Don't know what to do with \"${file}\"" >&2

				exit 1
				;;
		esac

		if [ -d "$(echo *)" ]; then
			mv */* . >/dev/null 2>/dev/null
		fi
	) < "${file}" || return 1

	return 0
}

function make() {
	"${MAKE:-$(which make)}" "$@"
}

function buildLibUSB() {
	local version url pkg sha256 configure_extra
	local archive workdir instdir

	pkg='libusb'
	version='1.0.9'
	url="http://sourceforge.net/projects/libusb/files/libusb-1.0/libusb-${version}/libusb-${version}.tar.bz2"
	sha256='e920eedc2d06b09606611c99ec7304413c6784cba6e33928e78243d323195f9b'
	configure_extra=(--disable-shared --enable-static --with-pic "${global_configure_extra[@]}")

	archive="archive/${pkg}-${version}.tar.bz2"
	workdir="workdir-${RANDOM}${RANDOM}${RANDOM}${RANDOM}.build"
	instdir="workdir-${RANDOM}${RANDOM}${RANDOM}${RANDOM}.inst"

	download "${url}" "${archive}" "${sha256}" || return 1
	extract "${archive}" "${workdir}" || return 1

	(
		mkdir "${instdir}"

		instdir="$(cd "${instdir}" && pwd)" || exit 1

		cd "${workdir}" || exit 1

		./configure --prefix='' "${configure_extra[@]}" || exit 1
		make V=1 || exit 1
		make V=1 DESTDIR="${instdir}" install || exit 1
	) || return 1

	rm -rf "${workdir}"

	cackeyChromeExtLibUSBDir="$(cd "${instdir}" && pwd)" || return 1
	export LIBUSB_LIBS="-L${cackeyChromeExtLibUSBDir}/lib -lusb-1.0 -lrt -pthread"
	export LIBUSB_CFLAGS="-I${cackeyChromeExtLibUSBDir}/include/libusb-1.0"

	return 0
}

function buildCCID() {
	local version url pkg sha256 configure_extra
	local archive workdir instdir

	pkg='ccid'
	version='1.4.22'
	url="https://alioth.debian.org/frs/download.php/file/4162/ccid-${version}.tar.bz2"
	sha256='9c5c8be465b6d33316be7a7ea720c24a776e2d76be9072116d28fc9adf58c106'
	configure_extra=(
		--with-pic
		--disable-shared --enable-static --enable-usb
		--enable-usbdropdir=/drivers
		"${global_configure_extra[@]}"
	)

	archive="archive/${pkg}-${version}.tar.bz2"
	workdir="workdir-${RANDOM}${RANDOM}${RANDOM}${RANDOM}.build"
	instdir="workdir-${RANDOM}${RANDOM}${RANDOM}${RANDOM}.inst"

	download "${url}" "${archive}" "${sha256}" || return 1
	extract "${archive}" "${workdir}" || return 1

	(
		mkdir "${instdir}"

		instdir="$(cd "${instdir}" && pwd)" || exit 1

		cd "${workdir}" || exit 1

		./configure --prefix='' "${configure_extra[@]}" || exit 1

		make V=1 || exit 1

		mkdir "${instdir}/lib"
		cp src/.libs/libccid.a "${instdir}/lib"

		mkdir "${instdir}/include"
		./src/create_Info_plist.pl ./readers/supported_readers.txt src/Info.plist.src --target=libccid.so --version=1.0.0 | \
			sed '/<key>ifdDriverOptions/ {n;c \'$'\n''<string>0x0004</string>'$'\n''p}' | \
			od -t x1 -v | sed 's@^[^ ]* @@;s@ @@g;s@..@\\x&@g;$ d;s@^@"@;s@$@"@' > "${instdir}/include/Info.plist.h"
	) || return 1

	rm -rf "${workdir}"

	cackeyChromeExtCCIDDir="$(cd "${instdir}" && pwd)" || return 1

	return 0
}

function buildPCSCLite() {
	local version url pkg sha256 configure_extra
	local archive workdir instdir

	buildLibUSB || return 1

	pkg='pcsc-lite'
	version='1.8.15'
	url="https://alioth.debian.org/frs/download.php/file/4157/pcsc-lite-${version}.tar.bz2"
	sha256='ad8b1f3d2c59d3a966cb203fc74588629c4a5fa30f8ad9005e06ef7aa445d341'
	configure_extra=(
		--disable-shared --enable-static --enable-usb --disable-libudev --disable-polkit --with-pic
		"${global_configure_extra[@]}"
	)

	archive="archive/${pkg}-${version}.tar.bz2"
	workdir="workdir-${RANDOM}${RANDOM}${RANDOM}${RANDOM}.build"
	instdir="workdir-${RANDOM}${RANDOM}${RANDOM}${RANDOM}.inst"

	download "${url}" "${archive}" "${sha256}" || return 1
	extract "${archive}" "${workdir}" || return 1

	(
		mkdir "${instdir}"

		instdir="$(cd "${instdir}" && pwd)" || exit 1

		cd "${workdir}" || exit 1

		./configure --prefix='' --sbindir="/bin" "${configure_extra[@]}" || exit 1
		make V=1 || exit 1
		make V=1 DESTDIR="${instdir}" install || exit 1
	) || return 1

	cackeyChromeExtPCSCLiteDir="$(cd "${instdir}" && pwd)"
	export PCSC_CFLAGS="-I${cackeyChromeExtPCSCLiteDir}/include/PCSC"
	export PCSC_LIBS="-L${cackeyChromeExtPCSCLiteDir}/lib -lpcsclite -pthread"

	buildCCID || return 1

	rm -rf "${instdir}"
	unset PCSC_CFLAGS PCSC_LIBS cackeyChromeExtPCSCLiteDir

	rm -rf "${workdir}"
	extract "${archive}" "${workdir}" || return 1

	(
		mkdir "${instdir}"

		instdir="$(cd "${instdir}" && pwd)" || exit 1

		cd "${workdir}" || exit 1

		sed -i 's@^pcscd_LDFLAGS[[:space:]]*=@& -all-static @' src/Makefile.in

		for patchFile in "${patchDir}"/pcsc-lite-*.diff; do
			if [ ! -f "${patchFile}" ]; then
				continue
			fi

			patch -p1 < "${patchFile}" || exit 1
		done

		cp "${cackeyChromeExtCCIDDir}/include/Info.plist.h" src/ || exit 1

		extraDefines='-DPCSCLITE_STATIC_DRIVER -DIFDHANDLERv3'

		./configure --prefix='' --sbindir="/bin" "${configure_extra[@]}" CFLAGS="-g3 -ggdb3 ${CFLAGS} ${extraDefines}" CPPFLAGS="${CPPFLAGS} ${extraDefines}" LIBS="${LIBS} -L${cackeyChromeExtCCIDDir}/lib -lccid" || exit 1
		make V=1 || exit 1
		make V=1 DESTDIR="${instdir}" install || exit 1
	) || return 1

	rm -rf "${cackeyChromeExtLibUSBDir}"
	unset LIBUSB_LIBS LIBUSB_CFLAGS

	rm -rf "${cackeyChromeExtCCIDDir}"
	rm -rf "${workdir}"

	cackeyChromeExtPCSCLiteDir="$(cd "${instdir}" && pwd)"
	export PCSC_CFLAGS="-I${cackeyChromeExtPCSCLiteDir}/include/PCSC"
	export PCSC_LIBS="-L${cackeyChromeExtPCSCLiteDir}/lib -lpcsclite -pthread"

	cp "${cackeyChromeExtPCSCLiteDir}/bin/pcscd" "${outdir}" || return 1

	return 0
}

function buildCACKey() {
	local file copied

	(
		cd ../.. || exit 1

		make distclean

		./configure --with-pcsc-headers="${cackeyChromeExtPCSCLiteDir}/include/PCSC" --with-pcsc-libs="${PCSC_LIBS}" || exit 1
		make || exit 1
	) || return 1

	copied='0'
	for file in ../../libcackey{,_g}.{so,dll,dylib}; do
		if [ -f "${file}" ]; then
			cp "${file}" "${outdir}"
			copied='1'
		fi
	done

	if [ "${copied}" = '0' ]; then
		echo "error: Unable to copy built libcackey to local directory" >&2

		return 1
	fi

	rm -rf "${cackeyChromeExtPCSCLiteDir}"
	unset PCSC_CFLAGS PCSC_LIBS

	return 0
}

outdir="workdir-${RANDOM}${RANDOM}${RANDOM}${RANDOM}.out"
rm -rf "${outdir}"
mkdir "${outdir}" || exit 1

buildPCSCLite || exit 1

buildCACKey || exit 1

exit 0

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































































































































































































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