Check-in [9279433b2f]
Overview
Comment:Added initial PKI support
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | tcl-ops
Files: files | file ages | folders
SHA1:9279433b2fb2920c41245fec9642f70f27ad19f6
User & Date: rkeene on 2014-11-10 04:52:58
Other Links: manifest | tags
Context
2014-11-10
05:02
Minor re-ordering so that FUSE things can be "near" each other check-in: f4e6b62dfb user: rkeene tags: tcl-ops
04:52
Added initial PKI support check-in: 9279433b2f user: rkeene tags: tcl-ops
04:22
More work towards getting the user multiplexing right check-in: d3bb0824ec user: rkeene tags: tcl-ops
Changes

Modified .fossil-settings/ignore-glob from [6f815d9a84] to [efc67b31c0].

     1      1   appfsd
     2      2   appfsd.o
     3      3   appfsd.tcl.h
     4      4   sha1.o
     5      5   sha1.tcl.h
            6  +pki.tcl.h
            7  +pki.tcl.new

Modified Makefile from [e0a242ebcc] to [d5b77089dc].

    21     21   TCL_LIBS = $(shell . $(TCLCONFIG_SH_PATH); echo "$${TCL_LIB_SPEC}")
    22     22   
    23     23   all: appfsd
    24     24   
    25     25   appfsd: appfsd.o sha1.o
    26     26   	$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -o appfsd appfsd.o sha1.o $(LIBS)
    27     27   
    28         -appfsd.o: appfsd.c appfsd.tcl.h
           28  +appfsd.o: appfsd.c appfsd.tcl.h pki.tcl.h
    29     29   	$(CC) $(CPPFLAGS) $(CFLAGS) -o appfsd.o -c appfsd.c
    30     30   
    31     31   sha1.o: sha1.c sha1.tcl.h
    32     32   	$(CC) $(CPPFLAGS) $(CFLAGS) -o sha1.o -c sha1.c
    33     33   
           34  +pki.tcl:
           35  +	rm -f pki.tcl.new
           36  +	curl http://core.tcl.tk/tcllib/raw/modules/asn/asn.tcl?name=aea6802a16e69c9f2d4f5eca20fdc23174609731 > pki.tcl.new
           37  +	curl http://core.tcl.tk/tcllib/raw/modules/aes/aes.tcl?name=94452b42b4ca98298ab1465c40fd87d11a40cf5e >> pki.tcl.new
           38  +	curl http://core.tcl.tk/tcllib/raw/modules/des/tcldes.tcl?name=ffea6ca6eb4468c0edef7a745b1dadc632ff5aeb >> pki.tcl.new
           39  +	curl http://core.tcl.tk/tcllib/raw/modules/des/des.tcl?name=5d8f3a7c1a6ea88ee988652643db8f06038aff49 >> pki.tcl.new
           40  +	curl http://core.tcl.tk/tcllib/raw/modules/math/bignum.tcl?name=3bc84d9b1f18c2e7360573381317c4dc9af731f9 >> pki.tcl.new
           41  +	curl http://core.tcl.tk/tcllib/raw/modules/md5/md5x.tcl?name=3cddfa803d680a79ab7dfac90edfd751f3d4fadd >> pki.tcl.new
           42  +	curl http://core.tcl.tk/tcllib/raw/modules/sha1/sha256.tcl?name=1fd001eb65e88c823b980456726079deae3512df >> pki.tcl.new
           43  +	curl 'http://core.tcl.tk/tcllib/raw/modules/pki/pki.tcl?name=8318fd31981dcc00bfadd6c427518f9d71a12b34' >> pki.tcl.new
           44  +	openssl sha1 pki.tcl.new | grep '918ddd77f485a58192b2e86230777092d790191a' >/dev/null
           45  +	mv pki.tcl.new pki.tcl
           46  +
    34     47   %.tcl.h: %.tcl
    35     48   	sed 's@[\\"]@\\&@g;s@^@   "@;s@$$@\\n"@' $^ > $@.new
    36     49   	mv $@.new $@
    37     50   
    38     51   install: appfsd appfs-cache appfs-mkfs
    39     52   	if [ ! -d '$(DESTDIR)$(sbindir)' ]; then mkdir -p '$(DESTDIR)$(sbindir)'; chmod 755 '$(DESTDIR)$(sbindir)'; fi
    40     53   	if [ ! -d '$(DESTDIR)$(bindir)' ]; then mkdir -p '$(DESTDIR)$(bindir)'; chmod 755 '$(DESTDIR)$(bindir)'; fi
................................................................................
    42     55   	cp appfs-cache '$(DESTDIR)$(sbindir)/'
    43     56   	cp appfs-mkfs '$(DESTDIR)$(bindir)/'
    44     57   
    45     58   clean:
    46     59   	rm -f appfsd appfsd.o
    47     60   	rm -f appfsd.tcl.h
    48     61   	rm -f sha1.o sha1.tcl.h
           62  +	rm -f pki.tcl.new pki.tcl.h
    49     63   
    50     64   distclean: clean
    51     65   
    52         -.PHONY: all test clean distclean install
           66  +mrproper: distclean
           67  +	rm -f pki.tcl
           68  +
           69  +.PHONY: all install clean distclean mrproper

Modified appfsd.c from [d452ee8ca8] to [423ee145a2].

   141    141   			*error_string = strdup(Tcl_GetStringResult(interp));
   142    142   		}
   143    143   
   144    144   		Tcl_DeleteInterp(interp);
   145    145   
   146    146   		return(NULL);
   147    147   	}
          148  +
          149  +	/*
          150  +	 * Load "pki.tcl" in the same way as appfsd.tcl (see below)
          151  +	 */
          152  +	tcl_ret = Tcl_Eval(interp, ""
          153  +#include "pki.tcl.h"
          154  +	"");
          155  +	if (tcl_ret != TCL_OK) {
          156  +		fprintf(stderr, "Unable to initialize Tcl PKI.  Aborting.\n");
          157  +		fprintf(stderr, "Tcl Error is: %s\n", Tcl_GetStringResult(interp));
          158  +
          159  +		if (error_string) {
          160  +			*error_string = strdup(Tcl_GetStringResult(interp));
          161  +		}
          162  +
          163  +		Tcl_DeleteInterp(interp);
          164  +
          165  +		return(NULL);
          166  +	}
   148    167   
   149    168   	/*
   150    169   	 * Load the "appfsd.tcl" script, which is "compiled" into a C header
   151    170   	 * so that it does not need to exist on the filesystem and can be
   152    171   	 * directly evaluated.
   153    172   	 */
   154    173   	tcl_ret = Tcl_Eval(interp, ""
................................................................................
  1322   1341   	test_interp = appfs_create_TclInterp(&test_interp_error);
  1323   1342   	if (test_interp == NULL) {
  1324   1343   		if (test_interp_error == NULL) {
  1325   1344   			test_interp_error = "Unknown error";
  1326   1345   		}
  1327   1346   
  1328   1347   		fprintf(stderr, "Unable to initialize Tcl interpreter for AppFSd:\n");
  1329         -		fprintf(stderr, "%s", test_interp_error);
         1348  +		fprintf(stderr, "%s\n", test_interp_error);
  1330   1349   
  1331   1350   		return(1);
  1332   1351   	}
  1333   1352   	Tcl_DeleteInterp(test_interp);
  1334   1353   
  1335   1354   	/*
  1336   1355   	 * Enter the FUSE main loop -- this will process any arguments
  1337   1356   	 * and start servicing requests.
  1338   1357   	 */
  1339   1358   	appfs_fuse_started = 1;
  1340   1359   	return(fuse_main(args.argc, args.argv, &appfs_operations, NULL));
  1341   1360   }
  1342   1361    

Modified appfsd.tcl from [af80dbf637] to [649eb3a6a1].

     1      1   #! /usr/bin/env tclsh
     2      2   
     3      3   package require http 2.7
     4      4   package require sqlite3
     5      5   package require sha1
     6      6   package require appfsd
     7      7   package require platform
            8  +package require pki
     8      9   
     9     10   namespace eval ::appfs {
    10     11   	variable cachedir "/tmp/appfs-cache"
    11     12   	variable ttl 3600
    12     13   	variable nttl 60
    13     14   
    14     15   	# User-replacable function to convert a hostname/hash/method to an URL