in reply to How to read UNIX socket credentials?
However, I would really like to see how this can be implemented without using IO::Socket::UNIX.use strict; use warnings; use IO::Socket; use IO::Handle::Record; $| = 1; unlink('/tmp/catsock'); my $server = new IO::Socket::UNIX( Type => SOCK_STREAM, Local => '/tmp/catsock', Listen => SOMAXCONN ); die "Coudn't open socket" unless $server; my $client; my $count = 0; while(1) { $client = $server->accept(); my ($pid, $uid, $gid) = $client->peercred; # name, pass, uid, gid, quota, comment, gcos, dir, shell, expire my @uinfo = getpwuid($uid); print "$count. Credentials User: $uinfo[0] PID: $pid UID: $uid GID +: $gid\n" . <$client> . "\n"; $count++; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to read UNIX socket credentials?
by ikegami (Patriarch) on Jan 07, 2011 at 09:14 UTC | |
by hackman (Acolyte) on Jan 08, 2011 at 10:32 UTC | |
by sayotte (Initiate) on Feb 09, 2012 at 18:28 UTC | |
|
Re^2: How to read UNIX socket credentials?
by cdarke (Prior) on Jan 07, 2011 at 08:38 UTC |