Beacon code feedback


I have a few comments on my recent experience setting up a Beacon client
on a Solaris 2.6 box (which you'll now find on the beacon page).

Be forewarned, I don't know Perl, I know combat Perl.  :-)

I wanted to run the client via a start-up script and as another user so
I added the following lines to the src/beacon.conf:

  RUNASUSER  = userid
  RUNASGROUP = groupid

Where userid/groupid are non-privileged user/group ids.  Then in the
src/beacon script, I added declartions as such:

  my $RUNASUSER;
  my $RUNASGROUP;
  my $userid;
  my $groupid;

In the foreach loop that processes options and just before the last else {}
I added the following:

  } elsif ($var eq "RUNASUSER") {
          $userid = $opts{$var};
          $< = $> = getpwnam($userid) || die "Unable to get $userid: $!\n";
  } elsif ($var eq "RUNASGROUP) {
          $groupid = $opts{$var};
          $( = $) = getgrnam($groupid) || die "Unable to get $groupid: $!\n";

Then much further along in the script where there was the following:

  $user = $ENV{'USER'} || `who am i`;

I changed that to:

  my $user;
  if ($userid) {
      $user = $userid;
  } else {
      $user = $ENV{'USER'} || `who am i`;
  }

The system I was running on was also one of those where the fully
qualified domain name of the host wasn't being retrieved by this line:

  my $host = $ENV{'HOSTNAME'} || `hostname`;

So after that line I added the following:

  if ($host !~ /\./) {
      require Net::Domain;
      $host = $Net::Domain::hostfqdn() || die "Unable to get fqdn: $!\n";
  }

Another problem I had was that during the runtime of the script I was
getting an error in reference to the inet_pton() call.  With the help of
Andy Elble, it turns out that Solaris 2.6 needed a couple of additional
libraries to be linked into the resulting Beacon.so.

In Net-Multicast-Beacon/Makefile.PL.in I changed:

  'LIBS' => [' -L../librtp -lrtp -L../libbeacon -lbeacon'],

to:

  'LIBS'   => ['-L../librtp -lrtp -L../libbeacon -lbeacon -lnsl -lresolv'],

I also noticed that Sys::Hostname does not every appear to be referenced
in the beacon script.  Unless I'm missing something, perhaps that should
be removed from the code.

John



Other Mailing lists | Author Index | Date Index | Subject Index | Thread Index