Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
use POSIX instead of special variables
  • Loading branch information
kraih committed Oct 5, 2011
1 parent 90cd440 commit 8da8921
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Changes
Expand Up @@ -5,7 +5,7 @@ This file documents the revision history for Perl extension Mojolicious.
- Increased Perl version requirement to 5.10.1.
- Improved message parser performance slightly.
- Improved Mojo::IOLoop to die if started twice.
- Improved setuidgid in Mojo::Server::Daemon slightly.
- Improved setuidgid in Mojo::Server::Daemon.
- Improved documentation.
- Improved tests.
- Fixed many portability issues.
Expand Down
9 changes: 3 additions & 6 deletions lib/Mojo/Server/Daemon.pm
Expand Up @@ -6,6 +6,7 @@ use File::Spec;
use IO::File;
use Mojo::Command;
use Mojo::IOLoop;
use POSIX;
use Scalar::Util 'weaken';
use Sys::Hostname;

Expand Down Expand Up @@ -214,9 +215,7 @@ sub _group {
return unless my $group = $self->group;
croak qq/Group "$group" does not exist/
unless defined(my $gid = (getgrnam($group))[2]);
undef $!;
$( = $) = $gid;
croak qq/Can't switch to group "$group": $!/ if $!;
POSIX::setgid($gid) or croak qq/Can't switch to group "$group": $!/;
}

sub _listen {
Expand Down Expand Up @@ -319,9 +318,7 @@ sub _user {
return unless my $user = $self->user;
croak qq/User "$user" does not exist/
unless defined(my $uid = (getpwnam($self->user))[2]);
undef $!;
$< = $> = $uid;
croak qq/Can't switch to user "$user": $!/ if $!;
POSIX::setuid($uid) or croak qq/Can't switch to user "$user": $!/;
}

sub _write {
Expand Down

0 comments on commit 8da8921

Please sign in to comment.