Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2013
311
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 27.99 KB | None | 0 0
  1. [code]# uname -a
  2. FreeBSD database_server 9.2-RELEASE FreeBSD 9.2-RELEASE #1: Tue Oct 22 11:11:35 EEST 2013 wagner@database_server:/usr/obj/usr/src/sys/DATABASE amd64
  3. # pkg_info
  4. ap22-mod_perl2-2.0.8,3 Embeds a Perl interpreter in the Apache2 server
  5. apache22-2.2.25 Version 2.2.x of Apache web server with prefork MPM.
  6. apr-1.4.8.1.5.2 Apache Portability Library
  7. aspell-0.60.6.1_2 Spelling checker with better suggestion logic than ispell
  8. autoconf-2.69 Automatically configure source code on many Un*x platforms
  9. autoconf-wrapper-20130530 Wrapper script for GNU autoconf
  10. bsdpan-Bit-Vector-7.3 Unknown perl module
  11. bsdpan-Carp-Clan-6.04 Unknown perl module
  12. bsdpan-DBI-1.628 DBI - Database independent interface for Perl
  13. bsdpan-Encode-Locale-1.03 Encode::Locale - Determine the locale encoding
  14. bsdpan-FCGI-0.74 Unknown perl module
  15. bsdpan-File-Listing-6.04 File::Listing - parse directory listing
  16. bsdpan-HTML-Parser-3.71 HTML::Parser - HTML parser class
  17. bsdpan-HTML-Tagset-3.20 HTML::Tagset - data tables useful in parsing HTML
  18. bsdpan-HTTP-Cookies-6.01 HTTP::Cookies - HTTP cookie jars
  19. bsdpan-HTTP-Daemon-6.01 HTTP::Daemon - a simple http server class
  20. bsdpan-HTTP-Date-6.02 HTTP::Date - date conversion routines
  21. bsdpan-HTTP-Message-6.06 HTTP::Message - HTTP style message (base class)
  22. bsdpan-HTTP-Negotiate-6.01 HTTP::Negotiate - choose a variant to serve
  23. bsdpan-IO-HTML-1.00 IO::HTML - Open an HTML file with automatic charset detecti
  24. bsdpan-IO-Interactive-0.0.6 IO::Interactive - Utilities for interactive I/O
  25. bsdpan-IO-stringy-2.110 IO-stringy - I/O on in-core objects like strings and arrays
  26. bsdpan-JSON-2.61 JSON - JSON (JavaScript Object Notation) encoder/decoder
  27. bsdpan-LWP-MediaTypes-6.02 LWP::MediaTypes - guess media type for a file or a URL
  28. bsdpan-Net-DNS-0.72 Net::DNS - Perl interface to the Domain Name System
  29. bsdpan-Net-HTTP-6.06 Net::HTTP - Low-level HTTP connection (client)
  30. bsdpan-Sub-Uplevel-0.24 Sub::Uplevel - apparently run a function in a higher stack
  31. bsdpan-TimeDate-2.30 Date::Parse - Parse date strings into time values
  32. bsdpan-URI-1.60 URI - Uniform Resource Identifiers (absolute and relative)
  33. bsdpan-WWW-RobotRules-6.02 WWW::RobotRules - database of robots.txt-derived permission
  34. bsdpan-libwww-perl-6.05 LWP - The World-Wide Web library for Perl
  35. cmake-2.8.11.2 Cross-platform Makefile generator
  36. fontconfig-2.10.95,1 XML-based font configuration API for X Windows
  37. freetype2-2.5.0.1 Free and portable TrueType font rendering engine
  38. gdbm-1.10 GNU database manager
  39. gmake-3.82_1 GNU version of 'make' utility
  40. help2man-1.43.3 Automatically generating simple manual pages from program o
  41. jbigkit-1.6 Lossless compression for bi-level images such as scanned pa
  42. jpeg-8_4 IJG's jpeg compression utilities
  43. libgd-2.1.0_1,1 A graphics library for fast creation of images
  44. libsigsegv-2.10 Handling page faults in user mode
  45. libtool-2.4.2_2 Generic shared library support script
  46. m4-1.4.17,1 GNU m4
  47. mysql55-client-5.5.34 Multithreaded SQL database (client)
  48. mysql55-server-5.5.34 Multithreaded SQL database (server)
  49. nginx-1.4.3,1 Robust and small WWW server
  50. otrs-3.2.10 Open Ticket Request System
  51. p5-Algorithm-Diff-1.1902 Perl interface to compute differences between two objects
  52. p5-Authen-SASL-2.16 Perl5 module for SASL authentication
  53. p5-BSD-Resource-1.2907 Perl module to access BSD resource limit and priority funct
  54. p5-Bit-Vector-7.3 Library of advanced math functions that includes a Perl OO
  55. p5-CSS-Minifier-XS-0.08 XS based CSS minifier
  56. p5-Carp-Clan-6.04 Report errors from perspective of caller of a "clan" of mod
  57. p5-Convert-BinHex-1.123 Perl module to extract data from Macintosh BinHex files
  58. p5-Crypt-PasswdMD5-1.3_1 Perl module that provides interoperable MD5-based crypt() f
  59. p5-DBD-mysql-4.024 MySQL driver for the Perl5 Database Interface (DBI)
  60. p5-DBI-1.628 The perl5 Database Interface. Required for DBD::* modules
  61. p5-Date-Pcalc-6.1 Gregorian calendar date calculations
  62. p5-Digest-HMAC-1.03 Perl5 interface to HMAC Message-Digest Algorithms
  63. p5-Digest-SHA-5.85 Perl extension for SHA-1/224/256/384/512
  64. p5-Email-Valid-1.192 Check validity of Internet email addresses
  65. p5-Encode-Locale-1.03 Determine the locale encoding
  66. p5-FCGI-0.74 Modules for perl5, for enabling FastCGI support in CGI scri
  67. p5-Filter-1.49 Number of source filters for perl5 programs
  68. p5-Font-TTF-1.02 Perl module for TrueType font hacking
  69. p5-GD-2.50 Perl5 interface to Gd Graphics Library version2
  70. p5-GD-Graph-1.48 Graph plotting module for perl5
  71. p5-GD-TextUtil-0.86_4 Text utilities for use with GD drawing package
  72. p5-GSSAPI-0.28 Perl extension providing access to the GSSAPIv2 library
  73. p5-IO-Interactive-0.0.6_1,1 Utilities for interactive I/O
  74. p5-IO-Socket-IP-0.24 Drop-in replacement for IO::Socket::INET supporting IPv4 an
  75. p5-IO-Socket-SSL-1.953 Perl5 interface to SSL sockets
  76. p5-IO-String-1.08 Simplified Perl5 module to handle I/O on in-core strings
  77. p5-IO-stringy-2.110 Perl5 module for using IO handles with non-file objects
  78. p5-JSON-2.59 Perl extension to convert to JSON (JavaScript Object Notati
  79. p5-JSON-XS-2.34 JSON serialising/deserialising, done correctly and fast
  80. p5-JavaScript-Minifier-XS-0.09 XS based JavaScript minifier
  81. p5-Locale-gettext-1.05_3 Message handling functions
  82. p5-MIME-Tools-5.504,2 Set of perl5 modules for MIME
  83. p5-Mail-POP3Client-2.19 Perl5 module to talk to a POP3 (RFC1939) server
  84. p5-Mail-Tools-2.12 Perl5 modules for dealing with Internet e-mail messages
  85. p5-Net-DNS-0.72 Perl5 interface to the DNS resolver, and dynamic updates
  86. p5-Net-Domain-TLD-1.70 Look up and validate TLDs
  87. p5-Net-SMTP-SSL-1.01_1 SMTP client supporting SSL
  88. p5-Net-SMTP-TLS-0.12_1 An SMTP client supporting TLS and AUTH
  89. p5-Net-SSLeay-1.55 Perl5 interface to SSL
  90. p5-PDF-API2-2.020 'The Next Generation' of Text::PDF::API
  91. p5-Socket-2.012 Networking constants and support functions
  92. p5-Text-CSV-1.32 Composition and decomposition of comma-separated values
  93. p5-Text-CSV_XS-1.01 Comma-separated values manipulation routines
  94. p5-Text-Diff-1.41 Text::Diff - Perform diffs on files and record sets
  95. p5-TimeDate-2.30_1,1 Perl5 module containing a better/faster date parser for abs
  96. p5-XML-FeedPP-0.43 Get an RSS file and parse it
  97. p5-XML-Parser-2.41_1 Perl extension interface to James Clark's XML parser, expat
  98. p5-XML-TreePP-0.41 Pure Perl implementation for parsing/writing xml files
  99. p5-YAML-0.84 YAML implementation in Perl
  100. p5-YAML-LibYAML-0.41 Perl YAML Serialization using XS and libyaml
  101. p5-common-sense-3.6 Perl common defaults with lower memory usage
  102. p5-libwww-6.05 Perl5 library for WWW access
  103. pcre-8.33 Perl Compatible Regular Expressions library
  104. perl-5.18.1_1 Practical Extraction and Report Language
  105. pkgconf-0.9.3 Utility to help to configure compiler and linker flags
  106. png-1.5.17 Library for manipulating PNG images
  107. tiff-4.0.3 Tools and library routines for working with TIFF images
  108. # pwd
  109. /usr/local/otrs/bin
  110. # ./otrs.CheckModules.pl
  111. o CGI..............................ok (v3.63)
  112. o Crypt::PasswdMD5.................ok (v1.3)
  113. o Crypt::SSLeay....................Not installed! (optional - Required for Generic Interface SOAP SSL connections.)
  114. o CSS::Minifier::XS................ok (v0.08)
  115. o Date::Format.....................ok (v2.24)
  116. o Date::Pcalc......................ok (v6.1)
  117. o DBI..............................ok (v1.628)
  118. o DBD::mysql.......................Not installed! (optional - Required to connect to a MySQL database.)
  119. o DBD::ODBC........................Not installed! (optional - Required to connect to a MS-SQL database.)
  120. o DBD::Oracle......................Not installed! (optional - Required to connect to a Oracle database.)
  121. o DBD::Pg..........................Not installed! (optional - Required to connect to a PostgreSQL database.)
  122. o Digest::MD5......................ok (v2.52)
  123. o Digest::SHA......................ok (v5.85)
  124. o Digest::SHA......................ok (v5.85)
  125. o Encode::HanExtra.................Not installed! (optional - Required to handle mails with several Chinese character sets.)
  126. o Encode::Locale...................ok (v1.03)
  127. o GD...............................ok (v2.50)
  128. o GD::Text.......................ok (v0.86)
  129. o GD::Graph......................ok (v1.48)
  130. o IO::Scalar.......................ok (v2.110)
  131. o IO::Wrap.........................ok (v2.110)
  132. o JavaScript::Minifier::XS.........ok (v0.09)
  133. o JSON.............................ok (v2.61)
  134. o JSON::PP.......................ok (v2.27202)
  135. o JSON::XS.......................Not installed! (optional - Recommended for faster AJAX/JavaScript handling.)
  136. o Locale::Codes....................ok (v3.25)
  137. o LWP::UserAgent...................ok (v6.05)
  138. o Mail::Internet...................ok (v2.12)
  139. o Mail::POP3Client.................ok (v2.19)
  140. o IO::Socket::SSL................ok (v1.953)
  141. o Mail::IMAPClient.................Not installed! (optional - Required for IMAP TLS connections.)
  142. o IO::Socket::SSL................ok (v1.953)
  143. o MIME::Base64.....................ok (v3.13)
  144. o MIME::Tools......................ok (v5.504)
  145. o ModPerl::Util....................ok (v2.000008)
  146. o Apache::DBI....................Not installed! (optional - Improves performance on Apache webservers with mod_perl by establishing persistent database connections.)
  147. o Apache2::Reload................ok (v0.12)
  148. o Net::DNS.........................ok (v0.72)
  149. o Net::POP3........................ok (v2.29)
  150. o Net::IMAP::Simple................Not installed! (optional - Required for IMAP connections.)
  151. o IO::Socket::SSL................ok (v1.953)
  152. o Net::SMTP........................ok (v2.31)
  153. o Authen::SASL...................ok (v2.16)
  154. o Net::SMTP::SSL.................ok (v1.01)
  155. o Net::SMTP::TLS::ButMaintained..Not installed! (optional - Required for TLS/SMTP connections.)
  156. o Net::LDAP........................Not installed! (optional - Required for directory authentication.)
  157. o Net::SSL.........................Not installed! (optional - Required for Generic Interface SOAP SSL connections.)
  158. o PDF::API2........................ok (v2.020)
  159. o Compress::Zlib.................ok (v2.060)
  160. o Storable.........................ok (v2.41)
  161. o SOAP::Lite.......................Not installed! (optional - Required for the SOAP interface.)
  162. o version........................ok (v0.9902)
  163. o Class::Inspector...............Not installed! (optional - Required for SOAP::Lite.)
  164. o Text::CSV........................ok (v1.32)
  165. o Text::CSV_PP...................ok (v1.31)
  166. o Text::CSV_XS...................ok (v1.01)
  167. o Time::HiRes......................ok (v1.9725)
  168. o XML::Parser......................ok (v2.41)
  169. o HTTP::Message....................ok (v6.06)
  170. o HTTP::Headers..................ok (v6.05)
  171. o URI..............................ok (v1.60)
  172. o URI::Escape....................ok (v3.31)
  173. o Scalar::Util.....................ok (v1.27)
  174. o YAML::XS.........................ok (v0.41)
  175. [/code]
  176. конфиги nginx и FCGI:
  177. [code]# cat /usr/local/etc/nginx/nginx.conf
  178.  
  179. user www;
  180. worker_processes 1;
  181.  
  182. #error_log logs/error.log;
  183. #error_log logs/error.log notice;
  184. #error_log logs/error.log info;
  185.  
  186. #pid logs/nginx.pid;
  187.  
  188.  
  189. events {
  190. worker_connections 1024;
  191. }
  192.  
  193.  
  194. http {
  195. include mime.types;
  196. default_type application/octet-stream;
  197.  
  198. #log_format main '$remote_addr - $remote_user [$time_local] "$request" '
  199. # '$status $body_bytes_sent "$http_referer" '
  200. # '"$http_user_agent" "$http_x_forwarded_for"';
  201.  
  202. #access_log logs/access.log main;
  203.  
  204. sendfile on;
  205. #tcp_nopush on;
  206.  
  207. #keepalive_timeout 0;
  208. keepalive_timeout 65;
  209.  
  210. #gzip on;
  211.  
  212. server {
  213. listen 80;
  214. root /usr/local/otrs/var/httpd/htdocs;
  215. access_log /var/log/nginx/otrs.nginx_access.log;
  216. index index.html;
  217. location /otrs-web {
  218. gzip on;
  219. alias /usr/local/otrs/var/httpd/htdocs;
  220. }
  221. location ~ ^/otrs/(.*.pl)(/.*)?$ {
  222. gzip off; #gzip makes scripts feel slower since they have to complete before getting gzipped
  223. # fastcgi_pass unix:/.$1.sock;
  224. fastcgi_pass unix:/var/run/perl-fcgi.sock;
  225. # fastcgi_pass 127.0.0.1:8999;
  226. fastcgi_index index.pl;
  227. fastcgi_param SCRIPT_FILENAME /usr/local/otrs/bin/fcgi-bin/$1;
  228. fastcgi_param QUERY_STRING $query_string;
  229. fastcgi_param REQUEST_METHOD $request_method;
  230. fastcgi_param CONTENT_TYPE $content_type;
  231. fastcgi_param CONTENT_LENGTH $content_length;
  232. fastcgi_param GATEWAY_INTERFACE CGI/1.1;
  233. fastcgi_param SERVER_SOFTWARE nginx;
  234. fastcgi_param SCRIPT_NAME $fastcgi_script_name;
  235. fastcgi_param REQUEST_URI $request_uri;
  236. fastcgi_param DOCUMENT_URI $document_uri;
  237. fastcgi_param DOCUMENT_ROOT $document_root;
  238. fastcgi_param SERVER_PROTOCOL $server_protocol;
  239. fastcgi_param REMOTE_ADDR $remote_addr;
  240. fastcgi_param REMOTE_PORT $remote_port;
  241. fastcgi_param SERVER_ADDR $server_addr;
  242. fastcgi_param SERVER_PORT $server_port;
  243. fastcgi_param SERVER_NAME $server_name;
  244. }
  245. }
  246.  
  247.  
  248. # another virtual host using mix of IP-, name-, and port-based configuration
  249. #
  250. #server {
  251. # listen 8000;
  252. # listen somename:8080;
  253. # server_name somename alias another.alias;
  254.  
  255. # location / {
  256. # root html;
  257. # index index.html index.htm;
  258. # }
  259. #}
  260.  
  261.  
  262. # HTTPS server
  263. #
  264. #server {
  265. # listen 443;
  266. # server_name localhost;
  267.  
  268. # ssl on;
  269. # ssl_certificate cert.pem;
  270. # ssl_certificate_key cert.key;
  271.  
  272. # ssl_session_timeout 5m;
  273.  
  274. # ssl_protocols SSLv2 SSLv3 TLSv1;
  275. # ssl_ciphers HIGH:!aNULL:!MD5;
  276. # ssl_prefer_server_ciphers on;
  277.  
  278. # location / {
  279. # root html;
  280. # index index.html index.htm;
  281. # }
  282. #}
  283.  
  284. }
  285. [/code]
  286. FCGI:
  287. [code]# cat /usr/local/etc/rc.d/perl-fcgi.rc
  288. #!/bin/sh
  289. ### Rozhuk Ivan 2009.05
  290. ### startup script file for perl-fcgi
  291. ###
  292.  
  293.  
  294. # PROVIDE: perl_fcgi
  295. # REQUIRE: DAEMON
  296. # BEFORE: LOGIN
  297. # KEYWORD: shutdown
  298.  
  299. . /etc/rc.subr
  300.  
  301. name="perl_fcgi"
  302. rcvar=`set_rcvar`
  303.  
  304. load_rc_config $name
  305.  
  306. : ${perl_fcgi_enable="NO"}
  307. : ${perl_fcgi_pidfile="/var/run/perl-fcgi.pid"}
  308. : ${perl_fcgi_user="www"}
  309. : ${perl_fcgi_group="www"}
  310. : ${perl_fcgi_chdir=""}
  311. : ${perl_fcgi_chroot=""}
  312. : ${perl_fcgi_socket="127.0.0.1:9001"}
  313. : ${perl_fcgi_socketbacklog="10"}
  314. : ${perl_fcgi_socketmode="0777"}
  315. : ${perl_fcgi_children="5"}
  316. : ${perl_fcgi_childrentimeout="30"}
  317. : ${perl_fcgi_max_requests="1000"}
  318. : ${perl_fcgi_path_env="/bin:/usr/bin"}
  319.  
  320.  
  321. command="/usr/local/etc/perl-fcgi.pl"
  322. command_args="-d ${perl_fcgi_chdir} -s ${perl_fcgi_socket} -sb ${perl_fcgi_socket} -M ${perl_fcgi_socketmode} -F ${perl_fcgi_children} -Ft ${perl_fcgi_childrentimeout} -Fm ${perl_fcgi_max_requests} -P ${perl_fcgi_pidfile} -e ${perl_fcgi_path_env}"
  323. procname="perl-fcgi-pm"
  324. pidfile="${perl_fcgi_chroot}${perl_fcgi_pidfile}"
  325. required_dirs=${perl_fcgi_chroot}
  326.  
  327. start_precmd="${name}_start_precmd"
  328. stop_postcmd="${name}_stop_postcmd"
  329.  
  330.  
  331. perl_fcgi_start_precmd()
  332. {
  333. touch ${perl_fcgi_chroot}${pidfile}
  334. chown ${perl_fcgi_user}:${perl_fcgi_group} ${perl_fcgi_chroot}${pidfile}
  335. }
  336.  
  337. perl_fcgi_stop_postcmd()
  338. {
  339. rm -f ${pidfile}
  340. }
  341.  
  342. run_rc_command "$1"
  343. # cat /etc/rc.conf
  344. hostname="database_server"
  345. #ifconfig_re0="DHCP"
  346. ifconfig_re0=" inet 172.20.1.253 netmask 255.255.255.0"
  347. defaultrouter="172.20.1.254"
  348. sshd_enable="YES"
  349. ntpd_enable="YES"
  350. #powerd_enable="YES"
  351. # Set dumpdev to "AUTO" to enable crash dumps, "NO" to disable
  352. dumpdev="NO"
  353. mysql_enable="YES"
  354. jail_enable="YES"
  355. jail_list="test"
  356. jail_test_rootdir="/home/jails/jail_database/" # jail's root directory
  357. jail_test_hostname="database_jail" # jail's hostname
  358. jail_test_ip="172.20.1.252" # jail's IP address
  359. jail_interface="lo0"
  360. perl_fcgi_enable="YES"
  361. perl_fcgi_pidfile="/var/run/perl-fcgi.pid"
  362. perl_fcgi_user="www"
  363. perl_fcgi_group="www"
  364. perl_fcgi_chdir="/usr/local/otrs/bin/fcgi-bin/"
  365. perl_fcgi_chroot=""
  366. perl_fcgi_socket="/tmp/perl-fcgi.sock"
  367. perl_fcgi_socketbacklog="100"
  368. perl_fcgi_socketmode="0777"
  369. perl_fcgi_children="2"
  370. perl_fcgi_childrentimeout="10"
  371. perl_fcgi_max_requests="10000"
  372. perl_fcgi_path_env="/bin:/usr/bin"
  373. # cat /usr/local/etc/perl-fcgi.pl
  374. #!/usr/bin/perl -w
  375. use strict;
  376. use warnings;
  377. use FCGI; # /usr/ports/www/p5-FastCGI
  378. use FCGI::ProcManager qw(pm_manage pm_pre_dispatch pm_post_dispatch); # /usr/ports/www/p5-FCGI-ProcManager
  379. use Socket;
  380. use POSIX qw(setsid setuid);
  381. use Getopt::Long;
  382. require 'sys/syscall.ph';
  383.  
  384. # settings
  385. my ($CURRENT_DIR,$SOCKET_ADDRESS,$SOCKET_BACKLOG,$SOCKET_MODE,$CHILDRENS_COUNT,$CHILDRENS_TIMEOUT,$CHILDRENS_MAX_REQ,$PIDFILE,$PATHENV);
  386.  
  387. # global variables
  388.  
  389.  
  390.  
  391. &startpoint();
  392.  
  393.  
  394. #this keeps the program alive or something after exec'ing perl scripts
  395. END() { }
  396. BEGIN() { }
  397. {no warnings; *CORE::GLOBAL::exit = sub { die "fakeexit\nrc=".shift()."\n"; }; };
  398. eval q{exit};
  399. if ($@) { exit unless $@ =~ /^fakeexit/; };
  400.  
  401.  
  402.  
  403. sub startpoint()
  404. {
  405. if ($#ARGV!=-1)
  406. {
  407. $CURRENT_DIR ='/';
  408. #$SOCKET_ADDRESS ='';
  409. $SOCKET_BACKLOG =10;
  410. $SOCKET_MODE =0777;
  411. $CHILDRENS_COUNT =2;
  412. $CHILDRENS_TIMEOUT =30;
  413. $CHILDRENS_MAX_REQ =100;
  414. #$PIDFILE ='';
  415. #$PATHENV ='/bin:/usr/bin';
  416.  
  417. GetOptions( 'd:s' => \$CURRENT_DIR,
  418. 's=s' => \$SOCKET_ADDRESS,
  419. 'sb:i' => \$SOCKET_BACKLOG,
  420. 'M:i' => \$SOCKET_MODE,
  421. 'F:i' => \$CHILDRENS_COUNT,
  422. 'Ft:i' => \$CHILDRENS_TIMEOUT,
  423. 'Fm:i' => \$CHILDRENS_MAX_REQ,
  424. 'P:s' => \$PIDFILE,
  425. 'e:s' => \$PATHENV,
  426. );
  427.  
  428. if (!defined($SOCKET_ADDRESS)) {usage();}
  429.  
  430. # untainte input
  431. if ($SOCKET_ADDRESS =~ /^(.*)$/) {$SOCKET_ADDRESS = $1;}
  432. if (defined($PIDFILE)) {if ($PIDFILE =~ /^(.*)$/) {$PIDFILE = $1;}}
  433. if (defined($PATHENV))
  434. {
  435. if ($PIDFILE =~ /^(.*)$/) {$PIDFILE = $1;}
  436. }else{
  437. $PATHENV='/bin:/usr/bin';
  438. }
  439.  
  440.  
  441. #print "SOCKET_ADDRESS: $SOCKET_ADDRESS SOCKET_BACKLOG: $SOCKET_BACKLOG CHILDRENS_COUNT: $CHILDRENS_COUNT CHILDRENS_TIMEOUT: $CHILDRENS_TIMEOUT PIDFILE: $PIDFILE\n";
  442. daemonize();
  443. }else{
  444. usage();
  445. }
  446. }
  447.  
  448.  
  449. sub usage
  450. {
  451. print "Usage: perl-fcgi [options]\n\n";
  452. print " -d <directory> chdir to directory before spawning (default /)\n";
  453. print " -s <address/path> unix socket or tcp address:port\n";
  454. print " -sb <size> socket backlog size (default 10)\n";
  455. print " -M <mode> change Unix domain socket mode (default 0777)\n";
  456. print " -F <children> number of children to fork (default 2)\n";
  457. print " -Ft <timeout> children process timeout (default 30)\n";
  458. print " -Fm <num> children process max requests (default 100)\n";
  459. print " -P <path> name of PID-file for spawned process\n";
  460. print " -e <path> set new PATH environment (default /bin:/usr/bin)\n";
  461. #print "(root only)\n";
  462. #print " -c <directory> chroot to directory (default /)\n";
  463. #print " -S create socket before chroot() (default is to create the socket in the chroot)\n";
  464. #print " -u <user> change to user-id\n";
  465. #print " -g <group> change to group-id (default: primary group of user if -u is given)\n";
  466. #print " -U <user> change Unix domain socket owner to user-id\n";
  467. #print " -G <group> change Unix domain socket group to group-id\n";
  468.  
  469. exit;
  470. }
  471.  
  472.  
  473. sub daemonize()
  474. {
  475. delete @ENV{qw(IFS CDPATH ENV BASH_ENV)}; # Make %ENV safer
  476. $ENV{'PATH'} = $PATHENV; # set new path environment
  477. chdir $CURRENT_DIR or die "Can't chdir to $CURRENT_DIR: $!\n";
  478. #setuid(65534) or die "Can't set uid: $!\n"; # nobody
  479.  
  480. open(STDIN, "+>/dev/null") or die "Can't open STDIN: $!\n";
  481. open(STDOUT, "+>&STDIN") or die "Can't open STDOUT: $!\n";
  482. open(STDERR, "+>&STDIN") or die "Can't open STDERR: $!\n";
  483. defined(my $tm = fork) or die "Can't fork: $!\n";
  484. exit if $tm;
  485. setsid or die "Can't start a new session: $!\n";
  486. umask 0;
  487.  
  488. main();
  489. }
  490.  
  491.  
  492. sub main
  493. {
  494. my ($ListenSocket);
  495. my ($proc_manager,$request,%req_params);
  496.  
  497. $ListenSocket = FCGI::OpenSocket( $SOCKET_ADDRESS, $SOCKET_BACKLOG );
  498. if (defined($ListenSocket))
  499. {
  500. if (defined($PIDFILE))
  501. {
  502. open FILE, "> $PIDFILE" or die $!;
  503. print FILE "$$\n";
  504. close FILE;
  505. }
  506.  
  507. if (substr($SOCKET_ADDRESS,0,1) eq '/')
  508. {
  509. print "chmod($SOCKET_MODE,$SOCKET_ADDRESS)\n";
  510. chmod(oct($SOCKET_MODE),$SOCKET_ADDRESS);
  511. }
  512.  
  513. $proc_manager = FCGI::ProcManager->new({ n_processes => $CHILDRENS_COUNT, die_timeout => $CHILDRENS_TIMEOUT });
  514. $request = FCGI::Request( \*STDIN, \*STDOUT, \*STDERR, \%req_params, $ListenSocket, &FCGI::FAIL_ACCEPT_ON_INTR );
  515. $proc_manager->pm_manage();
  516.  
  517. if ($request) { request_loop(\$proc_manager,\$request,\%req_params) };
  518.  
  519. FCGI::CloseSocket( $ListenSocket );
  520. if (substr($SOCKET_ADDRESS,0,1) eq '/') {unlink($SOCKET_ADDRESS);}
  521. if (defined($PIDFILE)) {unlink($PIDFILE);}
  522. }
  523. }
  524.  
  525.  
  526. sub request_loop()
  527. {
  528. my ($proc_manager_ref)=$_[0];
  529. my ($request_ref)=$_[1];
  530. my ($req_params_ref)=$_[2];
  531. my ($stdin_passthrough,$req_len,$key,$pid_child,$req_count);
  532.  
  533. $req_count=1;
  534. while( $$request_ref->Accept() >= 0 )
  535. {
  536. $$proc_manager_ref->pm_pre_dispatch();
  537.  
  538. #processing any STDIN input from WebServer (for CGI-POST actions)
  539. $stdin_passthrough ='';
  540. { no warnings; $req_len = 0 + $$req_params_ref{'CONTENT_LENGTH'}; };
  541. if (($$req_params_ref{'REQUEST_METHOD'} eq 'POST') && ($req_len != 0) )
  542. {
  543. my $bytes_read = 0;
  544. while ($bytes_read < $req_len)
  545. {
  546. my $data = '';
  547. my $bytes = read(STDIN, $data, ($req_len - $bytes_read));
  548. last if ($bytes == 0 || !defined($bytes));
  549. $stdin_passthrough .= $data;
  550. $bytes_read += $bytes;
  551. }
  552. }
  553.  
  554. #running the cgi app
  555. if ( (-x $$req_params_ref{SCRIPT_FILENAME}) && #can I execute this?
  556. (-s $$req_params_ref{SCRIPT_FILENAME}) && #Is this file empty?
  557. (-r $$req_params_ref{SCRIPT_FILENAME}) #can I read this file?
  558. ){
  559.  
  560. pipe(CHILD_RD, PARENT_WR);
  561. $pid_child = open(KID_TO_READ, "-|");
  562. unless(defined($pid_child))
  563. {
  564. print("Content-type: text/plain\r\n\r\n");
  565. print "Error: CGI app returned no output - Executing $$req_params_ref{SCRIPT_FILENAME} failed !\n";
  566. next;
  567. }
  568.  
  569. if ($pid_child > 0)
  570. {
  571. close(CHILD_RD);
  572. print PARENT_WR $stdin_passthrough;
  573. close(PARENT_WR);
  574.  
  575. while(my $s = <KID_TO_READ>) { print $s; }
  576. close KID_TO_READ;
  577. waitpid($pid_child, 0);
  578. }else{
  579. foreach $key ( keys %{$req_params_ref}){ $ENV{$key} = $$req_params_ref{$key}; }
  580. # cd to the script's local directory
  581. if ($$req_params_ref{SCRIPT_FILENAME} =~ /^(.*)\/[^\/]+$/) { chdir $1;}
  582.  
  583. close(PARENT_WR);
  584. close(STDIN);
  585. #fcntl(CHILD_RD, F_DUPFD, 0);
  586. syscall(&SYS_dup2, fileno(CHILD_RD), 0);
  587. #open(STDIN, "<&CHILD_RD");
  588. exec($$req_params_ref{SCRIPT_FILENAME});
  589. die("exec failed");
  590. }
  591. }else{
  592. print("Content-type: text/plain\r\n\r\n");
  593. print "Error: No such CGI app - $$req_params_ref{SCRIPT_FILENAME} may not exist or is not executable by this process.\n";
  594. }
  595.  
  596. $req_count++;
  597. exit if $req_count > $CHILDRENS_MAX_REQ;
  598.  
  599. $$proc_manager_ref->pm_post_dispatch();
  600. }
  601. }
  602. [/code]
  603. Доброго времени суток. О сабже:
  604. [code]# cgi-bin/installer.pl
  605. [Wed Oct 23 09:22:11 2013] HTMLUtils.pm: In '(?...)', splitting the initial '(?' is deprecated in regex; marked by <-- HERE in m/
  606. [Wed Oct 23 09:22:11 2013] HTMLUtils.pm: ( # $1 greater-than and less-than sign
  607. [Wed Oct 23 09:22:11 2013] HTMLUtils.pm: > | < | \s+ | \#{6} |
  608. [Wed Oct 23 09:22:11 2013] HTMLUtils.pm: (?: &[a-zA-Z0-9]+; ) # get html entities
  609. [Wed Oct 23 09:22:11 2013] HTMLUtils.pm: )
  610. [Wed Oct 23 09:22:11 2013] HTMLUtils.pm: ( # $2
  611. [Wed Oct 23 09:22:11 2013] HTMLUtils.pm: (?: # http or only www
  612. [Wed Oct 23 09:22:11 2013] HTMLUtils.pm: (?: (?: http s? | ftp ) :\/\/) | # http://,https:// and ftp://
  613. [Wed Oct 23 09:22:11 2013] HTMLUtils.pm: (?: (?: www | ftp ) \.) # www. and ftp.
  614. [Wed Oct 23 09:22:11 2013] HTMLUtils.pm: )
  615. [Wed Oct 23 09:22:11 2013] HTMLUtils.pm: )
  616. [Wed Oct 23 09:22:11 2013] HTMLUtils.pm: ( # $3
  617. [Wed Oct 23 09:22:11 2013] HTMLUtils.pm: (?: [a-z0-9\-]+ \. )* # get subdomains, optional
  618. [Wed Oct 23 09:22:11 2013] HTMLUtils.pm: [a-z0-9\-]+ # get top level domain
  619. [Wed Oct 23 09:22:11 2013] HTMLUtils.pm: (?: # file path element
  620. [Wed Oct 23 09:22:11 2013] HTMLUtils.pm: [\/\.]
  621. [Wed Oct 23 09:22:11 2013] HTMLUtils.pm: | [a-zA-Z0-9\-]
  622. [Wed Oct 23 09:22:11 2013] HTMLUtils.pm: )*
  623. [Wed Oct 23 09:22:11 2013] HTMLUtils.pm: (?: # param string
  624. [Wed Oct 23 09:22:11 2013] HTMLUtils.pm: [\?] # if param string is there, "?" must be present
  625. [Wed Oct 23 09:22:11 2013] HTMLUtils.pm: [a-zA-Z0-9&;=%]* # param string content, this will also catch entities like &amp;
  626. [Wed Oct 23 09:22:11 2013] HTMLUtils.pm: )?
  627. [Wed Oct 23 09:22:11 2013] HTMLUtils.pm: (?: # link hash string
  628. [Wed Oct 23 09:22:11 2013] HTMLUtils.pm: [\#] #
  629. [Wed Oct 23 09:22:11 2013] HTMLUtils.pm: [a-zA-Z0-9&;=%]* # hash string content, this will also catch entities like &amp;
  630. [Wed Oct 23 09:22:11 2013] HTMLUtils.pm: )?
  631. [Wed Oct 23 09:22:11 2013] HTMLUtils.pm: )
  632. [Wed Oct 23 09:22:11 2013] HTMLUtils.pm: ( # $4
  633. [Wed Oct 23 09:22:11 2013] HTMLUtils.pm: ? <-- HERE =(?:
  634. [Wed Oct 23 09:22:11 2013] HTMLUtils.pm: [\?,;!\.\)] (?: \s | $ ) # \)\s this construct is because of bug# 2450
  635. [Wed Oct 23 09:22:11 2013] HTMLUtils.pm: | \"
  636. [Wed Oct 23 09:22:11 2013] HTMLUtils.pm: | \]
  637. [Wed Oct 23 09:22:11 2013] HTMLUtils.pm: | \s+
  638. [Wed Oct 23 09:22:11 2013] HTMLUtils.pm: | '
  639. [Wed Oct 23 09:22:11 2013] HTMLUtils.pm: | > # greater-than and less-than sign
  640. [Wed Oct 23 09:22:11 2013] HTMLUtils.pm: | < # "
  641. [Wed Oct 23 09:22:11 2013] HTMLUtils.pm: | (?: &[a-zA-Z0-9]+; )+ # html entities
  642. [Wed Oct 23 09:22:11 2013] HTMLUtils.pm: | $ # bug# 2715
  643. [Wed Oct 23 09:22:11 2013] HTMLUtils.pm: )
  644. [Wed Oct 23 09:22:11 2013] HTMLUtils.pm: | \#{6} # ending LinkHash
  645. [Wed Oct 23 09:22:11 2013] HTMLUtils.pm: )
  646. [Wed Oct 23 09:22:11 2013] HTMLUtils.pm: / at /usr/local/otrs/bin/cgi-bin/../../Kernel/System/HTMLUtils.pm line 865.
  647. [Wed Oct 23 09:22:11 2013] installer.pl: Use of uninitialized value in shmctl at /usr/local/otrs/bin/cgi-bin/../../Kernel/System/Log.pm line 277.
  648. ERROR: OTRS-CGI-10 Perl: 5.18.1 OS: freebsd Time: Wed Oct 23 09:22:11 2013
  649.  
  650. Message: Can't remove shm for log: Function not implemented
  651.  
  652. Traceback (812):
  653. Module: Kernel::System::Log::CleanUp (OTRS 3.2.10) Line: 278
  654. Module: Kernel::System::Log::new (OTRS 3.2.10) Line: 99
  655. Module: Kernel::System::Web::InterfaceInstaller::new (OTRS 3.2.10) Line: 78
  656. Module: cgi-bin/installer.pl (unknown version) Line: 38
  657.  
  658. [Wed Oct 23 09:22:11 2013] installer.pl: Use of uninitialized value in shmread at /usr/local/otrs/bin/cgi-bin/../../Kernel/System/Log.pm line 254.
  659. Function not implemented at /usr/local/otrs/bin/cgi-bin/../../Kernel/System/Log.pm line 254.
  660. [/code]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement