$ cat find-illegal-chars.rb #!/usr/bin/ruby `find #{ARGV[0]} -type f`.each do |s| puts s[ARGV[0].size..-1] `iconv -f UTF-8 -o /dev/null #{s}` end $ ruby find-illegal-chars.rb /usr/local/lib/ruby/gems/1.9.1/gems/sbsm-1.0.5 /usage-en.txt /install.rb /History.txt /Rakefile /test/test_validator.rb iconv: illegal input sequence at position 892 /test/test_user.rb iconv: illegal input sequence at position 892 /test/test_lookandfeel.rb iconv: illegal input sequence at position 892 /test/test_session.rb iconv: illegal input sequence at position 892 /test/test_state.rb iconv: illegal input sequence at position 892 /test/stub/cgi.rb iconv: illegal input sequence at position 892 /test/suite.rb iconv: illegal input sequence at position 892 /test/test_trans_handler.rb /test/data/lnf_file.txt /test/data/dos_file.txt /test/data/mac_file.txt /test/test_index.rb iconv: illegal input sequence at position 892 /test/test_drbserver.rb iconv: illegal input sequence at position 892 /lib/sbsm/turing.rb /lib/sbsm/user.rb iconv: illegal input sequence at position 892 /lib/sbsm/session.rb /lib/sbsm/index.rb iconv: illegal input sequence at position 892 /lib/sbsm/viralstate.rb iconv: illegal input sequence at position 892 /lib/sbsm/time.rb iconv: illegal input sequence at position 892 /lib/sbsm/zone_uri_parser.rb /lib/sbsm/lookandfeelfactory.rb iconv: illegal input sequence at position 892 /lib/sbsm/flavored_uri_parser.rb iconv: illegal input sequence at position 315 /lib/sbsm/exception.rb iconv: illegal input sequence at position 892 /lib/sbsm/redirector.rb /lib/sbsm/lookandfeelwrapper.rb iconv: illegal input sequence at position 889 /lib/sbsm/uri_parser.rb iconv: illegal input sequence at position 297 /lib/sbsm/cgi.rb iconv: illegal input sequence at position 892 /lib/sbsm/request.rb iconv: illegal input sequence at position 891 /lib/sbsm/state.rb iconv: illegal input sequence at position 891 /lib/sbsm/validator.rb /lib/sbsm/lookandfeel.rb iconv: illegal input sequence at position 892 /lib/sbsm/trans_handler.rb /lib/sbsm/drbserver.rb iconv: illegal input sequence at position 892 /lib/sbsm/drb.rb /lib/cgi/drbsession.rb /.gemtest /data/_zone_uri.grammar /data/flavored_uri.grammar /data/uri.grammar /data/_flavored_uri.grammar /data/_uri.grammar /data/zone_uri.grammar /README.txt /LICENCE.txt /Manifest.txt ---------------------------------------------------------------------------------------------- crash url: http://dev.ywesee.com/uploads/$PageName//ch.oddb_crash_20.1.2012_15.55.txt $ iconv -f UTF-8 /usr/local/lib/ruby/gems/1.9.1/gems/sbsm-1.0.5/lib/sbsm/validator.rb -o /dev/null iconv: illegal input sequence at position 892 ---------------------------------------------------------------------------------------------- how to change between the two mod_ruby: $ cp /usr/lib64/apache2/modules/mod_ruby18.so /usr/lib64/apache2/modules/mod_ruby.so $ cp /usr/lib64/apache2/modules/mod_ruby19.so /usr/lib64/apache2/modules/mod_ruby.so $ /etc/init.d/apache2 restart ----------------------------------------------------------------------------------------------- this error comes up with mod_ruby.so compiled against ruby 1.9 [Fri Jan 20 14:48:22 2012] [error] mod_ruby: error in ruby [Fri Jan 20 14:48:22 2012] [error] mod_ruby: /usr/local/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': /usr/local/lib64/ruby/gems/1.9.1/gems/sbsm-1.0.5/lib/sbsm/flavored_uri_parser.rb:9: invalid multibyte char (US-ASCII) (SyntaxError) [Fri Jan 20 14:48:22 2012] [error] mod_ruby: /usr/local/lib64/ruby/gems/1.9.1/gems/sbsm-1.0.5/lib/sbsm/flavored_uri_parser.rb:9: syntax error, unexpected '~', expecting ')' [Fri Jan 20 14:48:22 2012] [error] mod_ruby: t1 = EofToken.new("EOF",/^(\xa4~~\xa4\xa4~^^~2220240369)/), [Fri Jan 20 14:48:22 2012] [error] mod_ruby: ^ [Fri Jan 20 14:48:22 2012] [error] mod_ruby: /usr/local/lib64/ruby/gems/1.9.1/gems/sbsm-1.0.5/lib/sbsm/flavored_uri_parser.rb:9: invalid multibyte char (US-ASCII) [Fri Jan 20 14:48:22 2012] [error] mod_ruby: from /usr/local/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require' [Fri Jan 20 14:48:22 2012] [error] mod_ruby: from /usr/local/lib64/ruby/gems/1.9.1/gems/sbsm-1.0.5/lib/sbsm/trans_handler.rb:125:in `uri_parser' [Fri Jan 20 14:48:22 2012] [error] mod_ruby: from /usr/local/lib64/ruby/gems/1.9.1/gems/sbsm-1.0.5/lib/sbsm/trans_handler.rb:74:in `parse_uri' [Fri Jan 20 14:48:22 2012] [error] mod_ruby: from /usr/local/lib64/ruby/gems/1.9.1/gems/sbsm-1.0.5/lib/sbsm/trans_handler.rb:105:in `translate_uri' ----------------------------------------------------------------------------------------------- $ vim /etc/apache2/modules.d/00_mpm.conf StartServers 1 MinSpareServers 1 MaxSpareServers 1 MaxClients 1 MaxRequestsPerChild 10000 restart apache ps -ef | grep apache starce -p pid-of-apache gdb -p pid-of-apache ----------------------------------------------------------------------------------------------- copied the two version of mod_ruby to apache2 cp /1.8path/mod_ruby.so /usr/lib64/apache2/modules/mod_ruby18.so cp /1.9path/mod_ruby.so /usr/lib64/apache2/modules/mod_ruby19.so ----------------------------------------------------------------------------------------------- apache with mod-ruby compiled against 1.9 complains: [Fri Jan 20 11:08:13 2012] [error] mod_ruby: error in ruby [Fri Jan 20 11:08:13 2012] [error] mod_ruby: /usr/local/lib64/ruby/gems/1.9.1/gems/sbsm-1.0.5/lib/sbsm/trans_handler.rb:21:in `expand_path': Insecure operation - expand_path (SecurityError) $ sudo vim /usr/local/lib64/ruby/gems/1.9.1/gems/sbsm-1.0.5/lib/sbsm/trans_handler.rb untaint __FILE_ and request.server.document_root this is a hack, i am not sure it is safe to do that: line 21: @grammar_path = File.expand_path("../../data/#{name}.grammar", File.dirname(__FILE__.untaint)) @parser_path = File.expand_path("#{name}_parser.rb", File.dirname(__FILE__.untaint)) line 29: path = File.expand_path(CONFIG_PATH, request.server.document_root.untaint) ----------------------------------------------------------------------------------------------- $ ruby19 bin/oddbd /usr/local/lib/ruby/gems/1.9.1/gems/odba-1.0.8/lib/odba/marshal.rb:15:in `load': undefined class/module CSV::Cell (ArgumentError) from /usr/local/lib/ruby/gems/1.9.1/gems/odba-1.0.8/lib/odba/marshal.rb:15:in `load' found this: http://dev.ywesee.com/wiki.php/Masa/20111006-ruby193-oddb $ sudo vim /usr/local/lib64/ruby/1.9.1/csv.rb add a Cell class class Cell < String def initialize(data = "", is_null = false) super(is_null ? "" : data) end def data to_s end end ----------------------------------------------------------------------------------------------- benchmark this is with mod_ruby-against-ruby-1.8 $ ab -n 25 http://oddb.andris.org/ This is ApacheBench, Version 2.3 <$Revision: 655654 $> Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Licensed to The Apache Software Foundation, http://www.apache.org/ Benchmarking oddb.andris.org (be patient).....done Server Software: Apache Server Hostname: oddb.andris.org Server Port: 80 Document Path: / Document Length: 16733 bytes Concurrency Level: 1 Time taken for tests: 3.450 seconds Complete requests: 25 Failed requests: 0 Write errors: 0 Total transferred: 428550 bytes HTML transferred: 418325 bytes Requests per second: 7.25 [#/sec] (mean) Time per request: 137.986 [ms] (mean) Time per request: 137.986 [ms] (mean, across all concurrent requests) Transfer rate: 121.32 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 0 0 0.0 0 0 Processing: 88 138 71.4 104 277 Waiting: 88 137 71.0 104 277 Total: 88 138 71.4 104 277 Percentage of the requests served within a certain time (ms) 50% 104 66% 106 75% 109 80% 254 90% 271 95% 273 98% 277 99% 277 100% 277 (longest request) and this is mod_ruby compiled aginst 1.9 $ ab -n 25 http://oddb.andris.org/ This is ApacheBench, Version 2.3 <$Revision: 655654 $> Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Licensed to The Apache Software Foundation, http://www.apache.org/ Benchmarking oddb.andris.org (be patient).....done Server Software: Apache Server Hostname: oddb.andris.org Server Port: 80 Document Path: / Document Length: 16733 bytes Concurrency Level: 1 Time taken for tests: 3.277 seconds Complete requests: 25 Failed requests: 0 Write errors: 0 Total transferred: 428550 bytes HTML transferred: 418325 bytes Requests per second: 7.63 [#/sec] (mean) Time per request: 131.077 [ms] (mean) Time per request: 131.077 [ms] (mean, across all concurrent requests) Transfer rate: 127.71 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 0 0 0.0 0 0 Processing: 83 131 71.7 96 281 Waiting: 82 131 71.3 96 281 Total: 83 131 71.7 96 281 Percentage of the requests served within a certain time (ms) 50% 96 66% 99 75% 100 80% 251 90% 253 95% 260 98% 281 99% 281 100% 281 (longest request) ----------------------------------------------------------------------------------------------- compile mod_ruby agains 1.9 $ cd $ cd src $ cp -rd mod_ruby mod_ruby_compiled-against-1.8 $ cd mod_ruby $ make clean $ ruby19 ./configure.rb --with-apxs --with-apr-includes=/usr/include/apr-1 $ make /usr/bin/ld: /usr/local/lib/libruby-static.a(array.o): relocation R_X86_64_32 against `a local symbol' can not be used when making a shared object; recompile with -fPIC http://lists.modruby.net/ml/archive/modruby/200603.month/1565.html recompiling ruby 1.9 with --enable-shared $ cd src/ruby $ ./configure --enable-shared $ make /usr/lib/gcc/x86_64-pc-linux-gnu/4.5.3/../../../../x86_64-pc-linux-gnu/bin/ld: dln.o: relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC dln.o: could not read symbols: Bad value collect2: ld returned 1 exit status $ make clean $ ./configure --enable-shared $ make $ sudo make install ----------------------------------------------------------------------------------------------- login was unsuccesfull set the mailer: $ vim /var/www/etc/oddb.yml url_bag_sl_zip: "http://bag.e-mediat.net/SL2007.Web.External/File.axd?file=XMLPublications.zip" smtp_server: smtp.gmail.com smtp_domain: gmail.com smtp_user: andris.tompe@gmail.com smtp_pass: xxxx smtp_port: 587 mail_from: '"andris" ' mail_to: - 'andris.tompe@gmail.com' text_info_searchform: 'http://www.kompendium.ch/Search.aspx?lang=de' text_info_newssource: 'http://www.documedinfo.ch/content/page_1.aspx' ----------------------------------------------------------------------------------------------- now test if it works $ cd /var/www/oddb/ $ ruby19 bin/oddbd ----------------------------------------------------------------------------------------------- set up yusd $ /usr/bin/yusd /usr/lib64/ruby/site_ruby/1.8/dbd/pg/database.rb:82:in `initialize': could not connect to server: Permission denied (DBI::OperationalError) well i will need a database for that root@alpine:~$ su - postgres postgres@alpine ~ $ createuser yus Shall the new role be a superuser? (y/n) n Shall the new role be allowed to create databases? (y/n) y Shall the new role be allowed to create more new roles? (y/n) y postgres@alpine ~ $ createdb yus postgres@alpine ~ $ exit $ /usr/bin/yusd E, [2012-01-20T09:37:14.929768 #26512] ERROR -- fatal: No such file or directory - /etc/yus/data/yus.key [path to an rsa private key] (Errno::ENOENT) but the file is there $ ls /etc/yus/data/yus.key /etc/yus/data/yus.key lets try it with normal user chmod 644 /etc/yus/data/yus.key chmod 644 /etc/yus/data/yus.crt $ /usr/bin/yusd /usr/lib64/ruby/site_ruby/1.8/dbd/pg/database.rb:82:in `initialize': could not connect to server: Permission denied (DBI::OperationalError) make a password for user yus $ sudo -u postgres psql -c "ALTER USER yus WITH PASSWORD 'yus';" $ /usr/bin/yusd /usr/lib64/ruby/site_ruby/1.8/dbd/pg/database.rb:82:in `initialize': could not connect to server: Permission denied (DBI::OperationalError) $ gpasswd -a jsaak postgres $ newgrp postgres $ newgrp users now it runs as normal user, same error as above $ /usr/bin/yusd E, [2012-01-20T09:37:14.929768 #26512] ERROR -- fatal: No such file or directory - /etc/yus/data/yus.key [path to an rsa private key] (Errno::ENOENT) $ irb18 irb(main):003:0> require 'openssl' => true irb(main):004:0> OpenSSL::PKey::RSA.new(File.read('/etc/yus/data/yus.key')) => -----BEGIN RSA PRIVATE KEY----- it seems i can read the file with irb, now whats wrong? $ emerge strace $ strace /usr/bin/yusd open("/etc/yus/data/yus.key [path to an rsa private key]", O_RDONLY) = -1 ENOENT (No such file or directory) in /etc/yus/yus.yml i had to remove comment [path to an rsa private key] to look like this ssl_key: /etc/yus/data/yus.key ssl_cert: /etc/yus/data/yus.crt $ /usr/bin/yusd & now it works $ /usr/bin/yus_add_user jsaak@napalm.hu login org.oddb.RootUser set a password $ /usr/bin/yus_grant jsaak@napalm.hu edit yus.entities ----------------------------------------------------------------------------------------------- install some packages $ emerge -av "=ruby-dbi-0.4.3" $ emerge -av "=pg-0.11.0" "=dbd-pg-0.3.9" $ gem18 install deprecated --version '2.0.1' ----------------------------------------------------------------------------------------------- added some things to .zshrc to make life easier: unset RUBYOPT alias ruby18='/usr/bin/ruby18' alias ruby19='/usr/local/bin/ruby' alias gem18='/usr/bin/gem18' alias gem19='/usr/local/bin/gem' ----------------------------------------------------------------------------------------------- changed sudo timestamp_timeout = 30 -----------------------------------------------------------------------------------------------