Subject: | use somehow interferes w/ Getopt::Long integers when setuid |
This was a real stumper. At first I was going to file a bug against
Getopt::Long, but then I tried my test script with regular 'YAML' and it
worked correctly. It seems that use of YAML::Syck in a setuid script
(and only when setuid) interferes with only the 'integer' type in
Getopt::Long. This is a really weird one. I am using perl 5.8.8 in
CentOS. I will try YAML::Syck 1.15 in a moment. --mark--
hedges@vm5:~$ cat /tmp/lamer.pl
#!/usr/bin/perl
use strict;
use warnings FATAL => 'all';
use English '-no_match_vars';
use Getopt::Long;
use YAML;
my %args = ();
warn "raw script args:\n".Dump(\@ARGV);
my $result = GetOptions(
'integer=i' => \$args{integer},
'string=s' => \$args{string},
'float=f' => \$args{float},
);
warn "getopt script args:\n".Dump(\%args);
hedges@vm5:~$ ls -lah /tmp/lamer.pl
-rwxr-x--- 1 root hedges 353 Oct 31 23:07 /tmp/lamer.pl
hedges@vm5:~$ /tmp/lamer.pl --float 2.3 --integer 1 --string foobar
raw script args:
---
- --float
- 2.3
- --integer
- 1
- --string
- foobar
getopt script args:
---
float: 2.3
integer: 1
string: foobar
hedges@vm5:~$ sudo chmod u+s /tmp/lamer.pl
hedges@vm5:~$ ls -lah /tmp/lamer.pl
-rwsr-x--- 1 root hedges 353 Oct 31 23:07 /tmp/lamer.pl
hedges@vm5:~$ /tmp/lamer.pl --float 2.3 --integer 1 --string foobar
raw script args:
---
- --float
- 2.3
- --integer
- 1
- --string
- foobar
getopt script args:
---
float: 2.3
integer: 1
string: foobar
hedges@vm5:~$ sudo perl -pi -e 's/YAML/YAML::Syck/' /tmp/lamer.pl
hedges@vm5:~$ cat /tmp/lamer.pl
#!/usr/bin/perl
use strict;
use warnings FATAL => 'all';
use English '-no_match_vars';
use Getopt::Long;
use YAML::Syck;
my %args = ();
warn "raw script args:\n".Dump(\@ARGV);
my $result = GetOptions(
'integer=i' => \$args{integer},
'string=s' => \$args{string},
'float=f' => \$args{float},
);
warn "getopt script args:\n".Dump(\%args);
hedges@vm5:~$ ls -lah /tmp/lamer.pl
-rwsr-x--- 1 root hedges 359 Oct 31 23:09 /tmp/lamer.pl
hedges@vm5:~$ /tmp/lamer.pl --float 2.3 --integer 1 --string foobar
raw script args:
---
- --float
- '2.3'
- --integer
- 1
- --string
- foobar
getopt script args:
---
float: '2.3'
integer: ~
string: foobar
hedges@vm5:~$ sudo chmod u-s /tmp/lamer
chmod: cannot access `/tmp/lamer': No such file or directory
hedges@vm5:~$ sudo chmod u-s /tmp/lamer.pl
hedges@vm5:~$ ls -lah /tmp/lamer.pl
-rwxr-x--- 1 root hedges 359 Oct 31 23:09 /tmp/lamer.pl
hedges@vm5:~$ /tmp/lamer.pl --float 2.3 --integer 1 --string foobar
raw script args:
---
- --float
- '2.3'
- --integer
- 1
- --string
- foobar
getopt script args:
---
float: '2.3'
integer: 1
string: foobar