You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Red Hat customer reported an interesting issue with $PROGRAM_NAME ($0).
There is $PROGRAM_NAME with result like /dev/fd/6 when the script is running under sudo with checksum verification.
We have /usr/local/bin/script.pl
#!/usr/bin/perl
use strict;
use warnings;
use Cwd qw( abs_path );
print "\$0: $0\n";
print "abs_path(\$0): " . abs_path($0) . "\n";
...
/* if find_script() returns, it returns a malloc()-ed value */
scriptname = PL_origfilename = find_script(scriptname, dosearch, NULL, 1);
s = scriptname + strlen(scriptname);
if (strBEGINs(scriptname, "/dev/fd/")
&& isDIGIT(scriptname[8])
&& grok_atoUV(scriptname + 8, &uv, &s)
&& uv <= PERL_INT_MAX
) {
fdscript = (int)uv;
if (*s) {
/* PSz 18 Feb 04
* Tell apart "normal" usage of fdscript, e.g.
* with bash on FreeBSD:
* perl <( echo '#!perl -DA'; echo 'print "$0\n"')
* from usage in suidperl.
* Does any "normal" usage leave garbage after the number???
* Is it a mistake to use a similar /dev/fd/ construct for
* suidperl?
*/
*suidscript = TRUE;
/* PSz 20 Feb 04
* Be supersafe and do some sanity-checks.
* Still, can we be sure we got the right thing?
*/
if (*s != '/') {
Perl_croak(aTHX_ "Wrong syntax (suid) fd script name \"%s\"\n", s);
}
if (! *(s+1)) {
Perl_croak(aTHX_ "Missing (suid) fd script name\n");
}
scriptname = savepv(s + 1);
Safefree(PL_origfilename);
PL_origfilename = (char *)scriptname;
}
}
}
...
The issue
The Red Hat customer reported an interesting issue with
$PROGRAM_NAME
($0
).There is
$PROGRAM_NAME
with result like/dev/fd/6
when the script is running undersudo
with checksum verification.We have /usr/local/bin/script.pl
Configuration of sudo:
Example user:
Running as user.
Result like (on Fedora Rawhide):
I investigated the issue, and there are some consequences:
$PROGRAM_NAME
C code in ex1.c:
Compilation:
The result is:
The condition:
hit the code, but there is no implementation for this situation.
The resolution
I tried to implement the resolving of /dev/fd/ to program name via
readlink
like:The result in 3) is /usr/local/bin/script.pl
The result in 4) is pipe:number
Questions
What do you think about this?
The text was updated successfully, but these errors were encountered: