Commit 33cded1d authored by Lev Walkin's avatar Lev Walkin

CGI environment for online ASN.1 compilation

parent 07cd6d82
0.9.6: 2004-Sep-19
* Added CGI for online ASN.1 compilation (asn1c/webcgi).
0.9.5: 2004-Sep-17
* Fixed CER (common BER) decoder code. See check-25.c/VisibleString
......
......@@ -5,8 +5,9 @@ SUBDIRS = \
skeletons examples tests \
doc asn1c
EXTRA_DIST = BUGS MANIFEST
docsdir = $(datadir)/doc/asn1c
docs_DATA = INSTALL README FAQ BUGS TODO
docs_DATA = README FAQ COPYING ChangeLog BUGS TODO
EXTRA_DIST = asn1c.spec.in FAQ BUGS MANIFEST
CLEANFILES = asn1c.spec
......@@ -36,10 +36,10 @@ PRE_UNINSTALL = :
POST_UNINSTALL = :
host_triplet = @host@
DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \
$(srcdir)/Makefile.in $(srcdir)/config.h.in \
$(top_srcdir)/configure AUTHORS COPYING ChangeLog INSTALL NEWS \
TODO config.guess config.sub depcomp install-sh ltconfig \
ltmain.sh missing mkinstalldirs
$(srcdir)/Makefile.in $(srcdir)/asn1c.spec.in \
$(srcdir)/config.h.in $(top_srcdir)/configure AUTHORS COPYING \
ChangeLog INSTALL NEWS TODO config.guess config.sub depcomp \
install-sh ltconfig ltmain.sh missing mkinstalldirs
subdir = .
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.in
......@@ -49,7 +49,7 @@ am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
configure.lineno configure.status.lineno
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_FILES = asn1c.spec
SOURCES =
DIST_SOURCES =
RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
......@@ -132,7 +132,6 @@ PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH = @PATH@
PATH_SEPARATOR = @PATH_SEPARATOR@
RANLIB = @RANLIB@
SET_MAKE = @SET_MAKE@
......@@ -191,9 +190,10 @@ SUBDIRS = \
skeletons examples tests \
doc asn1c
EXTRA_DIST = BUGS MANIFEST
docsdir = $(datadir)/doc/asn1c
docs_DATA = INSTALL README FAQ BUGS TODO
docs_DATA = README FAQ COPYING ChangeLog BUGS TODO
EXTRA_DIST = asn1c.spec.in FAQ BUGS MANIFEST
CLEANFILES = asn1c.spec
all: config.h
$(MAKE) $(AM_MAKEFLAGS) all-recursive
......@@ -248,6 +248,8 @@ $(srcdir)/config.h.in: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
distclean-hdr:
-rm -f config.h stamp-h1
asn1c.spec: $(top_builddir)/config.status $(srcdir)/asn1c.spec.in
cd $(top_builddir) && $(SHELL) ./config.status $@
mostlyclean-libtool:
-rm -f *.lo
......@@ -399,6 +401,7 @@ distclean-tags:
distdir: $(DISTFILES)
$(am__remove_distdir)
mkdir $(distdir)
$(mkdir_p) $(distdir)/.
@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
list='$(DISTFILES)'; for file in $$list; do \
......@@ -560,6 +563,7 @@ install-strip:
mostlyclean-generic:
clean-generic:
-test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
distclean-generic:
-rm -f $(CONFIG_CLEAN_FILES)
......
WHAT TO READ?
=============
For quick installation tips read INSTALL.
If you haven't installed the asn1c yet, read the INSTALL file for
a short installation guide.
For the list of asn1c command line options, see `asn1c -h` or `man asn1c`.
For more complete documentation on this compiler and on using the
results of compilation please look into ./doc directory.
results of compilation phase, please look into asn1c-usage.{pdf,html}.
If you are building the compiler from the sources, these documents reside
in the ./doc directory, otherwise they lie nearby the README file you're
reading right now.
Please also read the FAQ file.
......@@ -19,18 +23,19 @@ QUICK START
After building [and installing] the compiler (see INSTALL), you may use
the asn1c command to compile the ASN.1 specification:
asn1c <module.asn1>
asn1c <module.asn1> # Compile module
If several specifications contain interdependencies, all of them must be
specified:
asn1c <module1.asn1> <module2.asn1> ...
asn1c <module1.asn1> <module2.asn1> ... # Compile interdependent modules
The ./examples directory contains several ASN.1 modules and a script to
extract ASN.1 modules from RFC documents. Refer to the README file in that
directory. To compile X.509 PKI module:
If you are building the asn1c from the sources, the ./examples directory
contains several ASN.1 modules and a script to extract the ASN.1 modules
from RFC documents. Refer to the README file in that directory.
To compile the X.509 PKI module:
./asn1c/asn1c -P ./examples/rfc3280-*.asn1
./asn1c/asn1c -P ./examples/rfc3280-*.asn1 # Compile-n-print
In this example, -P option is used to instruct the compiler to print the
compiled text on the standard output instead of creating multiple .c
......@@ -44,7 +49,7 @@ to dump out the parsed (and fixed) ASN.1 specification as it was
whether a particular syntactic construction is properly supported
by the compiler.
asn1c -EF <module-to-test.asn1>
asn1c -EF <module-to-test.asn1> # Check semantic validity
MODEL OF OPERATION
......
SUBDIRS = . tests
SUBDIRS = . tests webcgi
AM_CFLAGS = @ADD_CFLAGS@
AM_CPPFLAGS = \
......
......@@ -143,7 +143,6 @@ PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH = @PATH@
PATH_SEPARATOR = @PATH_SEPARATOR@
RANLIB = @RANLIB@
SET_MAKE = @SET_MAKE@
......@@ -196,7 +195,7 @@ target_alias = @target_alias@
target_cpu = @target_cpu@
target_os = @target_os@
target_vendor = @target_vendor@
SUBDIRS = . tests
SUBDIRS = . tests webcgi
AM_CFLAGS = @ADD_CFLAGS@
AM_CPPFLAGS = \
-I${top_srcdir}/libasn1compiler \
......
......@@ -103,7 +103,6 @@ PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH = @PATH@
PATH_SEPARATOR = @PATH_SEPARATOR@
RANLIB = @RANLIB@
SET_MAKE = @SET_MAKE@
......
noinst_SCRIPTS = asn1c.cgi
noinst_PROGRAMS = asn1c-suid-helper
This diff is collapsed.
This is the source of the CGI-based Web wrapper around asn1c compiler.
To install, execute the following steps in this directory
CGIDIR=/path/where/webserver/CGIs/are/stored
make # Ensure the binary files are built
cp asn1c.cgi asn1c-suid-helper $CGIDIR
chmod 4555 $CGIDIR/asn1c-suid-helper
chown root $CGIDIR/asn1c-suid-helper
# edit the $CGIDIR/asn1c.cgi to set up a few preferences
# in the beginning of that Perl script.
The chmod command makes the asn1c-suid-helper program setuid.
The asn1c-suid-helper is a tiny wrapper (look in the asn1c-suid-helper.c),
which has the single purpose of running the asn1c compiler under extremely
strict environment.
The root uid and 4555 mode actually _raise_ security of the whole ASN.1 CGI
system, so don't worry.
If you're still uncertain, just go read the source code, it's only a page long.
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <sysexits.h>
/*
* This program chroots into a given directory,
* then executes the asn1c command with strict arguments checking.
*/
int
main(int ac, char **av) {
char **argv;
char *envp[] = { NULL }; /* Empty environment */
int ret;
int i;
if(ac < 3) {
setgid(getgid());
setuid(getuid());
fprintf(stderr,
"Usage: %s <chroot-to> <chdir-to> [options]\n", av[0]);
exit(EX_USAGE);
}
ret = chroot(av[1]);
/* Drop the privileges */
setgid(getgid());
setuid(getuid());
if(ret != 0) {
fprintf(stderr, "chroot(\"%s\") failed: %s\n",
av[1], strerror(errno));
exit(EX_OSERR);
}
if(chdir(av[2]) != 0) {
fprintf(stderr, "chdir(\"%s\") failed: %s\n",
av[2], strerror(errno));
exit(EX_OSERR);
}
if(ac > 64) {
fprintf(stderr, "Insecure number of arguments: %d\n", ac);
exit(EX_DATAERR);
}
argv = calloc(ac + 1, sizeof(*argv));
if(argv) {
argv[0] = "asn1c";
argv[1] = "-S/skeletons";
memcpy(argv + 2, av + 3, (ac - 3) * sizeof(*argv));
} else {
perror("malloc()");
exit(EX_OSERR);
}
/*
* Check arguments for the permitted alphabet constraints.
*/
for(i = 3; i < ac; i++) {
char *p;
for(p = av[i];; p++) {
switch(*p) {
case '0' ... '9': case 'A' ... 'Z': case 'a' ... 'z':
case '.': case '_': case '-': case '=':
continue;
case '\0':
default:
break;
}
break;
}
if(*p || (p - av[i]) > 250) {
fprintf(stderr, "Insecure argument %d\n", i);
exit(EX_DATAERR);
}
}
execve("/bin/asn1c", argv, envp);
exit(EX_UNAVAILABLE);
}
This diff is collapsed.
This diff is collapsed.
......@@ -3,9 +3,7 @@ AC_INIT(libasn1parser/asn1p_y.y)
AC_CANONICAL_BUILD
AC_CANONICAL_TARGET
AC_PREREQ(2.53)
AM_INIT_AUTOMAKE(asn1c, 0.9.5)
AC_SUBST(PATH)
AM_INIT_AUTOMAKE(asn1c, 0.9.6)
AM_MAINTAINER_MODE
......@@ -91,6 +89,7 @@ skeletons/tests/Makefile \
libasn1compiler/Makefile \
libasn1parser/Makefile \
libasn1print/Makefile \
asn1c/webcgi/Makefile \
asn1c/tests/Makefile \
libasn1fix/Makefile \
skeletons/Makefile \
......@@ -98,6 +97,7 @@ examples/Makefile \
tests/Makefile \
asn1c/Makefile \
doc/Makefile \
asn1c.spec \
Makefile \
)
......@@ -107,7 +107,6 @@ PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH = @PATH@
PATH_SEPARATOR = @PATH_SEPARATOR@
RANLIB = @RANLIB@
SET_MAKE = @SET_MAKE@
......
......@@ -108,7 +108,6 @@ PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH = @PATH@
PATH_SEPARATOR = @PATH_SEPARATOR@
RANLIB = @RANLIB@
SET_MAKE = @SET_MAKE@
......
......@@ -134,7 +134,6 @@ PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH = @PATH@
PATH_SEPARATOR = @PATH_SEPARATOR@
RANLIB = @RANLIB@
SET_MAKE = @SET_MAKE@
......
......@@ -153,7 +153,6 @@ PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH = @PATH@
PATH_SEPARATOR = @PATH_SEPARATOR@
RANLIB = @RANLIB@
SET_MAKE = @SET_MAKE@
......
......@@ -142,7 +142,6 @@ PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH = @PATH@
PATH_SEPARATOR = @PATH_SEPARATOR@
RANLIB = @RANLIB@
SET_MAKE = @SET_MAKE@
......@@ -448,9 +447,9 @@ distclean-generic:
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
-rm -f asn1p_l.c
-rm -f asn1p_y.c
-rm -f asn1p_y.h
-rm -f asn1p_l.c
clean: clean-am
clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \
......
......@@ -124,7 +124,6 @@ PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH = @PATH@
PATH_SEPARATOR = @PATH_SEPARATOR@
RANLIB = @RANLIB@
SET_MAKE = @SET_MAKE@
......
......@@ -117,7 +117,6 @@ PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH = @PATH@
PATH_SEPARATOR = @PATH_SEPARATOR@
RANLIB = @RANLIB@
SET_MAKE = @SET_MAKE@
......
......@@ -161,7 +161,6 @@ PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH = @PATH@
PATH_SEPARATOR = @PATH_SEPARATOR@
RANLIB = @RANLIB@
SET_MAKE = @SET_MAKE@
......
......@@ -103,7 +103,6 @@ PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH = @PATH@
PATH_SEPARATOR = @PATH_SEPARATOR@
RANLIB = @RANLIB@
SET_MAKE = @SET_MAKE@
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment