Browse Source

cppcms_make_key now a little C program instead of not-portable bash+od

master
Artyom Beilis 15 years ago
parent
commit
ce4f54d930
5 changed files with 52 additions and 11 deletions
  1. +1
    -0
      Changelog
  2. +4
    -2
      Makefile.am
  3. +5
    -0
      configure.in
  4. +0
    -9
      cppcms_make_key
  5. +42
    -0
      cppcms_make_key.c

+ 1
- 0
Changelog View File

@@ -1,3 +1,4 @@
- Changed cppcms_make_key now written in C instead of unportable bash/od
- Fixed -- widgets are default constructable
- Added help to templates compiler, BSD bugfix
- Now session timeout is preserved withing session.


+ 4
- 2
Makefile.am View File

@@ -2,7 +2,8 @@ SUBDIRS = ./transtext

noinst_PROGRAMS = hello_world.fcgi
noinst_HEADERS = hello_world_view.h
dist_bin_SCRIPTS = cppcms_tmpl_cc cppcms_run cppcms_make_key
dist_bin_SCRIPTS = cppcms_tmpl_cc cppcms_run
bin_PROGRAMS = cppcms_make_key

EXTRA_DIST = hello_world_skin1.tmpl hello_world_view1.tmpl hello_world_skin2.tmpl Changelog

@@ -57,9 +58,10 @@ nobase_pkginclude_HEADERS = global_config.h text_tool.h url.h cppcms_error.h \

if EN_TCP_CACHE
libcppcms_la_SOURCES += tcp_cache.cpp tcp_messenger.cpp session_tcp_storage.cpp tcp_connector.cpp
bin_PROGRAMS = cppcms_tcp_scale
bin_PROGRAMS += cppcms_tcp_scale
cppcms_tcp_scale_SOURCES = base_cache.cpp thread_cache.cpp tcp_cache_server.cpp session_file_storage.cpp cppcms_error.cpp
cppcms_tcp_scale_CXXFLAGS=-DNO_BUILDER_INTERFACE
cppcms_tcp_scale_LDADD = @TCPSCALE_LIBS@
if EN_SQLITE_SESSIONS
cppcms_tcp_scale_SOURCES += session_sqlite_storage.cpp
endif


+ 5
- 0
configure.in View File

@@ -27,6 +27,8 @@ fi

CPPCMS_LIBS=""

MY_SAVE_LIBS="$LIBS"

case $host in
*solaris*)
echo "Adding -pthreads for Solaris host"
@@ -223,5 +225,8 @@ else
CPPCMS_LIBS="-lboost_regex-$bsts -lboost_iostreams-$bsts -lboost_signals-$bsts $CPPCMS_LIBS"
fi

TCPSCALE_LIBS="$LIBS"
LIBS="$SAVE_LIBS"
AC_SUBST(TCPSCALE_LIBS)
AC_SUBST(CPPCMS_LIBS)
AC_OUTPUT

+ 0
- 9
cppcms_make_key View File

@@ -1,9 +0,0 @@
#!/usr/bin/env bash

SECRET=`od -An -t x4 -N16 /dev/random | awk '{ print $1$2$3$4}'`

echo
echo "# This is your PRIVATE KEY --- keep it in secret!"
echo "# Put this line into your configuration file"
echo
echo "session.cookies_key = \"$SECRET\""

+ 42
- 0
cppcms_make_key.c View File

@@ -0,0 +1,42 @@
#include <stdio.h>
#include <stdlib.h>

int main(int argv,char **argc)
{
char const *file_name="/dev/random";
if(argv>=2) {
if(argv>2 || strcmp(argc[1],"-h")==0 || strcmp(argc[1],"--help")==0) {
printf( "Usage: cppcms_make_key [ random-device ] [>>config.txt] \n"
" default random device is /dev/random\n"
" you may specify other, for example:\n"
"\n"
" cppcms_make_key /dev/urandom >>config.txt\n"
"\n");
return 1;
}
file_name=argc[1];
}
FILE *f=fopen(file_name,"r");
if(!f) {
perror("fopen");
return 1;
}
unsigned char buf[16];
if(fread(buf,1,16,f)!=16) {
fprintf(stderr,"Failed to read 16 bytes from file %s\n",file_name);
fclose(f);
return 1;
}
fclose(f);
int i;
printf( "\n"
"# This is your PRIVATE KEY --- keep it in secret!\n"
"# Put this line into your configuration file\n"
"\n"
"session.cookies_key = \"" );
for(i=0;i<sizeof(buf);i++) {
printf("%02x",buf[i]);
}
printf("\"\n\n");
return 0;
}

Loading…
Cancel
Save