Search Results

Search found 16 results on 1 pages for 'codeholic'.

Page 1/1 | 1 

  • May the file size returned by stat be compromised?

    - by codeholic
    I want to make sure that nobody changed a file. In order to accomplish that, I want not only to check MD5 sum of the file, but also check its size, since as far as I understand this additional simple check can sophisticate falsification by several digits. May I trust the size that stat returns? I don't mean if changes were made to stat itself. I don't go that deep. But, for instance, may one compromise the file size that stat returns by hacking the directory file? Or by similar means, that do not require superuser privileges? It's Linux.

    Read the article

  • Delete files from directory: memory exhausted

    - by codeholic
    This question is a logical continuation of http://serverfault.com/questions/45245/how-can-i-delete-all-files-from-a-directory-when-it-reports-argument-list-too-lo I have drwxr-xr-x 2 doreshkin doreshkin 198291456 Apr 6 21:35 session_data I tried find session_data -type f -delete find session_data -type f | xargs rm -f find session_data -maxdepth 1 -type f -print0 | xargs -r0 rm -f The result is the same: find: memory exhausted What can I do to remove this directory?

    Read the article

  • Pass parameters to a script securely

    - by codeholic
    What is the best way to pass parameters to a forked script securely? E. g. passing parameters through command line operands is not secure, since someone who has an account on the host can run ps and see them. Unnamed pipe is quite secure, as far as I understand, isn't it? I mean, passing parameters to STDIN of the forked process. What about passing parameters in environment vars? Is it secure? What about passing parameters by other means I didn't mention?

    Read the article

  • Why doesn't Apache2::SubProcess spawn my subprocess?

    - by codeholic
    The following script works without errors, but /tmp/test.touch is not being created (even being checked later in the command line). It seems to me as if $r->spawn_proc_prog doesn't spawn a process. What may cause the problem? #!/usr/bin/perl use strict; use warnings; use Apache2::RequestUtil; use Apache2::SubProcess (); my $r = Apache2::RequestUtil->request; print "Content-Type: text/plain\n\n"; print eval { $r->spawn_proc_prog('/usr/bin/touch', ['/tmp/test.touch']) } ? `ls -l /tmp/test.touch` : $@;

    Read the article

  • What is the safe way to use fork with Apache::DBI under mod_perl2?

    - by codeholic
    I have a problem when I use Apache::DBI in child processes. The problem is that Apache::DBI provides a single handle for all processes which use it, so I get DBD::mysql::db selectall_arrayref failed: Commands out of sync; you can't run this command now at /usr/local/www/apache22/data/test-fork.cgi line 20. Reconnection doesn't help, since Apache::DBI reconnects in all processes, as I understood the following error The server encountered an internal error and was unable to complete your request. Error message: DBD driver has not implemented the AutoCommit attribute at /usr/local/lib/perl5/site_perl/5.8.9/Apache/DBI.pm line 283. , Here's the origin code: use Data::Dumper 'Dumper'; use DBI (); my $dbh = DBI->connect($dsn, $username, $password, { RaiseError => 1, PrintError => 0, }); my $file = "/tmp/test-fork.tmp"; my $pid = fork; defined $pid or die "fork: $!"; if ($pid) { my $rows = eval { $dbh->selectall_arrayref('SELECT SLEEP(1)') }; print "Content-Type: text/plain\n\n"; print $rows ? "parent: " . Dumper($rows) : $@; } else { my $rows = eval { $dbh->selectall_arrayref('SELECT SLEEP(1)') }; open FH, '>', $file or die "$file: $!"; print FH $rows ? "child: " . Dumper($rows) : $@; close FH; } The code I used for reconnection: ... else { $dbh->disconnect; $dbh = DBI->connect($dsn, $username, $password, $attrs); my $rows = eval { $dbh->selectall_arrayref('SELECT SLEEP(1)') }; open FH, '>', $file or die "$file: $!"; print FH $rows ? "child: " . Dumper($rows) : $@; close FH; } Is there a safe way to use Apache::DBI with forking? Is there a way to make it create a new connection perhaps?

    Read the article

  • No coverage for runtime with Devel::Cover and ModPerl::Registry

    - by codeholic
    When I'm running Devel::Cover with ModPerl::Registry, I get no coverage info except for BEGIN blocks. When I'm running the same script with Devel::Cover from command line or as a CGI, everything works alright (obviously). How can I make Devel::Cover "see" my code being executed in the runtime? Here's Devel::Cover related stuff in my httpd.conf: MaxClients 1 PerlSetEnv DEVEL_COVER_OPTIONS -db,/tmp/cover_db,silent,1 PerlRequire /var/www/project/startup.pl Here's startup.pl: #!/usr/bin/perl use strict; use warnings; use Apache2::Directive (); use File::Basename (); use File::Find (); BEGIN { # Devel::Cover database must be writable by worker processes my $conftree = Apache2::Directive::conftree->as_hash; my $name = $conftree->{User} or die "couldn't find user in Apache config"; print "user=$name\n"; my $uid = getpwnam($name); defined $uid or die "couldn't determine uid by name"; no warnings 'redefine'; local $> = $uid; require Devel::Cover; my $old_report = \&Devel::Cover::report; *Devel::Cover::report = sub { local $> = $uid; $old_report->(@_) }; Devel::Cover->import; } 1; (As you may see, I made a monkey patch for Devel::Cover since startup.pl is being run by root, but worker processes run under a different user, and otherwise they couldn't read directories created by startup.pl. If you know a better solution, make a note, please.)

    Read the article

  • How can I run Devel::Cover under mod_perl2?

    - by codeholic
    Unfortunately, Devel::Cover does not yet work with threads. It doesn't work with prefork either. Being use'd in startup.pl, Devel::Cover issues Not a CODE reference. END failed--call queue aborted. perl 5.8.9, Apache 2.2.13. My OS is FreeBSD, if that matters. The same problem is reported for win32.

    Read the article

  • Are keys and values of %INC platform-dependent or not?

    - by codeholic
    I'd like to get the full filename of an included module. Consider this code: package MyTest; my $path = join '/', split /::/, __PACKAGE__; $path .= ".pm"; print "$INC{$path}\n"; 1; $ perl -Ipath/to/module -MMyTest -e0 path/to/module/MyTest.pm Will it work on all platforms? perlvar The hash %INC contains entries for each filename included via the do, require, or useoperators. The key is the filename you specified (with module names converted to pathnames), and the value is the location of the file found. Are these keys platform-dependent or not? Should I use File::Spec or what? At least ActivePerl on win32 uses / instead of \. Update: What about %INC values? Are they platform-dependent?

    Read the article

  • How to make Net::Msmgr run?

    - by codeholic
    There's Net::Msmgr module on CPAN. It's written clean and the code looks trustworthy at the first glance. However this module seems to be beta and there is little documentation and no tests :-/ Has anyone used this module in production? I haven't managed to make it run by now, because it requires all event loop processing to be done in the application and as I've already said there is little documentation and no working examples to study. That's where I've gone so far: #!/usr/bin/perl use strict; use warnings; use Event; use Net::Msmgr::Object; use Net::Msmgr::Session; use Net::Msmgr::User; use constant DEBUG => 511; use constant EVENT_TIMEOUT => 5; # seconds my ($username, $password) = qw/[email protected] my.password/; my $buddy = '[email protected]'; my $user = Net::Msmgr::User->new(user => $username, password => $password); my $session = Net::Msmgr::Session->new; $session->debug(DEBUG); $session->login_handler(\&login_handler); $session->user($user); my $conv; sub login_handler { my $self = shift; print "LOGIN\n"; $self->ui_state_nln; $conv = $session->ui_new_conversation; $conv->invite($buddy); } our %watcher; sub ConnectHandler { my ($connection) = @_; warn "CONNECT\n"; my $socket = $connection->socket; $watcher{$connection} = Event->io(fd => $socket, cb => [ $connection, '_recv_message' ], poll => 're', desc => 'recv_watcher', repeat => 1); } sub DisconnectHandler { my $connection = shift; print "DISCONNECT\n"; $watcher{$connection}->cancel; } $session->connect_handler(\&ConnectHandler); $session->disconnect_handler(\&DisconnectHandler); $session->Login; Event::loop(); That's what it outputs: Dispatch Server connecting to: messenger.hotmail.com:1863 Dispatch Server connected CONNECT Dispatch Server >>>VER 1 MSNP2 CVR0 --> VER 1 MSNP2 CVR0 Dispatch Server >>>USR 2 MD5 I [email protected] --> USR 2 MD5 I [email protected] Dispatch Server <<<VER 1 CVR0 <-- VER 1 CVR0 And that's all, here it hangs. The handler on login is not being triggered. What am I doing wrong?

    Read the article

  • How to make Net::Msmnr run?

    - by codeholic
    There's Net::Msmgr module on CPAN. It's written clean and the code looks trustworthy at the first glance. However this module seems to be beta and there is little documentation and no tests :-/ Has anyone used this module in production? I haven't managed to make it run by now, because it requires all event loop processing to be done in the application and as I've already said there is little documentation and no working examples to study. That's where I've gone so far: #!/usr/bin/perl use strict; use warnings; use Event; use Net::Msmgr::Object; use Net::Msmgr::Session; use Net::Msmgr::User; use constant DEBUG => 511; use constant EVENT_TIMEOUT => 5; # seconds my ($username, $password) = qw/[email protected] my.password/; my $buddy = '[email protected]'; my $user = Net::Msmgr::User->new(user => $username, password => $password); my $session = Net::Msmgr::Session->new; $session->debug(DEBUG); $session->login_handler(\&login_handler); $session->user($user); my $conv; sub login_handler { my $self = shift; print "LOGIN\n"; $self->ui_state_nln; $conv = $session->ui_new_conversation; $conv->invite($buddy); } our %watcher; sub ConnectHandler { my ($connection) = @_; warn "CONNECT\n"; my $socket = $connection->socket; $watcher{$connection} = Event->io(fd => $socket, cb => [ $connection, '_recv_message' ], poll => 're', desc => 'recv_watcher', repeat => 1); } sub DisconnectHandler { my $connection = shift; print "DISCONNECT\n"; $watcher{$connection}->cancel; } $session->connect_handler(\&ConnectHandler); $session->disconnect_handler(\&DisconnectHandler); $session->Login; Event::loop(); That's what it outputs: Dispatch Server connecting to: messenger.hotmail.com:1863 Dispatch Server connected CONNECT Dispatch Server >>>VER 1 MSNP2 CVR0 --> VER 1 MSNP2 CVR0 Dispatch Server >>>USR 2 MD5 I [email protected] --> USR 2 MD5 I [email protected] Dispatch Server <<<VER 1 CVR0 <-- VER 1 CVR0 And that's all, here it hangs. The handler on login is not being triggered. What am I doing wrong?

    Read the article

  • Why does Perl's Net::Msmgr hang when I try to authenticate?

    - by codeholic
    There's Net::Msmgr module on CPAN. It's written clean and the code looks trustworthy at the first glance. However this module seems to be beta and there is little documentation and no tests :-/ Has anyone used this module in production? I haven't managed to make it run by now, because it requires all event loop processing to be done in the application and as I've already said there is little documentation and no working examples to study. That's where I've gone so far: #!/usr/bin/perl use strict; use warnings; use Event; use Net::Msmgr::Object; use Net::Msmgr::Session; use Net::Msmgr::User; use constant DEBUG => 511; use constant EVENT_TIMEOUT => 5; # seconds my ($username, $password) = qw/[email protected] my.password/; my $buddy = '[email protected]'; my $user = Net::Msmgr::User->new(user => $username, password => $password); my $session = Net::Msmgr::Session->new; $session->debug(DEBUG); $session->login_handler(\&login_handler); $session->user($user); my $conv; sub login_handler { my $self = shift; print "LOGIN\n"; $self->ui_state_nln; $conv = $session->ui_new_conversation; $conv->invite($buddy); } our %watcher; sub ConnectHandler { my ($connection) = @_; warn "CONNECT\n"; my $socket = $connection->socket; $watcher{$connection} = Event->io(fd => $socket, cb => [ $connection, '_recv_message' ], poll => 're', desc => 'recv_watcher', repeat => 1); } sub DisconnectHandler { my $connection = shift; print "DISCONNECT\n"; $watcher{$connection}->cancel; } $session->connect_handler(\&ConnectHandler); $session->disconnect_handler(\&DisconnectHandler); $session->Login; Event::loop(); That's what it outputs: Dispatch Server connecting to: messenger.hotmail.com:1863 Dispatch Server connected CONNECT Dispatch Server >>>VER 1 MSNP2 CVR0 --> VER 1 MSNP2 CVR0 Dispatch Server >>>USR 2 MD5 I [email protected] --> USR 2 MD5 I [email protected] Dispatch Server <<<VER 1 CVR0 <-- VER 1 CVR0 And that's all, here it hangs. The handler on login is not being triggered. What am I doing wrong?

    Read the article

1